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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2176183002: [interpreter] Implement static loop depth tracking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_osr-2
Patch Set: Created 4 years, 5 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 | « src/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698