Index: src/compiler/bytecode-graph-builder.cc |
diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc |
index 6f7b374a7599eae1e15008d684b5c0b6fd0f02af..b5fe387f92710514518aad805cc444bd4119f3ba 100644 |
--- a/src/compiler/bytecode-graph-builder.cc |
+++ b/src/compiler/bytecode-graph-builder.cc |
@@ -504,6 +504,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder( |
bytecode_array()->parameter_count(), |
bytecode_array()->register_count(), info->shared_info())), |
osr_ast_id_(info->osr_ast_id()), |
+ osr_loop_offset_(-1), |
merge_environments_(local_zone), |
exception_handlers_(local_zone), |
current_exception_handler_(0), |
@@ -1933,7 +1934,7 @@ void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) { |
} |
void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) { |
- if (!osr_ast_id_.IsNone() && osr_ast_id_.ToInt() == current_offset) { |
+ if (!osr_ast_id_.IsNone() && osr_loop_offset_ == current_offset) { |
// For OSR add a special {OsrLoopEntry} node into the current loop header. |
// It will be turned into a usable entry by the OSR deconstruction. |
Environment* loop_env = merge_environments_[current_offset]; |
@@ -1948,9 +1949,10 @@ void BytecodeGraphBuilder::BuildOSRNormalEntryPoint() { |
// For OSR add an {OsrNormalEntry} as the the top-level environment start. |
// It will be replaced with {Dead} by the OSR deconstruction. |
NewNode(common()->OsrNormalEntry()); |
- // Note that the requested OSR entry point must be the target of a backward |
- // branch, otherwise there will not be a proper loop header available. |
- DCHECK(branch_analysis()->backward_branches_target(osr_ast_id_.ToInt())); |
+ // Translate the offset of the jump instruction to the jump target offset of |
+ // that instruction so that the derived BailoutId points to the loop header. |
+ osr_loop_offset_ = loop_analysis()->GetLoopOffsetFor(osr_ast_id_.ToInt()); |
+ DCHECK(branch_analysis()->backward_branches_target(osr_loop_offset_)); |
} |
} |