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

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: Rebased. 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 af58ef1374646657eb2ef328949510e940b8b544..ba0db0c9e4c81455dc9d080285da9154f926a5aa 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -266,7 +266,10 @@ class BytecodeGenerator::ControlScopeForIteration final
LoopBuilder* loop_builder)
: ControlScope(generator),
statement_(statement),
- loop_builder_(loop_builder) {}
+ loop_builder_(loop_builder) {
+ generator->loop_depth_++;
+ }
+ ~ControlScopeForIteration() { generator()->loop_depth_--; }
protected:
bool Execute(Command command, Statement* statement) override {
@@ -597,7 +600,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());
}
@@ -719,8 +723,8 @@ 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.
- builder()->OsrPoll(0);
+ int level = Min(loop_depth_, AbstractCode::kMaxLoopNestingMarker - 1);
+ builder()->OsrPoll(level);
}
if (stmt->yield_count() > 0) {
« 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