@@ -328,7 +328,10 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat
328
328
else :
329
329
# Skip finalize and only extract the metadata.
330
330
if in_wasm != out_wasm :
331
- shutil .copy (in_wasm , out_wasm )
331
+ if settings .MEMORY64 :
332
+ building .run_wasm_opt (in_wasm , out_wasm , ['--table64-lowering' ])
333
+ else :
334
+ shutil .copy (in_wasm , out_wasm )
332
335
metadata = get_metadata (in_wasm , out_wasm , False , [])
333
336
334
337
if settings .RELOCATABLE and settings .MEMORY64 == 2 :
@@ -662,18 +665,18 @@ def create_tsd(metadata, embind_tsd):
662
665
out += create_tsd_exported_runtime_methods (metadata )
663
666
# Manually generate defintions for any Wasm function exports.
664
667
out += 'interface WasmModule {\n '
665
- for name , types in metadata .function_exports .items ():
668
+ for name , functype in metadata .function_exports .items ():
666
669
mangled = asmjs_mangle (name )
667
670
should_export = settings .EXPORT_KEEPALIVE and mangled in settings .EXPORTED_FUNCTIONS
668
671
if not should_export :
669
672
continue
670
673
arguments = []
671
- for index , type in enumerate (types .params ):
674
+ for index , type in enumerate (functype .params ):
672
675
arguments .append (f"_{ index } : { type_to_ts_type (type )} " )
673
676
out += f' { mangled } ({ ", " .join (arguments )} ): '
674
- assert len (types .returns ) <= 1 , 'One return type only supported'
675
- if types .returns :
676
- out += f'{ type_to_ts_type (types .returns [0 ])} '
677
+ assert len (functype .returns ) <= 1 , 'One return type only supported'
678
+ if functype .returns :
679
+ out += f'{ type_to_ts_type (functype .returns [0 ])} '
677
680
else :
678
681
out += 'void'
679
682
out += ';\n '
@@ -791,6 +794,8 @@ def add_standard_wasm_imports(send_items_map):
791
794
792
795
if settings .RELOCATABLE :
793
796
send_items_map ['__indirect_function_table' ] = 'wasmTable'
797
+ if settings .MEMORY64 :
798
+ send_items_map ['__table_base32' ] = '___table_base32'
794
799
795
800
if settings .AUTODEBUG :
796
801
extra_sent_items += [
@@ -1100,7 +1105,17 @@ def create_pointer_conversion_wrappers(metadata):
1100
1105
1101
1106
sigs_seen = set ()
1102
1107
wrap_functions = []
1103
- for symbol in metadata .function_exports :
1108
+ for symbol , functype in metadata .function_exports .items ():
1109
+ # dynCall_ functions are generated by binaryen. They all take a
1110
+ # function pointer as their first argument.
1111
+ # The second part of this check can be removed once the table64
1112
+ # llvm changs lands.
1113
+ if symbol .startswith ('dynCall_' ) and functype .params [0 ] == webassembly .Type .I64 :
1114
+ sig = symbol .split ('_' )[- 1 ]
1115
+ sig = ['p' if t == 'p' else '_' for t in sig ]
1116
+ sig .insert (1 , 'p' )
1117
+ sig = '' .join (sig )
1118
+ mapping [symbol ] = sig
1104
1119
sig = mapping .get (symbol )
1105
1120
if sig :
1106
1121
if settings .MEMORY64 :
0 commit comments