Commit 817b59c8 authored by bbudge's avatar bbudge Committed by Commit bot

Turbofan: Modify WASM linkage to store floats using only 4 bytes.

Adds instructions for ARM to push floats.

LOG=N
BUG=v8:4124

Review-Url: https://codereview.chromium.org/2024443002
Cr-Commit-Position: refs/heads/master@{#36654}
parent 279e274e
...@@ -1320,6 +1320,10 @@ class Assembler : public AssemblerBase { ...@@ -1320,6 +1320,10 @@ class Assembler : public AssemblerBase {
vstm(db_w, sp, src, src, cond); vstm(db_w, sp, src, src, cond);
} }
void vpush(SwVfpRegister src, Condition cond = al) {
vstm(db_w, sp, src, src, cond);
}
void vpop(DwVfpRegister dst, Condition cond = al) { void vpop(DwVfpRegister dst, Condition cond = al) {
vldm(ia_w, sp, dst, dst, cond); vldm(ia_w, sp, dst, dst, cond);
} }
......
...@@ -1204,8 +1204,15 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1204,8 +1204,15 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
case kArmPush: case kArmPush:
if (instr->InputAt(0)->IsFPRegister()) { if (instr->InputAt(0)->IsFPRegister()) {
__ vpush(i.InputDoubleRegister(0)); LocationOperand* op = LocationOperand::cast(instr->InputAt(0));
frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); if (op->representation() == MachineRepresentation::kFloat64) {
__ vpush(i.InputFloat64Register(0));
frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize);
} else {
DCHECK_EQ(MachineRepresentation::kFloat32, op->representation());
__ vpush(i.InputFloat32Register(0));
frame_access_state()->IncreaseSPDelta(1);
}
} else { } else {
__ push(i.InputRegister(0)); __ push(i.InputRegister(0));
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
......
...@@ -1230,9 +1230,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1230,9 +1230,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
case kIA32PushFloat32: case kIA32PushFloat32:
if (instr->InputAt(0)->IsFPRegister()) { if (instr->InputAt(0)->IsFPRegister()) {
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kFloatSize));
__ movss(Operand(esp, 0), i.InputDoubleRegister(0)); __ movss(Operand(esp, 0), i.InputDoubleRegister(0));
frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); frame_access_state()->IncreaseSPDelta(kFloatSize / kPointerSize);
} else if (HasImmediateInput(instr, 0)) { } else if (HasImmediateInput(instr, 0)) {
__ Move(kScratchDoubleReg, i.InputDouble(0)); __ Move(kScratchDoubleReg, i.InputDouble(0));
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kDoubleSize));
...@@ -1264,9 +1264,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1264,9 +1264,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
case kIA32Push: case kIA32Push:
if (instr->InputAt(0)->IsFPRegister()) { if (instr->InputAt(0)->IsFPRegister()) {
__ sub(esp, Immediate(kDoubleSize)); __ sub(esp, Immediate(kFloatSize));
__ movsd(Operand(esp, 0), i.InputDoubleRegister(0)); __ movsd(Operand(esp, 0), i.InputDoubleRegister(0));
frame_access_state()->IncreaseSPDelta(kDoubleSize / kPointerSize); frame_access_state()->IncreaseSPDelta(kFloatSize / kPointerSize);
} else if (HasImmediateInput(instr, 0)) { } else if (HasImmediateInput(instr, 0)) {
__ push(i.InputImmediate(0)); __ push(i.InputImmediate(0));
frame_access_state()->IncreaseSPDelta(1); frame_access_state()->IncreaseSPDelta(1);
......
...@@ -199,11 +199,7 @@ struct Allocator { ...@@ -199,11 +199,7 @@ struct Allocator {
return type == kAstF32 || type == kAstF64; return type == kAstF32 || type == kAstF64;
} }
int Words(LocalType type) { int Words(LocalType type) {
// The code generation for pushing parameters on the stack does not if (kPointerSize < 8 && (type == kAstI64 || type == kAstF64)) {
// distinguish between float32 and float64. Therefore also float32 needs
// two words.
if (kPointerSize < 8 &&
(type == kAstI64 || type == kAstF64 || type == kAstF32)) {
return 2; return 2;
} }
return 1; return 1;
......
...@@ -154,10 +154,7 @@ struct Allocator { ...@@ -154,10 +154,7 @@ struct Allocator {
} }
} }
int StackWords(MachineType type) { int StackWords(MachineType type) {
// TODO(titzer): hack. float32 occupies 8 bytes on stack. int size = 1 << ElementSizeLog2Of(type.representation());
int size = IsFloatingPoint(type.representation())
? kDoubleSize
: (1 << ElementSizeLog2Of(type.representation()));
return size <= kPointerSize ? 1 : size / kPointerSize; return size <= kPointerSize ? 1 : size / kPointerSize;
} }
void Reset() { void Reset() {
......
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