summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2020-07-27 22:23:17 -0700
committerGitHub <noreply@github.com>2020-07-27 22:23:17 -0700
commit32ab8bac04af52121c6985a9a019c0fdec957f03 (patch)
tree07f9471a68be9cf5c2176e92c69e3a94bbf9df9f /src/tools
parent85e45a4371ef9e6b143e9675d5f52136ef881c12 (diff)
downloadbinaryen-32ab8bac04af52121c6985a9a019c0fdec957f03.tar.gz
binaryen-32ab8bac04af52121c6985a9a019c0fdec957f03.tar.bz2
binaryen-32ab8bac04af52121c6985a9a019c0fdec957f03.zip
Move stack-check into its own pass (#2994)
This new pass takes an optional stack-check-handler argument which is the name of the function to call on stack overflow. If no argument is passed then it just traps.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/wasm-emscripten-finalize.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp
index 6e0831a08..cc57c9311 100644
--- a/src/tools/wasm-emscripten-finalize.cpp
+++ b/src/tools/wasm-emscripten-finalize.cpp
@@ -242,7 +242,15 @@ int main(int argc, const char* argv[]) {
wasm.updateMaps();
if (checkStackOverflow && !sideModule) {
- generator.enforceStackLimit();
+ PassOptions options;
+ if (!standaloneWasm) {
+ // In standalone mode we don't set a handler at all.. which means
+ // just trap on overflow.
+ options.arguments["stack-check-handler"] = "__handle_stack_overflow";
+ }
+ PassRunner passRunner(&wasm, options);
+ passRunner.add("stack-check");
+ passRunner.run();
}
if (sideModule) {
@@ -288,8 +296,7 @@ int main(int argc, const char* argv[]) {
// Legalize the wasm, if BigInts don't make that moot.
if (!bigInt) {
BYN_TRACE("legalizing types\n");
- PassRunner passRunner(&wasm);
- passRunner.setOptions(options.passOptions);
+ PassRunner passRunner(&wasm, options.passOptions);
passRunner.setDebug(options.debug);
passRunner.setDebugInfo(debugInfo);
passRunner.add(ABI::getLegalizationPass(