Index: src/compiler/ia32/code-generator-ia32.cc |
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc |
index ed499f76613671110b8f8f617c5bb37e932fb247..64b0a6d9db56a2a9b77c9ccc8864d44dfa7b9c14 100644 |
--- a/src/compiler/ia32/code-generator-ia32.cc |
+++ b/src/compiler/ia32/code-generator-ia32.cc |
@@ -48,12 +48,18 @@ class IA32OperandConverter : public InstructionOperandConverter { |
return Operand(ToDoubleRegister(op)); |
} |
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
- FrameOffset offset = |
- linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); |
+ FrameOffset offset = linkage()->GetFrameOffset( |
+ AllocatedOperand::cast(op)->index(), frame_access_state()); |
return Operand(offset.from_stack_pointer() ? esp : ebp, |
offset.offset() + extra); |
} |
+ Operand ToMaterializableOperand(int materializable_offset) { |
+ FrameOffset offset = linkage()->GetFrameOffset( |
+ Frame::FPOffsetToSlot(materializable_offset), frame_access_state()); |
+ return Operand(offset.from_stack_pointer() ? esp : ebp, offset.offset()); |
+ } |
+ |
Operand HighOperand(InstructionOperand* op) { |
DCHECK(op->IsDoubleStackSlot()); |
return ToOperand(op, kPointerSize); |
@@ -346,6 +352,7 @@ void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
} |
__ pop(ebp); |
} |
+ frame_access_state()->UseDefaultFrameAccess(); |
} |
@@ -359,8 +366,10 @@ void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
total_discarded_slots -= stack_param_delta; |
if (total_discarded_slots < 0) { |
__ sub(esp, Immediate(-total_discarded_slots * kPointerSize)); |
+ frame_access_state()->IncreaseSPDelta(-total_discarded_slots); |
} |
} |
+ frame_access_state()->UseSPToAccessFrame(); |
} |
@@ -380,6 +389,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
__ call(reg); |
} |
RecordCallPosition(instr); |
+ frame_access_state()->ClearSPDelta(); |
break; |
} |
case kArchTailCallCodeObject: { |
@@ -393,6 +403,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
__ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
__ jmp(reg); |
} |
+ frame_access_state()->ClearSPDelta(); |
break; |
} |
case kArchCallJSFunction: { |
@@ -405,6 +416,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
} |
__ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
RecordCallPosition(instr); |
+ frame_access_state()->ClearSPDelta(); |
break; |
} |
case kArchTailCallJSFunction: { |
@@ -417,6 +429,7 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
AssembleDeconstructActivationRecord(stack_param_delta); |
__ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
+ frame_access_state()->ClearSPDelta(); |
break; |
} |
case kArchLazyBailout: { |
@@ -425,6 +438,8 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
break; |
} |
case kArchPrepareCallCFunction: { |
+ // Frame alignment requires using FP-relative frame addressing. |
+ frame_access_state()->UseFPToAccessFrame(); |
int const num_parameters = MiscField::decode(instr->opcode()); |
__ PrepareCallCFunction(num_parameters, i.TempRegister(0)); |
break; |
@@ -441,6 +456,8 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
Register func = i.InputRegister(0); |
__ CallCFunction(func, num_parameters); |
} |
+ frame_access_state()->UseDefaultFrameAccess(); |
+ frame_access_state()->ClearSPDelta(); |
break; |
} |
case kArchJmp: |
@@ -996,10 +1013,13 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
if (instr->InputAt(0)->IsDoubleRegister()) { |
__ sub(esp, Immediate(kDoubleSize)); |
__ movsd(Operand(esp, 0), i.InputDoubleRegister(0)); |
+ frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); |
} else if (HasImmediateInput(instr, 0)) { |
__ push(i.InputImmediate(0)); |
+ frame_access_state()->IncreaseSPDelta(1); |
} else { |
__ push(i.InputOperand(0)); |
+ frame_access_state()->IncreaseSPDelta(1); |
} |
break; |
case kIA32Poke: { |
@@ -1379,11 +1399,12 @@ void CodeGenerator::AssemblePrologue() { |
// code aging. |
CompilationInfo* info = this->info(); |
__ Prologue(info->IsCodePreAgingActive()); |
- } else if (needs_frame_) { |
+ } else if (frame()->needs_frame()) { |
__ StubPrologue(); |
} else { |
frame()->SetElidedFrameSizeInSlots(kPCOnStackSize / kPointerSize); |
} |
+ frame_access_state()->UseDefaultFrameAccess(); |
int stack_shrink_slots = frame()->GetSpillSlotCount(); |
if (info()->is_osr()) { |
@@ -1434,7 +1455,7 @@ void CodeGenerator::AssembleReturn() { |
if (descriptor->kind() == CallDescriptor::kCallAddress) { |
__ mov(esp, ebp); // Move stack pointer back to frame pointer. |
__ pop(ebp); // Pop caller's frame pointer. |
- } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
+ } else if (descriptor->IsJSFunctionCall() || frame()->needs_frame()) { |
// Canonicalize JSFunction return sites for now. |
if (return_label_.is_bound()) { |
__ jmp(&return_label_); |
@@ -1481,11 +1502,11 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, |
if (IsMaterializableFromFrame(src, &offset)) { |
if (destination->IsRegister()) { |
Register dst = g.ToRegister(destination); |
- __ mov(dst, Operand(ebp, offset)); |
+ __ mov(dst, g.ToMaterializableOperand(offset)); |
} else { |
DCHECK(destination->IsStackSlot()); |
Operand dst = g.ToOperand(destination); |
- __ push(Operand(ebp, offset)); |
+ __ push(g.ToMaterializableOperand(offset)); |
__ pop(dst); |
} |
} else if (destination->IsRegister()) { |
@@ -1577,12 +1598,16 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source, |
__ xchg(g.ToRegister(source), g.ToOperand(destination)); |
} else if (source->IsStackSlot() && destination->IsStackSlot()) { |
// Memory-memory. |
- Operand src = g.ToOperand(source); |
- Operand dst = g.ToOperand(destination); |
- __ push(dst); |
- __ push(src); |
- __ pop(dst); |
- __ pop(src); |
+ Operand dst1 = g.ToOperand(destination); |
+ __ push(dst1); |
+ frame_access_state()->IncreaseSPDelta(1); |
+ Operand src1 = g.ToOperand(source); |
+ __ push(src1); |
+ Operand dst2 = g.ToOperand(destination); |
+ __ pop(dst2); |
+ frame_access_state()->IncreaseSPDelta(-1); |
+ Operand src2 = g.ToOperand(source); |
+ __ pop(src2); |
} else if (source->IsDoubleRegister() && destination->IsDoubleRegister()) { |
// XMM register-register swap. |
XMMRegister src = g.ToDoubleRegister(source); |