diff options
Diffstat (limited to 'src/tools/wasm-split')
-rw-r--r-- | src/tools/wasm-split/split-options.cpp | 9 | ||||
-rw-r--r-- | src/tools/wasm-split/split-options.h | 1 | ||||
-rw-r--r-- | src/tools/wasm-split/wasm-split.cpp | 10 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp index bd6d6f09a..b5929aad7 100644 --- a/src/tools/wasm-split/split-options.cpp +++ b/src/tools/wasm-split/split-options.cpp @@ -191,6 +191,15 @@ WasmSplitOptions::WasmSplitOptions() placeholderNamespace = argument; }) .add( + "--asyncify", + "", + "Transform the module to support unwinding the stack from placeholder " + "functions and rewinding it once the secondary module has been loaded.", + WasmSplitOption, + {Mode::Split}, + Options::Arguments::Zero, + [&](Options* o, const std::string& argument) { asyncify = true; }) + .add( "--export-prefix", "", "An identifying prefix to prepend to new export names created " diff --git a/src/tools/wasm-split/split-options.h b/src/tools/wasm-split/split-options.h index d52f215cd..16e7b75e6 100644 --- a/src/tools/wasm-split/split-options.h +++ b/src/tools/wasm-split/split-options.h @@ -43,6 +43,7 @@ struct WasmSplitOptions : ToolOptions { bool emitBinary = true; bool symbolMap = false; bool placeholderMap = false; + bool asyncify = false; // TODO: Remove this. See the comment in wasm-binary.h. bool emitModuleNames = false; diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp index 2732502ad..871d6bc95 100644 --- a/src/tools/wasm-split/wasm-split.cpp +++ b/src/tools/wasm-split/wasm-split.cpp @@ -280,6 +280,16 @@ void splitModule(const WasmSplitOptions& options) { adjustTableSize(wasm, options.initialTableSize); adjustTableSize(*secondary, options.initialTableSize); + // Run asyncify on the primary module + if (options.asyncify) { + PassOptions passOptions; + passOptions.optimizeLevel = 1; + passOptions.arguments.insert({"asyncify-ignore-imports", ""}); + PassRunner runner(&wasm, passOptions); + runner.add("asyncify"); + runner.run(); + } + if (options.symbolMap) { writeSymbolMap(wasm, options.primaryOutput + ".symbols"); writeSymbolMap(*secondary, options.secondaryOutput + ".symbols"); |