Skip to content

Commit 8812015

Browse files
committed
Use asyncify-export-globals when building main modules. NFC
Depends on WebAssembly/binaryen#8074
1 parent 893b32e commit 8812015

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

src/lib/libcore.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,11 +2212,6 @@ addToLibrary({
22122212
__global_base: '{{{ GLOBAL_BASE }}}',
22132213
#endif // RELOCATABLE
22142214

2215-
#if (MAIN_MODULE || RELOCATABLE) && ASYNCIFY == 1
2216-
__asyncify_state: "new WebAssembly.Global({'value': 'i32', 'mutable': true}, 0)",
2217-
__asyncify_data: "new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}, {{{ to64(0) }}})",
2218-
#endif
2219-
22202215
_emscripten_fs_load_embedded_files__deps: ['$FS', '$PATH'],
22212216
_emscripten_fs_load_embedded_files: (ptr) => {
22222217
#if RUNTIME_DEBUG

tools/emscripten.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def update_settings_glue(wasm_file, metadata, base_metadata):
114114
settings.WASM_EXPORTS = metadata.all_exports
115115
settings.HAVE_EM_ASM = bool(settings.MAIN_MODULE or len(metadata.em_asm_consts) != 0)
116116

117+
if settings.MAIN_MODULE:
118+
# These will be exported from Wasm, but only once we run the asyncify pass.
119+
settings.WASM_EXPORTS += ['__asyncify_state', '__asyncify_data']
120+
117121
# start with the MVP features, and add any detected features.
118122
building.binaryen_features = ['--mvp-features'] + metadata.features
119123
if settings.ASYNCIFY == 2:
@@ -351,9 +355,6 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat
351355
if settings.INITIAL_TABLE == -1:
352356
settings.INITIAL_TABLE = dylink_sec.table_size + 1
353357

354-
if settings.MAIN_MODULE and settings.ASYNCIFY == 1:
355-
metadata.imports += ['__asyncify_state', '__asyncify_data']
356-
357358
if metadata.invoke_funcs:
358359
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$getWasmTableEntry']
359360

tools/link.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ def get_binaryen_passes(options):
431431
passes += ['--fpcast-emu']
432432
if settings.ASYNCIFY == 1:
433433
passes += ['--asyncify']
434-
if settings.RELOCATABLE or settings.MAIN_MODULE:
434+
if settings.MAIN_MODULE:
435+
passes += ['--pass-arg=asyncify-export-globals']
436+
elif settings.RELOCATABLE:
435437
passes += ['--pass-arg=asyncify-relocatable']
436438
if settings.ASSERTIONS:
437439
passes += ['--pass-arg=asyncify-asserts']
@@ -1331,13 +1333,6 @@ def limit_incoming_module_api():
13311333
'$relocateExports',
13321334
'$GOTHandler',
13331335
]
1334-
1335-
if settings.ASYNCIFY == 1:
1336-
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += [
1337-
'__asyncify_state',
1338-
'__asyncify_data',
1339-
]
1340-
13411336
# shared modules need memory utilities to allocate their memory
13421337
settings.ALLOW_TABLE_GROWTH = 1
13431338

tools/maint/gen_sig_info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def ignore_symbol(s, cxx):
179179
return True
180180
if s in {'__stack_base', '__memory_base', '__table_base', '__global_base', '__heap_base',
181181
'__stack_pointer', '__stack_high', '__stack_low', '_load_secondary_module',
182-
'__asyncify_state', '__asyncify_data',
183182
# legacy aliases, not callable from native code.
184183
'stackSave', 'stackRestore', 'stackAlloc', 'getTempRet0', 'setTempRet0',
185184
}:

0 commit comments

Comments
 (0)