From e238b7e11fa973cd86721e5b1ed45b50b52e3c0d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 11 Nov 2013 10:23:40 -0800 Subject: minify in asm arg coercions that denormalizeAsm generates, to handle Math.fround calls --- tools/js-optimizer.js | 30 +++++++++++++++++++----------- 1 file 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]); } } } -- cgit v1.2.3-18-g5258