aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-05 14:35:13 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-05 14:35:13 -0700
commitc054ea211c278912913a9a537a1ec3cb71796b29 (patch)
tree62cdb60ab6af04e3f368c05cba2f70fe27919f61 /tools/js-optimizer.js
parent41d10c114da0316f90d1b482cacd61d10c2da5cb (diff)
parent00338e07d6365fdf2f0ddfa55f95b89d3061f34c (diff)
Merge pull request #559 from stechz/incoming
Bitshift optimizer anticipates fns with switches
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js9
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) {