Commit e4ca64de authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[cleanup][arm64] Replace kPointerSize usages in arm64 ...

to kTaggedSize or kSystemPointerSize.

Like X64's CLs, but combined:
https://chromium-review.googlesource.com/c/v8/v8/+/1384092
https://chromium-review.googlesource.com/c/v8/v8/+/1384309 and
https://chromium-review.googlesource.com/c/v8/v8/+/1473291

Bug: v8:8477, v8:8834
Change-Id: I832999996a0b56bd34ec6aa4fd86d9a5476e1065
Reviewed-on: https://chromium-review.googlesource.com/c/1477215
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59681}
parent 4cbdf97d
......@@ -583,7 +583,7 @@ int Assembler::deserialization_special_target_size(Address location) {
return kSpecialTargetSize;
} else {
DCHECK_EQ(instr->InstructionBits(), 0);
return kPointerSize;
return kSystemPointerSize;
}
}
......@@ -645,7 +645,7 @@ int RelocInfo::target_address_size() {
return Assembler::kSpecialTargetSize;
} else {
DCHECK(reinterpret_cast<Instruction*>(pc_)->IsLdrLiteralX());
return kPointerSize;
return kSystemPointerSize;
}
}
......
......@@ -377,7 +377,7 @@ int ConstPool::WorstCaseSize() {
// blr xzr
// nop
// All entries are 64-bit for now.
return 4 * kInstrSize + EntryCount() * kPointerSize;
return 4 * kInstrSize + EntryCount() * kSystemPointerSize;
}
......@@ -395,7 +395,7 @@ int ConstPool::SizeIfEmittedAtCurrentPc(bool require_jump) {
IsAligned(assm_->pc_offset() + prologue_size, 8) ? 0 : kInstrSize;
// All entries are 64-bit for now.
return prologue_size + EntryCount() * kPointerSize;
return prologue_size + EntryCount() * kSystemPointerSize;
}
......
......@@ -2856,7 +2856,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Functions used for testing.
int GetConstantPoolEntriesSizeForTesting() const {
// Do not include branch over the pool.
return constpool_.EntryCount() * kPointerSize;
return constpool_.EntryCount() * kSystemPointerSize;
}
static constexpr int GetCheckConstPoolIntervalForTesting() {
......
......@@ -215,7 +215,7 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
// frame description.
__ Add(x3, x1, FrameDescription::frame_content_offset());
__ SlotAddress(x1, 0);
__ Lsr(unwind_limit, unwind_limit, kPointerSizeLog2);
__ Lsr(unwind_limit, unwind_limit, kSystemPointerSizeLog2);
__ Mov(x5, unwind_limit);
__ CopyDoubleWords(x3, x1, x5);
__ Drop(unwind_limit);
......@@ -240,15 +240,15 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
Label outer_push_loop, outer_loop_header;
__ Ldrsw(x1, MemOperand(x4, Deoptimizer::output_count_offset()));
__ Ldr(x0, MemOperand(x4, Deoptimizer::output_offset()));
__ Add(x1, x0, Operand(x1, LSL, kPointerSizeLog2));
__ Add(x1, x0, Operand(x1, LSL, kSystemPointerSizeLog2));
__ B(&outer_loop_header);
__ Bind(&outer_push_loop);
Register current_frame = x2;
Register frame_size = x3;
__ Ldr(current_frame, MemOperand(x0, kPointerSize, PostIndex));
__ Ldr(current_frame, MemOperand(x0, kSystemPointerSize, PostIndex));
__ Ldr(x3, MemOperand(current_frame, FrameDescription::frame_size_offset()));
__ Lsr(frame_size, x3, kPointerSizeLog2);
__ Lsr(frame_size, x3, kSystemPointerSizeLog2);
__ Claim(frame_size);
__ Add(x7, current_frame, FrameDescription::frame_content_offset());
......
......@@ -37,8 +37,8 @@ class EntryFrameConstants : public AllStatic {
public:
// This is the offset to where JSEntry pushes the current value of
// Isolate::c_entry_fp onto the stack.
static constexpr int kCallerFPOffset = -3 * kPointerSize;
static constexpr int kFixedFrameSize = 6 * kPointerSize;
static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
static constexpr int kFixedFrameSize = 6 * kSystemPointerSize;
};
class ExitFrameConstants : public TypedFrameConstants {
......@@ -62,7 +62,7 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kFixedFrameSizeFromFp =
// Header is padded to 16 byte (see {MacroAssembler::EnterFrame}).
RoundUp<16>(TypedFrameConstants::kFixedFrameSizeFromFp) +
kNumberOfSavedGpParamRegs * kPointerSize +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
};
......@@ -74,7 +74,7 @@ class JavaScriptFrameConstants : public AllStatic {
// There are two words on the stack (saved fp and saved lr) between fp and
// the arguments.
static constexpr int kLastParameterOffset = 2 * kPointerSize;
static constexpr int kLastParameterOffset = 2 * kSystemPointerSize;
static constexpr int kFunctionOffset =
StandardFrameConstants::kFunctionOffset;
......
......@@ -1471,7 +1471,7 @@ void TurboAssembler::CopyDoubleWords(Register dst, Register src, Register count,
Bind(&pointer1_below_pointer2);
Add(pointer1, pointer1, pointer2);
}
static_assert(kPointerSize == kDRegSize,
static_assert(kSystemPointerSize == kDRegSize,
"pointers must be the same size as doubles");
int direction = (mode == kDstLessThanSrc) ? 1 : -1;
......@@ -1482,21 +1482,23 @@ void TurboAssembler::CopyDoubleWords(Register dst, Register src, Register count,
Label pairs, loop, done;
Tbz(count, 0, &pairs);
Ldr(temp0, MemOperand(src, direction * kPointerSize, PostIndex));
Ldr(temp0, MemOperand(src, direction * kSystemPointerSize, PostIndex));
Sub(count, count, 1);
Str(temp0, MemOperand(dst, direction * kPointerSize, PostIndex));
Str(temp0, MemOperand(dst, direction * kSystemPointerSize, PostIndex));
Bind(&pairs);
if (mode == kSrcLessThanDst) {
// Adjust pointers for post-index ldp/stp with negative offset:
Sub(dst, dst, kPointerSize);
Sub(src, src, kPointerSize);
Sub(dst, dst, kSystemPointerSize);
Sub(src, src, kSystemPointerSize);
}
Bind(&loop);
Cbz(count, &done);
Ldp(temp0, temp1, MemOperand(src, 2 * direction * kPointerSize, PostIndex));
Ldp(temp0, temp1,
MemOperand(src, 2 * direction * kSystemPointerSize, PostIndex));
Sub(count, count, 2);
Stp(temp0, temp1, MemOperand(dst, 2 * direction * kPointerSize, PostIndex));
Stp(temp0, temp1,
MemOperand(dst, 2 * direction * kSystemPointerSize, PostIndex));
B(&loop);
// TODO(all): large copies may benefit from using temporary Q registers
......@@ -1506,11 +1508,11 @@ void TurboAssembler::CopyDoubleWords(Register dst, Register src, Register count,
}
void TurboAssembler::SlotAddress(Register dst, int slot_offset) {
Add(dst, sp, slot_offset << kPointerSizeLog2);
Add(dst, sp, slot_offset << kSystemPointerSizeLog2);
}
void TurboAssembler::SlotAddress(Register dst, Register slot_offset) {
Add(dst, sp, Operand(slot_offset, LSL, kPointerSizeLog2));
Add(dst, sp, Operand(slot_offset, LSL, kSystemPointerSizeLog2));
}
void TurboAssembler::AssertFPCRState(Register fpcr) {
......@@ -2171,23 +2173,25 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count,
#endif
// Calculate the end of destination area where we will put the arguments
// after we drop current frame. We add kPointerSize to count the receiver
// argument which is not included into formal parameters count.
// after we drop current frame. We add kSystemPointerSize to count the
// receiver argument which is not included into formal parameters count.
Register dst_reg = scratch0;
Add(dst_reg, fp, Operand(caller_args_count_reg, LSL, kPointerSizeLog2));
Add(dst_reg, dst_reg, StandardFrameConstants::kCallerSPOffset + kPointerSize);
Add(dst_reg, fp, Operand(caller_args_count_reg, LSL, kSystemPointerSizeLog2));
Add(dst_reg, dst_reg,
StandardFrameConstants::kCallerSPOffset + kSystemPointerSize);
// Round dst_reg up to a multiple of 16 bytes, so that we overwrite any
// potential padding.
Add(dst_reg, dst_reg, 15);
Bic(dst_reg, dst_reg, 15);
Register src_reg = caller_args_count_reg;
// Calculate the end of source area. +kPointerSize is for the receiver.
// Calculate the end of source area. +kSystemPointerSize is for the receiver.
if (callee_args_count.is_reg()) {
Add(src_reg, sp, Operand(callee_args_count.reg(), LSL, kPointerSizeLog2));
Add(src_reg, src_reg, kPointerSize);
Add(src_reg, sp,
Operand(callee_args_count.reg(), LSL, kSystemPointerSizeLog2));
Add(src_reg, src_reg, kSystemPointerSize);
} else {
Add(src_reg, sp, (callee_args_count.immediate() + 1) * kPointerSize);
Add(src_reg, sp, (callee_args_count.immediate() + 1) * kSystemPointerSize);
}
// Round src_reg up to a multiple of 16 bytes, so we include any potential
......@@ -2214,8 +2218,8 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count,
Label loop, entry;
B(&entry);
bind(&loop);
Ldr(tmp_reg, MemOperand(src_reg, -kPointerSize, PreIndex));
Str(tmp_reg, MemOperand(dst_reg, -kPointerSize, PreIndex));
Ldr(tmp_reg, MemOperand(src_reg, -kSystemPointerSize, PreIndex));
Str(tmp_reg, MemOperand(dst_reg, -kSystemPointerSize, PreIndex));
bind(&entry);
Cmp(sp, src_reg);
B(ne, &loop);
......@@ -2306,7 +2310,7 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
Operand actual_op = actual.is_immediate() ? Operand(actual.immediate())
: Operand(actual.reg());
Mov(x4, actual_op);
Ldr(x4, MemOperand(sp, x4, LSL, kPointerSizeLog2));
Ldr(x4, MemOperand(sp, x4, LSL, kSystemPointerSizeLog2));
FrameScope frame(this,
has_frame() ? StackFrame::NONE : StackFrame::INTERNAL);
......@@ -2488,7 +2492,7 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
// type_reg pushed twice for alignment.
Push(lr, fp, type_reg, type_reg);
const int kFrameSize =
TypedFrameConstants::kFixedFrameSizeFromFp + kPointerSize;
TypedFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize;
Add(fp, sp, kFrameSize);
// sp[3] : lr
// sp[2] : fp
......@@ -2516,7 +2520,8 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
// The context pointer isn't part of the fixed frame, so add an extra slot
// to account for it.
Add(fp, sp, TypedFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
Add(fp, sp,
TypedFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
......@@ -2572,12 +2577,16 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, const Register& scratch,
// fp[-16]: Space reserved for SPOffset.
// fp[-24]: CodeObject()
// sp -> fp[-32]: padding
STATIC_ASSERT((2 * kPointerSize) == ExitFrameConstants::kCallerSPOffset);
STATIC_ASSERT((1 * kPointerSize) == ExitFrameConstants::kCallerPCOffset);
STATIC_ASSERT((0 * kPointerSize) == ExitFrameConstants::kCallerFPOffset);
STATIC_ASSERT((-2 * kPointerSize) == ExitFrameConstants::kSPOffset);
STATIC_ASSERT((-3 * kPointerSize) == ExitFrameConstants::kCodeOffset);
STATIC_ASSERT((-4 * kPointerSize) == ExitFrameConstants::kPaddingOffset);
STATIC_ASSERT((2 * kSystemPointerSize) ==
ExitFrameConstants::kCallerSPOffset);
STATIC_ASSERT((1 * kSystemPointerSize) ==
ExitFrameConstants::kCallerPCOffset);
STATIC_ASSERT((0 * kSystemPointerSize) ==
ExitFrameConstants::kCallerFPOffset);
STATIC_ASSERT((-2 * kSystemPointerSize) == ExitFrameConstants::kSPOffset);
STATIC_ASSERT((-3 * kSystemPointerSize) == ExitFrameConstants::kCodeOffset);
STATIC_ASSERT((-4 * kSystemPointerSize) ==
ExitFrameConstants::kPaddingOffset);
// Save the frame pointer and context pointer in the top frame.
Mov(scratch,
......@@ -2587,7 +2596,8 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, const Register& scratch,
ExternalReference::Create(IsolateAddressId::kContextAddress, isolate()));
Str(cp, MemOperand(scratch));
STATIC_ASSERT((-4 * kPointerSize) == ExitFrameConstants::kLastExitFrameField);
STATIC_ASSERT((-4 * kSystemPointerSize) ==
ExitFrameConstants::kLastExitFrameField);
if (save_doubles) {
ExitFramePreserveFPRegs();
}
......@@ -2948,13 +2958,13 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
}
// Although the object register is tagged, the offset is relative to the start
// of the object, so offset must be a multiple of kPointerSize.
DCHECK(IsAligned(offset, kPointerSize));
// of the object, so offset must be a multiple of kTaggedSize.
DCHECK(IsAligned(offset, kTaggedSize));
Add(scratch, object, offset - kHeapObjectTag);
if (emit_debug_code()) {
Label ok;
Tst(scratch, kPointerSize - 1);
Tst(scratch, kTaggedSize - 1);
B(eq, &ok);
Abort(AbortReason::kUnalignedCellInWriteBarrier);
Bind(&ok);
......
......@@ -252,9 +252,9 @@ uintptr_t Simulator::PushAddress(uintptr_t address) {
intptr_t new_sp = sp() - 2 * kXRegSize;
uintptr_t* alignment_slot =
reinterpret_cast<uintptr_t*>(new_sp + kXRegSize);
memcpy(alignment_slot, &kSlotsZapValue, kPointerSize);
memcpy(alignment_slot, &kSlotsZapValue, kSystemPointerSize);
uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp);
memcpy(stack_slot, &address, kPointerSize);
memcpy(stack_slot, &address, kSystemPointerSize);
set_sp(new_sp);
return new_sp;
}
......
......@@ -860,13 +860,13 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
// Commonly-used special cases.
template<typename T>
void set_lr(T value) {
DCHECK_EQ(sizeof(T), static_cast<unsigned>(kPointerSize));
DCHECK_EQ(sizeof(T), static_cast<unsigned>(kSystemPointerSize));
set_reg(kLinkRegCode, value);
}
template<typename T>
void set_sp(T value) {
DCHECK_EQ(sizeof(T), static_cast<unsigned>(kPointerSize));
DCHECK_EQ(sizeof(T), static_cast<unsigned>(kSystemPointerSize));
set_reg(31, value, Reg31IsStackPointer);
}
......
This diff is collapsed.
......@@ -722,7 +722,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ PushCPURegList(argument_registers);
// Set frame pointer in place.
__ Add(frame_pointer(), sp, argument_registers.Count() * kPointerSize);
__ Add(frame_pointer(), sp, argument_registers.Count() * kSystemPointerSize);
// Initialize callee-saved registers.
__ Mov(start_offset(), w1);
......@@ -880,9 +880,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ Add(capture_end, input_length, capture_end);
}
// The output pointer advances for a possible global match.
__ Stp(capture_start,
capture_end,
MemOperand(output_array(), kPointerSize, PostIndex));
__ Stp(capture_start, capture_end,
MemOperand(output_array(), kSystemPointerSize, PostIndex));
}
// Only carry on if there are more than kNumCachedRegisters capture
......@@ -901,9 +900,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
STATIC_ASSERT(kNumRegistersToUnroll > 2);
if (num_registers_left_on_stack <= kNumRegistersToUnroll) {
for (int i = 0; i < num_registers_left_on_stack / 2; i++) {
__ Ldp(capture_end,
capture_start,
MemOperand(base, -kPointerSize, PostIndex));
__ Ldp(capture_end, capture_start,
MemOperand(base, -kSystemPointerSize, PostIndex));
if ((i == 0) && global_with_zero_length_check()) {
// Keep capture start for the zero-length check later.
__ Mov(first_capture_start, capture_start);
......@@ -919,26 +917,23 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ Add(capture_end, input_length, capture_end);
}
// The output pointer advances for a possible global match.
__ Stp(capture_start,
capture_end,
MemOperand(output_array(), kPointerSize, PostIndex));
__ Stp(capture_start, capture_end,
MemOperand(output_array(), kSystemPointerSize, PostIndex));
}
} else {
Label loop, start;
__ Mov(x11, num_registers_left_on_stack);
__ Ldp(capture_end,
capture_start,
MemOperand(base, -kPointerSize, PostIndex));
__ Ldp(capture_end, capture_start,
MemOperand(base, -kSystemPointerSize, PostIndex));
if (global_with_zero_length_check()) {
__ Mov(first_capture_start, capture_start);
}
__ B(&start);
__ Bind(&loop);
__ Ldp(capture_end,
capture_start,
MemOperand(base, -kPointerSize, PostIndex));
__ Ldp(capture_end, capture_start,
MemOperand(base, -kSystemPointerSize, PostIndex));
__ Bind(&start);
if (mode_ == UC16) {
__ Add(capture_start, input_length, Operand(capture_start, ASR, 1));
......@@ -948,9 +943,8 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
__ Add(capture_end, input_length, capture_end);
}
// The output pointer advances for a possible global match.
__ Stp(capture_start,
capture_end,
MemOperand(output_array(), kPointerSize, PostIndex));
__ Stp(capture_start, capture_end,
MemOperand(output_array(), kSystemPointerSize, PostIndex));
__ Sub(x11, x11, 2);
__ Cbnz(x11, &loop);
}
......@@ -1288,7 +1282,7 @@ void RegExpMacroAssemblerARM64::ClearRegisters(int reg_from, int reg_to) {
__ Mov(x11, num_registers);
__ Bind(&loop);
__ Str(twice_non_position_value(),
MemOperand(base, -kPointerSize, PostIndex));
MemOperand(base, -kSystemPointerSize, PostIndex));
__ Sub(x11, x11, 2);
__ Cbnz(x11, &loop);
} else {
......@@ -1368,10 +1362,10 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
__ Claim(xreg_to_claim);
// CheckStackGuardState needs the end and start addresses of the input string.
__ Poke(input_end(), 2 * kPointerSize);
__ Add(x5, sp, 2 * kPointerSize);
__ Poke(input_start(), kPointerSize);
__ Add(x4, sp, kPointerSize);
__ Poke(input_end(), 2 * kSystemPointerSize);
__ Add(x5, sp, 2 * kSystemPointerSize);
__ Poke(input_start(), kSystemPointerSize);
__ Add(x4, sp, kSystemPointerSize);
__ Mov(w3, start_offset());
// RegExp code frame pointer.
......@@ -1406,8 +1400,8 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
}
// The input string may have been moved in memory, we need to reload it.
__ Peek(input_start(), kPointerSize);
__ Peek(input_end(), 2 * kPointerSize);
__ Peek(input_start(), kSystemPointerSize);
__ Peek(input_end(), 2 * kSystemPointerSize);
__ Drop(xreg_to_claim);
......
......@@ -105,19 +105,20 @@ class RegExpMacroAssemblerARM64: public NativeRegExpMacroAssembler {
static const int kCalleeSavedRegisters = 0;
// Return address.
// It is placed above the 11 callee-saved registers.
static const int kReturnAddress = kCalleeSavedRegisters + 11 * kPointerSize;
static const int kReturnAddress =
kCalleeSavedRegisters + 11 * kSystemPointerSize;
// Stack parameter placed by caller.
static const int kIsolate = kReturnAddress + kPointerSize;
static const int kIsolate = kReturnAddress + kSystemPointerSize;
// Below the frame pointer.
// Register parameters stored by setup code.
static const int kDirectCall = kCalleeSavedRegisters - kPointerSize;
static const int kStackBase = kDirectCall - kPointerSize;
static const int kOutputSize = kStackBase - kPointerSize;
static const int kInput = kOutputSize - kPointerSize;
static const int kDirectCall = kCalleeSavedRegisters - kSystemPointerSize;
static const int kStackBase = kDirectCall - kSystemPointerSize;
static const int kOutputSize = kStackBase - kSystemPointerSize;
static const int kInput = kOutputSize - kSystemPointerSize;
// When adding local variables remember to push space for them in
// the frame in GetCode.
static const int kSuccessCounter = kInput - kPointerSize;
static const int kSuccessCounter = kInput - kSystemPointerSize;
// First position register address on the stack. Following positions are
// below it. A position is a 32 bit value.
static const int kFirstRegisterOnStack = kSuccessCounter - kWRegSize;
......
......@@ -14721,7 +14721,7 @@ TEST(jump_tables_forward) {
Label base;
__ Adr(x10, &base);
__ Ldr(x11, MemOperand(x10, index, LSL, kPointerSizeLog2));
__ Ldr(x11, MemOperand(x10, index, LSL, kSystemPointerSizeLog2));
__ Br(x11);
__ Bind(&base);
for (int i = 0; i < kNumCases; ++i) {
......@@ -14789,7 +14789,7 @@ TEST(jump_tables_backward) {
Label base;
__ Adr(x10, &base);
__ Ldr(x11, MemOperand(x10, index, LSL, kPointerSizeLog2));
__ Ldr(x11, MemOperand(x10, index, LSL, kSystemPointerSizeLog2));
__ Br(x11);
__ Bind(&base);
for (int i = 0; i < kNumCases; ++i) {
......
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