Commit 17f4c5bb authored by titzer's avatar titzer Committed by Commit bot

Reland: [turbofan] Various fixes to allow unboxed doubles as arguments in...

Reland: [turbofan] Various fixes to allow unboxed doubles as arguments in registers and on the stack.

OCL: https://codereview.chromium.org/1263033004/

R=mstarzinger@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#30115}
parent debf58cd
......@@ -147,12 +147,9 @@ class ArmOperandConverter final : public InstructionOperandConverter {
MemOperand ToMemOperand(InstructionOperand* op) const {
DCHECK(op != NULL);
DCHECK(!op->IsRegister());
DCHECK(!op->IsDoubleRegister());
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), 0);
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
}
};
......@@ -992,6 +989,8 @@ void CodeGenerator::AssemblePrologue() {
__ StubPrologue();
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
} else {
frame()->SetPCOnStack(false);
}
if (info()->is_osr()) {
......@@ -1019,6 +1018,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
if (frame()->GetRegisterSaveAreaSize() > 0) {
// Remove this frame's spill slots first.
......@@ -1041,23 +1041,17 @@ void CodeGenerator::AssembleReturn() {
}
}
__ LeaveFrame(StackFrame::MANUAL);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ b(&return_label_);
return;
} else {
__ bind(&return_label_);
__ LeaveFrame(StackFrame::MANUAL);
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count != 0) {
__ Drop(pop_count);
}
__ Ret();
}
} else {
__ Ret();
}
__ Ret(pop_count);
}
......
......@@ -184,12 +184,9 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
MemOperand ToMemOperand(InstructionOperand* op, MacroAssembler* masm) const {
DCHECK(op != NULL);
DCHECK(!op->IsRegister());
DCHECK(!op->IsDoubleRegister());
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), 0);
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return MemOperand(offset.from_stack_pointer() ? masm->StackPointer() : fp,
offset.offset());
}
......@@ -1118,6 +1115,8 @@ void CodeGenerator::AssemblePrologue() {
__ StubPrologue();
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
} else {
frame()->SetPCOnStack(false);
}
if (info()->is_osr()) {
......@@ -1149,6 +1148,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
if (frame()->GetRegisterSaveAreaSize() > 0) {
// Remove this frame's spill slots first.
......@@ -1169,24 +1169,19 @@ void CodeGenerator::AssembleReturn() {
__ Mov(csp, fp);
__ Pop(fp, lr);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ B(&return_label_);
return;
} else {
__ Bind(&return_label_);
__ Mov(jssp, fp);
__ Pop(fp, lr);
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count != 0) {
__ Drop(pop_count);
}
__ Ret();
}
} else {
__ Ret();
}
__ Drop(pop_count);
__ Ret();
}
......
......@@ -22,7 +22,8 @@ class Frame : public ZoneObject {
spill_slot_count_(0),
osr_stack_slot_count_(0),
allocated_registers_(NULL),
allocated_double_registers_(NULL) {}
allocated_double_registers_(NULL),
pc_on_stack_(true) {}
inline int GetSpillSlotCount() { return spill_slot_count_; }
......@@ -71,12 +72,17 @@ class Frame : public ZoneObject {
spill_slot_count_ = static_cast<int>(slot_count);
}
void SetPCOnStack(bool val) { pc_on_stack_ = val; }
int PCOnStackSize() { return pc_on_stack_ ? kRegisterSize : 0; }
private:
int register_save_area_size_;
int spill_slot_count_;
int osr_stack_slot_count_;
BitVector* allocated_registers_;
BitVector* allocated_double_registers_;
bool pc_on_stack_;
DISALLOW_COPY_AND_ASSIGN(Frame);
};
......
......@@ -46,10 +46,10 @@ class IA32OperandConverter : public InstructionOperandConverter {
return Operand(ToDoubleRegister(op));
}
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), extra);
return Operand(offset.from_stack_pointer() ? esp : ebp, offset.offset());
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return Operand(offset.from_stack_pointer() ? esp : ebp,
offset.offset() + extra);
}
Operand HighOperand(InstructionOperand* op) {
......@@ -1325,31 +1325,26 @@ void CodeGenerator::AssembleReturn() {
}
}
__ pop(ebp); // Pop caller's frame pointer.
__ ret(0);
} else {
// No saved registers.
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
return;
} else {
__ bind(&return_label_);
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count == 0) {
__ ret(0);
} else {
__ Ret(pop_count * kPointerSize, ebx);
}
}
} else {
__ ret(0);
}
size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
// Might need ecx for scratch if pop_size is too big.
DCHECK_EQ(0, descriptor->CalleeSavedRegisters() & ecx.bit());
__ Ret(static_cast<int>(pop_size), ecx);
}
......
......@@ -70,7 +70,7 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
std::ostream& operator<<(std::ostream& os, const CallDescriptor& d) {
// TODO(svenpanne) Output properties etc. and be less cryptic.
return os << d.kind() << ":" << d.debug_name() << ":r" << d.ReturnCount()
<< "j" << d.JSParameterCount() << "i" << d.InputCount() << "f"
<< "s" << d.StackParameterCount() << "i" << d.InputCount() << "f"
<< d.FrameStateCount() << "t" << d.SupportsTailCalls();
}
......@@ -189,8 +189,7 @@ CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
}
FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
int extra) const {
FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame) const {
if (frame->GetSpillSlotCount() > 0 || incoming_->IsJSFunctionCall() ||
incoming_->kind() == CallDescriptor::kCallAddress) {
int offset;
......@@ -198,12 +197,11 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
if (spill_slot >= 0) {
// Local or spill slot. Skip the frame pointer, function, and
// context in the fixed part of the frame.
offset =
-(spill_slot + 1) * kPointerSize - register_save_area_size + extra;
offset = -(spill_slot + 1) * kPointerSize - register_save_area_size;
} else {
// Incoming parameter. Skip the return address.
offset = -(spill_slot + 1) * kPointerSize + kFPOnStackSize +
kPCOnStackSize + extra;
frame->PCOnStackSize();
}
return FrameOffset::FromFramePointer(offset);
} else {
......@@ -211,7 +209,7 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
DCHECK(spill_slot < 0); // Must be a parameter.
int register_save_area_size = frame->GetRegisterSaveAreaSize();
int offset = register_save_area_size - (spill_slot + 1) * kPointerSize +
kPCOnStackSize + extra;
frame->PCOnStackSize();
return FrameOffset::FromStackPointer(offset);
}
}
......
......@@ -313,9 +313,8 @@ class Linkage : public ZoneObject {
// Get the frame offset for a given spill slot. The location depends on the
// calling convention and the specific frame layout, and may thus be
// architecture-specific. Negative spill slots indicate arguments on the
// caller's frame. The {extra} parameter indicates an additional offset from
// the frame offset, e.g. to index into part of a double slot.
FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0) const;
// caller's frame.
FrameOffset GetFrameOffset(int spill_slot, Frame* frame) const;
static int FrameStateInputCount(Runtime::FunctionId function);
......
......@@ -116,6 +116,11 @@ inline int ElementSizeOf(MachineType machine_type) {
return 1 << shift;
}
inline bool IsFloatingPoint(MachineType type) {
MachineType rep = RepresentationOf(type);
return rep == kRepFloat32 || rep == kRepFloat64;
}
typedef Signature<MachineType> MachineSignature;
} // namespace compiler
......
......@@ -106,12 +106,9 @@ class MipsOperandConverter final : public InstructionOperandConverter {
MemOperand ToMemOperand(InstructionOperand* op) const {
DCHECK(op != NULL);
DCHECK(!op->IsRegister());
DCHECK(!op->IsDoubleRegister());
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), 0);
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
}
};
......@@ -1082,13 +1079,14 @@ void CodeGenerator::AssemblePrologue() {
// kNumCalleeSaved includes the fp register, but the fp register
// is saved separately in TF.
DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
int register_save_area_size = kNumCalleeSaved * kPointerSize;
int register_save_area_size =
base::bits::CountPopulation32(saves) * kPointerSize;
const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
// Save callee-saved FPU registers.
__ MultiPushFPU(saves_fpu);
DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu));
register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize;
register_save_area_size += kNumCalleeSavedFPU * kDoubleSize;
frame()->SetRegisterSaveAreaSize(register_save_area_size);
} else if (descriptor->IsJSFunctionCall()) {
......@@ -1100,6 +1098,8 @@ void CodeGenerator::AssemblePrologue() {
__ StubPrologue();
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
} else {
frame()->SetPCOnStack(false);
}
if (info()->is_osr()) {
......@@ -1127,6 +1127,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
if (frame()->GetRegisterSaveAreaSize() > 0) {
// Remove this frame's spill slots first.
......@@ -1143,22 +1144,19 @@ void CodeGenerator::AssembleReturn() {
}
__ mov(sp, fp);
__ Pop(ra, fp);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ Branch(&return_label_);
return;
} else {
__ bind(&return_label_);
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count != 0) {
__ DropAndRet(pop_count);
} else {
__ Ret();
}
}
}
if (pop_count != 0) {
__ DropAndRet(pop_count);
} else {
__ Ret();
}
......
......@@ -106,12 +106,9 @@ class MipsOperandConverter final : public InstructionOperandConverter {
MemOperand ToMemOperand(InstructionOperand* op) const {
DCHECK(op != NULL);
DCHECK(!op->IsRegister());
DCHECK(!op->IsDoubleRegister());
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), 0);
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
}
};
......@@ -1158,13 +1155,14 @@ void CodeGenerator::AssemblePrologue() {
// kNumCalleeSaved includes the fp register, but the fp register
// is saved separately in TF.
DCHECK(kNumCalleeSaved == base::bits::CountPopulation32(saves) + 1);
int register_save_area_size = kNumCalleeSaved * kPointerSize;
int register_save_area_size =
base::bits::CountPopulation32(saves) * kPointerSize;
const RegList saves_fpu = descriptor->CalleeSavedFPRegisters();
// Save callee-saved FPU registers.
__ MultiPushFPU(saves_fpu);
DCHECK(kNumCalleeSavedFPU == base::bits::CountPopulation32(saves_fpu));
register_save_area_size += kNumCalleeSavedFPU * kDoubleSize * kPointerSize;
register_save_area_size += kNumCalleeSavedFPU * kDoubleSize;
frame()->SetRegisterSaveAreaSize(register_save_area_size);
} else if (descriptor->IsJSFunctionCall()) {
......@@ -1176,6 +1174,8 @@ void CodeGenerator::AssemblePrologue() {
__ StubPrologue();
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
} else {
frame()->SetPCOnStack(false);
}
if (info()->is_osr()) {
......@@ -1203,6 +1203,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
if (frame()->GetRegisterSaveAreaSize() > 0) {
// Remove this frame's spill slots first.
......@@ -1219,22 +1220,19 @@ void CodeGenerator::AssembleReturn() {
}
__ mov(sp, fp);
__ Pop(ra, fp);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ Branch(&return_label_);
return;
} else {
__ bind(&return_label_);
__ mov(sp, fp);
__ Pop(ra, fp);
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count != 0) {
__ DropAndRet(pop_count);
} else {
__ Ret();
}
}
}
if (pop_count != 0) {
__ DropAndRet(pop_count);
} else {
__ Ret();
}
......
......@@ -99,12 +99,9 @@ class PPCOperandConverter final : public InstructionOperandConverter {
MemOperand ToMemOperand(InstructionOperand* op) const {
DCHECK(op != NULL);
DCHECK(!op->IsRegister());
DCHECK(!op->IsDoubleRegister());
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), 0);
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
}
};
......@@ -1360,6 +1357,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
if (frame()->GetRegisterSaveAreaSize() > 0) {
// Remove this frame's spill slots first.
......@@ -1378,21 +1376,17 @@ void CodeGenerator::AssembleReturn() {
const RegList saves = descriptor->CalleeSavedRegisters() & ~frame_saves;
__ MultiPop(saves);
}
__ LeaveFrame(StackFrame::MANUAL);
__ Ret();
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ b(&return_label_);
return;
} else {
__ bind(&return_label_);
int pop_count = static_cast<int>(descriptor->StackParameterCount());
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize);
__ Ret();
}
} else {
__ Ret();
}
__ LeaveFrame(StackFrame::MANUAL, pop_count * kPointerSize);
__ Ret();
}
......
......@@ -100,6 +100,22 @@ void RawMachineAssembler::Return(Node* value) {
}
Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function,
Node** args) {
int param_count =
static_cast<int>(desc->GetMachineSignature()->parameter_count());
Node** buffer = zone()->NewArray<Node*>(param_count + 1);
int index = 0;
buffer[index++] = function;
for (int i = 0; i < param_count; i++) {
buffer[index++] = args[i];
}
Node* call = graph()->NewNode(common()->Call(desc), param_count + 1, buffer);
schedule()->AddNode(CurrentBlock(), call);
return call;
}
Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver,
Node* context, Node* frame_state,
CallFunctionFlags flags) {
......
......@@ -479,25 +479,28 @@ class RawMachineAssembler {
return HeapConstant(isolate()->factory()->InternalizeUtf8String(string));
}
// Call a given call descriptor and the given arguments.
Node* CallN(CallDescriptor* desc, Node* function, Node** args);
// Call through CallFunctionStub with lazy deopt and frame-state.
Node* CallFunctionStub0(Node* function, Node* receiver, Node* context,
Node* frame_state, CallFunctionFlags flags);
// Call to a JS function with zero parameters.
// Call to a JS function with zero arguments.
Node* CallJS0(Node* function, Node* receiver, Node* context,
Node* frame_state);
// Call to a runtime function with zero parameters.
// Call to a runtime function with zero arguments.
Node* CallRuntime1(Runtime::FunctionId function, Node* arg0, Node* context,
Node* frame_state);
// Call to a C function with zero parameters.
// Call to a C function with zero arguments.
Node* CallCFunction0(MachineType return_type, Node* function);
// Call to a C function with one parameter.
Node* CallCFunction1(MachineType return_type, MachineType arg0_type,
Node* function, Node* arg0);
// Call to a C function with two parameters.
// Call to a C function with two arguments.
Node* CallCFunction2(MachineType return_type, MachineType arg0_type,
MachineType arg1_type, Node* function, Node* arg0,
Node* arg1);
// Call to a C function with eight parameters.
// Call to a C function with eight arguments.
Node* CallCFunction8(MachineType return_type, MachineType arg0_type,
MachineType arg1_type, MachineType arg2_type,
MachineType arg3_type, MachineType arg4_type,
......
......@@ -155,7 +155,7 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op,
int vreg = unallocated->virtual_register();
constraint->virtual_register_ = vreg;
if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) {
constraint->type_ = kFixedSlot;
constraint->type_ = sequence()->IsFloat(vreg) ? kDoubleSlot : kSlot;
constraint->value_ = unallocated->fixed_slot_index();
} else {
switch (unallocated->extended_policy()) {
......@@ -185,11 +185,7 @@ void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op,
}
break;
case UnallocatedOperand::MUST_HAVE_SLOT:
if (sequence()->IsFloat(vreg)) {
constraint->type_ = kDoubleSlot;
} else {
constraint->type_ = kSlot;
}
constraint->type_ = sequence()->IsFloat(vreg) ? kDoubleSlot : kSlot;
break;
case UnallocatedOperand::SAME_AS_FIRST_INPUT:
constraint->type_ = kSameAsFirst;
......
......@@ -1242,8 +1242,11 @@ InstructionOperand* ConstraintBuilder::AllocateFixed(
machine_type = data()->MachineTypeFor(virtual_register);
}
if (operand->HasFixedSlotPolicy()) {
allocated = AllocatedOperand(AllocatedOperand::STACK_SLOT, machine_type,
operand->fixed_slot_index());
AllocatedOperand::AllocatedKind kind =
IsFloatingPoint(machine_type) ? AllocatedOperand::DOUBLE_STACK_SLOT
: AllocatedOperand::STACK_SLOT;
allocated =
AllocatedOperand(kind, machine_type, operand->fixed_slot_index());
} else if (operand->HasFixedRegisterPolicy()) {
allocated = AllocatedOperand(AllocatedOperand::REGISTER, machine_type,
operand->fixed_register_index());
......
......@@ -48,10 +48,10 @@ class X64OperandConverter : public InstructionOperandConverter {
Operand ToOperand(InstructionOperand* op, int extra = 0) {
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), extra);
return Operand(offset.from_stack_pointer() ? rsp : rbp, offset.offset());
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return Operand(offset.from_stack_pointer() ? rsp : rbp,
offset.offset() + extra);
}
static size_t NextOffset(size_t* offset) {
......@@ -1219,6 +1219,10 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
} else {
if (instr->InputAt(0)->IsRegister()) {
__ pushq(i.InputRegister(0));
} else if (instr->InputAt(0)->IsDoubleRegister()) {
// TODO(titzer): use another machine instruction?
__ subq(rsp, Immediate(kDoubleSize));
__ movsd(Operand(rsp, 0), i.InputDoubleRegister(0));
} else {
__ pushq(i.InputOperand(0));
}
......@@ -1554,31 +1558,26 @@ void CodeGenerator::AssembleReturn() {
}
}
__ popq(rbp); // Pop caller's frame pointer.
__ ret(0);
} else {
// No saved registers.
__ movq(rsp, rbp); // Move stack pointer back to frame pointer.
__ popq(rbp); // Pop caller's frame pointer.
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
return;
} else {
__ bind(&return_label_);
__ movq(rsp, rbp); // Move stack pointer back to frame pointer.
__ popq(rbp); // Pop caller's frame pointer.
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count == 0) {
__ Ret();
} else {
__ Ret(pop_count * kPointerSize, rbx);
}
}
} else {
__ Ret();
}
size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
// Might need rcx for scratch if pop_size is too big.
DCHECK_EQ(0, descriptor->CalleeSavedRegisters() & rcx.bit());
__ Ret(static_cast<int>(pop_size), rcx);
}
......
......@@ -38,15 +38,12 @@ class X87OperandConverter : public InstructionOperandConverter {
if (op->IsRegister()) {
DCHECK(extra == 0);
return Operand(ToRegister(op));
} else if (op->IsDoubleRegister()) {
DCHECK(extra == 0);
UNIMPLEMENTED();
}
DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot());
// The linkage computes where all spill slots are located.
FrameOffset offset = linkage()->GetFrameOffset(
AllocatedOperand::cast(op)->index(), frame(), extra);
return Operand(offset.from_stack_pointer() ? esp : ebp, offset.offset());
FrameOffset offset =
linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame());
return Operand(offset.from_stack_pointer() ? esp : ebp,
offset.offset() + extra);
}
Operand HighOperand(InstructionOperand* op) {
......@@ -1568,6 +1565,7 @@ void CodeGenerator::AssemblePrologue() {
void CodeGenerator::AssembleReturn() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (descriptor->kind() == CallDescriptor::kCallAddress) {
const RegList saves = descriptor->CalleeSavedRegisters();
if (frame()->GetRegisterSaveAreaSize() > 0) {
......@@ -1583,30 +1581,26 @@ void CodeGenerator::AssembleReturn() {
}
}
__ pop(ebp); // Pop caller's frame pointer.
__ ret(0);
} else {
// No saved registers.
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
__ ret(0);
}
} else if (descriptor->IsJSFunctionCall() || needs_frame_) {
// Canonicalize JSFunction return sites for now.
if (return_label_.is_bound()) {
__ jmp(&return_label_);
return;
} else {
__ bind(&return_label_);
__ mov(esp, ebp); // Move stack pointer back to frame pointer.
__ pop(ebp); // Pop caller's frame pointer.
int pop_count = static_cast<int>(descriptor->StackParameterCount());
if (pop_count == 0) {
__ ret(0);
} else {
__ Ret(pop_count * kPointerSize, ebx);
}
}
} else {
}
if (pop_count == 0) {
__ ret(0);
} else {
__ Ret(pop_count * kPointerSize, ebx);
}
}
......
......@@ -76,6 +76,7 @@
'compiler/test-run-jsexceptions.cc',
'compiler/test-run-jsops.cc',
'compiler/test-run-machops.cc',
'compiler/test-run-native-calls.cc',
'compiler/test-run-properties.cc',
'compiler/test-run-stackcheck.cc',
'compiler/test-run-stubs.cc',
......
......@@ -69,6 +69,10 @@ class CSignature : public MachineSignature {
}
}
static CSignature* FromMachine(Zone* zone, MachineSignature* msig) {
return reinterpret_cast<CSignature*>(msig);
}
static CSignature* New(Zone* zone, MachineType ret,
MachineType p1 = kMachNone, MachineType p2 = kMachNone,
MachineType p3 = kMachNone, MachineType p4 = kMachNone,
......
......@@ -304,6 +304,21 @@ class CallHelper {
Isolate* isolate_;
};
// A call helper that calls the given code object assuming C calling convention.
template <typename T>
class CodeRunner : public CallHelper<T> {
public:
CodeRunner(Isolate* isolate, Handle<Code> code, CSignature* csig)
: CallHelper<T>(isolate, csig), code_(code) {}
virtual ~CodeRunner() {}
virtual byte* Generate() { return code_->entry(); }
private:
Handle<Code> code_;
};
} // namespace compiler
} // namespace internal
} // namespace v8
......
......@@ -28,6 +28,12 @@ class GraphAndBuilders {
main_machine_(zone),
main_simplified_(zone) {}
Graph* graph() const { return main_graph_; }
Zone* zone() const { return graph()->zone(); }
CommonOperatorBuilder* common() { return &main_common_; }
MachineOperatorBuilder* machine() { return &main_machine_; }
SimplifiedOperatorBuilder* simplified() { return &main_simplified_; }
protected:
// Prefixed with main_ to avoid naming conflicts.
Graph* main_graph_;
......@@ -39,7 +45,7 @@ class GraphAndBuilders {
template <typename ReturnType>
class GraphBuilderTester : public HandleAndZoneScope,
private GraphAndBuilders,
public GraphAndBuilders,
public CallHelper<ReturnType> {
public:
explicit GraphBuilderTester(MachineType p0 = kMachNone,
......@@ -67,12 +73,7 @@ class GraphBuilderTester : public HandleAndZoneScope,
}
Isolate* isolate() { return main_isolate(); }
Graph* graph() const { return main_graph_; }
Zone* zone() const { return graph()->zone(); }
Factory* factory() { return isolate()->factory(); }
CommonOperatorBuilder* common() { return &main_common_; }
MachineOperatorBuilder* machine() { return &main_machine_; }
SimplifiedOperatorBuilder* simplified() { return &main_simplified_; }
// Initialize graph and builder.
void Begin(int num_parameters) {
......
This diff is collapsed.
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