[interpreter] Implement static loop depth tracking.
This adds tracking of the loop depth to the {BytecodeGenerator} in order to statically determine the loop nesting level for {OsrPoll} bytecodes. R=rmcilroy@chromium.org BUG=v8:4764 Review-Url: https://codereview.chromium.org/2176183002 Cr-Commit-Position: refs/heads/master@{#38064}
This commit is contained in:
parent
fbf04c3705
commit
7bb24abe03
@ -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) {
|
||||
|
@ -214,6 +214,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
RegisterAllocationScope* register_allocator_;
|
||||
ZoneVector<BytecodeLabel> generator_resume_points_;
|
||||
Register generator_state_;
|
||||
int loop_depth_;
|
||||
};
|
||||
|
||||
} // namespace interpreter
|
||||
|
Loading…
Reference in New Issue
Block a user