From 65d29d321bda17bb8836099944d8b5d6ee5f1c76 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Mon, 25 Apr 2022 17:57:21 +0200 Subject: [PATCH] [maglev] Fix deopt vs translation index Correct use the lazy deopt's deopt index in safepoints, instead of the index in the translation array. Bug: v8:7700 Change-Id: I4a99ceb8bb54f2fba5bee0e6ddd6629b44439ce1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3605609 Commit-Queue: Leszek Swirski Auto-Submit: Leszek Swirski Reviewed-by: Victor Gomes Commit-Queue: Victor Gomes Cr-Commit-Position: refs/heads/main@{#80157} --- src/maglev/maglev-code-generator.cc | 18 +++++++++++------- src/maglev/maglev-ir.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/maglev/maglev-code-generator.cc b/src/maglev/maglev-code-generator.cc index 17ea68cfe9..805a40a900 100644 --- a/src/maglev/maglev-code-generator.cc +++ b/src/maglev/maglev-code-generator.cc @@ -361,6 +361,8 @@ class MaglevCodeGeneratorImpl final { USE(optimized_out_constant_index); DCHECK_EQ(kOptimizedOutConstantIndex, optimized_out_constant_index); + int deopt_index = 0; + __ RecordComment("-- Non-lazy deopts"); for (EagerDeoptInfo* deopt_info : code_gen_state_.eager_deopts()) { EmitEagerDeopt(deopt_info); @@ -369,6 +371,7 @@ class MaglevCodeGeneratorImpl final { __ CallForDeoptimization(Builtin::kDeoptimizationEntry_Eager, 0, &deopt_info->deopt_entry_label, DeoptimizeKind::kEager, nullptr, nullptr); + deopt_index++; } __ RecordComment("-- Lazy deopts"); @@ -385,7 +388,8 @@ class MaglevCodeGeneratorImpl final { safepoint_table_builder_.UpdateDeoptimizationInfo( deopt_info->deopting_call_return_pc, deopt_info->deopt_entry_label.pos(), last_updated_safepoint, - deopt_info->deopt_index); + deopt_index); + deopt_index++; } } @@ -416,7 +420,7 @@ class MaglevCodeGeneratorImpl final { int frame_count = 1 + deopt_info->unit.inlining_depth(); int jsframe_count = frame_count; int update_feedback_count = 0; - deopt_info->deopt_index = translation_array_builder_.BeginTranslation( + deopt_info->translation_index = translation_array_builder_.BeginTranslation( frame_count, jsframe_count, update_feedback_count); EmitDeoptFrame(deopt_info->unit, deopt_info->state, @@ -431,7 +435,7 @@ class MaglevCodeGeneratorImpl final { int frame_count = 1; int jsframe_count = 1; int update_feedback_count = 0; - deopt_info->deopt_index = translation_array_builder_.BeginTranslation( + deopt_info->translation_index = translation_array_builder_.BeginTranslation( frame_count, jsframe_count, update_feedback_count); // Return offsets are counted from the end of the translation frame, which @@ -675,9 +679,9 @@ class MaglevCodeGeneratorImpl final { // Populate deoptimization entries. int i = 0; for (EagerDeoptInfo* deopt_info : code_gen_state_.eager_deopts()) { - DCHECK_NE(deopt_info->deopt_index, -1); + DCHECK_NE(deopt_info->translation_index, -1); data->SetBytecodeOffset(i, deopt_info->state.bytecode_position); - data->SetTranslationIndex(i, Smi::FromInt(deopt_info->deopt_index)); + data->SetTranslationIndex(i, Smi::FromInt(deopt_info->translation_index)); data->SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos())); #ifdef DEBUG data->SetNodeId(i, Smi::FromInt(i)); @@ -685,9 +689,9 @@ class MaglevCodeGeneratorImpl final { i++; } for (LazyDeoptInfo* deopt_info : code_gen_state_.lazy_deopts()) { - DCHECK_NE(deopt_info->deopt_index, -1); + DCHECK_NE(deopt_info->translation_index, -1); data->SetBytecodeOffset(i, deopt_info->state.bytecode_position); - data->SetTranslationIndex(i, Smi::FromInt(deopt_info->deopt_index)); + data->SetTranslationIndex(i, Smi::FromInt(deopt_info->translation_index)); data->SetPc(i, Smi::FromInt(deopt_info->deopt_entry_label.pos())); #ifdef DEBUG data->SetNodeId(i, Smi::FromInt(i)); diff --git a/src/maglev/maglev-ir.h b/src/maglev/maglev-ir.h index 358e817f65..6f1e212dc9 100644 --- a/src/maglev/maglev-ir.h +++ b/src/maglev/maglev-ir.h @@ -358,7 +358,7 @@ class DeoptInfo { CheckpointedInterpreterState state; InputLocation* input_locations = nullptr; Label deopt_entry_label; - int deopt_index = -1; + int translation_index = -1; }; class EagerDeoptInfo : public DeoptInfo {