Commit 224d87d7 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff][ia32] Clean up "half stack slot" accesses

Bring ia32 in line with the arm implemention. Instead of computing the
"half index" manually, pass the index and an enum pointing to either
half.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: Ia3799a42fe2b9890aa4076d2e09947380331348e
Reviewed-on: https://chromium-review.googlesource.com/c/1391758
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58501}
parent 088bdc00
......@@ -61,11 +61,9 @@ inline MemOperand GetHalfStackSlot(uint32_t half_index) {
}
inline MemOperand GetHalfStackSlot(uint32_t index, RegPairHalf half) {
if (half == kLowWord) {
return GetHalfStackSlot(2 * index);
} else {
return GetHalfStackSlot(2 * index - 1);
}
STATIC_ASSERT(kLowWord == 0);
STATIC_ASSERT(kHighWord == 1);
return GetHalfStackSlot(2 * index - half);
}
inline MemOperand GetInstanceOperand() {
......
......@@ -39,6 +39,12 @@ inline Operand GetHalfStackSlot(uint32_t half_index) {
return Operand(ebp, -kFirstStackSlotOffset - offset);
}
inline MemOperand GetHalfStackSlot(uint32_t index, RegPairHalf half) {
STATIC_ASSERT(kLowWord == 0);
STATIC_ASSERT(kHighWord == 1);
return GetHalfStackSlot(2 * index - half);
}
// TODO(clemensh): Make this a constexpr variable once Operand is constexpr.
inline Operand GetInstanceOperand() { return Operand(ebp, -8); }
......@@ -436,8 +442,8 @@ void LiftoffAssembler::Spill(uint32_t index, LiftoffRegister reg,
mov(dst, reg.gp());
break;
case kWasmI64:
mov(dst, reg.low_gp());
mov(liftoff::GetHalfStackSlot(2 * index - 1), reg.high_gp());
mov(liftoff::GetHalfStackSlot(index, kLowWord), reg.low_gp());
mov(liftoff::GetHalfStackSlot(index, kHighWord), reg.high_gp());
break;
case kWasmF32:
movss(dst, reg.fp());
......@@ -460,8 +466,8 @@ void LiftoffAssembler::Spill(uint32_t index, WasmValue value) {
case kWasmI64: {
int32_t low_word = value.to_i64();
int32_t high_word = value.to_i64() >> 32;
mov(dst, Immediate(low_word));
mov(liftoff::GetHalfStackSlot(2 * index - 1), Immediate(high_word));
mov(liftoff::GetHalfStackSlot(index, kLowWord), Immediate(low_word));
mov(liftoff::GetHalfStackSlot(index, kHighWord), Immediate(high_word));
break;
}
default:
......@@ -478,8 +484,8 @@ void LiftoffAssembler::Fill(LiftoffRegister reg, uint32_t index,
mov(reg.gp(), src);
break;
case kWasmI64:
mov(reg.low_gp(), src);
mov(reg.high_gp(), liftoff::GetHalfStackSlot(2 * index - 1));
mov(reg.low_gp(), liftoff::GetHalfStackSlot(index, kLowWord));
mov(reg.high_gp(), liftoff::GetHalfStackSlot(index, kHighWord));
break;
case kWasmF32:
movss(reg.fp(), src);
......@@ -1741,10 +1747,9 @@ void LiftoffStackSlots::Construct() {
case LiftoffAssembler::VarState::kStack:
if (src.type() == kWasmF64) {
DCHECK_EQ(kLowWord, slot.half_);
asm_->push(liftoff::GetHalfStackSlot(2 * slot.src_index_ - 1));
asm_->push(liftoff::GetHalfStackSlot(slot.src_index_, kHighWord));
}
asm_->push(liftoff::GetHalfStackSlot(2 * slot.src_index_ -
(slot.half_ == kLowWord ? 0 : 1)));
asm_->push(liftoff::GetHalfStackSlot(slot.src_index_, slot.half_));
break;
case LiftoffAssembler::VarState::kRegister:
if (src.type() == kWasmI64) {
......
......@@ -26,7 +26,7 @@ enum RegClass : uint8_t {
kNoReg = kGpRegPair + kNeedI64RegPair
};
enum RegPairHalf : uint8_t { kLowWord, kHighWord };
enum RegPairHalf : uint8_t { kLowWord = 0, kHighWord = 1 };
static inline constexpr bool needs_reg_pair(ValueType type) {
return kNeedI64RegPair && type == kWasmI64;
......
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