From 1c5d4d7eda4a0e7c8c907df461a26f28f5d92a4e Mon Sep 17 00:00:00 2001 From: jarin Date: Wed, 10 Jun 2015 23:09:07 -0700 Subject: [PATCH] Make writing of frame translation platform independent. BUG= R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/1175963002 Cr-Commit-Position: refs/heads/master@{#28923} --- src/arm/lithium-codegen-arm.cc | 88 +----------------------------- src/arm/lithium-codegen-arm.h | 3 -- src/arm64/lithium-codegen-arm64.cc | 88 +----------------------------- src/arm64/lithium-codegen-arm64.h | 3 -- src/ia32/lithium-codegen-ia32.cc | 88 +----------------------------- src/ia32/lithium-codegen-ia32.h | 3 -- src/lithium-codegen.cc | 100 +++++++++++++++++++++++++++++++++-- src/lithium-codegen.h | 6 +++ src/mips/lithium-codegen-mips.cc | 88 +----------------------------- src/mips/lithium-codegen-mips.h | 3 -- src/mips64/lithium-codegen-mips64.cc | 88 +----------------------------- src/mips64/lithium-codegen-mips64.h | 3 -- src/ppc/lithium-codegen-ppc.cc | 88 +----------------------------- src/ppc/lithium-codegen-ppc.h | 3 -- src/x64/lithium-codegen-x64.cc | 88 +----------------------------- src/x64/lithium-codegen-x64.h | 3 -- src/x87/lithium-codegen-x87.cc | 44 +-------------- src/x87/lithium-codegen-x87.h | 3 -- 18 files changed, 110 insertions(+), 680 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 6cf98f8..8f6cdd3 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -596,85 +596,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -1002,16 +926,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index add08a1..75b0fc0 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -27,7 +27,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -242,7 +241,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -328,7 +326,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index cf6816d..ec6e3c7 100644 --- a/src/arm64/lithium-codegen-arm64.cc +++ b/src/arm64/lithium-codegen-arm64.cc @@ -224,85 +224,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -383,16 +307,6 @@ void LCodeGen::AddToTranslation(LEnvironment* environment, } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment, Safepoint::DeoptMode mode) { environment->set_has_been_used(); diff --git a/src/arm64/lithium-codegen-arm64.h b/src/arm64/lithium-codegen-arm64.h index 76ad8d4..c9ad76c 100644 --- a/src/arm64/lithium-codegen-arm64.h +++ b/src/arm64/lithium-codegen-arm64.h @@ -28,7 +28,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -198,7 +197,6 @@ class LCodeGen: public LCodeGenBase { Condition EmitIsString(Register input, Register temp1, Label* is_not_string, SmiCheck check_needed); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationData(Handle code); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -342,7 +340,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 3e5a2fe..ba601db 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -618,85 +618,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -1006,16 +930,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/ia32/lithium-codegen-ia32.h b/src/ia32/lithium-codegen-ia32.h index 256fa81..e56168f 100644 --- a/src/ia32/lithium-codegen-ia32.h +++ b/src/ia32/lithium-codegen-ia32.h @@ -29,7 +29,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -221,7 +220,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -329,7 +327,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc index 6fac0b9..24c1301 100644 --- a/src/lithium-codegen.cc +++ b/src/lithium-codegen.cc @@ -45,8 +45,7 @@ HGraph* LCodeGenBase::graph() const { } -LCodeGenBase::LCodeGenBase(LChunk* chunk, - MacroAssembler* assembler, +LCodeGenBase::LCodeGenBase(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) : chunk_(static_cast(chunk)), masm_(assembler), @@ -56,8 +55,8 @@ LCodeGenBase::LCodeGenBase(LChunk* chunk, current_block_(-1), current_instruction_(-1), instructions_(chunk->instructions()), - last_lazy_deopt_pc_(0) { -} + deoptimization_literals_(8, info->zone()), + last_lazy_deopt_pc_(0) {} bool LCodeGenBase::GenerateBody() { @@ -190,6 +189,99 @@ void LCodeGenBase::AddStabilityDependency(Handle map) { } +int LCodeGenBase::DefineDeoptimizationLiteral(Handle literal) { + int result = deoptimization_literals_.length(); + for (int i = 0; i < deoptimization_literals_.length(); ++i) { + if (deoptimization_literals_[i].is_identical_to(literal)) return i; + } + deoptimization_literals_.Add(literal, zone()); + return result; +} + + +void LCodeGenBase::WriteTranslationFrame(LEnvironment* environment, + Translation* translation) { + int translation_size = environment->translation_size(); + // The output frame height does not include the parameters. + int height = translation_size - environment->parameter_count(); + + switch (environment->frame_type()) { + case JS_FUNCTION: { + int shared_id = DefineDeoptimizationLiteral( + environment->entry() ? environment->entry()->shared() + : info()->shared_info()); + translation->BeginJSFrame(environment->ast_id(), shared_id, height); + if (info()->closure().is_identical_to(environment->closure())) { + translation->StoreJSFrameFunction(); + } else { + int closure_id = DefineDeoptimizationLiteral(environment->closure()); + translation->StoreLiteral(closure_id); + } + break; + } + case JS_CONSTRUCT: { + int shared_id = DefineDeoptimizationLiteral( + environment->entry() ? environment->entry()->shared() + : info()->shared_info()); + translation->BeginConstructStubFrame(shared_id, translation_size); + if (info()->closure().is_identical_to(environment->closure())) { + translation->StoreJSFrameFunction(); + } else { + int closure_id = DefineDeoptimizationLiteral(environment->closure()); + translation->StoreLiteral(closure_id); + } + break; + } + case JS_GETTER: { + DCHECK(translation_size == 1); + DCHECK(height == 0); + int shared_id = DefineDeoptimizationLiteral( + environment->entry() ? environment->entry()->shared() + : info()->shared_info()); + translation->BeginGetterStubFrame(shared_id); + if (info()->closure().is_identical_to(environment->closure())) { + translation->StoreJSFrameFunction(); + } else { + int closure_id = DefineDeoptimizationLiteral(environment->closure()); + translation->StoreLiteral(closure_id); + } + break; + } + case JS_SETTER: { + DCHECK(translation_size == 2); + DCHECK(height == 0); + int shared_id = DefineDeoptimizationLiteral( + environment->entry() ? environment->entry()->shared() + : info()->shared_info()); + translation->BeginSetterStubFrame(shared_id); + if (info()->closure().is_identical_to(environment->closure())) { + translation->StoreJSFrameFunction(); + } else { + int closure_id = DefineDeoptimizationLiteral(environment->closure()); + translation->StoreLiteral(closure_id); + } + break; + } + case ARGUMENTS_ADAPTOR: { + int shared_id = DefineDeoptimizationLiteral( + environment->entry() ? environment->entry()->shared() + : info()->shared_info()); + translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); + if (info()->closure().is_identical_to(environment->closure())) { + translation->StoreJSFrameFunction(); + } else { + int closure_id = DefineDeoptimizationLiteral(environment->closure()); + translation->StoreLiteral(closure_id); + } + break; + } + case STUB: + translation->BeginCompiledStubFrame(translation_size); + break; + } +} + + Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo( LInstruction* instr, Deoptimizer::DeoptReason deopt_reason) { Deoptimizer::DeoptInfo deopt_info(instr->hydrogen_value()->position(), diff --git a/src/lithium-codegen.h b/src/lithium-codegen.h index 80afbaf..fddc1b2 100644 --- a/src/lithium-codegen.h +++ b/src/lithium-codegen.h @@ -14,6 +14,7 @@ namespace v8 { namespace internal { +class LEnvironment; class LInstruction; class LPlatformChunk; @@ -50,6 +51,10 @@ class LCodeGenBase BASE_EMBEDDED { void RegisterWeakObjectsInOptimizedCode(Handle code); + void WriteTranslationFrame(LEnvironment* environment, + Translation* translation); + int DefineDeoptimizationLiteral(Handle literal); + // Check that an environment assigned via AssignEnvironment is actually being // used. Redundant assignments keep things alive longer than necessary, and // consequently lead to worse code, so it's important to minimize this. @@ -71,6 +76,7 @@ class LCodeGenBase BASE_EMBEDDED { int current_block_; int current_instruction_; const ZoneList* instructions_; + ZoneList > deoptimization_literals_; int last_lazy_deopt_pc_; bool is_unused() const { return status_ == UNUSED; } diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 8aa2160..39a5477 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -594,85 +594,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -969,16 +893,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/mips/lithium-codegen-mips.h b/src/mips/lithium-codegen-mips.h index a683596..7b68bd7 100644 --- a/src/mips/lithium-codegen-mips.h +++ b/src/mips/lithium-codegen-mips.h @@ -26,7 +26,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -240,7 +239,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -359,7 +357,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index cbfc2f8..c06d80f 100644 --- a/src/mips64/lithium-codegen-mips64.cc +++ b/src/mips64/lithium-codegen-mips64.cc @@ -582,85 +582,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -958,16 +882,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/mips64/lithium-codegen-mips64.h b/src/mips64/lithium-codegen-mips64.h index a9539a7..be08bd4 100644 --- a/src/mips64/lithium-codegen-mips64.h +++ b/src/mips64/lithium-codegen-mips64.h @@ -26,7 +26,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -241,7 +240,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -360,7 +358,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc index c392b10..fea04e3 100644 --- a/src/ppc/lithium-codegen-ppc.cc +++ b/src/ppc/lithium-codegen-ppc.cc @@ -566,85 +566,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -932,16 +856,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/ppc/lithium-codegen-ppc.h b/src/ppc/lithium-codegen-ppc.h index 5ebb72e..b266e8e 100644 --- a/src/ppc/lithium-codegen-ppc.h +++ b/src/ppc/lithium-codegen-ppc.h @@ -27,7 +27,6 @@ class LCodeGen : public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -213,7 +212,6 @@ class LCodeGen : public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -290,7 +288,6 @@ class LCodeGen : public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index b242bf3..331584a 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -537,85 +537,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - - switch (environment->frame_type()) { - case JS_FUNCTION: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginJSFrame(environment->ast_id(), shared_id, height); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_CONSTRUCT: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginConstructStubFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_GETTER: { - DCHECK(translation_size == 1); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginGetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case JS_SETTER: { - DCHECK(translation_size == 2); - DCHECK(height == 0); - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginSetterStubFrame(shared_id); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case ARGUMENTS_ADAPTOR: { - int shared_id = DefineDeoptimizationLiteral( - environment->entry() ? environment->entry()->shared() - : info()->shared_info()); - translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); - if (info()->closure().is_identical_to(environment->closure())) { - translation->StoreJSFrameFunction(); - } else { - int closure_id = DefineDeoptimizationLiteral(environment->closure()); - translation->StoreLiteral(closure_id); - } - break; - } - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -930,16 +854,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 4a0ed7d..d6682b6 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -28,7 +28,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -218,7 +217,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -318,7 +316,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index 58925cd..ef9807f 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -884,41 +884,9 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, // The translation includes one command per value in the environment. int translation_size = environment->translation_size(); - // The output frame height does not include the parameters. - int height = translation_size - environment->parameter_count(); WriteTranslation(environment->outer(), translation); - bool has_closure_id = !info()->closure().is_null() && - !info()->closure().is_identical_to(environment->closure()); - int closure_id = has_closure_id - ? DefineDeoptimizationLiteral(environment->closure()) - : Translation::kSelfLiteralId; - switch (environment->frame_type()) { - case JS_FUNCTION: - translation->BeginJSFrame(environment->ast_id(), closure_id, height); - break; - case JS_CONSTRUCT: - translation->BeginConstructStubFrame(closure_id, translation_size); - break; - case JS_GETTER: - DCHECK(translation_size == 1); - DCHECK(height == 0); - translation->BeginGetterStubFrame(closure_id); - break; - case JS_SETTER: - DCHECK(translation_size == 2); - DCHECK(height == 0); - translation->BeginSetterStubFrame(closure_id); - break; - case ARGUMENTS_ADAPTOR: - translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); - break; - case STUB: - translation->BeginCompiledStubFrame(translation_size); - break; - default: - UNREACHABLE(); - } + WriteTranslationFrame(environment, translation); int object_index = 0; int dematerialized_index = 0; @@ -1251,16 +1219,6 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { } -int LCodeGen::DefineDeoptimizationLiteral(Handle literal) { - int result = deoptimization_literals_.length(); - for (int i = 0; i < deoptimization_literals_.length(); ++i) { - if (deoptimization_literals_[i].is_identical_to(literal)) return i; - } - deoptimization_literals_.Add(literal, zone()); - return result; -} - - void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { DCHECK_EQ(0, deoptimization_literals_.length()); for (auto function : chunk()->inlined_functions()) { diff --git a/src/x87/lithium-codegen-x87.h b/src/x87/lithium-codegen-x87.h index 8104b1b..4376f75 100644 --- a/src/x87/lithium-codegen-x87.h +++ b/src/x87/lithium-codegen-x87.h @@ -30,7 +30,6 @@ class LCodeGen: public LCodeGenBase { : LCodeGenBase(chunk, assembler, info), deoptimizations_(4, info->zone()), jump_table_(4, info->zone()), - deoptimization_literals_(8, info->zone()), inlined_function_count_(0), scope_(info->scope()), translations_(info->zone()), @@ -248,7 +247,6 @@ class LCodeGen: public LCodeGenBase { int* object_index_pointer, int* dematerialized_index_pointer); void PopulateDeoptimizationData(Handle code); - int DefineDeoptimizationLiteral(Handle literal); void PopulateDeoptimizationLiteralsWithInlinedFunctions(); @@ -363,7 +361,6 @@ class LCodeGen: public LCodeGenBase { ZoneList deoptimizations_; ZoneList jump_table_; - ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; TranslationBuffer translations_; -- 2.7.4