Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10796084: Use 'default:' for the first bailout-case with more than one target. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698