Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,19 @@ function abort(what) {
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
#if WASM_EXCEPTIONS == 1
// See above, in the meantime, we resort to wasm code for trapping.
___trap();
#else
//
// In case abort() is called before the module is initialized, Module['asm']
// and its exported '__trap' function is not available, in which case we throw
// a RuntimeError.
//
// We trap instead of throwing RuntimeError to prevent infinite-looping in
// Wasm EH code (because RuntimeError is considered as a foreign exception and
// caught by 'catch_all'), but in case throwing RuntimeError is fine because
// the module has not even been instantiated, even less running.
if (runtimeInitialized) {
___trap();
}
#endif
/** @suppress {checkTypes} */
var e = new WebAssembly.RuntimeError(what);

Expand All @@ -483,7 +494,6 @@ function abort(what) {
// in code paths apart from instantiation where an exception is expected
// to be thrown when abort is called.
throw e;
#endif
}

#include "memoryprofiler.js"
Expand Down