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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 9635014: Support compilation of for loops. (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 | « no previous file | 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..44a7fafeadf6aa244e62a19037998d976c5e773d 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -610,7 +610,41 @@ void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) {
void EffectGraphVisitor::VisitForNode(ForNode* node) {
- Bailout("EffectGraphVisitor::VisitForNode");
+ EffectGraphVisitor for_initializer(owner(), temp_index());
+ node->initializer()->Visit(&for_initializer);
+ Append(for_initializer);
+ if (!is_open()) return;
srdjan 2012/03/08 17:55:12 Should this be an assert? Can we have initializers
Kevin Millikin (Google) 2012/03/09 08:52:53 Other than the throw in expression context issue t
+
+ EffectGraphVisitor for_body(owner(), temp_index());
+ node->body()->Visit(&for_body);
+ if (for_body.is_open()) {
+ EffectGraphVisitor for_increment(owner(), temp_index());
+ node->increment()->Visit(&for_increment);
+ for_body.Append(for_increment);
+ }
+
+ if (node->condition() != NULL) {
+ TestGraphVisitor for_test(owner(), temp_index());
+ node->condition()->Visit(&for_test);
+ TieLoop(for_test, for_body);
+ return;
+ }
+
+ // Degenerate cases. An absent condition is implicitly true. No
+ // normal exit from loop => no back edge.
+ if (!for_body.is_open()) {
+ Append(for_body);
+ return;
+ }
+ JoinEntryInstr* join = new JoinEntryInstr();
+ AddInstruction(join);
+ if (for_body.is_empty()) {
+ join->SetSuccessor(join);
+ } else {
+ join->SetSuccessor(for_body.entry());
+ for_body.exit()->SetSuccessor(join);
+ }
+ CloseFragment();
}
« 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