aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-08 17:30:58 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-08 17:30:58 -0800
commit8a7a96a56bcb63d19c03c0c93c662c9493c3c77f (patch)
tree47ee801a55c6d266530f6bad4c28d8deb86ee9d8 /tools/js-optimizer.js
parentdac020142d05493a1c47632e561f4069a85ee13a (diff)
start to minify inside functions, using global data from previous pass
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 092c9f35..7b774dee 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1397,14 +1397,26 @@ function denormalizeAsm(func, data) {
//printErr('denormalized \n\n' + astToSrc(func) + '\n\n');
}
-// Very simple 'registerization', coalescing of variables into a smaller number.
+// Very simple 'registerization', coalescing of variables into a smaller number,
+// as part of minification. Globals-level minification began in a previous pass,
+// we receive minifierInfo which tells us how to rename globals.
+//
// We do not optimize when there are switches, so this pass only makes sense with
// relooping.
// TODO: Consider how this fits in with the rest of the optimization toolchain. Do
// we still need the eliminator? Closure? And in what order? Perhaps just
// closure simple?
function registerize(ast) {
+ assert(minifierInfo);
+
traverseGeneratedFunctions(ast, function(fun) {
+ // 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;
+ }
+ });
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)