Commit 1e6f2ff3 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Frame elision for code stubs.

  port 53d51c52 (r35139)

  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.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#35473}
parent 3699f902
...@@ -337,6 +337,15 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -337,6 +337,15 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
__ bind(&done); \ __ bind(&done); \
} while (false) } while (false)
void CodeGenerator::AssembleDeconstructFrame() {
__ mov(esp, ebp);
__ pop(ebp);
}
// For insert fninit/fld1 instructions after the Prologue
thread_local bool is_block_0 = false;
void CodeGenerator::AssembleSetupStackPointer() { is_block_0 = true; }
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);
...@@ -353,7 +362,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { ...@@ -353,7 +362,7 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
__ sub(esp, Immediate(-sp_slot_delta * kPointerSize)); __ sub(esp, Immediate(-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()) {
__ mov(ebp, MemOperand(ebp, 0)); __ mov(ebp, MemOperand(ebp, 0));
} }
frame_access_state()->SetFrameAccessToSP(); frame_access_state()->SetFrameAccessToSP();
...@@ -402,6 +411,14 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -402,6 +411,14 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
X87OperandConverter i(this, instr); X87OperandConverter i(this, instr);
InstructionCode opcode = instr->opcode(); InstructionCode opcode = instr->opcode();
ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode);
// Workaround for CL #35139 (https://codereview.chromium.org/1775323002)
if (is_block_0) {
__ fninit();
__ fld1();
is_block_0 = false;
}
switch (arch_opcode) { switch (arch_opcode) {
case kArchCallCodeObject: { case kArchCallCodeObject: {
if (FLAG_debug_code && FLAG_enable_slow_asserts) { if (FLAG_debug_code && FLAG_enable_slow_asserts) {
...@@ -599,7 +616,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -599,7 +616,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ mov(i.OutputRegister(), esp); __ mov(i.OutputRegister(), esp);
break; break;
case kArchParentFramePointer: case kArchParentFramePointer:
if (frame_access_state()->frame()->needs_frame()) { if (frame_access_state()->has_frame()) {
__ mov(i.OutputRegister(), Operand(ebp, 0)); __ mov(i.OutputRegister(), Operand(ebp, 0));
} else { } else {
__ mov(i.OutputRegister(), ebp); __ mov(i.OutputRegister(), ebp);
...@@ -2081,7 +2098,7 @@ void CodeGenerator::AssembleDeoptimizerCall( ...@@ -2081,7 +2098,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(ebp); __ push(ebp);
__ mov(ebp, esp); __ mov(ebp, esp);
...@@ -2090,11 +2107,7 @@ void CodeGenerator::AssemblePrologue() { ...@@ -2090,11 +2107,7 @@ void CodeGenerator::AssemblePrologue() {
} else { } else {
__ StubPrologue(info()->GetOutputStackFrameType()); __ StubPrologue(info()->GetOutputStackFrameType());
} }
} else {
frame()->SetElidedFrameSizeInSlots(kPCOnStackSize / kPointerSize);
} }
frame_access_state()->SetFrameAccessToDefault();
int stack_shrink_slots = frame()->GetSpillSlotCount(); int stack_shrink_slots = frame()->GetSpillSlotCount();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -2107,6 +2120,10 @@ void CodeGenerator::AssemblePrologue() { ...@@ -2107,6 +2120,10 @@ void CodeGenerator::AssemblePrologue() {
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); stack_shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots();
// Initailize FPU state.
__ fninit();
__ fld1();
} }
const RegList saves = descriptor->CalleeSavedRegisters(); const RegList saves = descriptor->CalleeSavedRegisters();
...@@ -2124,10 +2141,6 @@ void CodeGenerator::AssemblePrologue() { ...@@ -2124,10 +2141,6 @@ void CodeGenerator::AssemblePrologue() {
} }
frame()->AllocateSavedCalleeRegisterSlots(pushed); frame()->AllocateSavedCalleeRegisterSlots(pushed);
} }
// Initailize FPU state.
__ fninit();
__ fld1();
} }
...@@ -2160,17 +2173,15 @@ void CodeGenerator::AssembleReturn() { ...@@ -2160,17 +2173,15 @@ void CodeGenerator::AssembleReturn() {
} }
if (descriptor->IsCFunctionCall()) { if (descriptor->IsCFunctionCall()) {
__ mov(esp, ebp); // Move stack pointer back to frame pointer. AssembleDeconstructFrame();
__ pop(ebp); // Pop caller's frame pointer. } else if (frame_access_state()->has_frame()) {
} else if (frame()->needs_frame()) {
// Canonicalize JSFunction return sites for now. // Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) { if (return_label_.is_bound()) {
__ jmp(&return_label_); __ jmp(&return_label_);
return; return;
} else { } else {
__ bind(&return_label_); __ bind(&return_label_);
__ mov(esp, ebp); // Move stack pointer back to frame pointer. AssembleDeconstructFrame();
__ pop(ebp); // Pop caller's frame pointer.
} }
} }
if (pop_count == 0) { if (pop_count == 0) {
......
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