Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a wasm RuntimeError in abort #9730

Merged
merged 2 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,25 @@ function abort(what) {
EXITSTATUS = 1;

#if ASSERTIONS == 0
throw 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.';
what = 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.';
#else
var extra = '';
var output = 'abort(' + what + ') at ' + stackTrace() + extra;
var output = 'abort(' + what + ') at ' + stackTrace();
#if EMTERPRETIFY_ASYNC
abortDecorators.forEach(function(decorator) {
output = decorator(output, what);
});
#endif
throw output;
what = output;
#endif // ASSERTIONS

// Throw a wasm runtime error, because a JS error might be seen as a foreign
// exception, which means we'd run destructors on it. We need the error to
// simply make the program stop.
#if WASM
throw new WebAssembly.RuntimeError(what);
#else
throw what;
#endif
}

#if RELOCATABLE
Expand Down
4 changes: 3 additions & 1 deletion src/wasm2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ WebAssembly = {
});
}
};
}
},

RuntimeError: Error
};

// We don't need to actually download a wasm binary, mark it as present but empty.
Expand Down