Chromium Code Reviews| Index: src/compiler/code-generator.cc |
| diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc |
| index b091a5ceb8ffda5c142c7784197ac1e1cc2086f4..32c57a2cad43b489f0f8c5440e5a6e5c98567704 100644 |
| --- a/src/compiler/code-generator.cc |
| +++ b/src/compiler/code-generator.cc |
| @@ -56,12 +56,8 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, |
| for (int i = 0; i < code->InstructionBlockCount(); ++i) { |
| new (&labels_[i]) Label; |
| } |
| - if (code->ContainsCall()) { |
| - frame->MarkNeedsFrame(); |
| - } |
| } |
| - |
| Handle<Code> CodeGenerator::GenerateCode() { |
| CompilationInfo* info = this->info(); |
| @@ -80,10 +76,6 @@ Handle<Code> CodeGenerator::GenerateCode() { |
| } |
| // Architecture-specific, linkage-specific prologue. |
| info->set_prologue_offset(masm()->pc_offset()); |
| - AssemblePrologue(); |
| - if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) { |
| - masm()->InitializeRootRegister(); |
| - } |
| // Define deoptimization literals for all inlined functions. |
| DCHECK_EQ(0u, deoptimization_literals_.size()); |
| @@ -103,7 +95,9 @@ Handle<Code> CodeGenerator::GenerateCode() { |
| DefineDeoptimizationLiteral(inlined.inlined_code_object_root); |
| } |
| } |
| - |
| + // Finish the Frame |
| + frame()->AlignFrame(kFrameAlignmentInBytes); |
| + SetupStackPointer(); |
| // Assemble all non-deferred blocks, followed by deferred ones. |
| for (int deferred = 0; deferred < 2; ++deferred) { |
| for (const InstructionBlock* block : code()->instruction_blocks()) { |
| @@ -143,10 +137,26 @@ Handle<Code> CodeGenerator::GenerateCode() { |
| SNPrintF(buffer, " --"); |
| masm()->RecordComment(buffer_start); |
| } |
| + |
| + frame_access_state()->MarkHasFrame(block->needs_frame()); |
| + |
| masm()->bind(GetLabel(current_block_)); |
| + if (block->must_construct_frame()) { |
| + AssemblePrologue(); |
| + if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) { |
| + masm()->InitializeRootRegister(); |
| + } |
| + } |
| + |
| for (int i = block->code_start(); i < block->code_end(); ++i) { |
| - AssembleInstruction(code()->InstructionAt(i)); |
| + Instruction* instr = code()->InstructionAt(i); |
|
danno
2016/03/22 18:10:09
This is way more complicated than it needs to be A
|
| + if (i == block->last_instruction_index()) { |
| + frame_access_state()->set_deconstruct_frame_if_needed( |
| + block->must_deconstruct_frame()); |
| + } |
| + AssembleInstruction(instr); |
| } |
| + AssembleDeconstructFrameIfNeeded(); |
|
danno
2016/03/22 18:10:09
And directly here:
if (block->must_deconstruct_fr
Mircea Trofin
2016/03/22 19:04:09
The problem is the instruction being assembled. I
|
| } |
| } |
| @@ -290,6 +300,29 @@ bool CodeGenerator::IsMaterializableFromRoot( |
| return false; |
| } |
| +void CodeGenerator::AssembleDeconstructFrameIfNeeded() { |
| + if (frame_access_state()->deconstruct_frame_if_needed()) { |
| + AssembleDeconstructFrame(); |
| + frame_access_state()->set_deconstruct_frame_if_needed(false); |
| + } |
| +} |
| + |
| +bool CodeGenerator::AssembleDeconstructFrameUsingReturnLabel() { |
| + bool ret = return_label_.is_bound(); |
| + if (return_label_.is_bound()) { |
| + if (!frame_access_state()->return_block_deconstructs()) { |
| + AssembleDeconstructFrameIfNeeded(); |
| + } |
| + masm()->jmp(&return_label_); |
| + } else { |
| + masm()->bind(&return_label_); |
| + if (frame_access_state()->deconstruct_frame_if_needed()) { |
| + frame_access_state()->MarkReturnBlockDeconstructs(); |
| + } |
| + AssembleDeconstructFrameIfNeeded(); |
| + } |
| + return ret; |
| +} |
| void CodeGenerator::AssembleInstruction(Instruction* instr) { |
| AssembleGaps(instr); |
| @@ -761,19 +794,20 @@ DeoptimizationExit* CodeGenerator::AddDeoptimizationExit( |
| } |
| int CodeGenerator::TailCallFrameStackSlotDelta(int stack_param_delta) { |
| - CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| - int spill_slots = frame()->GetSpillSlotCount(); |
| - bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
| + // CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| + // int spill_slots = frame()->GetSpillSlotCount(); |
| + // bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
| + // DCHECK(has_frame == frame_access_state()->frame_enabled()); |
|
danno
2016/03/22 18:10:09
I think you can remove this commented-out code.
|
| // Leave the PC on the stack on platforms that have that as part of their ABI |
| int pc_slots = V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK ? 1 : 0; |
| - int sp_slot_delta = |
| - has_frame ? (frame()->GetTotalFrameSlotCount() - pc_slots) : 0; |
| + int sp_slot_delta = frame_access_state()->has_frame() |
| + ? (frame()->GetTotalFrameSlotCount() - pc_slots) |
| + : 0; |
| // Discard only slots that won't be used by new parameters. |
| sp_slot_delta += stack_param_delta; |
| return sp_slot_delta; |
| } |
| - |
| OutOfLineCode::OutOfLineCode(CodeGenerator* gen) |
| : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
| gen->ools_ = this; |