aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js4
-rw-r--r--src/library.js11
2 files changed, 11 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 8a3ac25e..08126e45 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1149,9 +1149,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
// If there is no current exception, set this one as it (during a resume, the current exception can be wiped out)
var ptr = makeStructuralAccess(item.ident, 0);
- return (EXCEPTION_DEBUG ? 'Module.print("Resuming exception");' : '') +
- 'if (' + makeGetValue('_llvm_eh_exception.buf', 0, 'void*') + ' == 0) { ' + makeSetValue('_llvm_eh_exception.buf', 0, ptr, 'void*') + ' } ' +
- makeThrow(ptr) + ';';
+ return '___resumeException(' + asmCoercion(ptr, 'i32') + ')';
});
makeFuncLineActor('invoke', function(item) {
// Wrapping in a function lets us easily return values if we are
diff --git a/src/library.js b/src/library.js
index 294ab200..2e0f3afb 100644
--- a/src/library.js
+++ b/src/library.js
@@ -5156,7 +5156,7 @@ LibraryManager.library = {
// functionality boils down to picking a suitable 'catch' block.
// We'll do that here, instead, to keep things simpler.
- __cxa_find_matching_catch__deps: ['__cxa_does_inherit', '__cxa_is_number_type'],
+ __cxa_find_matching_catch__deps: ['__cxa_does_inherit', '__cxa_is_number_type', '__resumeException'],
__cxa_find_matching_catch: function(thrown, throwntype) {
if (thrown == -1) thrown = {{{ makeGetValue('_llvm_eh_exception.buf', '0', 'void*') }}};
if (throwntype == -1) throwntype = {{{ makeGetValue('_llvm_eh_exception.buf', QUANTUM_SIZE, 'void*') }}};
@@ -5185,6 +5185,15 @@ LibraryManager.library = {
{{{ makeStructuralReturn(['thrown', 'throwntype']) }}};
},
+ __resumeException__deps: [function() { Functions.libraryFunctions['__resumeException'] = 1 }], // will be called directly from compiled code
+ __resumeException: function(ptr) {
+#if EXCEPTION_DEBUG
+ Module.print("Resuming exception");
+#endif
+ if ({{{ makeGetValue('_llvm_eh_exception.buf', 0, 'void*') }}} == 0) {{{ makeSetValue('_llvm_eh_exception.buf', 0, 'ptr', 'void*') }}};
+ {{{ makeThrow('ptr') }}};
+ },
+
// Recursively walks up the base types of 'possibilityType'
// to see if any of them match 'definiteType'.
__cxa_does_inherit__deps: ['__cxa_is_number_type'],