You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow the createWasm function to use async/await where possible
The advantage if using `await` in the cases where we can is that it
avoids the generation or wrapper function for each export.
So instead of
```
var wasmExport = createWasm(); // returns empty object
...
var malloc = ((..) => (malloc = wasmExports['malloc'])()
```
We can just generate:
```
var wasmExport = createWasm(); // returns empty object
...
var malloc = wasmExports['malloc'];
```
This only currently works in MODULARIZE mode where the code is running
inside a factory function. Otherwise it would end up using
top-level-await.
One wrinkle here is that this is not currently supported when closure is
enabled because we run closure only on the contents of the factory
function so closure ends up seeing this as a top level await when its
not.
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
1042
1042
// When the regression is fixed, can restore the above PTHREADS-enabled path.
1043
-
receiveInstance(result['instance']);
1043
+
returnreceiveInstance(result['instance']);
1044
1044
#endif
1045
1045
}
1046
1046
#endif // WASM_ASYNC_COMPILATION
@@ -1076,8 +1076,7 @@ function getWasmImports() {
1076
1076
// Instantiate from the module posted from the main thread.
1077
1077
// We can just use sync instantiation in the worker.
0 commit comments