diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 7 | ||||
-rw-r--r-- | src/jsifier.js | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index a1c009f2..9aa84650 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -290,7 +290,7 @@ function analyzer(data, sidePass) { continue; } // call, return: Return value is in an unlegalized array literal. Not fully optimal. - case 'call': case 'invoke': { + case 'call': { bits = getBits(value.type); var elements = getLegalVars(item.assignTo, bits); var toAdd = [value]; @@ -318,6 +318,11 @@ function analyzer(data, sidePass) { i++; continue; } + case 'invoke': { + // We can't add lines after this, since invoke already modifies control flow. So we handle this in invoke + i++; + continue; + } case 'value': { bits = getBits(value.type); var elements = getLegalVars(item.assignTo, bits); diff --git a/src/jsifier.js b/src/jsifier.js index 56e49788..b93cdf9a 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -969,7 +969,16 @@ function JSify(data, functionsOnly, givenFunctions) { + 'if (typeof e != "number") throw e; ' + 'if (ABORT) throw e; __THREW__ = true; ' + (EXCEPTION_DEBUG ? 'print("Exception: " + e + ", currently at: " + (new Error().stack)); ' : '') - + 'return null } })(); if (!__THREW__) { ' + getPhiSetsForLabel(phiSets, item.toLabel) + makeBranch(item.toLabel, item.currLabelId) + + 'return null } })();'; + if (item.assignTo) { + ret = 'var ' + item.assignTo + ' = ' + ret; + if (isIllegalType(item.type)) { + assert(item.type == 'i64', 'Can only handle i64 invoke among illegal invokes'); + ret += 'var ' + item.assignTo + '$0 = ' + item.assignTo + '[0], ' + item.assignTo + '$1 = ' + item.assignTo + '[1];'; + } + item.assignTo = null; + } + ret += 'if (!__THREW__) { ' + getPhiSetsForLabel(phiSets, item.toLabel) + makeBranch(item.toLabel, item.currLabelId) + ' } else { ' + getPhiSetsForLabel(phiSets, item.unwindLabel) + makeBranch(item.unwindLabel, item.currLabelId) + ' }'; return ret; }); |