OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 if (continue_join != NULL) { | 2169 if (continue_join != NULL) { |
2170 if (for_body.is_open()) for_body.Goto(continue_join); | 2170 if (for_body.is_open()) for_body.Goto(continue_join); |
2171 Instruction* current = AppendFragment(continue_join, for_increment); | 2171 Instruction* current = AppendFragment(continue_join, for_increment); |
2172 current->Goto(loop_entry); | 2172 current->Goto(loop_entry); |
2173 } else { | 2173 } else { |
2174 for_body.Append(for_increment); | 2174 for_body.Append(for_increment); |
2175 for_body.Goto(loop_entry); | 2175 for_body.Goto(loop_entry); |
2176 } | 2176 } |
2177 Goto(loop_entry); | 2177 Goto(loop_entry); |
2178 exit_ = loop_entry; | 2178 exit_ = loop_entry; |
| 2179 // Note: the stack overflow check happens on the back branch that jumps |
| 2180 // to the increment instruction. The token position for the overflow |
| 2181 // check must match the position of the increment expression, so that |
| 2182 // the context level (if any) matches the that of the increment |
| 2183 // expression. |
2179 AddInstruction( | 2184 AddInstruction( |
2180 new(Z) CheckStackOverflowInstr(node->token_pos(), | 2185 new(Z) CheckStackOverflowInstr(node->increment()->token_pos(), |
2181 owner()->loop_depth())); | 2186 owner()->loop_depth())); |
2182 } | 2187 } |
2183 | 2188 |
2184 if (node->condition() == NULL) { | 2189 if (node->condition() == NULL) { |
2185 // Endless loop, no test. | 2190 // Endless loop, no test. |
2186 Append(for_body); | 2191 Append(for_body); |
2187 exit_ = nested_loop.break_target(); // May be NULL. | 2192 exit_ = nested_loop.break_target(); // May be NULL. |
2188 } else { | 2193 } else { |
2189 EffectGraphVisitor for_test_preamble(owner()); | 2194 EffectGraphVisitor for_test_preamble(owner()); |
2190 if (node->condition_preamble() != NULL) { | 2195 if (node->condition_preamble() != NULL) { |
(...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4651 Script::Handle(function.script()), | 4656 Script::Handle(function.script()), |
4652 function.token_pos(), | 4657 function.token_pos(), |
4653 Report::AtLocation, | 4658 Report::AtLocation, |
4654 "FlowGraphBuilder Bailout: %s %s", | 4659 "FlowGraphBuilder Bailout: %s %s", |
4655 String::Handle(function.name()).ToCString(), | 4660 String::Handle(function.name()).ToCString(), |
4656 reason); | 4661 reason); |
4657 UNREACHABLE(); | 4662 UNREACHABLE(); |
4658 } | 4663 } |
4659 | 4664 |
4660 } // namespace dart | 4665 } // namespace dart |
OLD | NEW |