aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-09 18:33:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-09 18:33:48 -0700
commit24e61522f29d3796c0a1d2736d6008006b2e4ad6 (patch)
tree8f730aba89278f06856275a4c6f7c226d8082f5a /tools/js-optimizer.js
parentb12e4059465169ae9302c3565b08fc30e9132781 (diff)
parent953ebf768763fe93a0af76f5007d1f69f91d6440 (diff)
Merge branch 'incoming'
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) {