| 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..9cd1d8e66ef0ba1b47960fccbf60e8af35260f02 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.
|
| + */
|
| + final List<bool> defaultClauseUsedInBailoutStack;
|
|
|
| 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>[],
|
| + defaultClauseUsedInBailoutStack = <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 (!defaultClauseUsedInBailoutStack.last() &&
|
| + bailouts1.length + bailouts2.length >= 2) {
|
| + addIndented('default:\n');
|
| + int len = defaultClauseUsedInBailoutStack.length;
|
| + defaultClauseUsedInBailoutStack[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 (!defaultClauseUsedInBailoutStack.last() && guards.length >= 2) {
|
| + addIndented('default:\n');
|
| + int len = defaultClauseUsedInBailoutStack.length;
|
| + defaultClauseUsedInBailoutStack[len - 1] = true;
|
| + } else {
|
| + for (int i = 0, len = guards.length; i < len; i++) {
|
| + addIndented('case ${guards[i].state}:\n');
|
| + }
|
| }
|
| }
|
|
|
| void startBailoutSwitch() {
|
| + defaultClauseUsedInBailoutStack.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'.
|
| + defaultClauseUsedInBailoutStack.removeLast();
|
| }
|
|
|
| void beginLoop(HBasicBlock block) {
|
|
|