diff options
author | Benjamin Stover <benjamin.stover@gmail.com> | 2012-07-30 18:43:30 -0700 |
---|---|---|
committer | Benjamin Stover <benjamin.stover@gmail.com> | 2012-09-05 11:18:40 -0700 |
commit | 00338e07d6365fdf2f0ddfa55f95b89d3061f34c (patch) | |
tree | c667bb2730882a90ae75fc0839b7e7182e6463fb /tools/js-optimizer.js | |
parent | ef417d0e7f4d387e0dc378502651851a5f942a26 (diff) |
Bitshift optimizer anticipates fns with switches
Conflicts:
AUTHORS
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index d58c8c6c..e1cfbe65 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -485,13 +485,20 @@ function optimizeShiftsInternal(ast, conservative) { } // vars // XXX if var has >>=, ignore it here? That means a previous pass already optimized it - traverse(fun, function(node, type) { + var hasSwitch = traverse(fun, function(node, type) { if (type == 'var') { node[1].forEach(function(arg) { newVar(arg[0], false, arg[1]); }); + } else if (type == 'switch') { + // The relooper can't always optimize functions, and we currently don't work with + // switch statements when optimizing shifts. Bail. + return true; } }); + if (hasSwitch) { + break; + } // uses and defs TODO: weight uses by being inside a loop (powers). without that, we // optimize for code size, not speed. traverse(fun, function(node, type, stack) { |