diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-28 15:51:22 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-28 15:51:22 -0800 |
commit | 995e37ebc0a6a4906dd8dcd0a05f664ddd6dbaf1 (patch) | |
tree | 1ce108a44e88472104b769869b135746c6df2925 /tools | |
parent | f705c72430d292432c81737ed424729e56385ea9 (diff) |
ignore string nodes when recombining additions in optimizeShifts
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 4 | ||||
-rw-r--r-- | tools/test-js-optimizer-t2-output.js | 1 | ||||
-rw-r--r-- | tools/test-js-optimizer-t2.js | 1 |
3 files changed, 6 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 248ec9cd..5bf88a33 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -422,6 +422,7 @@ function optimizeShifts(ast) { if (subNode[3][0] == 'num') { subNode[3][1] += shifts; // XXX this may be wrong, if we removed a |0 that assumed we had this >> which |0's anyhow! + // should we only do this if CORRECT_OVERFLOWS is false? need more metadata for that if (subNode[3][1] == 0) return subNode[2]; } else { subNode[3] = ['binary', '+', subNode[3], ['num', shifts]]; @@ -585,6 +586,9 @@ function optimizeShifts(ast) { if (node[0] == 'num') return -1000; return -1; } + for (var i = 0; i < addedItems.length; i++) { + if (addedItems[i][0] == 'string') return; // this node is not relevant for us + } addedItems.sort(function(node1, node2) { return key(node1) - key(node2); }); diff --git a/tools/test-js-optimizer-t2-output.js b/tools/test-js-optimizer-t2-output.js index 11f1c3c9..ea4e903e 100644 --- a/tools/test-js-optimizer-t2-output.js +++ b/tools/test-js-optimizer-t2-output.js @@ -59,5 +59,6 @@ function shifty($id) { pause(6); q($idx << 3); q(1 << $idx << 1); + print(INDENT + "Entering: _main" + "hi"); } // EMSCRIPTEN_GENERATED_FUNCTIONS: ["shifty"] diff --git a/tools/test-js-optimizer-t2.js b/tools/test-js-optimizer-t2.js index 907907ef..18673bc7 100644 --- a/tools/test-js-optimizer-t2.js +++ b/tools/test-js-optimizer-t2.js @@ -67,5 +67,6 @@ function shifty($id) { pause(6); q($idx << 1 << 2); q(1 << $idx << 1); // Do not turn this into the slower 1 << $idx + 1 (which is identical though) + print(INDENT + "Entering: _main" + "hi"); // this order should not be modified } // EMSCRIPTEN_GENERATED_FUNCTIONS: ["shifty"] |