diff --git a/ChangeLog.md b/ChangeLog.md index dc33238c08875..1f82a1ad971ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -30,6 +30,9 @@ v.1.38.43: 08/30/2019 --------------------- - noExitRuntime is no longer a property on the Module object. Use `noExitRuntime` instead of `Module.noExitRuntime`. + - Module.abort is no longer exported by default. It can be exported in the normal + way using `EXTRA_EXPORTED_RUNTIME_METHODS`, and as with other such changes in + the past, forgetting to export it with show a clear error in `ASSERTIONS` mode. v.1.38.42: 08/19/2019 ---------------------- diff --git a/src/library.js b/src/library.js index 9ffce9d7c8f0f..f997f7f502086 100644 --- a/src/library.js +++ b/src/library.js @@ -717,7 +717,7 @@ LibraryManager.library = { // In MINIMAL_RUNTIME the module object does not exist, so its behavior to abort is to throw directly. throw 'abort'; #else - Module['abort'](); + abort(); #endif }, diff --git a/src/modules.js b/src/modules.js index d44cebb032a84..67865c36e6f0b 100644 --- a/src/modules.js +++ b/src/modules.js @@ -443,6 +443,7 @@ function exportRuntime() { 'getTempRet0', 'setTempRet0', 'callMain', + 'abort', ]; if (!MINIMAL_RUNTIME) { diff --git a/src/postamble.js b/src/postamble.js index 53c2bd8a1ce39..1ea425c1eb77b 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -415,44 +415,14 @@ function exit(status, implicit) { exitRuntime(); +#if expectToReceiveOnModule('onExit') if (Module['onExit']) Module['onExit'](status); +#endif } quit_(status, new ExitStatus(status)); } -var abortDecorators = []; - -function abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what); - } - -#if USE_PTHREADS - if (ENVIRONMENT_IS_PTHREAD) console.error('Pthread aborting at ' + new Error().stack); -#endif - what += ''; - out(what); - err(what); - - ABORT = true; - EXITSTATUS = 1; - -#if ASSERTIONS == 0 - throw 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.'; -#else - var extra = ''; - var output = 'abort(' + what + ') at ' + stackTrace() + extra; - if (abortDecorators) { - abortDecorators.forEach(function(decorator) { - output = decorator(output, what); - }); - } - throw output; -#endif // ASSERTIONS -} -Module['abort'] = abort; - #if expectToReceiveOnModule('preInit') if (Module['preInit']) { if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; diff --git a/src/preamble.js b/src/preamble.js index d54d56ca7b934..c7d4333d6583e 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -724,6 +724,41 @@ Module["preloadedAudios"] = {}; // maps url to audio data Module["preloadedWasm"] = {}; // maps url to wasm instance exports #endif +#if EMTERPRETIFY_ASYNC && ASSERTIONS +var abortDecorators = []; +#endif + +function abort(what) { +#if expectToReceiveOnModule('onAbort') + if (Module['onAbort']) { + Module['onAbort'](what); + } +#endif + +#if USE_PTHREADS + if (ENVIRONMENT_IS_PTHREAD) console.error('Pthread aborting at ' + new Error().stack); +#endif + what += ''; + out(what); + err(what); + + ABORT = true; + EXITSTATUS = 1; + +#if ASSERTIONS == 0 + throw 'abort(' + what + '). Build with -s ASSERTIONS=1 for more info.'; +#else + var extra = ''; + var output = 'abort(' + what + ') at ' + stackTrace() + extra; +#if EMTERPRETIFY_ASYNC + abortDecorators.forEach(function(decorator) { + output = decorator(output, what); + }); +#endif + throw output; +#endif // ASSERTIONS +} + #if RELOCATABLE {{{ (function() { diff --git a/tests/test_browser.py b/tests/test_browser.py index 72043bfd57ecd..53594b382e31c 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -4178,7 +4178,7 @@ def test_small_js_flags(self): size = os.path.getsize('test.js') print('size:', size) # Note that this size includes test harness additions (for reporting the result, etc.). - self.assertLess(abs(size - 5754), 100) + self.assertLess(abs(size - 5692), 100) # Tests that it is possible to initialize and render WebGL content in a pthread by using OffscreenCanvas. # -DTEST_CHAINED_WEBGL_CONTEXT_PASSING: Tests that it is possible to transfer WebGL canvas in a chain from main thread -> thread 1 -> thread 2 and then init and render WebGL content there. diff --git a/tests/test_other.py b/tests/test_other.py index 7e5318fd8bbef..ff0dfd415efd5 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -9664,7 +9664,7 @@ def test(args): # Changing this option to [] should decrease code size. self.assertLess(changed, normal) # Check an absolute code size as well, with some slack. - self.assertLess(abs(changed - 5905), 150) + self.assertLess(abs(changed - 5840), 150) def test_llvm_includes(self): self.build('#include ', self.get_dir(), 'atomics.c')