Commit 41c3140b authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[cleanup] Simplify CallOrConstructForwardVarargs

Removes unnecessary move after the removal of the arguments adaptor frame

Change-Id: If92b9505ca23bb06a01bd25ba8e9664697d381f8
Bug: v8:11307
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2639759
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72263}
parent 373803c9
......@@ -1874,12 +1874,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mov(r4, fp);
__ ldr(r5, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ ldr(r5, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ sub(r5, r5, r2, SetCC);
__ b(le, &stack_done);
{
......@@ -1889,7 +1885,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// -- r1 : the target to call (can be any Object)
// -- r2 : start index (to support rest parameters)
// -- r3 : the new.target (for [[Construct]] calls)
// -- r4 : point to the caller stack frame
// -- fp : point to the caller stack frame
// -- r5 : number of arguments to copy, i.e. arguments count - start index
// -----------------------------------
......@@ -1898,7 +1894,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Forward the arguments from the caller frame.
// Point to the first argument to copy (skipping the receiver).
__ add(r4, r4,
__ add(r4, fp,
Operand(CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ add(r4, r4, Operand(r2, LSL, kSystemPointerSizeLog2));
......
......@@ -2224,14 +2224,9 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ Bind(&new_target_constructor);
}
Register args_fp = x5;
Register len = x6;
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ Mov(args_fp, fp);
__ Ldr(len, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ Ldr(len, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ Subs(len, len, start_index);
__ B(le, &stack_done);
// Check for stack overflow.
......@@ -2241,9 +2236,10 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Push varargs.
{
Register args_fp = x5;
Register dst = x13;
// Point to the fist argument to copy from (skipping receiver).
__ Add(args_fp, args_fp,
__ Add(args_fp, fp,
CommonFrameConstants::kFixedFrameSizeAboveFp + kSystemPointerSize);
__ lsl(start_index, start_index, kSystemPointerSizeLog2);
__ Add(args_fp, args_fp, start_index);
......
......@@ -2014,12 +2014,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ movd(xmm1, edx); // Preserve new.target (in case of [[Construct]]).
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mov(scratch, ebp);
__ mov(edx, Operand(ebp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ mov(edx, Operand(ebp, StandardFrameConstants::kArgCOffset));
__ sub(edx, ecx);
__ j(less_equal, &stack_done);
{
......@@ -2029,7 +2025,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// -- ecx : start index (to support rest parameters)
// -- edx : number of arguments to copy, i.e. arguments count - start index
// -- edi : the target to call (can be any Object)
// -- esi : point to the caller stack frame
// -- ebp : point to the caller stack frame
// -- xmm0 : context for the Call / Construct builtin
// -- xmm1 : the new target (for [[Construct]] calls)
// -----------------------------------
......@@ -2041,17 +2037,11 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
Register scratch = ebx;
// Point to the first argument to copy (skipping receiver).
__ lea(ecx, Operand(ecx, times_system_pointer_size,
CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ add(esi, ecx);
// Move the arguments already in the stack,
// including the receiver and the return address.
{
Label copy, check;
Register src = ecx, current = edi;
Register src = esi, current = edi;
// Update stack pointer.
__ mov(src, esp);
__ lea(scratch, Operand(edx, times_system_pointer_size, 0));
......@@ -2068,18 +2058,24 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&check);
__ cmp(current, eax);
__ j(less, &copy);
__ lea(ecx, Operand(esp, eax, times_system_pointer_size, 0));
__ lea(esi, Operand(esp, eax, times_system_pointer_size, 0));
}
// Update total number of arguments.
__ sub(eax, Immediate(2));
__ add(eax, edx);
// Point to the first argument to copy (skipping receiver).
__ lea(ecx, Operand(ecx, times_system_pointer_size,
CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ add(ecx, ebp);
// Copy the additional caller arguments onto the stack.
// TODO(victorgomes): Consider using forward order as potentially more cache
// friendly.
{
Register src = esi, dest = ecx, num = edx;
Register src = ecx, dest = esi, num = edx;
Label loop;
__ bind(&loop);
__ dec(num);
......
......@@ -1839,12 +1839,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mov(t3, fp);
__ Lw(t2, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ Lw(t2, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ Subu(t2, t2, a2);
__ Branch(&stack_done, le, t2, Operand(zero_reg));
{
......@@ -1853,7 +1849,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Forward the arguments from the caller frame.
// Point to the first argument to copy (skipping the receiver).
__ Addu(t3, t3,
__ Addu(t3, fp,
Operand(CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ Lsa(t3, t3, a2, kSystemPointerSizeLog2);
......
......@@ -1902,12 +1902,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mov(a6, fp);
__ Ld(a7, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ Ld(a7, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ Subu(a7, a7, a2);
__ Branch(&stack_done, le, a7, Operand(zero_reg));
{
......@@ -1917,7 +1913,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Forward the arguments from the caller frame.
// Point to the first argument to copy (skipping the receiver).
__ Daddu(a6, a6,
__ Daddu(a6, fp,
Operand(CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ Dlsa(a6, a6, a2, kSystemPointerSizeLog2);
......
......@@ -1948,12 +1948,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mr(r7, fp);
__ LoadP(r8, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ LoadP(r8, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ sub(r8, r8, r5, LeaveOE, SetRC);
__ ble(&stack_done, cr0);
{
......@@ -1963,7 +1959,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// -- r4 : the target to call (can be any Object)
// -- r5 : start index (to support rest parameters)
// -- r6 : the new.target (for [[Construct]] calls)
// -- r7 : point to the caller stack frame
// -- fp : point to the caller stack frame
// -- r8 : number of arguments to copy, i.e. arguments count - start index
// -----------------------------------
......@@ -1972,7 +1968,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Forward the arguments from the caller frame.
// Point to the first argument to copy (skipping the receiver).
__ addi(r7, r7,
__ addi(r7, fp,
Operand(CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ ShiftLeftImm(scratch, r5, Operand(kSystemPointerSizeLog2));
......
......@@ -1996,12 +1996,8 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ mov(r6, fp);
__ LoadU64(r7, MemOperand(fp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ LoadU64(r7, MemOperand(fp, StandardFrameConstants::kArgCOffset));
__ SubS64(r7, r7, r4);
__ ble(&stack_done);
{
......@@ -2021,7 +2017,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
// Forward the arguments from the caller frame.
__ mov(r5, r5);
// Point to the first argument to copy (skipping the receiver).
__ AddS64(r6, r6,
__ AddS64(r6, fp,
Operand(CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ ShiftLeftU64(scratch, r4, Operand(kSystemPointerSizeLog2));
......
......@@ -1952,19 +1952,15 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ bind(&new_target_constructor);
}
// TODO(victorgomes): Remove this copy when all the arguments adaptor frame
// code is erased.
__ movq(rbx, rbp);
__ movq(r8, Operand(rbp, StandardFrameConstants::kArgCOffset));
Label stack_done, stack_overflow;
__ movq(r8, Operand(rbp, StandardFrameConstants::kArgCOffset));
__ subl(r8, rcx);
__ j(less_equal, &stack_done);
{
// ----------- S t a t e -------------
// -- rax : the number of arguments already in the stack (not including the
// receiver)
// -- rbx : point to the caller stack frame
// -- rbp : point to the caller stack frame
// -- rcx : start index (to support rest parameters)
// -- rdx : the new target (for [[Construct]] calls)
// -- rdi : the target to call (can be any Object)
......@@ -2005,13 +2001,13 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
__ leaq(rcx, Operand(rcx, times_system_pointer_size,
CommonFrameConstants::kFixedFrameSizeAboveFp +
kSystemPointerSize));
__ addq(rbx, rcx);
__ addq(rcx, rbp);
// Copy the additional caller arguments onto the stack.
// TODO(victorgomes): Consider using forward order as potentially more cache
// friendly.
{
Register src = rbx, dest = r9, num = r8;
Register src = rcx, dest = r9, num = r8;
Label loop;
__ bind(&loop);
__ decq(num);
......
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