diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-09 14:07:05 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-09 14:07:05 -0800 |
commit | d3d23885170ad1151277e8980d3b41313ed7b9a3 (patch) | |
tree | e55a9f6a4bfcfbac7121ab4cc9a56f0502a8ea2b | |
parent | 9f9be7e02e6f8173cf883f01ccef71892b4e33e0 (diff) |
refactor registerize global substitution
-rw-r--r-- | tools/js-optimizer.js | 24 |
1 files 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 |