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

PPC/S390: Argument Count Consistency

Port: 255aaed9

Original Commit Message:

   The receiver is now always included in the actual argument
   count and the formal parameter count.
   kDontAdaptArgumentsSentinel is changed from UINT16_MAX to 0
   to preserve the maximum allowed declared parameters.
   The build flag activating the changes is not set for any
   architecture yet.

Bug: v8:11112
Change-Id: Ib106775014a886da80684dcb83ed704bb898a244
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3271635Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#77907}
parent bb976645
This diff is collapsed.
This diff is collapsed.
......@@ -1493,20 +1493,27 @@ void MacroAssembler::InvokePrologue(Register expected_parameter_count,
// Underapplication. Move the arguments already in the stack, including the
// receiver and the return address.
{
Label copy;
Label copy, skip;
Register src = r9, dest = r8;
addi(src, sp, Operand(-kSystemPointerSize));
ShiftLeftU64(r0, expected_parameter_count, Operand(kSystemPointerSizeLog2));
sub(sp, sp, r0);
// Update stack pointer.
addi(dest, sp, Operand(-kSystemPointerSize));
addi(r0, actual_parameter_count, Operand(1));
if (!kJSArgcIncludesReceiver) {
addi(r0, actual_parameter_count, Operand(1));
} else {
mr(r0, actual_parameter_count);
cmpi(r0, Operand::Zero());
ble(&skip);
}
mtctr(r0);
bind(&copy);
LoadU64WithUpdate(r0, MemOperand(src, kSystemPointerSize));
StoreU64WithUpdate(r0, MemOperand(dest, kSystemPointerSize));
bdnz(&copy);
bind(&skip);
}
// Fill remaining expected arguments with undefined values.
......
......@@ -1691,7 +1691,11 @@ void MacroAssembler::InvokePrologue(Register expected_parameter_count,
lay(dest, MemOperand(dest, kSystemPointerSize));
SubS64(num, num, Operand(1));
bind(&check);
b(ge, &copy);
if (kJSArgcIncludesReceiver) {
b(gt, &copy);
} else {
b(ge, &copy);
}
}
// Fill remaining expected arguments with undefined values.
......
......@@ -4148,15 +4148,25 @@ void CodeGenerator::AssembleReturn(InstructionOperand* additional_pop_count) {
// max(argc_reg, parameter_slots-1), and the receiver is added in
// DropArguments().
if (parameter_slots > 1) {
const int parameter_slots_without_receiver = parameter_slots - 1;
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots_without_receiver), r0);
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots_without_receiver));
__ bind(&skip);
if (kJSArgcIncludesReceiver) {
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots), r0);
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots));
__ bind(&skip);
} else {
const int parameter_slots_without_receiver = parameter_slots - 1;
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots_without_receiver), r0);
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots_without_receiver));
__ bind(&skip);
}
}
__ DropArguments(argc_reg, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountExcludesReceiver);
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
} else if (additional_pop_count->IsImmediate()) {
int additional_count = g.ToConstant(additional_pop_count).ToInt32();
__ Drop(parameter_slots + additional_count);
......
......@@ -3914,15 +3914,25 @@ void CodeGenerator::AssembleReturn(InstructionOperand* additional_pop_count) {
// max(argc_reg, parameter_slots-1), and the receiver is added in
// DropArguments().
if (parameter_slots > 1) {
const int parameter_slots_without_receiver = parameter_slots - 1;
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots_without_receiver));
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots_without_receiver));
__ bind(&skip);
if (kJSArgcIncludesReceiver) {
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots));
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots));
__ bind(&skip);
} else {
const int parameter_slots_without_receiver = parameter_slots - 1;
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots_without_receiver));
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots_without_receiver));
__ bind(&skip);
}
}
__ DropArguments(argc_reg, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountExcludesReceiver);
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
} else if (additional_pop_count->IsImmediate()) {
int additional_count = g.ToConstant(additional_pop_count).ToInt32();
__ Drop(parameter_slots + additional_count);
......
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