Commit c728b8a5 authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips64][wasm] Keep call_indirect index on the stack

Port commit c2d46fe9

Bug: chromium:1350384
Change-Id: Id1cfb2dbb69093799658f366ade3b422a6b68f07
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3867134
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#82850}
parent 8e32d8f3
...@@ -80,24 +80,27 @@ inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } ...@@ -80,24 +80,27 @@ inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); }
template <typename T> template <typename T>
inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr, inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr,
Register offset, T offset_imm, Register offset, T offset_imm,
bool i64_offset = false) { bool i64_offset = false, unsigned shift_amount = 0) {
if (!i64_offset && offset != no_reg) { if (offset != no_reg) {
assm->bstrpick_d(kScratchReg2, offset, 31, 0); if (!i64_offset) {
offset = kScratchReg2; assm->bstrpick_d(kScratchReg, offset, 31, 0);
offset = kScratchReg;
}
if (shift_amount != 0) {
assm->alsl_d(kScratchReg, offset, addr, shift_amount);
} else {
assm->add_d(kScratchReg, offset, addr);
}
addr = kScratchReg;
} }
if (is_int31(offset_imm)) { if (is_int31(offset_imm)) {
int32_t offset_imm32 = static_cast<int32_t>(offset_imm); int32_t offset_imm32 = static_cast<int32_t>(offset_imm);
if (offset == no_reg) return MemOperand(addr, offset_imm32); return MemOperand(addr, offset_imm32);
assm->add_d(kScratchReg, addr, offset); } else {
return MemOperand(kScratchReg, offset_imm32); assm->li(kScratchReg2, Operand(offset_imm));
} assm->add_d(kScratchReg2, addr, kScratchReg2);
// Offset immediate does not fit in 31 bits. return MemOperand(kScratchReg2, 0);
assm->li(kScratchReg, Operand(offset_imm));
assm->add_d(kScratchReg, kScratchReg, addr);
if (offset != no_reg) {
assm->add_d(kScratchReg, kScratchReg, offset);
} }
return MemOperand(kScratchReg, 0);
} }
inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src,
...@@ -370,9 +373,11 @@ void LiftoffAssembler::ResetOSRTarget() {} ...@@ -370,9 +373,11 @@ void LiftoffAssembler::ResetOSRTarget() {}
void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
Register offset_reg, Register offset_reg,
int32_t offset_imm) { int32_t offset_imm, bool needs_shift) {
static_assert(kTaggedSize == kInt64Size); static_assert(kTaggedSize == kInt64Size);
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm); unsigned shift_amount = !needs_shift ? 0 : 3;
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm,
false, shift_amount);
Ld_d(dst, src_op); Ld_d(dst, src_op);
} }
...@@ -424,9 +429,11 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, ...@@ -424,9 +429,11 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm, Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc, LoadType type, uint32_t* protected_load_pc,
bool is_load_mem, bool i64_offset) { bool is_load_mem, bool i64_offset,
MemOperand src_op = bool needs_shift) {
liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm, i64_offset); unsigned shift_amount = needs_shift ? type.size_log_2() : 0;
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm,
i64_offset, shift_amount);
if (protected_load_pc) *protected_load_pc = pc_offset(); if (protected_load_pc) *protected_load_pc = pc_offset();
switch (type.value()) { switch (type.value()) {
......
...@@ -80,24 +80,27 @@ inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } ...@@ -80,24 +80,27 @@ inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); }
template <typename T> template <typename T>
inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr, inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr,
Register offset, T offset_imm, Register offset, T offset_imm,
bool i64_offset = false) { bool i64_offset = false, unsigned shift_amount = 0) {
if (!i64_offset && offset != no_reg) { if (offset != no_reg) {
if (!i64_offset) {
assm->Dext(kScratchReg2, offset, 0, 32); assm->Dext(kScratchReg2, offset, 0, 32);
offset = kScratchReg2; offset = kScratchReg;
}
if (shift_amount != 0) {
assm->Dlsa(kScratchReg, addr, offset, shift_amount);
} else {
assm->daddu(kScratchReg, offset, addr);
}
addr = kScratchReg;
} }
if (is_int31(offset_imm)) { if (is_int31(offset_imm)) {
int32_t offset_imm32 = static_cast<int32_t>(offset_imm); int32_t offset_imm32 = static_cast<int32_t>(offset_imm);
if (offset == no_reg) return MemOperand(addr, offset_imm32); return MemOperand(addr, offset_imm32);
assm->daddu(kScratchReg, addr, offset); } else {
return MemOperand(kScratchReg, offset_imm32); assm->li(kScratchReg2, Operand(offset_imm));
} assm->daddu(kScratchReg2, addr, kScratchReg2);
// Offset immediate does not fit in 31 bits. return MemOperand(kScratchReg2, 0);
assm->li(kScratchReg, offset_imm);
assm->daddu(kScratchReg, kScratchReg, addr);
if (offset != no_reg) {
assm->daddu(kScratchReg, kScratchReg, offset);
} }
return MemOperand(kScratchReg, 0);
} }
inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src,
...@@ -486,9 +489,11 @@ void LiftoffAssembler::ResetOSRTarget() {} ...@@ -486,9 +489,11 @@ void LiftoffAssembler::ResetOSRTarget() {}
void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
Register offset_reg, Register offset_reg,
int32_t offset_imm) { int32_t offset_imm, bool needs_shift) {
static_assert(kTaggedSize == kInt64Size); static_assert(kTaggedSize == kInt64Size);
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm); unsigned shift_amount = !needs_shift ? 0 : 3;
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm,
false, shift_amount);
Ld(dst, src_op); Ld(dst, src_op);
} }
...@@ -531,9 +536,11 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, ...@@ -531,9 +536,11 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm, Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc, LoadType type, uint32_t* protected_load_pc,
bool is_load_mem, bool i64_offset) { bool is_load_mem, bool i64_offset,
MemOperand src_op = bool needs_shift) {
liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm, i64_offset); unsigned shift_amount = needs_shift ? type.size_log_2() : 0;
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm,
i64_offset, shift_amount);
if (protected_load_pc) *protected_load_pc = pc_offset(); if (protected_load_pc) *protected_load_pc = pc_offset();
switch (type.value()) { switch (type.value()) {
......
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