diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-11 10:23:40 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-11 10:23:40 -0800 |
commit | e238b7e11fa973cd86721e5b1ed45b50b52e3c0d (patch) | |
tree | 66948ab87f59aa34ffd730754f738194e51f118f | |
parent | eb8172ed7872c99b6438c4ab0fa9f83372fc44b0 (diff) |
minify in asm arg coercions that denormalizeAsm generates, to handle Math.fround calls
-rw-r--r-- | tools/js-optimizer.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 0371b3a3..57ce0071 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2061,19 +2061,27 @@ function registerize(ast) { denormalizeAsm(fun, finalAsmData); if (extraInfo && extraInfo.globals) { // minify in asm var definitions, that denormalizeAsm just generated + function minify(value) { + if (value && value[0] === 'call' && value[1][0] === 'name') { + var name = value[1][1]; + var minified = extraInfo.globals[name]; + if (minified) { + value[1][1] = minified; + } + } + } var stats = fun[3]; - for (var i = fun[2].length; i < stats.length; i++) { + for (var i = 0; i < stats.length; i++) { var line = stats[i]; - if (line[0] !== 'var') break; - var pairs = line[1]; - for (var j = 0; j < pairs.length; j++) { - var value = pairs[j][1]; - if (value && value[0] === 'call' && value[1][0] === 'name') { - var name = value[1][1]; - var minified = extraInfo.globals[name]; - if (minified) { - value[1][1] = minified; - } + if (i >= fun[2].length && line[0] !== 'var') break; // when we pass the arg and var coercions, break + if (line[0] === 'stat') { + assert(line[1][0] === 'assign'); + minify(line[1][3]); + } else { + assert(line[0] === 'var'); + var pairs = line[1]; + for (var j = 0; j < pairs.length; j++) { + minify(pairs[j][1]); } } } |