From 00338e07d6365fdf2f0ddfa55f95b89d3061f34c Mon Sep 17 00:00:00 2001 From: Benjamin Stover Date: Mon, 30 Jul 2012 18:43:30 -0700 Subject: Bitshift optimizer anticipates fns with switches Conflicts: AUTHORS --- tools/js-optimizer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools/js-optimizer.js') 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) { -- cgit v1.2.3-70-g09d2