Skip to content

Commit 98aabf2

Browse files
authored
Replace globalThis polyfill in exportWasmSymbols. NFC (#25172)
The polyfill code itself was only moved and not changed.
1 parent e5e84e6 commit 98aabf2

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/lib/libcore.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,20 +1648,12 @@ addToLibrary({
16481648
#if !DECLARE_ASM_MODULE_EXPORTS
16491649
// When DECLARE_ASM_MODULE_EXPORTS is not set we export native symbols
16501650
// at runtime rather than statically in JS code.
1651-
$exportWasmSymbols__deps: ['$asmjsMangle'
1651+
$exportWasmSymbols__deps: ['$asmjsMangle', '$emGlobalThis',
16521652
#if DYNCALLS || !WASM_BIGINT
16531653
, '$dynCalls'
16541654
#endif
16551655
],
16561656
$exportWasmSymbols: (wasmExports) => {
1657-
#if ENVIRONMENT_MAY_BE_NODE && ENVIRONMENT_MAY_BE_WEB
1658-
var global_object = (typeof process != "undefined" ? global : this);
1659-
#elif ENVIRONMENT_MAY_BE_NODE
1660-
var global_object = global;
1661-
#else
1662-
var global_object = this;
1663-
#endif
1664-
16651657
for (var [name, exportedSymbol] of Object.entries(wasmExports)) {
16661658
name = asmjsMangle(name);
16671659
#if DYNCALLS || !WASM_BIGINT
@@ -1674,9 +1666,9 @@ addToLibrary({
16741666
// similar DECLARE_ASM_MODULE_EXPORTS = 0 treatment.
16751667
if (typeof exportedSymbol.value === 'undefined') {
16761668
#if MINIMAL_RUNTIME
1677-
global_object[name] = exportedSymbol;
1669+
emGlobalThis[name] = exportedSymbol;
16781670
#else
1679-
global_object[name] = Module[name] = exportedSymbol;
1671+
emGlobalThis[name] = Module[name] = exportedSymbol;
16801672
#endif
16811673
}
16821674
}

test/test_browser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4969,11 +4969,13 @@ def test_no_declare_asm_module_exports_wasm2js(self, args):
49694969
self.btest_exit('declare_asm_module_exports.c', cflags=['-sDECLARE_ASM_MODULE_EXPORTS=0', '-sENVIRONMENT=web', '-O3', '--closure=1', '-sWASM=0'] + args)
49704970

49714971
@parameterized({
4972-
'': (1,),
4973-
'2': (2,),
4972+
'': ([],),
4973+
'strict_js': (['-sSTRICT_JS'],),
4974+
'minimal_runtime': (['-sMINIMAL_RUNTIME=1'],),
4975+
'minimal_runtime_2': (['-sMINIMAL_RUNTIME=2'],),
49744976
})
4975-
def test_no_declare_asm_module_exports_wasm_minimal_runtime(self, mode):
4976-
self.btest_exit('declare_asm_module_exports.c', cflags=['-sDECLARE_ASM_MODULE_EXPORTS=0', '-sENVIRONMENT=web', '-O3', '--closure=1', f'-sMINIMAL_RUNTIME={mode}'])
4977+
def test_no_declare_asm_module_exports(self, args):
4978+
self.btest_exit('declare_asm_module_exports.c', cflags=['-sDECLARE_ASM_MODULE_EXPORTS=0', '-sENVIRONMENT=web', '-O3', '--closure=1'] + args)
49774979

49784980
# Tests that the different code paths in src/shell_minimal_runtime.html all work ok.
49794981
@parameterized({

0 commit comments

Comments
 (0)