summaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorRyan Kelly <ryan@rfk.id.au>2014-06-04 10:59:32 +1000
committerRyan Kelly <ryan@rfk.id.au>2014-06-04 10:59:32 +1000
commit22179ab0701edd4cee78bb7f2d7576508c96f96e (patch)
treea83173bcda7af522f5a8b18a5deaa3160a7d3868 /tools/js-optimizer.js
parent0af8535621bbc7c83f454d9c979de12abfc80856 (diff)
Fix registerizeHarder handling of unlabelled 'continue' inside a 'switch'.
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 989a7932..03d7fe7f 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -2087,12 +2087,18 @@ function registerizeHarder(ast) {
function pushActiveLabels(onContinue, onBreak) {
// Push the target junctions for continuing/breaking a loop.
// This should be called before traversing into a loop.
- var newLabels = copy(activeLabels[activeLabels.length-1]);
+ var prevLabels = activeLabels[activeLabels.length-1];
+ var newLabels = copy(prevLabels);
newLabels[null] = [onContinue, onBreak];
if (nextLoopLabel) {
newLabels[nextLoopLabel] = [onContinue, onBreak];
nextLoopLabel = null;
}
+ // An unlabelled 'continue' should jump to innermost loop,
+ // ignoring any nested 'switch' statements.
+ if (onContinue === null && prevLabels[null]) {
+ newLabels[null][0] = prevLabels[null][0];
+ }
activeLabels.push(newLabels);
}