| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 5ec33895e44d50f568edeff1b0c944fd4eff5b53..65da35e7e869d563dcc032c5e93598323e4494f2 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -7609,9 +7609,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
|
| unoptimized->kind() == Code::FUNCTION) {
|
| CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
|
| if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) {
|
| - isolate->runtime_profiler()->AttemptOnStackReplacement(*function);
|
| - unoptimized->set_allow_osr_at_loop_nesting_level(
|
| - Code::kMaxLoopNestingMarker);
|
| + for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) {
|
| + unoptimized->set_allow_osr_at_loop_nesting_level(i);
|
| + isolate->runtime_profiler()->AttemptOnStackReplacement(*function);
|
| + }
|
| } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("parallel"))) {
|
| function->MarkForParallelRecompilation();
|
| }
|
| @@ -7708,21 +7709,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
|
| // the AST id matching the PC.
|
| Address start = unoptimized->instruction_start();
|
| unsigned target_pc_offset = static_cast<unsigned>(frame->pc() - start);
|
| - Address table_cursor = start + unoptimized->stack_check_table_offset();
|
| + Address table_cursor = start + unoptimized->back_edge_table_offset();
|
| uint32_t table_length = Memory::uint32_at(table_cursor);
|
| table_cursor += kIntSize;
|
| + static const int kBackEdgeEntrySize = 2 * kIntSize + kOneByteSize;
|
| + uint8_t loop_depth = 0;
|
| for (unsigned i = 0; i < table_length; ++i) {
|
| // Table entries are (AST id, pc offset) pairs.
|
| uint32_t pc_offset = Memory::uint32_at(table_cursor + kIntSize);
|
| if (pc_offset == target_pc_offset) {
|
| ast_id = BailoutId(static_cast<int>(Memory::uint32_at(table_cursor)));
|
| + loop_depth = Memory::uint8_at(table_cursor + 2 * kIntSize);
|
| break;
|
| }
|
| - table_cursor += 2 * kIntSize;
|
| + table_cursor += kBackEdgeEntrySize;
|
| }
|
| ASSERT(!ast_id.IsNone());
|
| if (FLAG_trace_osr) {
|
| - PrintF("[replacing on-stack at AST id %d in ", ast_id.ToInt());
|
| + PrintF("[replacing on-stack at AST id %d, loop depth %d in ",
|
| + ast_id.ToInt(), loop_depth);
|
| function->PrintName();
|
| PrintF("]\n");
|
| }
|
| @@ -7757,11 +7762,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
|
| PrintF("]\n");
|
| }
|
| InterruptStub interrupt_stub;
|
| - Handle<Code> check_code = interrupt_stub.GetCode(isolate);
|
| + Handle<Code> interrupt_code = interrupt_stub.GetCode(isolate);
|
| Handle<Code> replacement_code = isolate->builtins()->OnStackReplacement();
|
| - Deoptimizer::RevertStackCheckCode(*unoptimized,
|
| - *check_code,
|
| - *replacement_code);
|
| + Deoptimizer::RevertInterruptCode(*unoptimized,
|
| + *interrupt_code,
|
| + *replacement_code);
|
|
|
| // Allow OSR only at nesting level zero again.
|
| unoptimized->set_allow_osr_at_loop_nesting_level(0);
|
|
|