Index: src/lithium-codegen.cc |
diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc |
index 6fac0b9e2c8a1f0d5d20fb607dc6994e87c15865..24c1301dc514b59dcfa5f4c7daa8bf38ff31122c 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<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(), |