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,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -171,12 +171,21 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
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));
if (dst.is_gp()) {
mov(dst.gp(), src);
} else {
movss(dst.fp(), src);
switch (type) {
case kWasmI32:
mov(dst.gp(), 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 {
inline void Store(Register dst_addr, Register offset_reg, uint32_t offset_imm,
LiftoffRegister src, StoreType type, LiftoffRegList pinned,
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 MoveToReturnRegister(LiftoffRegister);
......
......@@ -217,7 +217,7 @@ class LiftoffCompiler {
}
if (param_loc.IsCallerFrameSlot()) {
LiftoffRegister tmp_reg = __ GetUnusedRegister(rc);
__ LoadCallerFrameSlot(tmp_reg, -param_loc.AsCallerFrameSlot());
__ LoadCallerFrameSlot(tmp_reg, -param_loc.AsCallerFrameSlot(), type);
__ PushRegister(type, tmp_reg);
return;
}
......
......@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -44,7 +44,8 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst,
uint32_t caller_slot_idx) {
uint32_t caller_slot_idx,
ValueType type) {
UNIMPLEMENTED();
}
......
......@@ -172,13 +172,24 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
}
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));
// TODO(clemensh): Handle different sizes here.
if (dst.is_gp()) {
movq(dst.gp(), src);
} else {
Movsd(dst.fp(), src);
switch (type) {
case kWasmI32:
movl(dst.gp(), src);
break;
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