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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 9634009: Implement increment of locals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 4f387f971414ebb17531c0859d5693006b903521..0b7f559412b3606ba98b31eaede4fb51089ce0ba 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -339,7 +339,46 @@ void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) {
void EffectGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
- Bailout("EffectGraphVisitor::VisitIncrOpLocalNode");
+ ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
+ // In an effect context, treat postincrement as if it were preincrement
+ // because its value is not needed.
+
+ // 1. Load the value.
+ LoadLocalComp* load = new LoadLocalComp(node->local());
+ AddInstruction(new BindInstr(temp_index(), load));
+ // 2. Increment.
+ BuildIncrOpIncrement(node->kind(), node->id(), node->token_index(),
+ temp_index() + 1);
+ // 3. Perform the store, resulting in the new value.
+ StoreLocalComp* store =
+ new StoreLocalComp(node->local(), new TempVal(temp_index()));
+ ReturnComputation(store);
+}
+
+
+void ValueGraphVisitor::VisitIncrOpLocalNode(IncrOpLocalNode* node) {
+ ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
+ if (node->prefix()) {
+ // Base class handles preincrement.
+ EffectGraphVisitor::VisitIncrOpLocalNode(node);
+ return;
+ }
+ // For postincrement, duplicate the original value to use one copy as the
+ // result.
+ //
+ // 1. Load the value.
+ LoadLocalComp* load = new LoadLocalComp(node->local());
+ AddInstruction(new BindInstr(temp_index(), load));
+ // 2. Duplicate it to increment.
+ AddInstruction(new PickTempInstr(temp_index() + 1, temp_index()));
+ // 3. Increment.
+ BuildIncrOpIncrement(node->kind(), node->id(), node->token_index(),
+ temp_index() + 2);
+ // 4. Perform the store and return the original value.
+ StoreLocalComp* store =
+ new StoreLocalComp(node->local(), new TempVal(temp_index() + 1));
+ AddInstruction(new DoInstr(store));
+ ReturnValue(new TempVal(AllocateTempIndex()));
}
@@ -1124,7 +1163,7 @@ void FlowGraphPrinter::VisitDo(DoInstr* instr) {
void FlowGraphPrinter::VisitBind(BindInstr* instr) {
- OS::Print(" t%d <-", instr->temp_index());
+ OS::Print(" t%d <- ", instr->temp_index());
instr->computation()->Accept(this);
}
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698