Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 367a50983e129084403d6c03d32bfe6df568afb6..0f7a883eb587b291af98046b6a8dfe51f6fed644 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -266,7 +266,12 @@ class BytecodeGenerator::ControlScopeForIteration final |
LoopBuilder* loop_builder) |
: ControlScope(generator), |
statement_(statement), |
- loop_builder_(loop_builder) {} |
+ loop_builder_(loop_builder) { |
+ generator->loop_depth_++; // Increment tracked loop depth. |
+ } |
+ ~ControlScopeForIteration() { |
+ generator()->loop_depth_--; // Decrement tracked loop depth. |
rmcilroy
2016/07/26 09:28:52
Not sure the comments are necessary, pretty self e
Michael Starzinger
2016/07/26 09:46:02
Done. I mostly do this to trick clang-format into
|
+ } |
protected: |
bool Execute(Command command, Statement* statement) override { |
@@ -548,7 +553,8 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info) |
execution_result_(nullptr), |
register_allocator_(nullptr), |
generator_resume_points_(info->literal()->yield_count(), info->zone()), |
- generator_state_() { |
+ generator_state_(), |
+ loop_depth_(0) { |
InitializeAstVisitor(isolate()->stack_guard()->real_climit()); |
} |
@@ -670,9 +676,9 @@ void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, |
if (FLAG_ignition_osr) { |
// TODO(4764): Merge this with another bytecode (e.g. {Jump} back edge). |
// TODO(4764): Investigate interaction with generators. |
- // TODO(4764): Track and pass correct loop depth. |
DCHECK_EQ(0, stmt->yield_count()); |
- builder()->OsrPoll(0); |
+ int level = Min(loop_depth_, AbstractCode::kMaxLoopNestingMarker - 1); |
+ builder()->OsrPoll(level); |
} |
} |