Index: runtime/vm/flow_graph_builder.cc |
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc |
index c5460be9ff01b152ae9b246658cd9b9bb40edf5c..4bf3ec999cf74a8a5df01081991a6e97871525bc 100644 |
--- a/runtime/vm/flow_graph_builder.cc |
+++ b/runtime/vm/flow_graph_builder.cc |
@@ -2176,8 +2176,13 @@ void EffectGraphVisitor::VisitForNode(ForNode* node) { |
} |
Goto(loop_entry); |
exit_ = loop_entry; |
+ // Note: the stack overflow check happens on the back branch that jumps |
+ // to the increment instruction. The token position for the overflow |
+ // check must match the position of the increment expression, so that |
+ // the context level (if any) matches the that of the increment |
+ // expression. |
AddInstruction( |
- new(Z) CheckStackOverflowInstr(node->token_pos(), |
+ new(Z) CheckStackOverflowInstr(node->increment()->token_pos(), |
owner()->loop_depth())); |
} |