Open
Description
In release mode, when WASM_ASYNC_COMPILATION is used (i.e the default) we generate little thunks for all wasm exports. They looks like this:
var _foo = Module['_foo'] = () => (_foo = Module['_cfoo'] = wasmExports['foo'])();
The idea here is that these would then get re-assigned on first use. However, there are several problem with this:
- If somebody takes a reference early they will get a reference to wrapper that will not get re-assigned and will cause perpetual re-assignment:
// This runs early on
var myfunc = Module['foo'];
// Now my func will forever point to the wrapper:
myfunc(); // always goes via wrapper and always re-assigns.. strange
Module['foo'](); // now goes direct
- The identity of these function changes which can be observable (since we don't this re-assignment thing in debug builds):
var myfunc = Module['foo'];
// later after instantiation and usage
if (myfunc == Module['foo']) // would always be true in debug builds, but can be false in release builds
See #23337
Metadata
Metadata
Assignees
Labels
No labels