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

Unified Diff: frog/leg/ssa/codegen.dart

Issue 9632018: Switch-implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 9 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
Index: frog/leg/ssa/codegen.dart
diff --git a/frog/leg/ssa/codegen.dart b/frog/leg/ssa/codegen.dart
index 5a5531f571d41974aea29c77ab2772c5243a0e8f..cad5d8f56b798c3e796e27e23d39f0f0ed1f942a 100644
--- a/frog/leg/ssa/codegen.dart
+++ b/frog/leg/ssa/codegen.dart
@@ -215,7 +215,7 @@ class SsaCodeGenerator implements HVisitor {
if (i != HInvoke.ARGUMENTS_OFFSET) buffer.add(', ');
use(inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE);
}
- buffer.add(")");
+ buffer.add(')');
}
void define(HInstruction instruction) {
@@ -240,20 +240,28 @@ class SsaCodeGenerator implements HVisitor {
void handleLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
addIndentation();
- for (SourceString label in labeledBlockInfo.labels) {
+ for (LabelElement label in labeledBlockInfo.labels) {
addLabel(label);
- buffer.add(":");
+ buffer.add(':');
+ }
+ String implicitLabel = labeledBlockInfo.target.implicitLabel();
+ if (implicitLabel !== null) {
+ buffer.add(@'$');
+ buffer.add(implicitLabel);
+ buffer.add(@':');
}
- buffer.add("{\n");
+ buffer.add('{\n');
indent++;
visitSubGraph(labeledBlockInfo.body);
indent--;
addIndentation();
- buffer.add("}\n");
+ buffer.add('}\n');
- visitBasicBlock(labeledBlockInfo.joinBlock);
+ if (labeledBlockInfo.joinBlock !== null) {
+ visitBasicBlock(labeledBlockInfo.joinBlock);
+ }
}
@@ -422,8 +430,9 @@ class SsaCodeGenerator implements HVisitor {
// Used to write the name of labels.
// The default implementation uses the unmodified Dart label name.
// Specializations might change this.
- void addLabel(SourceString label) {
- buffer.add(label.slowToString());
+ void addLabel(LabelElement label) {
+ buffer.add(@'$');
+ buffer.add(label.labelName);
}
visitBreak(HBreak node) {
@@ -437,9 +446,17 @@ class SsaCodeGenerator implements HVisitor {
// Otherwise we would have bailed out in the builder.
addIndentation();
buffer.add("break");
- if (node.label !== null) {
+ if (node.target is LabelElement) {
+ LabelElement target = node.target;
buffer.add(" ");
- addLabel(node.label);
+ addLabel(target);
+ } else {
+ StatementElement target = node.target;
+ String implicitLabel = target.implicitLabel();
+ if (implicitLabel !== null) {
+ buffer.add(@' $');
+ buffer.add(implicitLabel);
+ }
}
buffer.add(";\n");
}
@@ -1140,8 +1157,9 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
void beginLoop(HBasicBlock block) {
addIndentation();
- for (SourceString label in block.loopInformation.labels) {
- buffer.add("${label.slowToString()}:");
+ for (LabelElement label in block.loopInformation.labels) {
+ addLabel(label);
+ buffer.add(":");
}
buffer.add('while (true) {\n');
indent++;
@@ -1307,8 +1325,8 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator {
// Adds a "$" in front of names of labels from the original source.
// This avoids conflicts with labels introduced by bailouts, which
// starts with a non-"$" character.
- void addLabel(SourceString label) {
- buffer.add("\$$label");
+ void addLabel(LabelElement label) {
+ buffer.add("\$${label.labelName}");
}
void beginLoop(HBasicBlock block) {
@@ -1319,7 +1337,7 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator {
}
addIndentation();
- for (SourceString label in block.loopInformation.labels) {
+ for (LabelElement label in block.loopInformation.labels) {
addLabel(label);
buffer.add(":");
}

Powered by Google App Engine
This is Rietveld 408576698