diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-25 14:12:00 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-25 14:12:00 -0700 |
commit | b1eeb1ccda3aa5684699c6f8920085250a7ef023 (patch) | |
tree | d471fbb2913b4085ca237fe199ca8958d15f855f | |
parent | 056d7563e2c65f730f0a369e915fcd486dc7c607 (diff) |
eliminate in if nodes
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 3 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index 6690acd9..51571747 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -72,8 +72,7 @@ function g(a1, a2) { } var $0 = HEAP[5]; MAYBE_HEAP[myglobal] = 123; - var $1 = $0 < 0; - if ($1) { + if ($0 < 0) { __label__ = 1; } else { __label__ = 2; diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index c7fdf10f..047eeac2 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1363,6 +1363,8 @@ function registerize(ast) { }); } +var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if'); + function eliminate(ast) { // Find variables that have a single use, and if they can be eliminated, do so traverseGeneratedFunctions(ast, function(func, type) { @@ -1545,7 +1547,7 @@ function eliminate(ast) { type = node[0]; } // Check for things that affect elimination - if (type == 'var' || type == 'assign' || type == 'call') { + if (type in ELIMINATION_SAFE_NODES) { // can we eliminate and/or track? if (!check(node)) continue; // try to eliminate |