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 {
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) {
......@@ -181,7 +182,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 r14 if the frame was elided.
__ Push(r14);
}
......@@ -194,7 +195,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
__ AddP(scratch1_, object_, offset_);
}
__ CallStub(&stub);
if (!frame()->needs_frame()) {
if (must_save_lr_) {
// We need to save and restore r14 if the frame was elided.
__ Pop(r14);
}
......@@ -208,6 +209,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
Register const scratch0_;
Register const scratch1_;
RecordWriteMode const mode_;
bool must_save_lr_;
};
Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) {
......@@ -560,6 +562,12 @@ Condition FlagsConditionToCondition(FlagsCondition condition, ArchOpcode op) {
__ bind(&done); \
} while (0)
void CodeGenerator::AssembleDeconstructFrame() {
__ LeaveFrame(StackFrame::MANUAL);
}
void CodeGenerator::AssembleSetupStackPointer() {}
void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
if (sp_slot_delta > 0) {
......@@ -574,7 +582,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
__ AddP(sp, sp, Operand(sp_slot_delta * kPointerSize));
frame_access_state()->IncreaseSPDelta(-sp_slot_delta);
}
if (frame()->needs_frame()) {
if (frame_access_state()->has_frame()) {
__ RestoreFrameStateForTailCall();
}
frame_access_state()->SetFrameAccessToSP();
......@@ -740,7 +748,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ LoadRR(i.OutputRegister(), fp);
break;
case kArchParentFramePointer:
if (frame_access_state()->frame()->needs_frame()) {
if (frame_access_state()->has_frame()) {
__ LoadP(i.OutputRegister(), MemOperand(fp, 0));
} else {
__ LoadRR(i.OutputRegister(), fp);
......@@ -1780,7 +1788,7 @@ void CodeGenerator::AssembleDeoptimizerCall(
void CodeGenerator::AssemblePrologue() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
if (frame()->needs_frame()) {
if (frame_access_state()->has_frame()) {
if (descriptor->IsCFunctionCall()) {
__ Push(r14, fp);
__ LoadRR(fp, sp);
......@@ -1788,18 +1796,11 @@ void CodeGenerator::AssemblePrologue() {
__ Prologue(this->info()->GeneratePreagedPrologue(), ip);
} else {
StackFrame::Type type = info()->GetOutputStackFrameType();
if (!ABI_CALL_VIA_IP &&
info()->output_code_kind() == Code::WASM_FUNCTION) {
// TODO(mbrandy): Restrict only to the wasm wrapper case.
__ StubPrologue(type);
} else {
__ StubPrologue(type, ip);
}
// TODO(mbrandy): Detect cases where ip is the entrypoint (for
// efficient intialization of the constant pool pointer register).
__ StubPrologue(type);
}
} else {
frame()->SetElidedFrameSizeInSlots(0);
}
frame_access_state()->SetFrameAccessToDefault();
int stack_shrink_slots = frame()->GetSpillSlotCount();
if (info()->is_osr()) {
......@@ -1861,20 +1862,18 @@ void CodeGenerator::AssembleReturn() {
}
if (descriptor->IsCFunctionCall()) {
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize);
} else if (frame()->needs_frame()) {
AssembleDeconstructFrame();
} else if (frame_access_state()->has_frame()) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ b(&return_label_);
return;
} else {
__ bind(&return_label_);
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize);
AssembleDeconstructFrame();
}
} else {
__ Drop(pop_count);
}
__ Ret();
__ Ret(pop_count);
}
void CodeGenerator::AssembleMove(InstructionOperand* source,
......
......@@ -960,8 +960,11 @@ void MacroAssembler::MovInt64ToDouble(DoubleRegister dst, Register src) {
void MacroAssembler::StubPrologue(StackFrame::Type type, Register base,
int prologue_offset) {
LoadSmiLiteral(r1, Smi::FromInt(type));
PushCommonFrame(r1);
{
ConstantPoolUnavailableScope constant_pool_unavailable(this);
LoadSmiLiteral(r1, Smi::FromInt(type));
PushCommonFrame(r1);
}
}
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