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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 17491003: Fix a bug in graph construction for for loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | tests/language/for_test.dart » ('j') | tests/language/for_test.dart » ('J')
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 bf5d5d11a0d7f217f166038bbb72c58285d60274..ac4e35d1f21fbb58ecfe14f70709ebc76ad40da7 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -1711,34 +1711,28 @@ void EffectGraphVisitor::VisitForNode(ForNode* node) {
node->increment()->Visit(&for_increment);
// Join the loop body and increment and then tie the loop.
- JoinEntryInstr* join = node->label()->join_for_continue();
- if ((join != NULL) || for_body.is_open()) {
- JoinEntryInstr* loop_start =
+ JoinEntryInstr* continue_join = node->label()->join_for_continue();
+ if ((continue_join != NULL) || for_body.is_open()) {
+ JoinEntryInstr* loop_entry =
new JoinEntryInstr(owner()->AllocateBlockId(), owner()->try_index());
- if (join != NULL) {
- if (for_body.is_open()) for_body.Goto(join);
- AppendFragment(join, for_increment);
- for_increment.Goto(loop_start);
Kevin Millikin (Google) 2013/06/20 09:44:24 The bug is in the order of side effects here. If
+ if (continue_join != NULL) {
+ if (for_body.is_open()) for_body.Goto(continue_join);
+ Instruction* current = AppendFragment(continue_join, for_increment);
+ current->Goto(loop_entry);
} else {
for_body.Append(for_increment);
- for_body.Goto(loop_start);
+ for_body.Goto(loop_entry);
}
- Goto(loop_start);
- exit_ = loop_start;
+ Goto(loop_entry);
+ exit_ = loop_entry;
AddInstruction(
new CheckStackOverflowInstr(node->token_pos(), owner()->loop_depth()));
}
if (node->condition() == NULL) {
// Endless loop, no test.
- JoinEntryInstr* body_entry =
- new JoinEntryInstr(owner()->AllocateBlockId(), owner()->try_index());
- AppendFragment(body_entry, for_body);
- Goto(body_entry);
- if (node->label()->join_for_break() != NULL) {
- // Control flow of ForLoop continues into join_for_break.
- exit_ = node->label()->join_for_break();
- }
+ Append(for_body);
+ exit_ = node->label()->join_for_break(); // May be NULL.
} else {
TestGraphVisitor for_test(owner(),
temp_index(),
« no previous file with comments | « no previous file | tests/language/for_test.dart » ('j') | tests/language/for_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698