Skip to content

Commit 0ee6b6f

Browse files
committed
Avoid creating wrapper thunks or wasm exports
In debug builds nothing really changes here since we exported functions still get statically assigned to debug wrappers/thunks. However, after this change, in release builds, if you attempt to access `_foo` (internally) or `Module['_foo']` externally before the module is loaded you will now get `undefined`. Since it was always the case that calling these function would crash anyway, the only effected folks would be folks that take the reference early and then call later. e.g. ``` var myfunc = Module['_foo']; // Run before module is loaded // wait until loaded myfunc(); // This will no longer work. ``` Fixes: #23339
1 parent 8e660ed commit 0ee6b6f

File tree

84 files changed

+146
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+146
-121
lines changed

src/postamble_minimal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
180180
wasmOffsetConverter = new WasmOffsetConverter(Module['wasm'], output.module);
181181
#endif
182182

183-
#if !DECLARE_ASM_MODULE_EXPORTS
184-
exportWasmSymbols(wasmExports);
185-
#else
183+
#if DECLARE_ASM_MODULE_EXPORTS
186184
assignWasmExports(wasmExports);
185+
#else
186+
exportWasmSymbols(wasmExports);
187187
#endif
188188
#if '$wasmTable' in addedLibraryItems
189189
wasmTable = wasmExports['__indirect_function_table'];

src/preamble.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,9 @@ function getWasmImports() {
966966
instrumentWasmTableWithAbort();
967967
#endif
968968

969-
#if !DECLARE_ASM_MODULE_EXPORTS
969+
#if DECLARE_ASM_MODULE_EXPORTS
970+
assignWasmExports(wasmExports);
971+
#else
970972
// If we didn't declare the asm exports as top level enties this function
971973
// is in charge of programmatically exporting them on the global object.
972974
exportWasmSymbols(wasmExports);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8343
1+
8337
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20273
1+
20247
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8327
1+
8321
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20241
1+
20215
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9343
1+
9316
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24041
1+
23938
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8294
1+
8286
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20166
1+
20136

0 commit comments

Comments
 (0)