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.
1034
1034
// When the regression is fixed, can restore the above PTHREADS-enabled path.
1035
-
receiveInstance(result['instance']);
1035
+
returnreceiveInstance(result['instance']);
1036
1036
#endif
1037
1037
}
1038
1038
#endif // WASM_ASYNC_COMPILATION
@@ -1068,8 +1068,7 @@ function getWasmImports() {
1068
1068
// Instantiate from the module posted from the main thread.
1069
1069
// We can just use sync instantiation in the worker.
0 commit comments