Commit 0e2a2808 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Load stack parameters as the right type

This ensures that i32 values which are loaded into 64 bit registers
have the upper 32 bits cleared.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: I5eb2b65ac079b5683c83d755b1aa4a626411d5d4
Reviewed-on: https://chromium-review.googlesource.com/888702Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50907}
parent 5615807b
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -171,12 +171,21 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -171,12 +171,21 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
Operand src(ebp, kPointerSize * (caller_slot_idx + 1)); Operand src(ebp, kPointerSize * (caller_slot_idx + 1));
if (dst.is_gp()) { switch (type) {
mov(dst.gp(), src); case kWasmI32:
} else { mov(dst.gp(), src);
movss(dst.fp(), src); break;
case kWasmF32:
movss(dst.fp(), src);
break;
case kWasmF64:
movsd(dst.fp(), src);
break;
default:
UNREACHABLE();
} }
} }
......
...@@ -295,7 +295,8 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -295,7 +295,8 @@ class LiftoffAssembler : public TurboAssembler {
inline void Store(Register dst_addr, Register offset_reg, uint32_t offset_imm, inline void Store(Register dst_addr, Register offset_reg, uint32_t offset_imm,
LiftoffRegister src, StoreType type, LiftoffRegList pinned, LiftoffRegister src, StoreType type, LiftoffRegList pinned,
uint32_t* protected_store_pc = nullptr); uint32_t* protected_store_pc = nullptr);
inline void LoadCallerFrameSlot(LiftoffRegister, uint32_t caller_slot_idx); inline void LoadCallerFrameSlot(LiftoffRegister, uint32_t caller_slot_idx,
ValueType);
inline void MoveStackValue(uint32_t dst_index, uint32_t src_index, ValueType); inline void MoveStackValue(uint32_t dst_index, uint32_t src_index, ValueType);
inline void MoveToReturnRegister(LiftoffRegister); inline void MoveToReturnRegister(LiftoffRegister);
......
...@@ -217,7 +217,7 @@ class LiftoffCompiler { ...@@ -217,7 +217,7 @@ class LiftoffCompiler {
} }
if (param_loc.IsCallerFrameSlot()) { if (param_loc.IsCallerFrameSlot()) {
LiftoffRegister tmp_reg = __ GetUnusedRegister(rc); LiftoffRegister tmp_reg = __ GetUnusedRegister(rc);
__ LoadCallerFrameSlot(tmp_reg, -param_loc.AsCallerFrameSlot()); __ LoadCallerFrameSlot(tmp_reg, -param_loc.AsCallerFrameSlot(), type);
__ PushRegister(type, tmp_reg); __ PushRegister(type, tmp_reg);
return; return;
} }
......
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -172,13 +172,24 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ...@@ -172,13 +172,24 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
} }
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) { uint32_t caller_slot_idx,
ValueType type) {
Operand src(rbp, kPointerSize * (caller_slot_idx + 1)); Operand src(rbp, kPointerSize * (caller_slot_idx + 1));
// TODO(clemensh): Handle different sizes here. switch (type) {
if (dst.is_gp()) { case kWasmI32:
movq(dst.gp(), src); movl(dst.gp(), src);
} else { break;
Movsd(dst.fp(), src); case kWasmI64:
movq(dst.gp(), src);
break;
case kWasmF32:
Movss(dst.fp(), src);
break;
case kWasmF64:
Movsd(dst.fp(), src);
break;
default:
UNREACHABLE();
} }
} }
......
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