Commit 3cb6a22a authored by jyan's avatar jyan Committed by Commit bot

S390: [turbofan] Frame elision for code stubs.

Port 53d51c52

Original commit message:
    Removed Frame::needs_frame and the function-wide logic using it in
    favor of FrameAccessState::has_frame, which can be set on a more
    granular level, and driving it block by block.

R=mtrofin@chromium.org, joransiu@ca.ibm.com, mbrandy@us.ibm.com, michael_dawson@ca.ibm.com, rmcilroy@chromium.org
BUG=v8:4533
LOG=N

Review URL: https://codereview.chromium.org/1848623003

Cr-Commit-Position: refs/heads/master@{#35177}
parent ac7f0e2b
...@@ -167,7 +167,8 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -167,7 +167,8 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
value_(value), value_(value),
scratch0_(scratch0), scratch0_(scratch0),
scratch1_(scratch1), scratch1_(scratch1),
mode_(mode) {} mode_(mode),
must_save_lr_(!gen->frame_access_state()->has_frame()) {}
void Generate() final { void Generate() final {
if (mode_ > RecordWriteMode::kValueIsPointer) { if (mode_ > RecordWriteMode::kValueIsPointer) {
...@@ -181,7 +182,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -181,7 +182,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
: OMIT_REMEMBERED_SET; : OMIT_REMEMBERED_SET;
SaveFPRegsMode const save_fp_mode = SaveFPRegsMode const save_fp_mode =
frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs;
if (!frame()->needs_frame()) { if (must_save_lr_) {
// We need to save and restore r14 if the frame was elided. // We need to save and restore r14 if the frame was elided.
__ Push(r14); __ Push(r14);
} }
...@@ -194,7 +195,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -194,7 +195,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
__ AddP(scratch1_, object_, offset_); __ AddP(scratch1_, object_, offset_);
} }
__ CallStub(&stub); __ CallStub(&stub);
if (!frame()->needs_frame()) { if (must_save_lr_) {
// We need to save and restore r14 if the frame was elided. // We need to save and restore r14 if the frame was elided.
__ Pop(r14); __ Pop(r14);
} }
...@@ -208,6 +209,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -208,6 +209,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
Register const scratch0_; Register const scratch0_;
Register const scratch1_; Register const scratch1_;
RecordWriteMode const mode_; RecordWriteMode const mode_;
bool must_save_lr_;
}; };
Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) { Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) {
...@@ -560,6 +562,12 @@ Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) { ...@@ -560,6 +562,12 @@ Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) {
__ bind(&done); \ __ bind(&done); \
} while (0) } while (0)
void CodeGenerator::AssembleDeconstructFrame() {
__ LeaveFrame(StackFrame::MANUAL);
}
void CodeGenerator::AssembleSetupStackPointer() {}
void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
if (sp_slot_delta > 0) { if (sp_slot_delta > 0) {
...@@ -574,7 +582,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { ...@@ -574,7 +582,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
__ AddP(sp, sp, Operand(sp_slot_delta * kPointerSize)); __ AddP(sp, sp, Operand(sp_slot_delta * kPointerSize));
frame_access_state()->IncreaseSPDelta(-sp_slot_delta); frame_access_state()->IncreaseSPDelta(-sp_slot_delta);
} }
if (frame()->needs_frame()) { if (frame_access_state()->has_frame()) {
__ RestoreFrameStateForTailCall(); __ RestoreFrameStateForTailCall();
} }
frame_access_state()->SetFrameAccessToSP(); frame_access_state()->SetFrameAccessToSP();
...@@ -740,7 +748,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -740,7 +748,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ LoadRR(i.OutputRegister(), fp); __ LoadRR(i.OutputRegister(), fp);
break; break;
case kArchParentFramePointer: case kArchParentFramePointer:
if (frame_access_state()->frame()->needs_frame()) { if (frame_access_state()->has_frame()) {
__ LoadP(i.OutputRegister(), MemOperand(fp, 0)); __ LoadP(i.OutputRegister(), MemOperand(fp, 0));
} else { } else {
__ LoadRR(i.OutputRegister(), fp); __ LoadRR(i.OutputRegister(), fp);
...@@ -1780,7 +1788,7 @@ void CodeGenerator::AssembleDeoptimizerCall( ...@@ -1780,7 +1788,7 @@ void CodeGenerator::AssembleDeoptimizerCall(
void CodeGenerator::AssemblePrologue() { void CodeGenerator::AssemblePrologue() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
if (frame()->needs_frame()) { if (frame_access_state()->has_frame()) {
if (descriptor->IsCFunctionCall()) { if (descriptor->IsCFunctionCall()) {
__ Push(r14, fp); __ Push(r14, fp);
__ LoadRR(fp, sp); __ LoadRR(fp, sp);
...@@ -1788,18 +1796,11 @@ void CodeGenerator::AssemblePrologue() { ...@@ -1788,18 +1796,11 @@ void CodeGenerator::AssemblePrologue() {
__ Prologue(this->info()->GeneratePreagedPrologue(), ip); __ Prologue(this->info()->GeneratePreagedPrologue(), ip);
} else { } else {
StackFrame::Type type = info()->GetOutputStackFrameType(); StackFrame::Type type = info()->GetOutputStackFrameType();
if (!ABI_CALL_VIA_IP && // TODO(mbrandy): Detect cases where ip is the entrypoint (for
info()->output_code_kind() == Code::WASM_FUNCTION) { // efficient intialization of the constant pool pointer register).
// TODO(mbrandy): Restrict only to the wasm wrapper case.
__ StubPrologue(type); __ StubPrologue(type);
} else {
__ StubPrologue(type, ip);
} }
} }
} else {
frame()->SetElidedFrameSizeInSlots(0);
}
frame_access_state()->SetFrameAccessToDefault();
int stack_shrink_slots = frame()->GetSpillSlotCount(); int stack_shrink_slots = frame()->GetSpillSlotCount();
if (info()->is_osr()) { if (info()->is_osr()) {
...@@ -1861,20 +1862,18 @@ void CodeGenerator::AssembleReturn() { ...@@ -1861,20 +1862,18 @@ void CodeGenerator::AssembleReturn() {
} }
if (descriptor->IsCFunctionCall()) { if (descriptor->IsCFunctionCall()) {
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize); AssembleDeconstructFrame();
} else if (frame()->needs_frame()) { } else if (frame_access_state()->has_frame()) {
// Canonicalize JSFunction return sites for now. // Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) { if (return_label_.is_bound()) {
__ b(&return_label_); __ b(&return_label_);
return; return;
} else { } else {
__ bind(&return_label_); __ bind(&return_label_);
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize); AssembleDeconstructFrame();
} }
} else {
__ Drop(pop_count);
} }
__ Ret(); __ Ret(pop_count);
} }
void CodeGenerator::AssembleMove(InstructionOperand* source, void CodeGenerator::AssembleMove(InstructionOperand* source,
......
...@@ -960,8 +960,11 @@ void MacroAssembler::MovInt64ToDouble(DoubleRegister dst, Register src) { ...@@ -960,8 +960,11 @@ void MacroAssembler::MovInt64ToDouble(DoubleRegister dst, Register src) {
void MacroAssembler::StubPrologue(StackFrame::Type type, Register base, void MacroAssembler::StubPrologue(StackFrame::Type type, Register base,
int prologue_offset) { int prologue_offset) {
{
ConstantPoolUnavailableScope constant_pool_unavailable(this);
LoadSmiLiteral(r1, Smi::FromInt(type)); LoadSmiLiteral(r1, Smi::FromInt(type));
PushCommonFrame(r1); PushCommonFrame(r1);
}
} }
void MacroAssembler::Prologue(bool code_pre_aging, Register base, void MacroAssembler::Prologue(bool code_pre_aging, Register base,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment