From d705c37e34ad11b01ad33e7c985818a14623dff7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 16 Aug 2013 17:02:43 -0700 Subject: emit switches in relooper --- src/jsifier.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/jsifier.js') diff --git a/src/jsifier.js b/src/jsifier.js index 683b1874..31e066ab 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -795,7 +795,13 @@ function JSify(data, functionsOnly, givenFunctions) { var label = block.labels[i]; var content = getLabelLines(label, '', true); //printErr(func.ident + ' : ' + label.ident + ' : ' + content + '\n'); - blockMap[label.ident] = Relooper.addBlock(content); + var last = label.lines[label.lines.length-1]; + if (last.intertype != 'switch') { + blockMap[label.ident] = Relooper.addBlock(content); + } else { + assert(last.signedIdent); + blockMap[label.ident] = Relooper.addBlock(content, last.signedIdent); + } } // add branchings function relevant(x) { return x && x.length > 2 ? x : 0 } // ignores ';' which valueJS and label*JS can be if empty @@ -1125,7 +1131,7 @@ function JSify(data, functionsOnly, givenFunctions) { } }); makeFuncLineActor('switch', function(item) { - var useIfs = RELOOP || item.switchLabels.length < 1024; // with a huge number of cases, if-else which looks nested to js parsers can cause problems + var useIfs = false; var phiSets = calcPhiSets(item); // Consolidate checks that go to the same label. This is important because it makes the relooper simpler and faster. var targetLabels = {}; // for each target label, the list of values going to it @@ -1139,7 +1145,8 @@ function JSify(data, functionsOnly, givenFunctions) { }); var ret = ''; var first = true; - var signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison + signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison + if (!useIfs) item.signedIdent = signedIdent; if (RELOOP) { item.groupedLabels = []; } -- cgit v1.2.3-18-g5258