Commit 153f6705 authored by Martyn Capewell's avatar Martyn Capewell Committed by Commit Bot

[arm64] Remove SetStackPointer

Remove SetStackPointer function and update assembler tests.

Bug: v8:6644
Change-Id: I5ea26e57b848d56433c84d8eea22d7e9b761e6bb
Reviewed-on: https://chromium-review.googlesource.com/864147Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Martyn Capewell <martyn.capewell@arm.com>
Cr-Commit-Position: refs/heads/master@{#50571}
parent e3ae8a31
...@@ -421,10 +421,6 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -421,10 +421,6 @@ void CEntryStub::Generate(MacroAssembler* masm) {
__ AssertFPCRState(); __ AssertFPCRState();
__ Ret(); __ Ret();
// The stack pointer is still csp if we aren't returning, and the frame
// hasn't changed (except for the return address).
__ SetStackPointer(csp);
// Handling of exception. // Handling of exception.
__ Bind(&exception_returned); __ Bind(&exception_returned);
...@@ -495,14 +491,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -495,14 +491,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
Label invoke, handler_entry, exit; Label invoke, handler_entry, exit;
// Push callee-saved registers and synchronize the system stack pointer (csp)
// and the JavaScript stack pointer (jssp).
//
// We must not write to jssp until after the PushCalleeSavedRegisters()
// call, since jssp is itself a callee-saved register.
__ SetStackPointer(csp);
__ PushCalleeSavedRegisters(); __ PushCalleeSavedRegisters();
__ Mov(jssp, csp);
ProfileEntryHookStub::MaybeCallEntryHook(masm); ProfileEntryHookStub::MaybeCallEntryHook(masm);
...@@ -655,10 +644,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -655,10 +644,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
"Size of entry frame is not a multiple of 16 bytes"); "Size of entry frame is not a multiple of 16 bytes");
__ Drop(EntryFrameConstants::kFixedFrameSize / kPointerSize); __ Drop(EntryFrameConstants::kFixedFrameSize / kPointerSize);
// Restore the callee-saved registers and return. // Restore the callee-saved registers and return.
__ SetStackPointer(csp);
__ PopCalleeSavedRegisters(); __ PopCalleeSavedRegisters();
// After this point, we must not modify jssp because it is a callee-saved
// register which we have just restored.
__ Ret(); __ Ret();
} }
...@@ -742,14 +728,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { ...@@ -742,14 +728,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
void DirectCEntryStub::Generate(MacroAssembler* masm) { void DirectCEntryStub::Generate(MacroAssembler* masm) {
// When calling into C++ code the stack pointer must be csp.
// Therefore this code must use csp for peek/poke operations when the
// stub is generated. When the stub is called
// (via DirectCEntryStub::GenerateCall), the caller must setup an ExitFrame
// and configure the stack pointer *before* doing the call.
const Register old_stack_pointer = __ StackPointer();
__ SetStackPointer(csp);
// Put return address on the stack (accessible to GC through exit frame pc). // Put return address on the stack (accessible to GC through exit frame pc).
__ Poke(lr, 0); __ Poke(lr, 0);
// Call the C++ function. // Call the C++ function.
...@@ -758,8 +736,6 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) { ...@@ -758,8 +736,6 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) {
__ Peek(lr, 0); __ Peek(lr, 0);
__ AssertFPCRState(); __ AssertFPCRState();
__ Ret(); __ Ret();
__ SetStackPointer(old_stack_pointer);
} }
void DirectCEntryStub::GenerateCall(MacroAssembler* masm, void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
......
...@@ -1048,7 +1048,6 @@ void MacroAssembler::AlignAndSetCSPForFrame() { ...@@ -1048,7 +1048,6 @@ void MacroAssembler::AlignAndSetCSPForFrame() {
DCHECK_GE(sp_alignment, 16); DCHECK_GE(sp_alignment, 16);
DCHECK(base::bits::IsPowerOfTwo(sp_alignment)); DCHECK(base::bits::IsPowerOfTwo(sp_alignment));
Bic(csp, StackPointer(), sp_alignment - 1); Bic(csp, StackPointer(), sp_alignment - 1);
SetStackPointer(csp);
} }
void TurboAssembler::BumpSystemStackPointer(const Operand& space) { void TurboAssembler::BumpSystemStackPointer(const Operand& space) {
......
...@@ -1854,33 +1854,6 @@ void TurboAssembler::CallCFunction(Register function, int num_of_reg_args, ...@@ -1854,33 +1854,6 @@ void TurboAssembler::CallCFunction(Register function, int num_of_reg_args,
DCHECK_LE(num_of_double_args + num_of_reg_args, 2); DCHECK_LE(num_of_double_args + num_of_reg_args, 2);
} }
// We rely on the frame alignment being 16 bytes, which means we never need
// to align the CSP by an unknown number of bytes and we always know the delta
// between the stack pointer and the frame pointer.
DCHECK_EQ(ActivationFrameAlignment(), 16);
// If the stack pointer is not csp, we need to derive an aligned csp from the
// current stack pointer.
const Register old_stack_pointer = StackPointer();
if (!csp.Is(old_stack_pointer)) {
AssertStackConsistency();
int sp_alignment = ActivationFrameAlignment();
// The current stack pointer is a callee saved register, and is preserved
// across the call.
DCHECK(kCalleeSaved.IncludesAliasOf(old_stack_pointer));
// If more than eight arguments are passed to the function, we expect the
// ninth argument onwards to have been placed on the csp-based stack
// already. We assume csp already points to the last stack-passed argument
// in that case.
// Otherwise, align and synchronize the system stack pointer with jssp.
if (num_of_reg_args <= kRegisterPassedArguments) {
Bic(csp, old_stack_pointer, sp_alignment - 1);
}
SetStackPointer(csp);
}
// Call directly. The function called cannot cause a GC, or allow preemption, // Call directly. The function called cannot cause a GC, or allow preemption,
// so the return address in the link register stays correct. // so the return address in the link register stays correct.
Call(function); Call(function);
...@@ -1890,16 +1863,6 @@ void TurboAssembler::CallCFunction(Register function, int num_of_reg_args, ...@@ -1890,16 +1863,6 @@ void TurboAssembler::CallCFunction(Register function, int num_of_reg_args,
int claim_slots = RoundUp(num_of_reg_args - kRegisterPassedArguments, 2); int claim_slots = RoundUp(num_of_reg_args - kRegisterPassedArguments, 2);
Drop(claim_slots); Drop(claim_slots);
} }
if (jssp.Is(old_stack_pointer)) {
if (emit_debug_code()) {
UseScratchRegisterScope temps(this);
Register temp = temps.AcquireX();
Mov(temp, csp);
Cmp(old_stack_pointer, temp);
Check(eq, AbortReason::kTheStackWasCorruptedByMacroAssemblerCall);
}
SetStackPointer(old_stack_pointer);
}
} }
void TurboAssembler::Jump(Register target) { Br(target); } void TurboAssembler::Jump(Register target) { Br(target); }
...@@ -2423,16 +2386,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result, ...@@ -2423,16 +2386,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result,
// contain our truncated int32 result. // contain our truncated int32 result.
TryConvertDoubleToInt64(result, double_input, &done); TryConvertDoubleToInt64(result, double_input, &done);
const Register old_stack_pointer = StackPointer();
if (csp.Is(old_stack_pointer)) {
// This currently only happens during compiler-unittest. If it arises
// during regular code generation the DoubleToI stub should be updated to
// cope with csp and have an extra parameter indicating which stack pointer
// it should use.
Push(jssp, xzr); // Push xzr to maintain csp required 16-bytes alignment.
Mov(jssp, csp);
}
// If we fell through then inline version didn't succeed - call stub instead. // If we fell through then inline version didn't succeed - call stub instead.
Push(lr, double_input); Push(lr, double_input);
...@@ -2443,13 +2396,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result, ...@@ -2443,13 +2396,6 @@ void TurboAssembler::TruncateDoubleToIDelayed(Zone* zone, Register result,
DCHECK_EQ(xzr.SizeInBytes(), double_input.SizeInBytes()); DCHECK_EQ(xzr.SizeInBytes(), double_input.SizeInBytes());
Pop(xzr, lr); // xzr to drop the double input on the stack. Pop(xzr, lr); // xzr to drop the double input on the stack.
if (csp.Is(old_stack_pointer)) {
Mov(csp, jssp);
SetStackPointer(csp);
AssertStackConsistency();
Pop(xzr, jssp);
}
Bind(&done); Bind(&done);
// Keep our invariant that the upper 32 bits are zero. // Keep our invariant that the upper 32 bits are zero.
Uxtw(result.W(), result.W()); Uxtw(result.W(), result.W());
...@@ -3055,12 +3001,6 @@ void TurboAssembler::Abort(AbortReason reason) { ...@@ -3055,12 +3001,6 @@ void TurboAssembler::Abort(AbortReason reason) {
} }
#endif #endif
// Abort is used in some contexts where csp is the stack pointer. In order to
// simplify the CallRuntime code, make sure that jssp is the stack pointer.
// There is no risk of register corruption here because Abort doesn't return.
Register old_stack_pointer = StackPointer();
Mov(jssp, old_stack_pointer);
// We need some scratch registers for the MacroAssembler, so make sure we have // We need some scratch registers for the MacroAssembler, so make sure we have
// some. This is safe here because Abort never returns. // some. This is safe here because Abort never returns.
RegList old_tmp_list = TmpList()->list(); RegList old_tmp_list = TmpList()->list();
...@@ -3100,7 +3040,6 @@ void TurboAssembler::Abort(AbortReason reason) { ...@@ -3100,7 +3040,6 @@ void TurboAssembler::Abort(AbortReason reason) {
} }
} }
SetStackPointer(old_stack_pointer);
TmpList()->set_list(old_tmp_list); TmpList()->set_list(old_tmp_list);
} }
......
...@@ -216,12 +216,6 @@ class TurboAssembler : public Assembler { ...@@ -216,12 +216,6 @@ class TurboAssembler : public Assembler {
bool allow_macro_instructions() const { return allow_macro_instructions_; } bool allow_macro_instructions() const { return allow_macro_instructions_; }
#endif #endif
// Set the current stack pointer, but don't generate any code.
inline void SetStackPointer(const Register& stack_pointer) {
DCHECK(!TmpList()->IncludesAliasOf(stack_pointer));
sp_ = stack_pointer;
}
// Activation support. // Activation support.
void EnterFrame(StackFrame::Type type); void EnterFrame(StackFrame::Type type);
void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) { void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) {
...@@ -767,8 +761,7 @@ class TurboAssembler : public Assembler { ...@@ -767,8 +761,7 @@ class TurboAssembler : public Assembler {
LS_MACRO_LIST(DECLARE_FUNCTION) LS_MACRO_LIST(DECLARE_FUNCTION)
#undef DECLARE_FUNCTION #undef DECLARE_FUNCTION
// Push or pop up to 4 registers of the same width to or from the stack, // Push or pop up to 4 registers of the same width to or from the stack.
// using the current stack pointer as set by SetStackPointer.
// //
// If an argument register is 'NoReg', all further arguments are also assumed // If an argument register is 'NoReg', all further arguments are also assumed
// to be 'NoReg', and are thus not pushed or popped. // to be 'NoReg', and are thus not pushed or popped.
...@@ -782,9 +775,8 @@ class TurboAssembler : public Assembler { ...@@ -782,9 +775,8 @@ class TurboAssembler : public Assembler {
// It is not valid to pop into the same register more than once in one // It is not valid to pop into the same register more than once in one
// operation, not even into the zero register. // operation, not even into the zero register.
// //
// If the current stack pointer (as set by SetStackPointer) is csp, then it // The stack pointer must be aligned to 16 bytes on entry and the total size
// must be aligned to 16 bytes on entry and the total size of the specified // of the specified registers must also be a multiple of 16 bytes.
// registers must also be a multiple of 16 bytes.
// //
// Even if the current stack pointer is not the system stack pointer (csp), // Even if the current stack pointer is not the system stack pointer (csp),
// Push (and derived methods) will still modify the system stack pointer in // Push (and derived methods) will still modify the system stack pointer in
...@@ -1705,10 +1697,6 @@ class MacroAssembler : public TurboAssembler { ...@@ -1705,10 +1697,6 @@ class MacroAssembler : public TurboAssembler {
// //
// Note that registers are not checked for invalid values. Use this method // Note that registers are not checked for invalid values. Use this method
// only if you know that the GC won't try to examine the values on the stack. // only if you know that the GC won't try to examine the values on the stack.
//
// This method must not be called unless the current stack pointer (as set by
// SetStackPointer) is the system stack pointer (csp), and is aligned to
// ActivationFrameAlignment().
void PushCalleeSavedRegisters(); void PushCalleeSavedRegisters();
// Restore the callee-saved registers (as defined by AAPCS64). // Restore the callee-saved registers (as defined by AAPCS64).
...@@ -1717,10 +1705,6 @@ class MacroAssembler : public TurboAssembler { ...@@ -1717,10 +1705,6 @@ class MacroAssembler : public TurboAssembler {
// thus come from higher addresses. // thus come from higher addresses.
// Floating-point registers are popped after general-purpose registers, and // Floating-point registers are popped after general-purpose registers, and
// thus come from higher addresses. // thus come from higher addresses.
//
// This method must not be called unless the current stack pointer (as set by
// SetStackPointer) is the system stack pointer (csp), and is aligned to
// ActivationFrameAlignment().
void PopCalleeSavedRegisters(); void PopCalleeSavedRegisters();
// Align csp for a frame, as per ActivationFrameAlignment, and make it the // Align csp for a frame, as per ActivationFrameAlignment, and make it the
......
...@@ -2254,8 +2254,6 @@ void CodeGenerator::FinishFrame(Frame* frame) { ...@@ -2254,8 +2254,6 @@ void CodeGenerator::FinishFrame(Frame* frame) {
frame->AlignFrame(16); frame->AlignFrame(16);
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
__ SetStackPointer(csp);
// Save FP registers. // Save FP registers.
CPURegList saves_fp = CPURegList(CPURegister::kVRegister, kDRegSizeInBits, CPURegList saves_fp = CPURegList(CPURegister::kVRegister, kDRegSizeInBits,
descriptor->CalleeSavedFPRegisters()); descriptor->CalleeSavedFPRegisters());
...@@ -2353,7 +2351,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2353,7 +2351,6 @@ void CodeGenerator::AssembleConstructFrame() {
if (FLAG_debug_code) { if (FLAG_debug_code) {
__ Brk(0); __ Brk(0);
} }
__ SetStackPointer(csp);
__ AssertStackConsistency(); __ AssertStackConsistency();
__ Bind(&done); __ Bind(&done);
} }
......
...@@ -115,7 +115,6 @@ RegExpMacroAssemblerARM64::RegExpMacroAssemblerARM64(Isolate* isolate, ...@@ -115,7 +115,6 @@ RegExpMacroAssemblerARM64::RegExpMacroAssemblerARM64(Isolate* isolate,
success_label_(), success_label_(),
backtrack_label_(), backtrack_label_(),
exit_label_() { exit_label_() {
__ SetStackPointer(csp);
DCHECK_EQ(0, registers_to_save % 2); DCHECK_EQ(0, registers_to_save % 2);
// We can cache at most 16 W registers in x0-x7. // We can cache at most 16 W registers in x0-x7.
STATIC_ASSERT(kNumCachedRegisters <= 16); STATIC_ASSERT(kNumCachedRegisters <= 16);
......
This diff is collapsed.
...@@ -57,10 +57,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, ...@@ -57,10 +57,7 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
byte* start = stub.GetCode()->instruction_start(); byte* start = stub.GetCode()->instruction_start();
__ SetStackPointer(csp);
__ PushCalleeSavedRegisters(); __ PushCalleeSavedRegisters();
__ Mov(jssp, csp);
__ SetStackPointer(jssp);
MacroAssembler::PushPopQueue queue(&masm); MacroAssembler::PushPopQueue queue(&masm);
...@@ -111,8 +108,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, ...@@ -111,8 +108,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
__ Mov(x0, destination_reg); __ Mov(x0, destination_reg);
// Restore callee save registers. // Restore callee save registers.
__ Mov(csp, jssp);
__ SetStackPointer(csp);
__ PopCalleeSavedRegisters(); __ PopCalleeSavedRegisters();
__ Ret(); __ Ret();
......
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