Skip to content

Commit 83410eb

Browse files
Milad Farichardlau
authored andcommitted
deps: V8: cherry-pick 59d52e311bb1
Original commit message: [liftoff] Fix parameter passing during CallC Values smaller than 8 bytes need to be sign/zero extended to 8 bytes then pushed on to the stack. Change-Id: I5c9a2179ef2b65cf08b7e773180d78b252c2253f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6597365 Commit-Queue: Milad Farazmand <[email protected]> Reviewed-by: Junliang Yan <[email protected]> Cr-Commit-Position: refs/heads/main@{#100578} Refs: v8/v8@59d52e3 PR-URL: #59485 Refs: nodejs/build#4091 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 48bfbd3 commit 83410eb

File tree

3 files changed

+60
-13
lines changed

3 files changed

+60
-13
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.30',
41+
'v8_embedder_string': '-node.31',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/wasm/baseline/ppc/liftoff-assembler-ppc-inl.h

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,14 +2776,38 @@ void LiftoffAssembler::CallC(const std::initializer_list<VarState> args,
27762776
parallel_move.LoadIntoRegister(LiftoffRegister{kCArgRegs[reg_args]}, arg);
27772777
++reg_args;
27782778
} else {
2779-
int bias = 0;
2780-
// On BE machines values with less than 8 bytes are right justified.
2781-
// bias here is relative to the stack pointer.
2782-
if (arg.kind() == kI32 || arg.kind() == kF32) bias = -stack_bias;
27832779
int offset =
27842780
(kStackFrameExtraParamSlot + stack_args) * kSystemPointerSize;
2785-
MemOperand dst{sp, offset + bias};
2786-
liftoff::StoreToMemory(this, dst, arg, r0, ip);
2781+
MemOperand dst{sp, offset};
2782+
Register scratch1 = r0;
2783+
Register scratch2 = ip;
2784+
if (arg.is_reg()) {
2785+
switch (arg.kind()) {
2786+
case kI16:
2787+
extsh(scratch1, arg.reg().gp());
2788+
StoreU64(scratch1, dst);
2789+
break;
2790+
case kI32:
2791+
extsw(scratch1, arg.reg().gp());
2792+
StoreU64(scratch1, dst);
2793+
break;
2794+
case kI64:
2795+
StoreU64(arg.reg().gp(), dst);
2796+
break;
2797+
default:
2798+
UNREACHABLE();
2799+
}
2800+
} else if (arg.is_const()) {
2801+
mov(scratch1, Operand(static_cast<int64_t>(arg.i32_const())));
2802+
StoreU64(scratch1, dst);
2803+
} else if (value_kind_size(arg.kind()) == 4) {
2804+
LoadS32(scratch1, liftoff::GetStackSlot(arg.offset()), scratch2);
2805+
StoreU64(scratch1, dst);
2806+
} else {
2807+
DCHECK_EQ(8, value_kind_size(arg.kind()));
2808+
LoadU64(scratch1, liftoff::GetStackSlot(arg.offset()), scratch1);
2809+
StoreU64(scratch1, dst);
2810+
}
27872811
++stack_args;
27882812
}
27892813
}

deps/v8/src/wasm/baseline/s390/liftoff-assembler-s390-inl.h

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,14 +3135,37 @@ void LiftoffAssembler::CallC(const std::initializer_list<VarState> args,
31353135
parallel_move.LoadIntoRegister(LiftoffRegister{kCArgRegs[reg_args]}, arg);
31363136
++reg_args;
31373137
} else {
3138-
int bias = 0;
3139-
// On BE machines values with less than 8 bytes are right justified.
3140-
// bias here is relative to the stack pointer.
3141-
if (arg.kind() == kI32 || arg.kind() == kF32) bias = -stack_bias;
31423138
int offset =
31433139
(kStackFrameExtraParamSlot + stack_args) * kSystemPointerSize;
3144-
MemOperand dst{sp, offset + bias};
3145-
liftoff::StoreToMemory(this, dst, arg, r0);
3140+
MemOperand dst{sp, offset};
3141+
Register scratch = ip;
3142+
if (arg.is_reg()) {
3143+
switch (arg.kind()) {
3144+
case kI16:
3145+
LoadS16(scratch, arg.reg().gp());
3146+
StoreU64(scratch, dst);
3147+
break;
3148+
case kI32:
3149+
LoadS32(scratch, arg.reg().gp());
3150+
StoreU64(scratch, dst);
3151+
break;
3152+
case kI64:
3153+
StoreU64(arg.reg().gp(), dst);
3154+
break;
3155+
default:
3156+
UNREACHABLE();
3157+
}
3158+
} else if (arg.is_const()) {
3159+
mov(scratch, Operand(static_cast<int64_t>(arg.i32_const())));
3160+
StoreU64(scratch, dst);
3161+
} else if (value_kind_size(arg.kind()) == 4) {
3162+
LoadS32(scratch, liftoff::GetStackSlot(arg.offset()), scratch);
3163+
StoreU64(scratch, dst);
3164+
} else {
3165+
DCHECK_EQ(8, value_kind_size(arg.kind()));
3166+
LoadU64(scratch, liftoff::GetStackSlot(arg.offset()), scratch);
3167+
StoreU64(scratch, dst);
3168+
}
31463169
++stack_args;
31473170
}
31483171
}

0 commit comments

Comments
 (0)