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

PPC/s390: [cleanup] Remove condition based on kJSArgcIncludesReceiver

Port db9f6bff

Original Commit Message:

    The receiver is included unconditionally on all platforms
    (kJSArgcIncludesReceiver is always true).
    Remove all usages of kJSArgcIncludesReceiver from the code.

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

Change-Id: Iec840804c1070f54f03ff80770246061996b4ea6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3395813Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#78655}
parent 9dc0dfdd
......@@ -79,11 +79,7 @@ void Generate_PushArguments(MacroAssembler* masm, Register array, Register argc,
ArgumentsElementType element_type) {
DCHECK(!AreAliased(array, argc, scratch));
Label loop, done;
if (kJSArgcIncludesReceiver) {
__ subi(scratch, argc, Operand(kJSArgcReceiverSlots));
} else {
__ mr(scratch, argc);
}
__ subi(scratch, argc, Operand(kJSArgcReceiverSlots));
__ cmpi(scratch, Operand::Zero());
__ beq(&done);
__ mtctr(scratch);
......@@ -160,9 +156,7 @@ void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) {
}
// Remove caller arguments from the stack and return.
__ DropArguments(scratch, TurboAssembler::kCountIsSmi,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
__ blr();
__ bind(&stack_overflow);
......@@ -324,9 +318,7 @@ void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
// Remove caller arguments from the stack and return.
__ DropArguments(r4, TurboAssembler::kCountIsSmi,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
__ blr();
__ bind(&check_receiver);
......@@ -434,9 +426,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
r6, FieldMemOperand(r7, JSFunction::kSharedFunctionInfoOffset), r0);
__ LoadU16(
r6, FieldMemOperand(r6, SharedFunctionInfo::kFormalParameterCountOffset));
if (kJSArgcIncludesReceiver) {
__ subi(r6, r6, Operand(kJSArgcReceiverSlots));
}
__ subi(r6, r6, Operand(kJSArgcReceiverSlots));
__ LoadTaggedPointerField(
r5, FieldMemOperand(r4, JSGeneratorObject::kParametersAndRegistersOffset),
r0);
......@@ -747,11 +737,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Check if we have enough stack space to push all arguments.
Label enough_stack_space, stack_overflow;
if (kJSArgcIncludesReceiver) {
__ mr(r3, r7);
} else {
__ addi(r3, r7, Operand(1));
}
__ mr(r3, r7);
__ StackOverflowCheck(r3, r9, &stack_overflow);
__ b(&enough_stack_space);
__ bind(&stack_overflow);
......@@ -853,10 +839,6 @@ static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1,
MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ ShiftLeftU64(actual_params_size, actual_params_size,
Operand(kSystemPointerSizeLog2));
if (!kJSArgcIncludesReceiver) {
__ addi(actual_params_size, actual_params_size,
Operand(kSystemPointerSize));
}
// If actual is bigger than formal, then we should use it to free up the stack
// arguments.
......@@ -1337,12 +1319,8 @@ void Builtins::Generate_InterpreterPushArgsThenCallImpl(
__ subi(r3, r3, Operand(1));
}
const bool skip_receiver =
receiver_mode == ConvertReceiverMode::kNullOrUndefined;
if (kJSArgcIncludesReceiver && skip_receiver) {
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
__ subi(r6, r3, Operand(kJSArgcReceiverSlots));
} else if (!kJSArgcIncludesReceiver && !skip_receiver) {
__ addi(r6, r3, Operand(1));
} else {
__ mr(r6, r3);
}
......@@ -1398,11 +1376,8 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl(
__ subi(r3, r3, Operand(1));
}
Register argc_without_receiver = r3;
if (kJSArgcIncludesReceiver) {
argc_without_receiver = ip;
__ subi(argc_without_receiver, r3, Operand(kJSArgcReceiverSlots));
}
Register argc_without_receiver = ip;
__ subi(argc_without_receiver, r3, Operand(kJSArgcReceiverSlots));
// Push the arguments.
GenerateInterpreterPushArgs(masm, argc_without_receiver, r7, r8);
......@@ -1742,10 +1717,8 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ LoadU64(r5, MemOperand(sp, 2 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r3, r8, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r3, r8, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -1828,10 +1801,8 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
__ LoadU64(r5, MemOperand(sp, 3 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r3, r8, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r3, r8, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -1879,10 +1850,8 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
__ blt(&done);
__ LoadU64(r6, MemOperand(sp, 3 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r3, r7, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r3, r7, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -1925,13 +1894,9 @@ void Generate_AllocateSpaceAndShiftExistingArguments(
Register dest = pointer_to_new_space_out;
__ addi(dest, sp, Operand(-kSystemPointerSize));
Label loop, skip;
if (!kJSArgcIncludesReceiver) {
__ addi(r0, argc_in_out, Operand(1));
} else {
__ mr(r0, argc_in_out);
__ cmpi(r0, Operand::Zero());
__ ble(&skip);
}
__ mr(r0, argc_in_out);
__ cmpi(r0, Operand::Zero());
__ ble(&skip);
__ mtctr(r0);
__ bind(&loop);
__ LoadU64WithUpdate(r0, MemOperand(old_sp, kSystemPointerSize));
......@@ -2053,9 +2018,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
Label stack_done, stack_overflow;
__ LoadU64(r8, MemOperand(fp, StandardFrameConstants::kArgCOffset));
if (kJSArgcIncludesReceiver) {
__ subi(r8, r8, Operand(kJSArgcReceiverSlots));
}
__ subi(r8, r8, Operand(kJSArgcReceiverSlots));
__ sub(r8, r8, r5, LeaveOE, SetRC);
__ ble(&stack_done, cr0);
{
......
......@@ -329,11 +329,7 @@ void Generate_PushArguments(MacroAssembler* masm, Register array, Register argc,
Register counter = scratch;
Register value = ip;
Label loop, entry;
if (kJSArgcIncludesReceiver) {
__ SubS64(counter, argc, Operand(kJSArgcReceiverSlots));
} else {
__ mov(counter, argc);
}
__ SubS64(counter, argc, Operand(kJSArgcReceiverSlots));
__ b(&entry);
__ bind(&loop);
__ ShiftLeftU64(value, counter, Operand(kSystemPointerSizeLog2));
......@@ -403,9 +399,7 @@ void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) {
}
// Remove caller arguments from the stack and return.
__ DropArguments(scratch, TurboAssembler::kCountIsSmi,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
__ Ret();
__ bind(&stack_overflow);
......@@ -563,9 +557,7 @@ void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
// Remove caller arguments from the stack and return.
__ DropArguments(r3, TurboAssembler::kCountIsSmi,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
__ Ret();
__ bind(&check_receiver);
......@@ -661,9 +653,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
r5, FieldMemOperand(r6, JSFunction::kSharedFunctionInfoOffset));
__ LoadU16(
r5, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset));
if (kJSArgcIncludesReceiver) {
__ SubS64(r5, r5, Operand(kJSArgcReceiverSlots));
}
__ SubS64(r5, r5, Operand(kJSArgcReceiverSlots));
__ LoadTaggedPointerField(
r4,
FieldMemOperand(r3, JSGeneratorObject::kParametersAndRegistersOffset));
......@@ -1031,11 +1021,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Check if we have enough stack space to push all arguments.
Label enough_stack_space, stack_overflow;
if (kJSArgcIncludesReceiver) {
__ mov(r7, r2);
} else {
__ AddS64(r7, r2, Operand(1));
}
__ mov(r7, r2);
__ StackOverflowCheck(r7, r1, &stack_overflow);
__ b(&enough_stack_space);
__ bind(&stack_overflow);
......@@ -1142,10 +1128,6 @@ static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1,
MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ ShiftLeftU64(actual_params_size, actual_params_size,
Operand(kSystemPointerSizeLog2));
if (!kJSArgcIncludesReceiver) {
__ AddS64(actual_params_size, actual_params_size,
Operand(kSystemPointerSize));
}
// If actual is bigger than formal, then we should use it to free up the stack
// arguments.
......@@ -1816,12 +1798,8 @@ void Builtins::Generate_InterpreterPushArgsThenCallImpl(
__ SubS64(r2, r2, Operand(1));
}
const bool skip_receiver =
receiver_mode == ConvertReceiverMode::kNullOrUndefined;
if (kJSArgcIncludesReceiver && skip_receiver) {
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
__ SubS64(r5, r2, Operand(kJSArgcReceiverSlots));
} else if (!kJSArgcIncludesReceiver && !skip_receiver) {
__ AddS64(r5, r2, Operand(1));
} else {
__ mov(r5, r2);
}
......@@ -1877,11 +1855,8 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl(
__ SubS64(r2, r2, Operand(1));
}
Register argc_without_receiver = r2;
if (kJSArgcIncludesReceiver) {
argc_without_receiver = ip;
__ SubS64(argc_without_receiver, r2, Operand(kJSArgcReceiverSlots));
}
Register argc_without_receiver = ip;
__ SubS64(argc_without_receiver, r2, Operand(kJSArgcReceiverSlots));
// Push the arguments. r4 and r5 will be modified.
GenerateInterpreterPushArgs(masm, argc_without_receiver, r6, r7);
......@@ -2167,10 +2142,8 @@ void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) {
__ LoadU64(r4, MemOperand(sp, 2 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r2, r7, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r2, r7, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -2254,10 +2227,8 @@ void Builtins::Generate_ReflectApply(MacroAssembler* masm) {
__ LoadU64(r4, MemOperand(sp, 3 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r2, r7, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r2, r7, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -2306,10 +2277,8 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
__ blt(&done);
__ LoadU64(r5, MemOperand(sp, 3 * kSystemPointerSize)); // argArray
__ bind(&done);
__ DropArgumentsAndPushNewReceiver(
r2, r6, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver ? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
__ DropArgumentsAndPushNewReceiver(r2, r6, TurboAssembler::kCountIsInteger,
TurboAssembler::kCountIncludesReceiver);
}
// ----------- S t a t e -------------
......@@ -2358,11 +2327,7 @@ void Generate_AllocateSpaceAndShiftExistingArguments(
Label loop, done;
__ bind(&loop);
__ CmpS64(old_sp, end);
if (kJSArgcIncludesReceiver) {
__ bge(&done);
} else {
__ bgt(&done);
}
__ bge(&done);
__ LoadU64(value, MemOperand(old_sp));
__ lay(old_sp, MemOperand(old_sp, kSystemPointerSize));
__ StoreU64(value, MemOperand(dest));
......@@ -2484,9 +2449,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
Label stack_done, stack_overflow;
__ LoadU64(r7, MemOperand(fp, StandardFrameConstants::kArgCOffset));
if (kJSArgcIncludesReceiver) {
__ SubS64(r7, r7, Operand(kJSArgcReceiverSlots));
}
__ SubS64(r7, r7, Operand(kJSArgcReceiverSlots));
__ SubS64(r7, r7, r4);
__ ble(&stack_done);
{
......
......@@ -1500,13 +1500,9 @@ void MacroAssembler::InvokePrologue(Register expected_parameter_count,
sub(sp, sp, r0);
// Update stack pointer.
addi(dest, sp, Operand(-kSystemPointerSize));
if (!kJSArgcIncludesReceiver) {
addi(r0, actual_parameter_count, Operand(1));
} else {
mr(r0, actual_parameter_count);
cmpi(r0, Operand::Zero());
ble(&skip);
}
mr(r0, actual_parameter_count);
cmpi(r0, Operand::Zero());
ble(&skip);
mtctr(r0);
bind(&copy);
......
......@@ -1698,11 +1698,7 @@ void MacroAssembler::InvokePrologue(Register expected_parameter_count,
lay(dest, MemOperand(dest, kSystemPointerSize));
SubS64(num, num, Operand(1));
bind(&check);
if (kJSArgcIncludesReceiver) {
b(gt, &copy);
} else {
b(ge, &copy);
}
b(gt, &copy);
}
// Fill remaining expected arguments with undefined values.
......
......@@ -4215,25 +4215,14 @@ void CodeGenerator::AssembleReturn(InstructionOperand* additional_pop_count) {
// max(argc_reg, parameter_slots-1), and the receiver is added in
// DropArguments().
if (parameter_slots > 1) {
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);
}
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots), r0);
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots));
__ bind(&skip);
}
__ DropArguments(argc_reg, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
} else if (additional_pop_count->IsImmediate()) {
int additional_count = g.ToConstant(additional_pop_count).ToInt32();
__ Drop(parameter_slots + additional_count);
......
......@@ -3952,25 +3952,15 @@ void CodeGenerator::AssembleReturn(InstructionOperand* additional_pop_count) {
// max(argc_reg, parameter_slots-1), and the receiver is added in
// DropArguments().
if (parameter_slots > 1) {
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);
}
Label skip;
__ CmpS64(argc_reg, Operand(parameter_slots));
__ bgt(&skip);
__ mov(argc_reg, Operand(parameter_slots));
__ bind(&skip);
}
__ DropArguments(argc_reg, TurboAssembler::kCountIsInteger,
kJSArgcIncludesReceiver
? TurboAssembler::kCountIncludesReceiver
: TurboAssembler::kCountExcludesReceiver);
TurboAssembler::kCountIncludesReceiver);
} 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