Skip to content

Commit ec0e813

Browse files
authored
Merge assignWasmExports and assignWasmSymbols. NFC (#25592)
These two functions serve exactly the same purpose so just make them into a single function. There are still two different methods by which this gets defined but from the POV of the caller they are the same thing.
1 parent dc92afc commit ec0e813

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

src/lib/libcore.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,14 +1615,16 @@ addToLibrary({
16151615
#endif
16161616

16171617
#if !DECLARE_ASM_MODULE_EXPORTS
1618-
// When DECLARE_ASM_MODULE_EXPORTS is not set we export native symbols
1619-
// at runtime rather than statically in JS code.
1620-
$exportWasmSymbols__deps: ['$asmjsMangle',
1618+
// When DECLARE_ASM_MODULE_EXPORTS is set, this function is programatically
1619+
// ceated during linking. See `create_receiving` in `emscripten.py`.
1620+
// When DECLARE_ASM_MODULE_EXPORTS=0 is set, `assignWasmExports` is instead
1621+
// defined here as a normal JS library function.
1622+
$assignWasmExports__deps: ['$asmjsMangle',
16211623
#if DYNCALLS || !WASM_BIGINT
16221624
, '$dynCalls'
16231625
#endif
16241626
],
1625-
$exportWasmSymbols: (wasmExports) => {
1627+
$assignWasmExports: (wasmExports) => {
16261628
for (var [name, exportedSymbol] of Object.entries(wasmExports)) {
16271629
name = asmjsMangle(name);
16281630
#if DYNCALLS || !WASM_BIGINT

src/postamble_minimal.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,7 @@ WebAssembly.instantiate(Module['wasm'], imports).then(/** @suppress {missingProp
258258
wasmExports = applySignatureConversions(wasmExports);
259259
#endif
260260

261-
#if DECLARE_ASM_MODULE_EXPORTS
262261
assignWasmExports(wasmExports);
263-
#else
264-
exportWasmSymbols(wasmExports);
265-
#endif
266262

267263
#if !IMPORTED_MEMORY
268264
updateMemoryViews();

src/preamble.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,7 @@ function getWasmImports() {
746746
__RELOC_FUNCS__.push(wasmExports['__wasm_apply_data_relocs']);
747747
#endif
748748

749-
#if DECLARE_ASM_MODULE_EXPORTS
750749
assignWasmExports(wasmExports);
751-
#else
752-
// If we didn't declare the asm exports as top level enties this function
753-
// is in charge of programmatically exporting them on the global object.
754-
exportWasmSymbols(wasmExports);
755-
#endif
756750

757751
#if ABORT_ON_WASM_EXCEPTIONS
758752
instrumentWasmTableWithAbort();

tools/emscripten.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,8 @@ def create_receiving(function_exports, other_exports, library_symbols, aliases):
940940

941941
return '\n'.join(receiving)
942942

943-
# When not declaring asm exports this section is empty and we instead programmatically export
944-
# symbols on the global object by calling exportWasmSymbols after initialization
943+
# When not declaring asm exports `assignWasmExports` is instead defined as a simple
944+
# library function.
945945
if not settings.DECLARE_ASM_MODULE_EXPORTS:
946946
return ''
947947

tools/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ def limit_incoming_module_api():
14141414
settings.REQUIRED_EXPORTS += ['emscripten_get_sbrk_ptr', 'emscripten_stack_get_base']
14151415

14161416
if not settings.DECLARE_ASM_MODULE_EXPORTS:
1417-
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$exportWasmSymbols']
1417+
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$assignWasmExports']
14181418

14191419
if settings.ALLOW_MEMORY_GROWTH:
14201420
# Setting ALLOW_MEMORY_GROWTH turns off ABORTING_MALLOC, as in that mode we default to

0 commit comments

Comments
 (0)