diff options
Diffstat (limited to 'deps/v8/src/lithium-codegen.cc')
-rw-r--r-- | deps/v8/src/lithium-codegen.cc | 103 |
1 files changed, 98 insertions, 5 deletions
diff --git a/deps/v8/src/lithium-codegen.cc b/deps/v8/src/lithium-codegen.cc index 89df2ce845..24c1301dc5 100644 --- a/deps/v8/src/lithium-codegen.cc +++ b/deps/v8/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<LPlatformChunk*>(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> map) { } +int LCodeGenBase::DefineDeoptimizationLiteral(Handle<Object> 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(), @@ -198,4 +290,5 @@ Deoptimizer::DeoptInfo LCodeGenBase::MakeDeoptInfo( deopt_info.inlining_id = enter_inlined ? enter_inlined->inlining_id() : 0; return deopt_info; } -} } // namespace v8::internal +} // namespace internal +} // namespace v8 |