diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-11 15:24:33 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-11 15:24:42 -0800 |
commit | e22e4a8192810891c7b3ff0b5790cd63ce5119ae (patch) | |
tree | d3d5ce09e20549ae5c4a767e46d7dbe618894cdb /tools/js-optimizer.js | |
parent | 1ba4722cda9dd14cca465bd640f25d18781a4754 (diff) |
optimize redundant frounds in -O3
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index f9be66df..c8766bc6 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -5099,6 +5099,17 @@ function safeHeap(ast) { }); } +function optimizeFrounds(ast) { + // collapse fround(fround(..)), which can happen due to elimination + function fix(node) { + traverseChildren(node, fix); + if (node[0] === 'call' && node[1][0] === 'name' && node[1][1] === 'Math_fround' && node[2][0][0] === 'call' && node[2][0][1][0] === 'name' && node[2][0][1][1] === 'Math_fround') { + return node[2][0]; + } + } + traverseChildren(ast, fix); +} + // Last pass utilities // Change +5 to DOT$ZERO(5). We then textually change 5 to 5.0 (uglify's ast cannot differentiate between 5 and 5.0 directly) @@ -5210,6 +5221,7 @@ var passes = { relocate: relocate, outline: outline, safeHeap: safeHeap, + optimizeFrounds: optimizeFrounds, // flags minifyWhitespace: function() { minifyWhitespace = true }, |