Commit 81f15091 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [wasm] Keep call_indirect index on the stack

Port c2d46fe9

Original Commit Message:

    When a call_indirect fails because of a signature mismatch or a null
    target, the value stack generated for debug doesn't contain the target
    index anymore, which makes it hard for users to understand the error.

    Keep the index on the stack, and ensure that the index is not modified
    until we generate the debug info. Previously, the index was shifted
    in-place to compute various offsets. Instead, use scaled loads to
    compute the offset directly in the load instruction.

R=thibaudm@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: I6ab0b5bfcac991f6e26a97bb2513556aa67dcf94
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3858300Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/main@{#82793}
parent fac19a24
......@@ -303,7 +303,12 @@ void LiftoffAssembler::ResetOSRTarget() {}
void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
Register offset_reg,
int32_t offset_imm) {
int32_t offset_imm, bool needs_shift) {
unsigned shift_amount = !needs_shift ? 0 : COMPRESS_POINTERS_BOOL ? 2 : 3;
if (offset_reg != no_reg && shift_amount != 0) {
ShiftLeftU64(ip, offset_reg, Operand(shift_amount));
offset_reg = ip;
}
LoadTaggedPointerField(dst, MemOperand(src_addr, offset_reg, offset_imm), r0);
}
......@@ -348,11 +353,17 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc,
bool is_load_mem, bool i64_offset) {
bool is_load_mem, bool i64_offset,
bool needs_shift) {
if (!i64_offset && offset_reg != no_reg) {
ZeroExtWord32(ip, offset_reg);
offset_reg = ip;
}
unsigned shift_amount = needs_shift ? type.size_log_2() : 0;
if (offset_reg != no_reg && shift_amount != 0) {
ShiftLeftU64(ip, offset_reg, Operand(shift_amount));
offset_reg = ip;
}
MemOperand src_op = MemOperand(src_addr, offset_reg, offset_imm);
if (protected_load_pc) *protected_load_pc = pc_offset();
switch (type.value()) {
......
......@@ -279,8 +279,13 @@ void LiftoffAssembler::ResetOSRTarget() {}
void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr,
Register offset_reg,
int32_t offset_imm) {
int32_t offset_imm, bool needs_shift) {
CHECK(is_int20(offset_imm));
unsigned shift_amount = !needs_shift ? 0 : COMPRESS_POINTERS_BOOL ? 2 : 3;
if (offset_reg != no_reg && shift_amount != 0) {
ShiftLeftU64(ip, offset_reg, Operand(shift_amount));
offset_reg = ip;
}
LoadTaggedPointerField(
dst,
MemOperand(src_addr, offset_reg == no_reg ? r0 : offset_reg, offset_imm));
......@@ -325,13 +330,19 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc,
bool is_load_mem, bool i64_offset) {
bool is_load_mem, bool i64_offset,
bool needs_shift) {
UseScratchRegisterScope temps(this);
if (offset_reg != no_reg && !i64_offset) {
// Clear the upper 32 bits of the 64 bit offset register.
llgfr(ip, offset_reg);
offset_reg = ip;
}
unsigned shift_amount = needs_shift ? type.size_log_2() : 0;
if (offset_reg != no_reg && shift_amount != 0) {
ShiftLeftU64(ip, offset_reg, Operand(shift_amount));
offset_reg = ip;
}
if (!is_int20(offset_imm)) {
if (offset_reg != no_reg) {
mov(r0, Operand(offset_imm));
......
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