diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 15 | ||||
-rw-r--r-- | src/utility.js | 4 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 1453b22c..cbb4f28e 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -9,7 +9,7 @@ var VAR_NATIVIZED = 'nativized'; var VAR_EMULATED = 'emulated'; var ENTRY_IDENT = toNiceIdent('%0'); -var ENTRY_IDENTS = set(toNiceIdent('%0'), toNiceIdent('%1')); +var ENTRY_IDENT_IDS = set(0, 1); // XXX function recomputeLines(func) { func.lines = func.labels.map(function(label) { return label.lines }).reduce(concatenator, []); @@ -1180,7 +1180,9 @@ function analyzer(data, sidePass) { func.labelIdsInverse = {}; func.labelIds[toNiceIdent('%0')] = 0; func.labelIdsInverse[0] = toNiceIdent('%0'); - func.labelIdCounter = 1; + func.labelIds[toNiceIdent('%1')] = 1; + func.labelIdsInverse[1] = toNiceIdent('%1'); + func.labelIdCounter = 2; func.labels.forEach(function(label) { func.labelIds[label.ident] = func.labelIdCounter++; func.labelIdsInverse[func.labelIdCounter-1] = label.ident; @@ -1206,6 +1208,7 @@ function analyzer(data, sidePass) { if (phi.intertype == 'phi') { for (var i = 0; i < phi.params.length; i++) { phi.params[i].label = func.labelIds[phi.params[i].label]; + assert(phi.params[i].label); } } }); @@ -1221,9 +1224,10 @@ function analyzer(data, sidePass) { // So we need to handle that in a special way here. function getActualLabelId(labelId) { if (func.labelsDict[labelId]) return labelId; - if (labelId in ENTRY_IDENTS) { - assert(func.labelsDict[ENTRY_IDENT]); - return ENTRY_IDENT; + if (labelId in ENTRY_IDENT_IDS) { + labelId = func.labelIds[ENTRY_IDENT]; + assert(func.labelsDict[labelId]); + return labelId; } return null; } @@ -1327,6 +1331,7 @@ function analyzer(data, sidePass) { if (phi.intertype == 'phi') { for (var i = 0; i < phi.params.length; i++) { var param = phi.params[i]; + assert(param.label); var sourceLabelId = getActualLabelId(param.label); if (sourceLabelId) { var sourceLabel = func.labelsDict[sourceLabelId]; diff --git a/src/utility.js b/src/utility.js index 7d5e0970..42e8ede4 100644 --- a/src/utility.js +++ b/src/utility.js @@ -40,7 +40,7 @@ function dumpKeys(item) { function assertEq(a, b) { if (a !== b) { - print('Stack: ' + new Error().stack); + printErr('Stack: ' + new Error().stack); throw 'Should have been equal: ' + a + ' : ' + b; } return false; @@ -50,7 +50,7 @@ function assertTrue(a, msg) { if (!a) { msg = 'Assertion failed: ' + msg; print(msg); - print('Stack: ' + new Error().stack); + printErr('Stack: ' + new Error().stack); throw msg; } } |