Chromium Code Reviews| Index: src/compiler/arm64/code-generator-arm64.cc |
| diff --git a/src/compiler/arm64/code-generator-arm64.cc b/src/compiler/arm64/code-generator-arm64.cc |
| index 54fe76c3d1762889a3a703f040764614417431ac..7125263fd5158dc39c3f18dea4688d94d2c773e5 100644 |
| --- a/src/compiler/arm64/code-generator-arm64.cc |
| +++ b/src/compiler/arm64/code-generator-arm64.cc |
| @@ -279,7 +279,8 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
| value_(value), |
| scratch0_(scratch0), |
| scratch1_(scratch1), |
| - mode_(mode) {} |
| + mode_(mode), |
| + must_save_lr_(!gen->frame_access_state()->has_frame()) {} |
| void Generate() final { |
| if (mode_ > RecordWriteMode::kValueIsPointer) { |
| @@ -293,7 +294,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
| : OMIT_REMEMBERED_SET; |
| SaveFPRegsMode const save_fp_mode = |
| frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; |
| - if (!frame()->needs_frame()) { |
| + if (must_save_lr_) { |
| // We need to save and restore lr if the frame was elided. |
| __ Push(lr); |
| } |
| @@ -301,7 +302,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
| remembered_set_action, save_fp_mode); |
| __ Add(scratch1_, object_, index_); |
| __ CallStub(&stub); |
| - if (!frame()->needs_frame()) { |
| + if (must_save_lr_) { |
| __ Pop(lr); |
| } |
| } |
| @@ -313,6 +314,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
| Register const scratch0_; |
| Register const scratch1_; |
| RecordWriteMode const mode_; |
| + bool must_save_lr_; |
| }; |
| @@ -466,6 +468,15 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { |
| } \ |
| } while (0) |
| +void CodeGenerator::AssembleDeconstructFrame() { |
| + const CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| + if (descriptor->IsCFunctionCall() || descriptor->UseNativeStack()) { |
| + __ Mov(csp, fp); |
| + } else { |
| + __ Mov(jssp, fp); |
| + } |
| + __ Pop(fp, lr); |
| +} |
| void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
| int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
| @@ -482,7 +493,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
| __ Claim(-sp_slot_delta); |
| frame_access_state()->IncreaseSPDelta(-sp_slot_delta); |
| } |
| - if (frame()->needs_frame()) { |
| + if (frame_access_state()->has_frame()) { |
| __ Ldr(lr, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); |
| __ Ldr(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| } |
| @@ -664,7 +675,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| __ mov(i.OutputRegister(), fp); |
| break; |
| case kArchParentFramePointer: |
| - if (frame_access_state()->frame()->needs_frame()) { |
| + if (frame_access_state()->has_frame()) { |
| __ ldr(i.OutputRegister(), MemOperand(fp, 0)); |
| } else { |
| __ mov(i.OutputRegister(), fp); |
| @@ -1464,22 +1475,24 @@ void CodeGenerator::AssembleDeoptimizerCall( |
| __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
| } |
| +void CodeGenerator::SetupStackPointer() { |
|
danno
2016/03/24 12:53:05
If wonder if this should be called AssemblePrologu
Mircea Trofin
2016/03/24 17:46:11
Possibly. I want to restructure AssemblePrologue b
|
| + const CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| + if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { |
| + __ SetStackPointer(csp); |
| + } else { |
| + __ SetStackPointer(jssp); |
| + } |
| +} |
| void CodeGenerator::AssemblePrologue() { |
| CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| frame()->AlignFrame(16); |
|
danno
2016/03/24 12:53:05
Shouldn't you remove this now?
Mircea Trofin
2016/03/24 17:46:11
Done.
|
| int stack_shrink_slots = frame()->GetSpillSlotCount(); |
| - if (frame()->needs_frame()) { |
| + if (frame_access_state()->has_frame()) { |
| if (descriptor->IsJSFunctionCall()) { |
| DCHECK(!descriptor->UseNativeStack()); |
| - __ SetStackPointer(jssp); |
| __ Prologue(this->info()->GeneratePreagedPrologue()); |
| } else { |
| - if (descriptor->UseNativeStack() || descriptor->IsCFunctionCall()) { |
| - __ SetStackPointer(csp); |
| - } else { |
| - __ SetStackPointer(jssp); |
| - } |
| if (descriptor->IsCFunctionCall()) { |
| __ Push(lr, fp); |
| __ Mov(fp, masm_.StackPointer()); |
| @@ -1489,15 +1502,8 @@ void CodeGenerator::AssemblePrologue() { |
| frame()->GetTotalFrameSlotCount()); |
| } |
| } |
| - } else { |
| - if (descriptor->UseNativeStack()) { |
| - __ SetStackPointer(csp); |
| - } else { |
| - __ SetStackPointer(jssp); |
| - } |
| - frame()->SetElidedFrameSizeInSlots(0); |
| } |
| - frame_access_state()->SetFrameAccessToDefault(); |
| + |
| if (info()->is_osr()) { |
| // TurboFan OSR-compiled functions cannot be entered directly. |
| __ Abort(kShouldNotDirectlyEnterOsrFunction); |
| @@ -1558,22 +1564,14 @@ void CodeGenerator::AssembleReturn() { |
| int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| if (descriptor->IsCFunctionCall()) { |
| - __ Mov(csp, fp); |
| - __ Pop(fp, lr); |
| - } else if (frame()->needs_frame()) { |
| - // Canonicalize JSFunction return sites for now. |
| + AssembleDeconstructFrame(); |
| + } else if (frame_access_state()->has_frame()) { |
| if (return_label_.is_bound()) { |
| __ B(&return_label_); |
| return; |
| } else { |
| __ Bind(&return_label_); |
| - if (descriptor->UseNativeStack()) { |
| - __ Mov(csp, fp); |
| - pop_count += (pop_count & 1); // align |
| - } else { |
| - __ Mov(jssp, fp); |
| - } |
| - __ Pop(fp, lr); |
| + AssembleDeconstructFrame(); |
| } |
| } else if (descriptor->UseNativeStack()) { |
| pop_count += (pop_count & 1); // align |