From d3d23885170ad1151277e8980d3b41313ed7b9a3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 9 Mar 2013 14:07:05 -0800 Subject: refactor registerize global substitution --- tools/js-optimizer.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 102ced8b..f944eb9b 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1408,18 +1408,6 @@ function denormalizeAsm(func, data) { // closure simple? function registerize(ast) { traverseGeneratedFunctions(ast, function(fun) { - if (minifierInfo) { - // First, fix globals. Note that we know/assume that locals cannot shadow globals. - traverse(fun, function(node, type) { - if (type == 'name') { - var minified = minifierInfo.globals[node[1]]; - if (minified) node[1] = minified; - } - }); - assert(fun[1] in minifierInfo.globals, fun[1]); - fun[1] = minifierInfo.globals[fun[1]]; - assert(fun[1]); - } if (asm) var asmData = normalizeAsm(fun); // Add parameters as a first (fake) var (with assignment), so they get taken into consideration var params = {}; // note: params are special, they can never share a register between them (see later) @@ -1456,6 +1444,18 @@ function registerize(ast) { } }); vacuum(fun); + if (minifierInfo) { + // Fix globals. Note that we know/assume that locals cannot shadow globals. + traverse(fun, function(node, type) { + if (type == 'name') { + var minified = minifierInfo.globals[node[1]]; + if (minified) node[1] = minified; + } + }); + assert(fun[1] in minifierInfo.globals, fun[1]); + fun[1] = minifierInfo.globals[fun[1]]; + assert(fun[1]); + } // Find the # of uses of each variable. // While doing so, check if all a variable's uses are dominated in a simple // way by a simple assign, if so, then we can assign its register to it -- cgit v1.2.3-18-g5258