Commit abe3bcdc authored by Martyn Capewell's avatar Martyn Capewell Committed by Commit Bot

[arm64] Rename csp to sp

Rename csp to sp and remove support for the stack pointer abstraction and
switching stack pointers.

Bug: v8:6644
Change-Id: I616633aabc1cee9926249fe95ce6c37ed6544fe3
Reviewed-on: https://chromium-review.googlesource.com/870870Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Martyn Capewell <martyn.capewell@arm.com>
Cr-Commit-Position: refs/heads/master@{#50687}
parent f47c824b
...@@ -95,7 +95,7 @@ inline void CPURegList::Remove(int code) { ...@@ -95,7 +95,7 @@ inline void CPURegList::Remove(int code) {
inline Register Register::XRegFromCode(unsigned code) { inline Register Register::XRegFromCode(unsigned code) {
if (code == kSPRegInternalCode) { if (code == kSPRegInternalCode) {
return csp; return sp;
} else { } else {
DCHECK_LT(code, static_cast<unsigned>(kNumberOfRegisters)); DCHECK_LT(code, static_cast<unsigned>(kNumberOfRegisters));
return Register::Create(code, kXRegSizeInBits); return Register::Create(code, kXRegSizeInBits);
...@@ -105,7 +105,7 @@ inline Register Register::XRegFromCode(unsigned code) { ...@@ -105,7 +105,7 @@ inline Register Register::XRegFromCode(unsigned code) {
inline Register Register::WRegFromCode(unsigned code) { inline Register Register::WRegFromCode(unsigned code) {
if (code == kSPRegInternalCode) { if (code == kSPRegInternalCode) {
return wcsp; return wsp;
} else { } else {
DCHECK_LT(code, static_cast<unsigned>(kNumberOfRegisters)); DCHECK_LT(code, static_cast<unsigned>(kNumberOfRegisters));
return Register::Create(code, kWRegSizeInBits); return Register::Create(code, kWRegSizeInBits);
......
...@@ -455,8 +455,8 @@ constexpr Register no_reg = NoReg; ...@@ -455,8 +455,8 @@ constexpr Register no_reg = NoReg;
GENERAL_REGISTER_CODE_LIST(DEFINE_REGISTERS) GENERAL_REGISTER_CODE_LIST(DEFINE_REGISTERS)
#undef DEFINE_REGISTERS #undef DEFINE_REGISTERS
DEFINE_REGISTER(Register, wcsp, kSPRegInternalCode, kWRegSizeInBits); DEFINE_REGISTER(Register, wsp, kSPRegInternalCode, kWRegSizeInBits);
DEFINE_REGISTER(Register, csp, kSPRegInternalCode, kXRegSizeInBits); DEFINE_REGISTER(Register, sp, kSPRegInternalCode, kXRegSizeInBits);
#define DEFINE_VREGISTERS(N) \ #define DEFINE_VREGISTERS(N) \
DEFINE_REGISTER(VRegister, b##N, N, kBRegSizeInBits); \ DEFINE_REGISTER(VRegister, b##N, N, kBRegSizeInBits); \
......
...@@ -30,7 +30,7 @@ namespace internal { ...@@ -30,7 +30,7 @@ namespace internal {
void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) { void ArrayNArgumentsConstructorStub::Generate(MacroAssembler* masm) {
__ Mov(x5, Operand(x0, LSL, kPointerSizeLog2)); __ Mov(x5, Operand(x0, LSL, kPointerSizeLog2));
__ Str(x1, MemOperand(__ StackPointer(), x5)); __ Poke(x1, Operand(x5));
__ Push(x1, x2); __ Push(x1, x2);
__ Add(x0, x0, Operand(3)); __ Add(x0, x0, Operand(3));
__ TailCallRuntime(Runtime::kNewArray); __ TailCallRuntime(Runtime::kNewArray);
...@@ -314,7 +314,6 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -314,7 +314,6 @@ void CEntryStub::Generate(MacroAssembler* masm) {
__ EnterExitFrame( __ EnterExitFrame(
save_doubles(), x10, extra_stack_space, save_doubles(), x10, extra_stack_space,
is_builtin_exit() ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT); is_builtin_exit() ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT);
DCHECK(csp.Is(__ StackPointer()));
// Poke callee-saved registers into reserved space. // Poke callee-saved registers into reserved space.
__ Poke(argv, 1 * kPointerSize); __ Poke(argv, 1 * kPointerSize);
...@@ -349,12 +348,12 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -349,12 +348,12 @@ void CEntryStub::Generate(MacroAssembler* masm) {
// fp -> fp[0]: CallerFP (old fp) // fp -> fp[0]: CallerFP (old fp)
// fp[-8]: Space reserved for SPOffset. // fp[-8]: Space reserved for SPOffset.
// fp[-16]: CodeObject() // fp[-16]: CodeObject()
// csp[...]: Saved doubles, if saved_doubles is true. // sp[...]: Saved doubles, if saved_doubles is true.
// csp[32]: Alignment padding, if necessary. // sp[32]: Alignment padding, if necessary.
// csp[24]: Preserved x23 (used for target). // sp[24]: Preserved x23 (used for target).
// csp[16]: Preserved x22 (used for argc). // sp[16]: Preserved x22 (used for argc).
// csp[8]: Preserved x21 (used for argv). // sp[8]: Preserved x21 (used for argv).
// csp -> csp[0]: Space reserved for the return address. // sp -> sp[0]: Space reserved for the return address.
// //
// After a successful call, the exit frame, preserved registers (x21-x23) and // After a successful call, the exit frame, preserved registers (x21-x23) and
// the arguments (including the receiver) are dropped or popped as // the arguments (including the receiver) are dropped or popped as
...@@ -364,8 +363,6 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -364,8 +363,6 @@ void CEntryStub::Generate(MacroAssembler* masm) {
// untouched, and the stub either throws an exception by jumping to one of // untouched, and the stub either throws an exception by jumping to one of
// the exception_returned label. // the exception_returned label.
DCHECK(csp.Is(__ StackPointer()));
// Prepare AAPCS64 arguments to pass to the builtin. // Prepare AAPCS64 arguments to pass to the builtin.
__ Mov(x0, argc); __ Mov(x0, argc);
__ Mov(x1, argv); __ Mov(x1, argv);
...@@ -437,7 +434,6 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -437,7 +434,6 @@ void CEntryStub::Generate(MacroAssembler* masm) {
// contain the current pending exception, don't clobber it. // contain the current pending exception, don't clobber it.
ExternalReference find_handler(Runtime::kUnwindAndFindExceptionHandler, ExternalReference find_handler(Runtime::kUnwindAndFindExceptionHandler,
isolate()); isolate());
DCHECK(csp.Is(masm->StackPointer()));
{ {
FrameScope scope(masm, StackFrame::MANUAL); FrameScope scope(masm, StackFrame::MANUAL);
__ Mov(x0, 0); // argc. __ Mov(x0, 0); // argc.
...@@ -454,7 +450,7 @@ void CEntryStub::Generate(MacroAssembler* masm) { ...@@ -454,7 +450,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Mov(scratch, Operand(pending_handler_sp_address)); __ Mov(scratch, Operand(pending_handler_sp_address));
__ Ldr(scratch, MemOperand(scratch)); __ Ldr(scratch, MemOperand(scratch));
__ Mov(csp, scratch); __ Mov(sp, scratch);
} }
__ Mov(fp, Operand(pending_handler_fp_address)); __ Mov(fp, Operand(pending_handler_fp_address));
__ Ldr(fp, MemOperand(fp)); __ Ldr(fp, MemOperand(fp));
...@@ -511,7 +507,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -511,7 +507,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ Push(x13, x12, xzr, x10); __ Push(x13, x12, xzr, x10);
// Set up fp. // Set up fp.
__ Sub(fp, __ StackPointer(), EntryFrameConstants::kCallerFPOffset); __ Sub(fp, sp, EntryFrameConstants::kCallerFPOffset);
// Push the JS entry frame marker. Also set js_entry_sp if this is the // Push the JS entry frame marker. Also set js_entry_sp if this is the
// outermost JS call. // outermost JS call.
...@@ -582,7 +578,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -582,7 +578,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
{ {
UseScratchRegisterScope temps(masm); UseScratchRegisterScope temps(masm);
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Mov(scratch, __ StackPointer()); __ Mov(scratch, sp);
__ Str(scratch, MemOperand(x11)); __ Str(scratch, MemOperand(x11));
} }
...@@ -740,10 +736,6 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) { ...@@ -740,10 +736,6 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) {
void DirectCEntryStub::GenerateCall(MacroAssembler* masm, void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
Register target) { Register target) {
// Make sure the caller configured the stack pointer (see comment in
// DirectCEntryStub::Generate).
DCHECK(csp.Is(__ StackPointer()));
intptr_t code = intptr_t code =
reinterpret_cast<intptr_t>(GetCode().location()); reinterpret_cast<intptr_t>(GetCode().location());
__ Mov(lr, Operand(code, RelocInfo::CODE_TARGET)); __ Mov(lr, Operand(code, RelocInfo::CODE_TARGET));
...@@ -1260,7 +1252,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) { ...@@ -1260,7 +1252,7 @@ void CallApiCallbackStub::Generate(MacroAssembler* masm) {
// Prepare arguments. // Prepare arguments.
Register args = x6; Register args = x6;
__ Mov(args, masm->StackPointer()); __ Mov(args, sp);
// Allocate the v8::Arguments structure in the arguments' space, since it's // Allocate the v8::Arguments structure in the arguments' space, since it's
// not controlled by GC. // not controlled by GC.
...@@ -1344,7 +1336,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) { ...@@ -1344,7 +1336,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
"slots must be a multiple of 2 for stack pointer alignment"); "slots must be a multiple of 2 for stack pointer alignment");
// Load address of v8::PropertyAccessorInfo::args_ array and name handle. // Load address of v8::PropertyAccessorInfo::args_ array and name handle.
__ Mov(x0, masm->StackPointer()); // x0 = Handle<Name> __ Mov(x0, sp); // x0 = Handle<Name>
__ Add(x1, x0, 1 * kPointerSize); // x1 = v8::PCI::args_ __ Add(x1, x0, 1 * kPointerSize); // x1 = v8::PCI::args_
const int kApiStackSpace = 1; const int kApiStackSpace = 1;
......
...@@ -33,7 +33,7 @@ void CopyRegListToFrame(MacroAssembler* masm, const Register& dst, ...@@ -33,7 +33,7 @@ void CopyRegListToFrame(MacroAssembler* masm, const Register& dst,
// up a temp with an offset for accesses out of the range of the addressing // up a temp with an offset for accesses out of the range of the addressing
// mode. // mode.
Register src = temps.AcquireX(); Register src = temps.AcquireX();
masm->Add(src, masm->StackPointer(), src_offset); masm->Add(src, sp, src_offset);
masm->Add(dst, dst, dst_offset); masm->Add(dst, dst, dst_offset);
// Write reg_list into the frame pointed to by dst. // Write reg_list into the frame pointed to by dst.
...@@ -140,8 +140,7 @@ void Deoptimizer::TableEntryGenerator::Generate() { ...@@ -140,8 +140,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ Mov(code_object, lr); __ Mov(code_object, lr);
// Compute the fp-to-sp delta, adding two words for alignment padding and // Compute the fp-to-sp delta, adding two words for alignment padding and
// bailout id. // bailout id.
__ Add(fp_to_sp, __ StackPointer(), __ Add(fp_to_sp, sp, kSavedRegistersAreaSize + (2 * kPointerSize));
kSavedRegistersAreaSize + (2 * kPointerSize));
__ Sub(fp_to_sp, fp, fp_to_sp); __ Sub(fp_to_sp, fp, fp_to_sp);
// Allocate a new deoptimizer object. // Allocate a new deoptimizer object.
...@@ -222,7 +221,7 @@ void Deoptimizer::TableEntryGenerator::Generate() { ...@@ -222,7 +221,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
UseScratchRegisterScope temps(masm()); UseScratchRegisterScope temps(masm());
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Ldr(scratch, MemOperand(x4, Deoptimizer::caller_frame_top_offset())); __ Ldr(scratch, MemOperand(x4, Deoptimizer::caller_frame_top_offset()));
__ Mov(__ StackPointer(), scratch); __ Mov(sp, scratch);
} }
// Replace the current (input) frame with the output frames. // Replace the current (input) frame with the output frames.
......
...@@ -3327,7 +3327,7 @@ void DisassemblingDecoder::AppendRegisterNameToOutput(const CPURegister& reg) { ...@@ -3327,7 +3327,7 @@ void DisassemblingDecoder::AppendRegisterNameToOutput(const CPURegister& reg) {
} }
} }
if (reg.IsVRegister() || !(reg.Aliases(csp) || reg.Aliases(xzr))) { if (reg.IsVRegister() || !(reg.Aliases(sp) || reg.Aliases(xzr))) {
// Filter special registers // Filter special registers
if (reg.IsX() && (reg.code() == 27)) { if (reg.IsX() && (reg.code() == 27)) {
AppendToOutput("cp"); AppendToOutput("cp");
...@@ -3339,9 +3339,9 @@ void DisassemblingDecoder::AppendRegisterNameToOutput(const CPURegister& reg) { ...@@ -3339,9 +3339,9 @@ void DisassemblingDecoder::AppendRegisterNameToOutput(const CPURegister& reg) {
// A core or scalar/vector register: [wx]0 - 30, [bhsdq]0 - 31. // A core or scalar/vector register: [wx]0 - 30, [bhsdq]0 - 31.
AppendToOutput("%c%d", reg_char, reg.code()); AppendToOutput("%c%d", reg_char, reg.code());
} }
} else if (reg.Aliases(csp)) { } else if (reg.Aliases(sp)) {
// Disassemble w31/x31 as stack pointer wcsp/csp. // Disassemble w31/x31 as stack pointer wsp/sp.
AppendToOutput("%s", reg.Is64Bits() ? "csp" : "wcsp"); AppendToOutput("%s", reg.Is64Bits() ? "sp" : "wsp");
} else { } else {
// Disassemble w31/x31 as zero register wzr/xzr. // Disassemble w31/x31 as zero register wzr/xzr.
AppendToOutput("%czr", reg_char); AppendToOutput("%czr", reg_char);
......
...@@ -11,7 +11,7 @@ namespace internal { ...@@ -11,7 +11,7 @@ namespace internal {
static const int kX0DwarfCode = 0; static const int kX0DwarfCode = 0;
static const int kFpDwarfCode = 29; static const int kFpDwarfCode = 29;
static const int kLrDwarfCode = 30; static const int kLrDwarfCode = 30;
static const int kCSpDwarfCode = 31; static const int kSpDwarfCode = 31;
const int EhFrameConstants::kCodeAlignmentFactor = 4; const int EhFrameConstants::kCodeAlignmentFactor = 4;
const int EhFrameConstants::kDataAlignmentFactor = -8; const int EhFrameConstants::kDataAlignmentFactor = -8;
...@@ -33,7 +33,7 @@ int EhFrameWriter::RegisterToDwarfCode(Register name) { ...@@ -33,7 +33,7 @@ int EhFrameWriter::RegisterToDwarfCode(Register name) {
case kRegCode_x30: case kRegCode_x30:
return kLrDwarfCode; return kLrDwarfCode;
case kSPRegInternalCode: case kSPRegInternalCode:
return kCSpDwarfCode; return kSpDwarfCode;
case kRegCode_x0: case kRegCode_x0:
return kX0DwarfCode; return kX0DwarfCode;
default: default:
...@@ -51,8 +51,8 @@ const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { ...@@ -51,8 +51,8 @@ const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) {
return "fp"; return "fp";
case kLrDwarfCode: case kLrDwarfCode:
return "lr"; return "lr";
case kCSpDwarfCode: case kSpDwarfCode:
return "csp"; // This could be zr as well return "sp"; // This could be zr as well
default: default:
UNIMPLEMENTED(); UNIMPLEMENTED();
return nullptr; return nullptr;
......
...@@ -258,7 +258,7 @@ class Instruction { ...@@ -258,7 +258,7 @@ class Instruction {
// Indicate whether Rd can be the stack pointer or the zero register. This // Indicate whether Rd can be the stack pointer or the zero register. This
// does not check that the instruction actually has an Rd field. // does not check that the instruction actually has an Rd field.
Reg31Mode RdMode() const { Reg31Mode RdMode() const {
// The following instructions use csp or wsp as Rd: // The following instructions use sp or wsp as Rd:
// Add/sub (immediate) when not setting the flags. // Add/sub (immediate) when not setting the flags.
// Add/sub (extended) when not setting the flags. // Add/sub (extended) when not setting the flags.
// Logical (immediate) when not setting the flags. // Logical (immediate) when not setting the flags.
...@@ -272,7 +272,7 @@ class Instruction { ...@@ -272,7 +272,7 @@ class Instruction {
} }
if (IsLogicalImmediate()) { if (IsLogicalImmediate()) {
// Of the logical (immediate) instructions, only ANDS (and its aliases) // Of the logical (immediate) instructions, only ANDS (and its aliases)
// can set the flags. The others can all write into csp. // can set the flags. The others can all write into sp.
// Note that some logical operations are not available to // Note that some logical operations are not available to
// immediate-operand instructions, so we have to combine two masks here. // immediate-operand instructions, so we have to combine two masks here.
if (Mask(LogicalImmediateMask & LogicalOpMask) == ANDS) { if (Mask(LogicalImmediateMask & LogicalOpMask) == ANDS) {
...@@ -287,7 +287,7 @@ class Instruction { ...@@ -287,7 +287,7 @@ class Instruction {
// Indicate whether Rn can be the stack pointer or the zero register. This // Indicate whether Rn can be the stack pointer or the zero register. This
// does not check that the instruction actually has an Rn field. // does not check that the instruction actually has an Rn field.
Reg31Mode RnMode() const { Reg31Mode RnMode() const {
// The following instructions use csp or wsp as Rn: // The following instructions use sp or wsp as Rn:
// All loads and stores. // All loads and stores.
// Add/sub (immediate). // Add/sub (immediate).
// Add/sub (extended). // Add/sub (extended).
......
...@@ -91,7 +91,6 @@ static const CounterDescriptor kCounterList[] = { ...@@ -91,7 +91,6 @@ static const CounterDescriptor kCounterList[] = {
{"PC Addressing", Gauge}, {"PC Addressing", Gauge},
{"Other", Gauge}, {"Other", Gauge},
{"SP Adjust", Gauge},
}; };
Instrument::Instrument(const char* datafile, uint64_t sample_period) Instrument::Instrument(const char* datafile, uint64_t sample_period)
...@@ -238,16 +237,8 @@ void Instrument::VisitPCRelAddressing(Instruction* instr) { ...@@ -238,16 +237,8 @@ void Instrument::VisitPCRelAddressing(Instruction* instr) {
void Instrument::VisitAddSubImmediate(Instruction* instr) { void Instrument::VisitAddSubImmediate(Instruction* instr) {
Update(); Update();
static Counter* sp_counter = GetCounter("SP Adjust"); static Counter* counter = GetCounter("Add/Sub DP");
static Counter* add_sub_counter = GetCounter("Add/Sub DP"); counter->Increment();
if (((instr->Mask(AddSubOpMask) == SUB) ||
(instr->Mask(AddSubOpMask) == ADD)) &&
(instr->Rd() == 31) && (instr->Rn() == 31)) {
// Count adjustments to the C stack pointer caused by V8 needing two SPs.
sp_counter->Increment();
} else {
add_sub_counter->Increment();
}
} }
...@@ -470,16 +461,8 @@ void Instrument::VisitAddSubShifted(Instruction* instr) { ...@@ -470,16 +461,8 @@ void Instrument::VisitAddSubShifted(Instruction* instr) {
void Instrument::VisitAddSubExtended(Instruction* instr) { void Instrument::VisitAddSubExtended(Instruction* instr) {
Update(); Update();
static Counter* sp_counter = GetCounter("SP Adjust"); static Counter* counter = GetCounter("Add/Sub DP");
static Counter* add_sub_counter = GetCounter("Add/Sub DP"); counter->Increment();
if (((instr->Mask(AddSubOpMask) == SUB) ||
(instr->Mask(AddSubOpMask) == ADD)) &&
(instr->Rd() == 31) && (instr->Rn() == 31)) {
// Count adjustments to the C stack pointer caused by V8 needing two SPs.
sp_counter->Increment();
} else {
add_sub_counter->Increment();
}
} }
......
...@@ -1042,58 +1042,6 @@ void TurboAssembler::Uxtw(const Register& rd, const Register& rn) { ...@@ -1042,58 +1042,6 @@ void TurboAssembler::Uxtw(const Register& rd, const Register& rn) {
uxtw(rd, rn); uxtw(rd, rn);
} }
void MacroAssembler::AlignAndSetCSPForFrame() {
int sp_alignment = ActivationFrameAlignment();
// AAPCS64 mandates at least 16-byte alignment.
DCHECK_GE(sp_alignment, 16);
DCHECK(base::bits::IsPowerOfTwo(sp_alignment));
Bic(csp, StackPointer(), sp_alignment - 1);
}
void TurboAssembler::BumpSystemStackPointer(const Operand& space) {
DCHECK(!csp.Is(StackPointer()));
if (!TmpList()->IsEmpty()) {
Sub(csp, StackPointer(), space);
} else {
// TODO(jbramley): Several callers rely on this not using scratch
// registers, so we use the assembler directly here. However, this means
// that large immediate values of 'space' cannot be handled cleanly. (Only
// 24-bits immediates or values of 'space' that can be encoded in one
// instruction are accepted.) Once we implement our flexible scratch
// register idea, we could greatly simplify this function.
InstructionAccurateScope scope(this);
DCHECK(space.IsImmediate());
// Align to 16 bytes.
uint64_t imm = RoundUp(space.ImmediateValue(), 0x10);
DCHECK(is_uint24(imm));
Register source = StackPointer();
if (CpuFeatures::IsSupported(ALWAYS_ALIGN_CSP)) {
bic(csp, source, 0xf);
source = csp;
}
if (!is_uint12(imm)) {
int64_t imm_top_12_bits = imm >> 12;
sub(csp, source, imm_top_12_bits << 12);
source = csp;
imm -= imm_top_12_bits << 12;
}
if (imm > 0) {
sub(csp, source, imm);
}
}
AssertStackConsistency();
}
void TurboAssembler::SyncSystemStackPointer() {
DCHECK(emit_debug_code());
DCHECK(!csp.Is(StackPointer()));
{ InstructionAccurateScope scope(this);
mov(csp, StackPointer());
}
AssertStackConsistency();
}
void TurboAssembler::InitializeRootRegister() { void TurboAssembler::InitializeRootRegister() {
ExternalReference roots_array_start = ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate()); ExternalReference::roots_array_start(isolate());
...@@ -1249,14 +1197,9 @@ void TurboAssembler::Claim(int64_t count, uint64_t unit_size) { ...@@ -1249,14 +1197,9 @@ void TurboAssembler::Claim(int64_t count, uint64_t unit_size) {
if (size == 0) { if (size == 0) {
return; return;
} }
DCHECK_EQ(size % 16, 0);
if (csp.Is(StackPointer())) { Sub(sp, sp, size);
DCHECK_EQ(size % 16, 0);
} else {
BumpSystemStackPointer(size);
}
Sub(StackPointer(), StackPointer(), size);
} }
void TurboAssembler::Claim(const Register& count, uint64_t unit_size) { void TurboAssembler::Claim(const Register& count, uint64_t unit_size) {
...@@ -1269,13 +1212,9 @@ void TurboAssembler::Claim(const Register& count, uint64_t unit_size) { ...@@ -1269,13 +1212,9 @@ void TurboAssembler::Claim(const Register& count, uint64_t unit_size) {
if (size.IsZero()) { if (size.IsZero()) {
return; return;
} }
AssertPositiveOrZero(count); AssertPositiveOrZero(count);
if (!csp.Is(StackPointer())) {
BumpSystemStackPointer(size);
}
Sub(StackPointer(), StackPointer(), size); Sub(sp, sp, size);
} }
...@@ -1290,11 +1229,7 @@ void MacroAssembler::ClaimBySMI(const Register& count_smi, uint64_t unit_size) { ...@@ -1290,11 +1229,7 @@ void MacroAssembler::ClaimBySMI(const Register& count_smi, uint64_t unit_size) {
return; return;
} }
if (!csp.Is(StackPointer())) { Sub(sp, sp, size);
BumpSystemStackPointer(size);
}
Sub(StackPointer(), StackPointer(), size);
} }
void TurboAssembler::Drop(int64_t count, uint64_t unit_size) { void TurboAssembler::Drop(int64_t count, uint64_t unit_size) {
...@@ -1305,16 +1240,8 @@ void TurboAssembler::Drop(int64_t count, uint64_t unit_size) { ...@@ -1305,16 +1240,8 @@ void TurboAssembler::Drop(int64_t count, uint64_t unit_size) {
return; return;
} }
Add(StackPointer(), StackPointer(), size); Add(sp, sp, size);
DCHECK_EQ(size % 16, 0);
if (csp.Is(StackPointer())) {
DCHECK_EQ(size % 16, 0);
} else if (emit_debug_code()) {
// It is safe to leave csp where it is when unwinding the JavaScript stack,
// but if we keep it matching StackPointer, the simulator can detect memory
// accesses in the now-free part of the stack.
SyncSystemStackPointer();
}
} }
void TurboAssembler::Drop(const Register& count, uint64_t unit_size) { void TurboAssembler::Drop(const Register& count, uint64_t unit_size) {
...@@ -1329,14 +1256,7 @@ void TurboAssembler::Drop(const Register& count, uint64_t unit_size) { ...@@ -1329,14 +1256,7 @@ void TurboAssembler::Drop(const Register& count, uint64_t unit_size) {
} }
AssertPositiveOrZero(count); AssertPositiveOrZero(count);
Add(StackPointer(), StackPointer(), size); Add(sp, sp, size);
if (!csp.Is(StackPointer()) && emit_debug_code()) {
// It is safe to leave csp where it is when unwinding the JavaScript stack,
// but if we keep it matching StackPointer, the simulator can detect memory
// accesses in the now-free part of the stack.
SyncSystemStackPointer();
}
} }
void TurboAssembler::DropArguments(const Register& count, void TurboAssembler::DropArguments(const Register& count,
...@@ -1378,14 +1298,7 @@ void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) { ...@@ -1378,14 +1298,7 @@ void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) {
return; return;
} }
Add(StackPointer(), StackPointer(), size); Add(sp, sp, size);
if (!csp.Is(StackPointer()) && emit_debug_code()) {
// It is safe to leave csp where it is when unwinding the JavaScript stack,
// but if we keep it matching StackPointer, the simulator can detect memory
// accesses in the now-free part of the stack.
SyncSystemStackPointer();
}
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -626,16 +626,15 @@ void Simulator::DoRuntimeCall(Instruction* instr) { ...@@ -626,16 +626,15 @@ void Simulator::DoRuntimeCall(Instruction* instr) {
} }
const char* Simulator::xreg_names[] = { const char* Simulator::xreg_names[] = {
"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10",
"x9", "x10", "x11", "x12", "x13", "x14", "x15", "ip0", "ip1", "x11", "x12", "x13", "x14", "x15", "ip0", "ip1", "x18", "x19", "x20", "x21",
"x18", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x22", "x23", "x24", "x25", "x26", "cp", "x28", "fp", "lr", "xzr", "sp"};
"cp", "x28", "fp", "lr", "xzr", "csp"};
const char* Simulator::wreg_names[] = { const char* Simulator::wreg_names[] = {
"w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8",
"w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17",
"w18", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w18", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26",
"wcp", "w28", "wfp", "wlr", "wzr", "wcsp"}; "wcp", "w28", "wfp", "wlr", "wzr", "wsp"};
const char* Simulator::sreg_names[] = { const char* Simulator::sreg_names[] = {
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
...@@ -768,7 +767,7 @@ int Simulator::CodeFromName(const char* name) { ...@@ -768,7 +767,7 @@ int Simulator::CodeFromName(const char* name) {
return i; return i;
} }
} }
if ((strcmp("csp", name) == 0) || (strcmp("wcsp", name) == 0)) { if ((strcmp("sp", name) == 0) || (strcmp("wsp", name) == 0)) {
return kSPRegInternalCode; return kSPRegInternalCode;
} }
return -1; return -1;
...@@ -2996,15 +2995,15 @@ bool Simulator::GetValue(const char* desc, int64_t* value) { ...@@ -2996,15 +2995,15 @@ bool Simulator::GetValue(const char* desc, int64_t* value) {
bool Simulator::PrintValue(const char* desc) { bool Simulator::PrintValue(const char* desc) {
if (strcmp(desc, "csp") == 0) { if (strcmp(desc, "sp") == 0) {
DCHECK(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); DCHECK(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode));
PrintF(stream_, "%s csp:%s 0x%016" PRIx64 "%s\n", PrintF(stream_, "%s sp:%s 0x%016" PRIx64 "%s\n", clr_reg_name,
clr_reg_name, clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal); clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal);
return true; return true;
} else if (strcmp(desc, "wcsp") == 0) { } else if (strcmp(desc, "wsp") == 0) {
DCHECK(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); DCHECK(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode));
PrintF(stream_, "%s wcsp:%s 0x%08" PRIx32 "%s\n", PrintF(stream_, "%s wsp:%s 0x%08" PRIx32 "%s\n", clr_reg_name,
clr_reg_name, clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal); clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal);
return true; return true;
} }
......
...@@ -552,7 +552,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ...@@ -552,7 +552,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
// Check the stack for overflow. We are not trying to catch interruptions // Check the stack for overflow. We are not trying to catch interruptions
// (i.e. debug break and preemption) here, so check the "real stack limit". // (i.e. debug break and preemption) here, so check the "real stack limit".
Label stack_overflow; Label stack_overflow;
__ CompareRoot(__ StackPointer(), Heap::kRealStackLimitRootIndex); __ CompareRoot(sp, Heap::kRealStackLimitRootIndex);
__ B(lo, &stack_overflow); __ B(lo, &stack_overflow);
// Get number of arguments for generator function. // Get number of arguments for generator function.
...@@ -663,7 +663,7 @@ static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, ...@@ -663,7 +663,7 @@ static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args,
__ LoadRoot(scratch, Heap::kRealStackLimitRootIndex); __ LoadRoot(scratch, Heap::kRealStackLimitRootIndex);
// Make scratch the space we have left. The stack might already be overflowed // Make scratch the space we have left. The stack might already be overflowed
// here which will cause scratch to become negative. // here which will cause scratch to become negative.
__ Sub(scratch, masm->StackPointer(), scratch); __ Sub(scratch, sp, scratch);
// Check if the arguments will overflow the stack. // Check if the arguments will overflow the stack.
__ Cmp(scratch, Operand(num_args, LSL, kPointerSizeLog2)); __ Cmp(scratch, Operand(num_args, LSL, kPointerSizeLog2));
__ B(le, stack_overflow); __ B(le, stack_overflow);
...@@ -745,7 +745,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -745,7 +745,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
// Poke the result into the stack. // Poke the result into the stack.
__ Str(x11, MemOperand(scratch, -kPointerSize, PreIndex)); __ Str(x11, MemOperand(scratch, -kPointerSize, PreIndex));
// Loop if we've not reached the end of copy marker. // Loop if we've not reached the end of copy marker.
__ Cmp(__ StackPointer(), scratch); __ Cmp(sp, scratch);
__ B(lt, &loop); __ B(lt, &loop);
__ Bind(&done); __ Bind(&done);
...@@ -1009,7 +1009,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1009,7 +1009,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// the frame (that is done below). // the frame (that is done below).
FrameScope frame_scope(masm, StackFrame::MANUAL); FrameScope frame_scope(masm, StackFrame::MANUAL);
__ Push(lr, fp, cp, closure); __ Push(lr, fp, cp, closure);
__ Add(fp, __ StackPointer(), StandardFrameConstants::kFixedFrameSizeFromFp); __ Add(fp, sp, StandardFrameConstants::kFixedFrameSizeFromFp);
// Get the bytecode array from the function object (or from the DebugInfo if // Get the bytecode array from the function object (or from the DebugInfo if
// it is present) and load it into kInterpreterBytecodeArrayRegister. // it is present) and load it into kInterpreterBytecodeArrayRegister.
...@@ -1060,7 +1060,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1060,7 +1060,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// Do a stack check to ensure we don't go over the limit. // Do a stack check to ensure we don't go over the limit.
Label ok; Label ok;
__ Sub(x10, __ StackPointer(), Operand(x11)); __ Sub(x10, sp, Operand(x11));
__ CompareRoot(x10, Heap::kRealStackLimitRootIndex); __ CompareRoot(x10, Heap::kRealStackLimitRootIndex);
__ B(hs, &ok); __ B(hs, &ok);
__ CallRuntime(Runtime::kThrowStackOverflow); __ CallRuntime(Runtime::kThrowStackOverflow);
...@@ -1613,7 +1613,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) { ...@@ -1613,7 +1613,7 @@ void Builtins::Generate_InstantiateAsmJs(MacroAssembler* masm) {
__ JumpIfSmi(x0, &failed); __ JumpIfSmi(x0, &failed);
// Peek the argument count from the stack, untagging at the same time. // Peek the argument count from the stack, untagging at the same time.
__ Ldr(w4, UntagSmiMemOperand(__ StackPointer(), 3 * kPointerSize)); __ Ldr(w4, UntagSmiMemOperand(sp, 3 * kPointerSize));
__ Drop(4); __ Drop(4);
scope.GenerateLeaveFrame(); scope.GenerateLeaveFrame();
...@@ -1646,7 +1646,7 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, ...@@ -1646,7 +1646,7 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm,
kPointerSize; kPointerSize;
// Set up frame pointer. // Set up frame pointer.
__ Add(fp, __ StackPointer(), frame_size); __ Add(fp, sp, frame_size);
if (with_result) { if (with_result) {
// Overwrite the hole inserted by the deoptimizer with the return value from // Overwrite the hole inserted by the deoptimizer with the return value from
...@@ -1682,7 +1682,7 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, ...@@ -1682,7 +1682,7 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm,
MemOperand(fp, BuiltinContinuationFrameConstants::kBuiltinOffset)); MemOperand(fp, BuiltinContinuationFrameConstants::kBuiltinOffset));
// Restore fp, lr. // Restore fp, lr.
__ Mov(__ StackPointer(), fp); __ Mov(sp, fp);
__ Pop(fp, lr); __ Pop(fp, lr);
// Call builtin. // Call builtin.
...@@ -2090,8 +2090,7 @@ void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { ...@@ -2090,8 +2090,7 @@ void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ Push(x11, x1); // x1: function __ Push(x11, x1); // x1: function
__ SmiTag(x11, x0); // x0: number of arguments. __ SmiTag(x11, x0); // x0: number of arguments.
__ Push(x11, padreg); __ Push(x11, padreg);
__ Add(fp, __ StackPointer(), __ Add(fp, sp, ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp);
ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp);
} }
void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
...@@ -2101,7 +2100,7 @@ void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { ...@@ -2101,7 +2100,7 @@ void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
// Get the number of arguments passed (as a smi), tear down the frame and // Get the number of arguments passed (as a smi), tear down the frame and
// then drop the parameters and the receiver. // then drop the parameters and the receiver.
__ Ldr(x10, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); __ Ldr(x10, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ Mov(__ StackPointer(), fp); __ Mov(sp, fp);
__ Pop(fp, lr); __ Pop(fp, lr);
// Drop actual parameters and receiver. // Drop actual parameters and receiver.
...@@ -2194,7 +2193,7 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, ...@@ -2194,7 +2193,7 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
__ LoadRoot(x10, Heap::kRealStackLimitRootIndex); __ LoadRoot(x10, Heap::kRealStackLimitRootIndex);
// Make x10 the space we have left. The stack might already be overflowed // Make x10 the space we have left. The stack might already be overflowed
// here which will cause x10 to become negative. // here which will cause x10 to become negative.
__ Sub(x10, masm->StackPointer(), x10); __ Sub(x10, sp, x10);
// Check if the arguments will overflow the stack. // Check if the arguments will overflow the stack.
__ Cmp(x10, Operand(len, LSL, kPointerSizeLog2)); __ Cmp(x10, Operand(len, LSL, kPointerSizeLog2));
__ B(gt, &done); // Signed comparison. __ B(gt, &done); // Signed comparison.
...@@ -2467,7 +2466,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) { ...@@ -2467,7 +2466,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
__ LoadRoot(x10, Heap::kRealStackLimitRootIndex); __ LoadRoot(x10, Heap::kRealStackLimitRootIndex);
// Make x10 the space we have left. The stack might already be overflowed // Make x10 the space we have left. The stack might already be overflowed
// here which will cause x10 to become negative. // here which will cause x10 to become negative.
__ Sub(x10, masm->StackPointer(), x10); __ Sub(x10, sp, x10);
// Check if the arguments will overflow the stack. // Check if the arguments will overflow the stack.
__ Cmp(x10, Operand(bound_argc, LSL, kPointerSizeLog2)); __ Cmp(x10, Operand(bound_argc, LSL, kPointerSizeLog2));
__ B(gt, &done); // Signed comparison. __ B(gt, &done); // Signed comparison.
...@@ -2539,8 +2538,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) { ...@@ -2539,8 +2538,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
Register scratch = x10; Register scratch = x10;
__ Tbz(bound_argc, 0, &done); __ Tbz(bound_argc, 0, &done);
// Store receiver. // Store receiver.
__ Add(scratch, __ StackPointer(), __ Add(scratch, sp, Operand(total_argc, LSL, kPointerSizeLog2));
Operand(total_argc, LSL, kPointerSizeLog2));
__ Str(receiver, MemOperand(scratch, kPointerSize, PostIndex)); __ Str(receiver, MemOperand(scratch, kPointerSize, PostIndex));
__ Tbnz(total_argc, 0, &done); __ Tbnz(total_argc, 0, &done);
// Store padding. // Store padding.
...@@ -2854,7 +2852,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2854,7 +2852,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ Bic(scratch1, scratch1, 1); __ Bic(scratch1, scratch1, 1);
__ Claim(scratch1, kPointerSize); __ Claim(scratch1, kPointerSize);
__ Mov(copy_to, __ StackPointer()); __ Mov(copy_to, sp);
// Preparing the expected arguments is done in four steps, the order of // Preparing the expected arguments is done in four steps, the order of
// which is chosen so we can use LDP/STP and avoid conditional branches as // which is chosen so we can use LDP/STP and avoid conditional branches as
...@@ -2918,8 +2916,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2918,8 +2916,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ RecordComment("-- Store receiver --"); __ RecordComment("-- Store receiver --");
__ Add(copy_from, fp, 2 * kPointerSize); __ Add(copy_from, fp, 2 * kPointerSize);
__ Ldr(scratch1, MemOperand(copy_from, argc_actual, LSL, kPointerSizeLog2)); __ Ldr(scratch1, MemOperand(copy_from, argc_actual, LSL, kPointerSizeLog2));
__ Str(scratch1, __ Str(scratch1, MemOperand(sp, argc_expected, LSL, kPointerSizeLog2));
MemOperand(__ StackPointer(), argc_expected, LSL, kPointerSizeLog2));
// Arguments have been adapted. Now call the entry point. // Arguments have been adapted. Now call the entry point.
__ RecordComment("-- Call entry point --"); __ RecordComment("-- Call entry point --");
......
...@@ -256,8 +256,7 @@ class Arm64OperandConverter final : public InstructionOperandConverter { ...@@ -256,8 +256,7 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
offset = FrameOffset::FromStackPointer(from_sp); offset = FrameOffset::FromStackPointer(from_sp);
} }
} }
return MemOperand(offset.from_stack_pointer() ? tasm->StackPointer() : fp, return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
offset.offset());
} }
}; };
...@@ -297,8 +296,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { ...@@ -297,8 +296,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
if (must_save_lr_) { if (must_save_lr_) {
// We need to save and restore lr if the frame was elided. // We need to save and restore lr if the frame was elided.
__ Push(lr, padreg); __ Push(lr, padreg);
unwinding_info_writer_->MarkLinkRegisterOnTopOfStack(__ pc_offset(), unwinding_info_writer_->MarkLinkRegisterOnTopOfStack(__ pc_offset(), sp);
__ StackPointer());
} }
__ CallRecordWriteStub(object_, scratch1_, remembered_set_action, __ CallRecordWriteStub(object_, scratch1_, remembered_set_action,
save_fp_mode); save_fp_mode);
...@@ -455,7 +453,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { ...@@ -455,7 +453,7 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
} while (0) } while (0)
void CodeGenerator::AssembleDeconstructFrame() { void CodeGenerator::AssembleDeconstructFrame() {
__ Mov(csp, fp); __ Mov(sp, fp);
__ Pop(fp, lr); __ Pop(fp, lr);
unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset()); unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset());
...@@ -799,7 +797,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -799,7 +797,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
AssembleReturn(instr->InputAt(0)); AssembleReturn(instr->InputAt(0));
break; break;
case kArchStackPointer: case kArchStackPointer:
__ mov(i.OutputRegister(), tasm()->StackPointer()); __ mov(i.OutputRegister(), sp);
break; break;
case kArchFramePointer: case kArchFramePointer:
__ mov(i.OutputRegister(), fp); __ mov(i.OutputRegister(), fp);
...@@ -844,7 +842,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -844,7 +842,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchStackSlot: { case kArchStackSlot: {
FrameOffset offset = FrameOffset offset =
frame_access_state()->GetFrameOffset(i.InputInt32(0)); frame_access_state()->GetFrameOffset(i.InputInt32(0));
Register base = offset.from_stack_pointer() ? __ StackPointer() : fp; Register base = offset.from_stack_pointer() ? sp : fp;
__ Add(i.OutputRegister(0), base, Operand(offset.offset())); __ Add(i.OutputRegister(0), base, Operand(offset.offset()));
break; break;
} }
...@@ -1195,7 +1193,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1195,7 +1193,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArm64Claim: { case kArm64Claim: {
int count = i.InputInt32(0); int count = i.InputInt32(0);
DCHECK_EQ(count % 2, 0); DCHECK_EQ(count % 2, 0);
__ AssertCspAligned(); __ AssertSpAligned();
if (count > 0) { if (count > 0) {
__ Claim(count); __ Claim(count);
frame_access_state()->IncreaseSPDelta(count); frame_access_state()->IncreaseSPDelta(count);
...@@ -2195,7 +2193,6 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr, ...@@ -2195,7 +2193,6 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
__ Drop(pop_count); __ Drop(pop_count);
__ Ret(); __ Ret();
} else { } else {
DCHECK(csp.Is(__ StackPointer()));
gen_->AssembleSourcePosition(instr_); gen_->AssembleSourcePosition(instr_);
__ Call(__ isolate()->builtins()->builtin_handle(trap_id), __ Call(__ isolate()->builtins()->builtin_handle(trap_id),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
...@@ -2291,7 +2288,7 @@ void CodeGenerator::FinishFrame(Frame* frame) { ...@@ -2291,7 +2288,7 @@ void CodeGenerator::FinishFrame(Frame* frame) {
void CodeGenerator::AssembleConstructFrame() { void CodeGenerator::AssembleConstructFrame() {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
__ AssertCspAligned(); __ AssertSpAligned();
// The frame has been previously padded in CodeGenerator::FinishFrame(). // The frame has been previously padded in CodeGenerator::FinishFrame().
DCHECK_EQ(frame()->GetTotalFrameSlotCount() % 2, 0); DCHECK_EQ(frame()->GetTotalFrameSlotCount() % 2, 0);
...@@ -2312,7 +2309,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2312,7 +2309,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ Prologue(); __ Prologue();
} else { } else {
__ Push(lr, fp); __ Push(lr, fp);
__ Mov(fp, __ StackPointer()); __ Mov(fp, sp);
} }
unwinding_info_writer_.MarkFrameConstructed(__ pc_offset()); unwinding_info_writer_.MarkFrameConstructed(__ pc_offset());
...@@ -2346,7 +2343,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2346,7 +2343,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ isolate()))); __ isolate())));
__ Ldr(scratch, MemOperand(scratch)); __ Ldr(scratch, MemOperand(scratch));
__ Add(scratch, scratch, shrink_slots * kPointerSize); __ Add(scratch, scratch, shrink_slots * kPointerSize);
__ Cmp(__ StackPointer(), scratch); __ Cmp(sp, scratch);
__ B(hs, &done); __ B(hs, &done);
} }
...@@ -2356,8 +2353,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2356,8 +2353,6 @@ void CodeGenerator::AssembleConstructFrame() {
// runtime call. // runtime call.
__ EnterFrame(StackFrame::WASM_COMPILED); __ EnterFrame(StackFrame::WASM_COMPILED);
} }
DCHECK(__ StackPointer().Is(csp));
__ AssertStackConsistency();
__ Mov(cp, Smi::kZero); __ Mov(cp, Smi::kZero);
__ CallRuntimeDelayed(zone(), Runtime::kThrowWasmStackOverflow); __ CallRuntimeDelayed(zone(), Runtime::kThrowWasmStackOverflow);
// We come from WebAssembly, there are no references for the GC. // We come from WebAssembly, there are no references for the GC.
...@@ -2367,7 +2362,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2367,7 +2362,6 @@ void CodeGenerator::AssembleConstructFrame() {
if (FLAG_debug_code) { if (FLAG_debug_code) {
__ Brk(0); __ Brk(0);
} }
__ AssertStackConsistency();
__ Bind(&done); __ Bind(&done);
} }
...@@ -2473,7 +2467,7 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) { ...@@ -2473,7 +2467,7 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
__ DropArguments(pop_reg); __ DropArguments(pop_reg);
} }
__ AssertCspAligned(); __ AssertSpAligned();
__ Ret(); __ Ret();
} }
......
...@@ -1692,7 +1692,7 @@ void InstructionSelector::EmitPrepareArguments( ...@@ -1692,7 +1692,7 @@ void InstructionSelector::EmitPrepareArguments(
// Bump the stack pointer(s). // Bump the stack pointer(s).
if (claim_count > 0) { if (claim_count > 0) {
// TODO(titzer): claim and poke probably take small immediates. // TODO(titzer): claim and poke probably take small immediates.
// TODO(titzer): it would be better to bump the csp here only // TODO(titzer): it would be better to bump the sp here only
// and emit paired stores with increment for non c frames. // and emit paired stores with increment for non c frames.
Emit(kArm64Claim, g.NoOutput(), g.TempImmediate(claim_count)); Emit(kArm64Claim, g.NoOutput(), g.TempImmediate(claim_count));
} }
......
...@@ -35,10 +35,9 @@ void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { ...@@ -35,10 +35,9 @@ void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) {
// - Leave the frame. // - Leave the frame.
// - Restart the frame by calling the function. // - Restart the frame by calling the function.
__ Mov(fp, x1); __ Mov(fp, x1);
__ AssertStackConsistency();
__ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ Mov(masm->StackPointer(), Operand(fp)); __ Mov(sp, fp);
__ Pop(fp, lr); // Frame, Return address. __ Pop(fp, lr); // Frame, Return address.
__ Ldr(x0, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); __ Ldr(x0, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
......
...@@ -41,7 +41,7 @@ namespace internal { ...@@ -41,7 +41,7 @@ namespace internal {
* - x29/fp : Frame pointer. Used to access arguments, local variables and * - x29/fp : Frame pointer. Used to access arguments, local variables and
* RegExp registers. * RegExp registers.
* - x16/x17 : IP registers, used by assembler. Very volatile. * - x16/x17 : IP registers, used by assembler. Very volatile.
* - csp : Points to tip of C stack. * - sp : Points to tip of C stack.
* *
* - x0-x7 : Used as a cache to store 32 bit capture registers. These * - x0-x7 : Used as a cache to store 32 bit capture registers. These
* registers need to be retained every time a call to C code * registers need to be retained every time a call to C code
...@@ -57,7 +57,7 @@ namespace internal { ...@@ -57,7 +57,7 @@ namespace internal {
* the code) * the code)
* *
* - fp[96] isolate Address of the current isolate. * - fp[96] isolate Address of the current isolate.
* ^^^ csp when called ^^^ * ^^^ sp when called ^^^
* - fp[88] lr Return from the RegExp code. * - fp[88] lr Return from the RegExp code.
* - fp[80] r29 Old frame pointer (CalleeSaved). * - fp[80] r29 Old frame pointer (CalleeSaved).
* - fp[0..72] r19-r28 Backup of CalleeSaved registers. * - fp[0..72] r19-r28 Backup of CalleeSaved registers.
...@@ -77,7 +77,7 @@ namespace internal { ...@@ -77,7 +77,7 @@ namespace internal {
* - ... num_saved_registers_ registers. * - ... num_saved_registers_ registers.
* - ... * - ...
* - register N + num_registers - 1 * - register N + num_registers - 1
* ^^^^^^^^^ csp ^^^^^^^^^ * ^^^^^^^^^ sp ^^^^^^^^^
* *
* The first num_saved_registers_ registers are initialized to point to * The first num_saved_registers_ registers are initialized to point to
* "character -1" in the string (i.e., char_size() bytes before the first * "character -1" in the string (i.e., char_size() bytes before the first
...@@ -704,9 +704,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -704,9 +704,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// x6: Address stack_base // x6: Address stack_base
// x7: int direct_call // x7: int direct_call
// The stack pointer should be csp on entry. // sp[8]: address of the current isolate
// csp[8]: address of the current isolate // sp[0]: secondary link/return address used by native call
// csp[0]: secondary link/return address used by native call
// Tell the system that we have a stack frame. Because the type is MANUAL, no // Tell the system that we have a stack frame. Because the type is MANUAL, no
// code is generated. // code is generated.
...@@ -719,12 +718,11 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -719,12 +718,11 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
DCHECK_EQ(11, kCalleeSaved.Count()); DCHECK_EQ(11, kCalleeSaved.Count());
registers_to_retain.Combine(lr); registers_to_retain.Combine(lr);
DCHECK(csp.Is(__ StackPointer()));
__ PushCPURegList(registers_to_retain); __ PushCPURegList(registers_to_retain);
__ PushCPURegList(argument_registers); __ PushCPURegList(argument_registers);
// Set frame pointer in place. // Set frame pointer in place.
__ Add(frame_pointer(), csp, argument_registers.Count() * kPointerSize); __ Add(frame_pointer(), sp, argument_registers.Count() * kPointerSize);
// Initialize callee-saved registers. // Initialize callee-saved registers.
__ Mov(start_offset(), w1); __ Mov(start_offset(), w1);
...@@ -755,7 +753,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -755,7 +753,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
ExternalReference::address_of_stack_limit(isolate()); ExternalReference::address_of_stack_limit(isolate());
__ Mov(x10, stack_limit); __ Mov(x10, stack_limit);
__ Ldr(x10, MemOperand(x10)); __ Ldr(x10, MemOperand(x10));
__ Subs(x10, csp, x10); __ Subs(x10, sp, x10);
// Handle it if the stack pointer is already below the stack limit. // Handle it if the stack pointer is already below the stack limit.
__ B(ls, &stack_limit_hit); __ B(ls, &stack_limit_hit);
...@@ -1015,9 +1013,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -1015,9 +1013,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ Bind(&return_w0); __ Bind(&return_w0);
// Set stack pointer back to first register to retain // Set stack pointer back to first register to retain
DCHECK(csp.Is(__ StackPointer())); __ Mov(sp, fp);
__ Mov(csp, fp);
__ AssertStackConsistency();
// Restore registers. // Restore registers.
__ PopCPURegList(registers_to_retain); __ PopCPURegList(registers_to_retain);
...@@ -1036,7 +1032,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -1036,7 +1032,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// The cached registers need to be retained. // The cached registers need to be retained.
__ PushCPURegList(cached_registers); __ PushCPURegList(cached_registers);
CallCheckStackGuardState(x10); CallCheckStackGuardState(x10);
// Returning from the regexp code restores the stack (csp <- fp) // Returning from the regexp code restores the stack (sp <- fp)
// so we don't need to drop the link register from it before exiting. // so we don't need to drop the link register from it before exiting.
__ Cbnz(w0, &return_w0); __ Cbnz(w0, &return_w0);
// Reset the cached registers. // Reset the cached registers.
...@@ -1059,7 +1055,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -1059,7 +1055,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ CallCFunction(grow_stack, 3); __ CallCFunction(grow_stack, 3);
// If return nullptr, we have failed to grow the stack, and // If return nullptr, we have failed to grow the stack, and
// must exit with a stack-overflow exception. // must exit with a stack-overflow exception.
// Returning from the regexp code restores the stack (csp <- fp) // Returning from the regexp code restores the stack (sp <- fp)
// so we don't need to drop the link register from it before exiting. // so we don't need to drop the link register from it before exiting.
__ Cbz(w0, &exit_with_exception); __ Cbz(w0, &exit_with_exception);
// Otherwise use return value as new stack pointer. // Otherwise use return value as new stack pointer.
...@@ -1366,14 +1362,13 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) { ...@@ -1366,14 +1362,13 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
int align_mask = (alignment / kXRegSize) - 1; int align_mask = (alignment / kXRegSize) - 1;
int xreg_to_claim = (3 + align_mask) & ~align_mask; int xreg_to_claim = (3 + align_mask) & ~align_mask;
DCHECK(csp.Is(__ StackPointer()));
__ Claim(xreg_to_claim); __ Claim(xreg_to_claim);
// CheckStackGuardState needs the end and start addresses of the input string. // CheckStackGuardState needs the end and start addresses of the input string.
__ Poke(input_end(), 2 * kPointerSize); __ Poke(input_end(), 2 * kPointerSize);
__ Add(x5, csp, 2 * kPointerSize); __ Add(x5, sp, 2 * kPointerSize);
__ Poke(input_start(), kPointerSize); __ Poke(input_start(), kPointerSize);
__ Add(x4, csp, kPointerSize); __ Add(x4, sp, kPointerSize);
__ Mov(w3, start_offset()); __ Mov(w3, start_offset());
// RegExp code frame pointer. // RegExp code frame pointer.
...@@ -1384,7 +1379,7 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) { ...@@ -1384,7 +1379,7 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
// We need to pass a pointer to the return address as first argument. // We need to pass a pointer to the return address as first argument.
// The DirectCEntry stub will place the return address on the stack before // The DirectCEntry stub will place the return address on the stack before
// calling so the stack pointer will point to it. // calling so the stack pointer will point to it.
__ Mov(x0, csp); __ Mov(x0, sp);
ExternalReference check_stack_guard_state = ExternalReference check_stack_guard_state =
ExternalReference::re_check_stack_guard_state(isolate()); ExternalReference::re_check_stack_guard_state(isolate());
...@@ -1396,7 +1391,6 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) { ...@@ -1396,7 +1391,6 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
__ Peek(input_start(), kPointerSize); __ Peek(input_start(), kPointerSize);
__ Peek(input_end(), 2 * kPointerSize); __ Peek(input_end(), 2 * kPointerSize);
DCHECK(csp.Is(__ StackPointer()));
__ Drop(xreg_to_claim); __ Drop(xreg_to_claim);
// Reload the Code pointer. // Reload the Code pointer.
...@@ -1445,8 +1439,7 @@ void RegExpMacroAssemblerARM64::CheckPreemption() { ...@@ -1445,8 +1439,7 @@ void RegExpMacroAssemblerARM64::CheckPreemption() {
ExternalReference::address_of_stack_limit(isolate()); ExternalReference::address_of_stack_limit(isolate());
__ Mov(x10, stack_limit); __ Mov(x10, stack_limit);
__ Ldr(x10, MemOperand(x10)); __ Ldr(x10, MemOperand(x10));
DCHECK(csp.Is(__ StackPointer())); __ Cmp(sp, x10);
__ Cmp(csp, x10);
CallIf(&check_preempt_label_, ls); CallIf(&check_preempt_label_, ls);
} }
...@@ -1557,14 +1550,12 @@ void RegExpMacroAssemblerARM64::CallIf(Label* to, Condition condition) { ...@@ -1557,14 +1550,12 @@ void RegExpMacroAssemblerARM64::CallIf(Label* to, Condition condition) {
void RegExpMacroAssemblerARM64::RestoreLinkRegister() { void RegExpMacroAssemblerARM64::RestoreLinkRegister() {
DCHECK(csp.Is(__ StackPointer()));
__ Pop(lr, xzr); __ Pop(lr, xzr);
__ Add(lr, lr, Operand(masm_->CodeObject())); __ Add(lr, lr, Operand(masm_->CodeObject()));
} }
void RegExpMacroAssemblerARM64::SaveLinkRegister() { void RegExpMacroAssemblerARM64::SaveLinkRegister() {
DCHECK(csp.Is(__ StackPointer()));
__ Sub(lr, lr, Operand(masm_->CodeObject())); __ Sub(lr, lr, Operand(masm_->CodeObject()));
__ Push(xzr, lr); __ Push(xzr, lr);
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -287,7 +287,7 @@ void Clobber(MacroAssembler* masm, RegList reg_list, uint64_t const value) { ...@@ -287,7 +287,7 @@ void Clobber(MacroAssembler* masm, RegList reg_list, uint64_t const value) {
if (reg_list & (1UL << i)) { if (reg_list & (1UL << i)) {
Register xn = Register::Create(i, kXRegSizeInBits); Register xn = Register::Create(i, kXRegSizeInBits);
// We should never write into csp here. // We should never write into csp here.
CHECK(!xn.Is(csp)); CHECK(!xn.Is(sp));
if (!xn.IsZero()) { if (!xn.IsZero()) {
if (!first.IsValid()) { if (!first.IsValid()) {
// This is the first register we've hit, so construct the literal. // This is the first register we've hit, so construct the literal.
...@@ -337,8 +337,6 @@ void Clobber(MacroAssembler* masm, CPURegList reg_list) { ...@@ -337,8 +337,6 @@ void Clobber(MacroAssembler* masm, CPURegList reg_list) {
void RegisterDump::Dump(MacroAssembler* masm) { void RegisterDump::Dump(MacroAssembler* masm) {
CHECK(__ StackPointer().Is(csp));
// Ensure that we don't unintentionally clobber any registers. // Ensure that we don't unintentionally clobber any registers.
RegList old_tmp_list = masm->TmpList()->list(); RegList old_tmp_list = masm->TmpList()->list();
RegList old_fptmp_list = masm->FPTmpList()->list(); RegList old_fptmp_list = masm->FPTmpList()->list();
...@@ -372,9 +370,9 @@ void RegisterDump::Dump(MacroAssembler* masm) { ...@@ -372,9 +370,9 @@ void RegisterDump::Dump(MacroAssembler* masm) {
// The stack pointer cannot be stored directly; it needs to be moved into // The stack pointer cannot be stored directly; it needs to be moved into
// another register first. Also, we pushed four X registers, so we need to // another register first. Also, we pushed four X registers, so we need to
// compensate here. // compensate here.
__ Add(tmp, csp, 4 * kXRegSize); __ Add(tmp, sp, 4 * kXRegSize);
__ Str(tmp, MemOperand(dump_base, sp_offset)); __ Str(tmp, MemOperand(dump_base, sp_offset));
__ Add(tmp_w, wcsp, 4 * kXRegSize); __ Add(tmp_w, wsp, 4 * kXRegSize);
__ Str(tmp_w, MemOperand(dump_base, wsp_offset)); __ Str(tmp_w, MemOperand(dump_base, wsp_offset));
// Dump X registers. // Dump X registers.
......
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