Chromium Code Reviews| Index: lib/compiler/implementation/ssa/codegen.dart |
| diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart |
| index 431f501127b9dfe4d4509a17ab91a172d0b9a162..bee01e2b07b789494cfb9d6832847591f483922f 100644 |
| --- a/lib/compiler/implementation/ssa/codegen.dart |
| +++ b/lib/compiler/implementation/ssa/codegen.dart |
| @@ -2866,6 +2866,12 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| final CodeBuffer newParameters; |
| final List<String> labels; |
| int labelId = 0; |
| + /** |
| + * Keeps track if a bailout switch already used its [:default::] clause. New |
| + * bailout-switches just push [:false:] on the stack and replace it when |
| + * they used the [:default::] clause.'s |
|
ricow1
2012/07/23 12:03:59
strange end of comment
floitsch
2012/07/23 13:04:26
Done.
|
| + */ |
| + final List<bool> bailoutHasUsedDefaultClauseStack; |
|
ricow1
2012/07/23 12:03:59
defaultClauseUsedInBailoutStack - one character sm
floitsch
2012/07/23 13:04:26
Done.
|
| SsaBailoutPropagator propagator; |
| HInstruction savedFirstInstruction; |
| @@ -2874,7 +2880,8 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| : super(backend, work, parameters, parameterNames), |
| setup = new CodeBuffer(), |
| newParameters = new CodeBuffer(), |
| - labels = <String>[]; |
| + labels = <String>[], |
| + bailoutHasUsedDefaultClauseStack = <bool>[]; |
| String pushLabel() { |
| String label = 'L${labelId++}'; |
| @@ -3000,18 +3007,32 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| void startBailoutCase(List<HTypeGuard> bailouts1, |
| List<HTypeGuard> bailouts2) { |
| indent--; |
| - handleBailoutCase(bailouts1); |
| - handleBailoutCase(bailouts2); |
| + if (!bailoutHasUsedDefaultClauseStack.last() && |
| + bailouts1.length + bailouts2.length >= 2) { |
| + addIndented('default:\n'); |
| + int len = bailoutHasUsedDefaultClauseStack.length; |
| + bailoutHasUsedDefaultClauseStack[len - 1] = true; |
| + } else { |
| + handleBailoutCase(bailouts1); |
| + handleBailoutCase(bailouts2); |
| + } |
| indent++; |
| } |
| void handleBailoutCase(List<HTypeGuard> guards) { |
| - for (int i = 0, len = guards.length; i < len; i++) { |
| - addIndented('case ${guards[i].state}:\n'); |
| + if (!bailoutHasUsedDefaultClauseStack.last() && guards.length >= 2) { |
| + addIndented('default:\n'); |
| + int len = bailoutHasUsedDefaultClauseStack.length; |
| + bailoutHasUsedDefaultClauseStack[len - 1] = true; |
| + } else { |
| + for (int i = 0, len = guards.length; i < len; i++) { |
| + addIndented('case ${guards[i].state}:\n'); |
| + } |
| } |
| } |
| void startBailoutSwitch() { |
| + bailoutHasUsedDefaultClauseStack.add(false); |
| addIndented('switch (state) {\n'); |
| indent++; |
| addIndented('case 0:\n'); |
| @@ -3022,6 +3043,7 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| indent--; // Close 'case'. |
| indent--; |
| addIndented('}\n'); // Close 'switch'. |
| + bailoutHasUsedDefaultClauseStack.removeLast(); |
| } |
| void beginLoop(HBasicBlock block) { |