diff options
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index a6a3fb28..0e8b825a 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -664,7 +664,7 @@ function JSify(data, functionsOnly, givenFunctions) { } // otherwise, should have been set before! if (func.setjmpTable) { var setjmpTable = {}; - ret += indent + 'var setjmped = false;'; // set to true if we setjmp in this invocation + ret += indent + 'var mySetjmpIds = {};\n'; ret += indent + 'var setjmpTable = {'; func.setjmpTable.forEach(function(triple) { // original label, label we created for right after the setjmp, variable setjmp result goes into ret += '"' + getLabelId(triple[0]) + '": ' + 'function(value) { label = ' + getLabelId(triple[1]) + '; ' + triple[2] + ' = value },'; @@ -683,7 +683,7 @@ function JSify(data, functionsOnly, givenFunctions) { }).join('\n'); ret += '\n' + indent + ' default: assert(0, "bad label: " + label);\n' + indent + '}'; if (func.setjmpTable) { - ret += ' } catch(e) { if (!setjmped) throw(e); if (!e.longjmp) throw(e); setjmpTable[e.label](e.value) }'; + ret += ' } catch(e) { if (!e.longjmp || !(e.id in mySetjmpIds)) throw(e); setjmpTable[setjmpLabels[e.id]](e.value) }'; } } else { ret += (SHOW_LABELS ? indent + '/* ' + block.entries[0] + ' */' : '') + '\n' + getLabelLines(block.labels[0], indent); @@ -1081,8 +1081,10 @@ function JSify(data, functionsOnly, givenFunctions) { return ret + ';'; }); makeFuncLineActor('resume', function(item) { + // If there is no current exception, set this one as it (during a resume, the current exception can be wiped out) return (EXCEPTION_DEBUG ? 'Module.print("Resuming exception");' : '') + - 'throw ' + makeGetValue('_llvm_eh_exception.buf', '0', 'void*') + ';'; + 'if (' + makeGetValue('_llvm_eh_exception.buf', 0, 'void*') + ' == 0) { ' + makeSetValue('_llvm_eh_exception.buf', 0, item.ident + '.f0', 'void*') + ' } ' + + 'throw ' + item.ident + '.f0;'; }); makeFuncLineActor('invoke', function(item) { // Wrapping in a function lets us easily return values if we are |