Commit 9f1eceee authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

[arm64] Prepare for pushing arguments to runtime with padding.

Also updates TurboAssembler::DropArguments to simplify dropping the receiver
and the arguments.

Bug: v8:6644
Change-Id: Ief3b529ffc574c213816a533948c7b1f5d014bd7
Reviewed-on: https://chromium-review.googlesource.com/723466Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Cr-Commit-Position: refs/heads/master@{#48669}
parent d4339289
...@@ -484,7 +484,7 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -484,7 +484,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
DCHECK(jssp.Is(__ StackPointer())); DCHECK(jssp.Is(__ StackPointer()));
if (!argv_in_register()) { if (!argv_in_register()) {
// Drop the remaining stack slots and return from the stub. // Drop the remaining stack slots and return from the stub.
__ Drop(x11); __ DropArguments(x11);
} }
__ AssertFPCRState(); __ AssertFPCRState();
__ Ret(); __ Ret();
......
...@@ -1353,14 +1353,24 @@ void TurboAssembler::Drop(const Register& count, uint64_t unit_size) { ...@@ -1353,14 +1353,24 @@ void TurboAssembler::Drop(const Register& count, uint64_t unit_size) {
} }
} }
void TurboAssembler::DropArguments(const Register& count, uint64_t unit_size) { void TurboAssembler::DropArguments(const Register& count,
Drop(count, unit_size); ArgumentsCountMode mode) {
if (mode == kCountExcludesReceiver) {
UseScratchRegisterScope temps(this);
Register tmp = temps.AcquireX();
Add(tmp, count, 1);
Drop(tmp);
} else {
Drop(count);
}
} }
void TurboAssembler::DropSlots(int64_t count, uint64_t unit_size) { void TurboAssembler::DropSlots(int64_t count, uint64_t unit_size) {
Drop(count, unit_size); Drop(count, unit_size);
} }
void TurboAssembler::PushArgument(const Register& arg) { Push(arg); }
void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) { void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) {
DCHECK(unit_size == 0 || base::bits::IsPowerOfTwo(unit_size)); DCHECK(unit_size == 0 || base::bits::IsPowerOfTwo(unit_size));
const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits) - kSmiShift; const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits) - kSmiShift;
......
...@@ -2254,10 +2254,10 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target, ...@@ -2254,10 +2254,10 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
if (new_target.is_valid()) { if (new_target.is_valid()) {
Push(new_target); Push(new_target);
} }
Push(fun); Push(fun, padreg);
Push(fun); PushArgument(fun);
CallRuntime(Runtime::kDebugOnFunctionCall); CallRuntime(Runtime::kDebugOnFunctionCall);
Pop(fun); Pop(padreg, fun);
if (new_target.is_valid()) { if (new_target.is_valid()) {
Pop(new_target); Pop(new_target);
} }
......
...@@ -695,12 +695,15 @@ class TurboAssembler : public Assembler { ...@@ -695,12 +695,15 @@ class TurboAssembler : public Assembler {
inline void Drop(const Register& count, uint64_t unit_size = kXRegSize); inline void Drop(const Register& count, uint64_t unit_size = kXRegSize);
// Drop arguments from stack without actually accessing memory. // Drop arguments from stack without actually accessing memory.
// This will currently drop 'count' arguments of the given size from the // This will currently drop 'count' arguments from the stack.
// stack. // We assume the size of the arguments is the pointer size.
// An optional mode argument is passed, which can indicate we need to
// explicitly add the receiver to the count.
// TODO(arm64): Update this to round up the number of bytes dropped to // TODO(arm64): Update this to round up the number of bytes dropped to
// a multiple of 16, so that we can remove jssp. // a multiple of 16, so that we can remove jssp.
enum ArgumentsCountMode { kCountIncludesReceiver, kCountExcludesReceiver };
inline void DropArguments(const Register& count, inline void DropArguments(const Register& count,
uint64_t unit_size = kXRegSize); ArgumentsCountMode mode = kCountIncludesReceiver);
// Drop slots from stack without actually accessing memory. // Drop slots from stack without actually accessing memory.
// This will currently drop 'count' slots of the given size from the stack. // This will currently drop 'count' slots of the given size from the stack.
...@@ -708,6 +711,10 @@ class TurboAssembler : public Assembler { ...@@ -708,6 +711,10 @@ class TurboAssembler : public Assembler {
// a multiple of 16, so that we can remove jssp. // a multiple of 16, so that we can remove jssp.
inline void DropSlots(int64_t count, uint64_t unit_size = kXRegSize); inline void DropSlots(int64_t count, uint64_t unit_size = kXRegSize);
// Push a single argument to the stack.
// TODO(arm64): Update this to push a padding slot above the argument.
inline void PushArgument(const Register& arg);
// Re-synchronizes the system stack pointer (csp) with the current stack // Re-synchronizes the system stack pointer (csp) with the current stack
// pointer (according to StackPointer()). // pointer (according to StackPointer()).
// //
......
...@@ -169,13 +169,14 @@ static void GenerateTailCallToReturnedCode(MacroAssembler* masm, ...@@ -169,13 +169,14 @@ static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
// Push a copy of the target function and the new target. // Push a copy of the target function and the new target.
// Push another copy as a parameter to the runtime call. // Push another copy as a parameter to the runtime call.
__ SmiTag(x0); __ SmiTag(x0);
__ Push(x0, x1, x3, x1); __ Push(x0, x1, x3, padreg);
__ PushArgument(x1);
__ CallRuntime(function_id, 1); __ CallRuntime(function_id, 1);
__ Move(x2, x0); __ Move(x2, x0);
// Restore target function and new target. // Restore target function and new target.
__ Pop(x3, x1, x0); __ Pop(padreg, x3, x1, x0);
__ SmiUntag(x0); __ SmiUntag(x0);
} }
...@@ -244,8 +245,8 @@ void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) { ...@@ -244,8 +245,8 @@ void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) {
} }
// Remove caller arguments from the stack and return. // Remove caller arguments from the stack and return.
__ DropBySMI(x1); __ SmiUntag(x1);
__ Drop(1); __ DropArguments(x1, TurboAssembler::kCountExcludesReceiver);
__ Ret(); __ Ret();
} }
...@@ -414,8 +415,8 @@ void Generate_JSConstructStubGeneric(MacroAssembler* masm, ...@@ -414,8 +415,8 @@ void Generate_JSConstructStubGeneric(MacroAssembler* masm,
// Leave construct frame. // Leave construct frame.
} }
// Remove caller arguments from the stack and return. // Remove caller arguments from the stack and return.
__ DropBySMI(x1); __ SmiUntag(x1);
__ Drop(1); __ DropArguments(x1, TurboAssembler::kCountExcludesReceiver);
__ Ret(); __ Ret();
} }
} // namespace } // namespace
...@@ -437,7 +438,7 @@ void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { ...@@ -437,7 +438,7 @@ void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) {
void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
__ Push(x1); __ PushArgument(x1);
__ CallRuntime(Runtime::kThrowConstructedNonConstructable); __ CallRuntime(Runtime::kThrowConstructedNonConstructable);
} }
...@@ -530,7 +531,8 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ...@@ -530,7 +531,8 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
__ Bind(&prepare_step_in_if_stepping); __ Bind(&prepare_step_in_if_stepping);
{ {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
__ Push(x1, x2, x4); __ Push(x1, x2);
__ PushArgument(x4);
__ CallRuntime(Runtime::kDebugOnFunctionCall); __ CallRuntime(Runtime::kDebugOnFunctionCall);
__ Pop(x2, x1); __ Pop(x2, x1);
__ Ldr(x4, FieldMemOperand(x1, JSGeneratorObject::kFunctionOffset)); __ Ldr(x4, FieldMemOperand(x1, JSGeneratorObject::kFunctionOffset));
...@@ -688,19 +690,24 @@ static void ReplaceClosureCodeWithOptimizedCode( ...@@ -688,19 +690,24 @@ static void ReplaceClosureCodeWithOptimizedCode(
} }
static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) {
Register args_count = scratch; Register args_size = scratch;
// Get the arguments + receiver count. // Get the arguments + receiver count.
__ ldr(args_count, __ Ldr(args_size,
MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp));
__ Ldr(args_count.W(), __ Ldr(args_size.W(),
FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); FieldMemOperand(args_size, BytecodeArray::kParameterSizeOffset));
// Leave the frame (also dropping the register file). // Leave the frame (also dropping the register file).
__ LeaveFrame(StackFrame::INTERPRETED); __ LeaveFrame(StackFrame::INTERPRETED);
// Drop receiver + arguments. // Drop receiver + arguments.
__ Drop(args_count, 1); if (__ emit_debug_code()) {
__ Tst(args_size, kPointerSize - 1);
__ Check(eq, kUnexpectedValue);
}
__ Lsr(args_size, args_size, kPointerSizeLog2);
__ DropArguments(args_size);
} }
// Tail-call |function_id| if |smi_entry| == |marker| // Tail-call |function_id| if |smi_entry| == |marker|
...@@ -1484,8 +1491,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { ...@@ -1484,8 +1491,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
scope.GenerateLeaveFrame(); scope.GenerateLeaveFrame();
// Drop arguments and receiver. // Drop arguments and receiver.
__ Add(x4, x4, 1); __ DropArguments(x4, TurboAssembler::kCountExcludesReceiver);
__ DropArguments(x4);
__ Ret(); __ Ret();
__ Bind(&failed); __ Bind(&failed);
...@@ -1601,7 +1607,7 @@ static void Generate_OnStackReplacementHelper(MacroAssembler* masm, ...@@ -1601,7 +1607,7 @@ static void Generate_OnStackReplacementHelper(MacroAssembler* masm,
{ {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
// Pass function as argument. // Pass function as argument.
__ Push(x0); __ PushArgument(x0);
__ CallRuntime(Runtime::kCompileForOnStackReplacement); __ CallRuntime(Runtime::kCompileForOnStackReplacement);
} }
...@@ -1911,11 +1917,8 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { ...@@ -1911,11 +1917,8 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
__ Pop(fp, lr); __ Pop(fp, lr);
// Drop actual parameters and receiver. // Drop actual parameters and receiver.
// TODO(all): This will need to be rounded up to a multiple of two when using __ SmiUntag(x10);
// the CSP, as we will have claimed an even number of slots in total for the __ DropArguments(x10, TurboAssembler::kCountExcludesReceiver);
// parameters.
__ DropBySMI(x10, kXRegSize);
__ Drop(1);
} }
// static // static
...@@ -2002,7 +2005,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, ...@@ -2002,7 +2005,7 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
{ {
FrameScope scope(masm, StackFrame::MANUAL); FrameScope scope(masm, StackFrame::MANUAL);
__ EnterFrame(StackFrame::INTERNAL); __ EnterFrame(StackFrame::INTERNAL);
__ Push(x3); __ PushArgument(x3);
__ CallRuntime(Runtime::kThrowNotConstructor); __ CallRuntime(Runtime::kThrowNotConstructor);
} }
__ Bind(&new_target_constructor); __ Bind(&new_target_constructor);
...@@ -2156,7 +2159,7 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm, ...@@ -2156,7 +2159,7 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm,
__ Bind(&class_constructor); __ Bind(&class_constructor);
{ {
FrameScope frame(masm, StackFrame::INTERNAL); FrameScope frame(masm, StackFrame::INTERNAL);
__ Push(padreg, x1); __ PushArgument(x1);
__ CallRuntime(Runtime::kThrowConstructorNonCallableError); __ CallRuntime(Runtime::kThrowConstructorNonCallableError);
} }
} }
...@@ -2291,7 +2294,7 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ...@@ -2291,7 +2294,7 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) {
__ bind(&non_callable); __ bind(&non_callable);
{ {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
__ Push(x1); __ PushArgument(x1);
__ CallRuntime(Runtime::kThrowCalledNonCallable); __ CallRuntime(Runtime::kThrowCalledNonCallable);
} }
} }
...@@ -2404,7 +2407,7 @@ void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) { ...@@ -2404,7 +2407,7 @@ void Builtins::Generate_AllocateInNewSpace(MacroAssembler* masm) {
// -- lr : return address // -- lr : return address
// ----------------------------------- // -----------------------------------
__ SmiTag(x1); __ SmiTag(x1);
__ Push(x1); __ PushArgument(x1);
__ Move(cp, Smi::kZero); __ Move(cp, Smi::kZero);
__ TailCallRuntime(Runtime::kAllocateInNewSpace); __ TailCallRuntime(Runtime::kAllocateInNewSpace);
} }
...@@ -2431,7 +2434,7 @@ void Builtins::Generate_Abort(MacroAssembler* masm) { ...@@ -2431,7 +2434,7 @@ void Builtins::Generate_Abort(MacroAssembler* masm) {
// -- lr : return address // -- lr : return address
// ----------------------------------- // -----------------------------------
MacroAssembler::NoUseRealAbortsScope no_use_real_aborts(masm); MacroAssembler::NoUseRealAbortsScope no_use_real_aborts(masm);
__ Push(x1); __ PushArgument(x1);
__ Move(cp, Smi::kZero); __ Move(cp, Smi::kZero);
__ TailCallRuntime(Runtime::kAbort); __ TailCallRuntime(Runtime::kAbort);
} }
...@@ -2444,7 +2447,7 @@ void Builtins::Generate_AbortJS(MacroAssembler* masm) { ...@@ -2444,7 +2447,7 @@ void Builtins::Generate_AbortJS(MacroAssembler* masm) {
// -- lr : return address // -- lr : return address
// ----------------------------------- // -----------------------------------
MacroAssembler::NoUseRealAbortsScope no_use_real_aborts(masm); MacroAssembler::NoUseRealAbortsScope no_use_real_aborts(masm);
__ Push(x1); __ PushArgument(x1);
__ Move(cp, Smi::kZero); __ Move(cp, Smi::kZero);
__ TailCallRuntime(Runtime::kAbortJS); __ TailCallRuntime(Runtime::kAbortJS);
} }
......
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