Commit d183d42f authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup][x64] Final set of x64-specific kPointerSize fixes

Bug: v8:8477, v8:8562
Change-Id: I28a8244ef22035db85b520d86aa6d5578c7c7f5d
Reviewed-on: https://chromium-review.googlesource.com/c/1384309
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58426}
parent 4b4175d7
......@@ -729,7 +729,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
__ j(below_equal, &stack_limit_hit);
// Check if there is room for the variable number of registers above
// the stack limit.
__ cmpp(rcx, Immediate(num_registers_ * kPointerSize));
__ cmpp(rcx, Immediate(num_registers_ * kSystemPointerSize));
__ j(above_equal, &stack_ok);
// Exit with OutOfMemory exception. There is not enough space on the stack
// for our working registers.
......@@ -746,7 +746,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
__ bind(&stack_ok);
// Allocate space on stack for registers.
__ subp(rsp, Immediate(num_registers_ * kPointerSize));
__ subp(rsp, Immediate(num_registers_ * kSystemPointerSize));
// Load string length.
__ movp(rsi, Operand(rbp, kInputEnd));
// Load input position.
......@@ -770,7 +770,7 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
// Ensure that we have written to each stack page, in order. Skipping a page
// on Windows can cause segmentation faults. Assuming page size is 4k.
const int kPageSize = 4096;
const int kRegistersPerPage = kPageSize / kPointerSize;
const int kRegistersPerPage = kPageSize / kSystemPointerSize;
for (int i = num_saved_registers_ + kRegistersPerPage - 1;
i < num_registers_;
i += kRegistersPerPage) {
......@@ -804,9 +804,9 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) {
Label init_loop;
__ bind(&init_loop);
__ movp(Operand(rbp, rcx, times_1, 0), rax);
__ subq(rcx, Immediate(kPointerSize));
__ cmpq(rcx,
Immediate(kRegisterZero - num_saved_registers_ * kPointerSize));
__ subq(rcx, Immediate(kSystemPointerSize));
__ cmpq(rcx, Immediate(kRegisterZero -
num_saved_registers_ * kSystemPointerSize));
__ j(greater, &init_loop);
} else { // Unroll the loop.
for (int i = 0; i < num_saved_registers_; i++) {
......@@ -1093,12 +1093,11 @@ void RegExpMacroAssemblerX64::PushRegister(int register_index,
if (check_stack_limit) CheckStackLimit();
}
STATIC_ASSERT(kPointerSize == kInt64Size || kPointerSize == kInt32Size);
STATIC_ASSERT(kSystemPointerSize == kInt64Size ||
kSystemPointerSize == kInt32Size);
void RegExpMacroAssemblerX64::ReadCurrentPositionFromRegister(int reg) {
if (kPointerSize == kInt64Size) {
if (kSystemPointerSize == kInt64Size) {
__ movq(rdi, register_location(reg));
} else {
// Need sign extension for x32 as rdi might be used as an index register.
......@@ -1108,7 +1107,7 @@ void RegExpMacroAssemblerX64::ReadCurrentPositionFromRegister(int reg) {
void RegExpMacroAssemblerX64::ReadPositionFromRegister(Register dst, int reg) {
if (kPointerSize == kInt64Size) {
if (kSystemPointerSize == kInt64Size) {
__ movq(dst, register_location(reg));
} else {
// Need sign extension for x32 as dst might be used as an index register.
......@@ -1189,7 +1188,7 @@ void RegExpMacroAssemblerX64::CallCheckStackGuardState() {
__ movp(r8, rbp);
// First argument: Next address on the stack (will be address of
// return address).
__ leap(rcx, Operand(rsp, -kPointerSize));
__ leap(rcx, Operand(rsp, -kSystemPointerSize));
#else
// Third argument: RegExp code frame pointer.
__ movp(rdx, rbp);
......@@ -1236,7 +1235,7 @@ Operand RegExpMacroAssemblerX64::register_location(int register_index) {
if (num_registers_ <= register_index) {
num_registers_ = register_index + 1;
}
return Operand(rbp, kRegisterZero - register_index * kPointerSize);
return Operand(rbp, kRegisterZero - register_index * kSystemPointerSize);
}
......
......@@ -147,13 +147,15 @@ class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler {
static const int kLastCalleeSaveRegister = kBackup_rbx;
#endif
static const int kSuccessfulCaptures = kLastCalleeSaveRegister - kPointerSize;
static const int kSuccessfulCaptures =
kLastCalleeSaveRegister - kSystemPointerSize;
// When adding local variables remember to push space for them in
// the frame in GetCode.
static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize;
static const int kStringStartMinusOne =
kSuccessfulCaptures - kSystemPointerSize;
// First register address. Following registers are below it on the stack.
static const int kRegisterZero = kStringStartMinusOne - kPointerSize;
static const int kRegisterZero = kStringStartMinusOne - kSystemPointerSize;
// Initial size of code buffer.
static const size_t kRegExpCodeSize = 1024;
......
......@@ -325,16 +325,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Patch will be appiled to other FIXED_SEQUENCE call
static constexpr int kCallTargetAddressOffset = 6;
// The length of FIXED_SEQUENCE call
// iihf r8, <address_hi> // <64-bit only>
// iilf r8, <address_lo>
// basr r14, r8
#if V8_TARGET_ARCH_S390X
static constexpr int kCallSequenceLength = 14;
#else
static constexpr int kCallSequenceLength = 8;
#endif
// ---------------------------------------------------------------------------
// Code generation
......
......@@ -311,7 +311,7 @@ int RelocInfo::target_address_size() {
if (IsCodedSpecially()) {
return Assembler::kSpecialTargetSize;
} else {
return kPointerSize;
return kSystemPointerSize;
}
}
......
......@@ -1656,12 +1656,12 @@ void Assembler::emit_lea(Register dst, Operand src, int size) {
void Assembler::load_rax(Address value, RelocInfo::Mode mode) {
EnsureSpace ensure_space(this);
if (kPointerSize == kInt64Size) {
if (kSystemPointerSize == kInt64Size) {
emit(0x48); // REX.W
emit(0xA1);
emitp(value, mode);
} else {
DCHECK_EQ(kPointerSize, kInt32Size);
DCHECK_EQ(kSystemPointerSize, kInt32Size);
emit(0xA1);
emitp(value, mode);
// In 64-bit mode, need to zero extend the operand to 8 bytes.
......@@ -1805,11 +1805,11 @@ void Assembler::movp(Register dst, Address value, RelocInfo::Mode rmode) {
if (constpool_.TryRecordEntry(value, rmode)) {
// Emit rip-relative move with offset = 0
Label label;
emit_mov(dst, Operand(&label, 0), kPointerSize);
emit_mov(dst, Operand(&label, 0), kSystemPointerSize);
bind(&label);
} else {
EnsureSpace ensure_space(this);
emit_rex(dst, kPointerSize);
emit_rex(dst, kSystemPointerSize);
emit(0xB8 | dst.low_bits());
emitp(value, rmode);
}
......@@ -1817,7 +1817,7 @@ void Assembler::movp(Register dst, Address value, RelocInfo::Mode rmode) {
void Assembler::movp_heap_number(Register dst, double value) {
EnsureSpace ensure_space(this);
emit_rex(dst, kPointerSize);
emit_rex(dst, kSystemPointerSize);
emit(0xB8 | dst.low_bits());
RequestHeapObject(HeapObjectRequest(value));
emitp(0, RelocInfo::EMBEDDED_OBJECT);
......@@ -1825,7 +1825,7 @@ void Assembler::movp_heap_number(Register dst, double value) {
void Assembler::movp_string(Register dst, const StringConstantBase* str) {
EnsureSpace ensure_space(this);
emit_rex(dst, kPointerSize);
emit_rex(dst, kSystemPointerSize);
emit(0xB8 | dst.low_bits());
RequestHeapObject(HeapObjectRequest(str));
emitp(0, RelocInfo::EMBEDDED_OBJECT);
......@@ -1835,7 +1835,7 @@ void Assembler::movq(Register dst, int64_t value, RelocInfo::Mode rmode) {
if (constpool_.TryRecordEntry(value, rmode)) {
// Emit rip-relative move with offset = 0
Label label;
emit_mov(dst, Operand(&label, 0), kPointerSize);
emit_mov(dst, Operand(&label, 0), kInt64Size);
bind(&label);
} else {
EnsureSpace ensure_space(this);
......@@ -2329,12 +2329,12 @@ void Assembler::emit_xchg(Register dst, Operand src, int size) {
void Assembler::store_rax(Address dst, RelocInfo::Mode mode) {
EnsureSpace ensure_space(this);
if (kPointerSize == kInt64Size) {
if (kSystemPointerSize == kInt64Size) {
emit(0x48); // REX.W
emit(0xA3);
emitp(dst, mode);
} else {
DCHECK_EQ(kPointerSize, kInt32Size);
DCHECK_EQ(kSystemPointerSize, kInt32Size);
emit(0xA3);
emitp(dst, mode);
// In 64-bit mode, need to zero extend the operand to 8 bytes.
......
......@@ -192,7 +192,7 @@ class V8_EXPORT_PRIVATE Operand {
const Data data_;
};
ASSERT_TRIVIALLY_COPYABLE(Operand);
static_assert(sizeof(Operand) <= 2 * kPointerSize,
static_assert(sizeof(Operand) <= 2 * kSystemPointerSize,
"Operand must be small enough to pass it by value");
#define ASSEMBLER_INSTRUCTION_LIST(V) \
......@@ -219,8 +219,8 @@ static_assert(sizeof(Operand) <= 2 * kPointerSize,
V(xchg) \
V(xor)
// Shift instructions on operands/registers with kPointerSize, kInt32Size and
// kInt64Size.
// Shift instructions on operands/registers with kSystemPointerSize, kInt32Size
// and kInt64Size.
#define SHIFT_INSTRUCTION_LIST(V) \
V(rol, 0x0) \
V(ror, 0x1) \
......@@ -366,15 +366,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Distance between the address of the code target in the call instruction
// and the return address pushed on the stack.
static constexpr int kCallTargetAddressOffset = 4; // 32-bit displacement.
// The length of call(kScratchRegister).
static constexpr int kCallScratchRegisterInstructionLength = 3;
// The length of movq(kScratchRegister, address).
static constexpr int kMoveAddressIntoScratchRegisterInstructionLength =
2 + kPointerSize;
// The length of movq(kScratchRegister, address) and call(kScratchRegister).
static constexpr int kCallSequenceLength =
kMoveAddressIntoScratchRegisterInstructionLength +
kCallScratchRegisterInstructionLength;
// One byte opcode for test eax,0xXXXXXXXX.
static constexpr byte kTestEaxByte = 0xA9;
......@@ -566,7 +557,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void repmovsb();
void repmovsw();
void repmovsp() { emit_repmovs(kPointerSize); }
void repmovsp() { emit_repmovs(kSystemPointerSize); }
void repmovsl() { emit_repmovs(kInt32Size); }
void repmovsq() { emit_repmovs(kInt64Size); }
......@@ -645,41 +636,45 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Multiply rax by src, put the result in rdx:rax.
void mulq(Register src);
#define DECLARE_SHIFT_INSTRUCTION(instruction, subcode) \
void instruction##p(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kPointerSize); \
} \
\
void instruction##l(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt32Size); \
} \
\
void instruction##q(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt64Size); \
} \
\
void instruction##p(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kPointerSize); \
} \
\
void instruction##l(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt32Size); \
} \
\
void instruction##q(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt64Size); \
} \
\
void instruction##p_cl(Register dst) { shift(dst, subcode, kPointerSize); } \
\
void instruction##l_cl(Register dst) { shift(dst, subcode, kInt32Size); } \
\
void instruction##q_cl(Register dst) { shift(dst, subcode, kInt64Size); } \
\
void instruction##p_cl(Operand dst) { shift(dst, subcode, kPointerSize); } \
\
void instruction##l_cl(Operand dst) { shift(dst, subcode, kInt32Size); } \
\
#define DECLARE_SHIFT_INSTRUCTION(instruction, subcode) \
void instruction##p(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kSystemPointerSize); \
} \
\
void instruction##l(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt32Size); \
} \
\
void instruction##q(Register dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt64Size); \
} \
\
void instruction##p(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kSystemPointerSize); \
} \
\
void instruction##l(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt32Size); \
} \
\
void instruction##q(Operand dst, Immediate imm8) { \
shift(dst, imm8, subcode, kInt64Size); \
} \
\
void instruction##p_cl(Register dst) { \
shift(dst, subcode, kSystemPointerSize); \
} \
\
void instruction##l_cl(Register dst) { shift(dst, subcode, kInt32Size); } \
\
void instruction##q_cl(Register dst) { shift(dst, subcode, kInt64Size); } \
\
void instruction##p_cl(Operand dst) { \
shift(dst, subcode, kSystemPointerSize); \
} \
\
void instruction##l_cl(Operand dst) { shift(dst, subcode, kInt32Size); } \
\
void instruction##q_cl(Operand dst) { shift(dst, subcode, kInt64Size); }
SHIFT_INSTRUCTION_LIST(DECLARE_SHIFT_INSTRUCTION)
#undef DECLARE_SHIFT_INSTRUCTION
......
......@@ -124,7 +124,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Fill in the input registers.
for (int i = kNumberOfRegisters -1; i >= 0; i--) {
int offset = (i * kPointerSize) + FrameDescription::registers_offset();
int offset = (i * kRegisterSize) + FrameDescription::registers_offset();
__ PopQuad(Operand(rbx, offset));
}
......@@ -200,7 +200,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
__ bind(&inner_loop_header);
__ testp(rcx, rcx);
__ j(not_zero, &inner_push_loop);
__ addp(rax, Immediate(kPointerSize));
__ addp(rax, Immediate(kSystemPointerSize));
__ bind(&outer_loop_header);
__ cmpp(rax, rdx);
__ j(below, &outer_push_loop);
......@@ -218,7 +218,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// Push the registers from the last output frame.
for (int i = 0; i < kNumberOfRegisters; i++) {
int offset = (i * kPointerSize) + FrameDescription::registers_offset();
int offset = (i * kRegisterSize) + FrameDescription::registers_offset();
__ PushQuad(Operand(rbx, offset));
}
......@@ -254,18 +254,18 @@ void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
bool Deoptimizer::PadTopOfStackRegister() { return false; }
void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) {
if (kPCOnStackSize == 2 * kPointerSize) {
if (kPCOnStackSize == 2 * kSystemPointerSize) {
// Zero out the high-32 bit of PC for x32 port.
SetFrameSlot(offset + kPointerSize, 0);
SetFrameSlot(offset + kSystemPointerSize, 0);
}
SetFrameSlot(offset, value);
}
void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) {
if (kFPOnStackSize == 2 * kPointerSize) {
if (kFPOnStackSize == 2 * kSystemPointerSize) {
// Zero out the high-32 bit of FP for x32 port.
SetFrameSlot(offset + kPointerSize, 0);
SetFrameSlot(offset + kSystemPointerSize, 0);
}
SetFrameSlot(offset, value);
}
......
......@@ -21,9 +21,9 @@ void EhFrameWriter::WriteReturnAddressRegisterCode() {
}
void EhFrameWriter::WriteInitialStateInCie() {
SetBaseAddressRegisterAndOffset(rsp, kPointerSize);
SetBaseAddressRegisterAndOffset(rsp, kSystemPointerSize);
// x64 rip (r16) has no Register instance associated.
RecordRegisterSavedToStack(kRipDwarfCode, -kPointerSize);
RecordRegisterSavedToStack(kRipDwarfCode, -kSystemPointerSize);
}
// static
......
......@@ -25,17 +25,18 @@ class EntryFrameConstants : public AllStatic {
// pushing the c_entry_fp, plus we manually allocate kXMMRegistersBlockSize
// bytes on the stack.
static constexpr int kCallerFPOffset =
-3 * kPointerSize + -7 * kRegisterSize - kXMMRegistersBlockSize;
-3 * kSystemPointerSize + -7 * kRegisterSize - kXMMRegistersBlockSize;
// Stack offsets for arguments passed to JSEntry.
static constexpr int kArgvOffset = 6 * kPointerSize;
static constexpr int kRootRegisterValueOffset = 7 * kPointerSize;
static constexpr int kArgvOffset = 6 * kSystemPointerSize;
static constexpr int kRootRegisterValueOffset = 7 * kSystemPointerSize;
#else
// This is the offset to where JSEntry pushes the current value of
// Isolate::c_entry_fp onto the stack.
// On x64, there are 5 pushq() and 3 Push() calls between setting up rbp and
// pushing the c_entry_fp.
static constexpr int kCallerFPOffset = -3 * kPointerSize + -5 * kRegisterSize;
static constexpr int kCallerFPOffset =
-3 * kSystemPointerSize + -5 * kRegisterSize;
#endif
};
......@@ -45,7 +46,7 @@ class ExitFrameConstants : public TypedFrameConstants {
static constexpr int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
DEFINE_TYPED_FRAME_SIZES(2);
static constexpr int kCallerFPOffset = +0 * kPointerSize;
static constexpr int kCallerFPOffset = +0 * kSystemPointerSize;
static constexpr int kCallerPCOffset = kFPOnStackSize;
// FP-relative displacement of the caller's SP. It points just
......@@ -64,7 +65,7 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kPointerSize +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kSimd128Size;
};
......@@ -78,8 +79,8 @@ class JavaScriptFrameConstants : public AllStatic {
StandardFrameConstants::kFunctionOffset;
// Caller SP-relative.
static constexpr int kParam0Offset = -2 * kPointerSize;
static constexpr int kReceiverOffset = -1 * kPointerSize;
static constexpr int kParam0Offset = -2 * kSystemPointerSize;
static constexpr int kReceiverOffset = -1 * kSystemPointerSize;
};
} // namespace internal
......
This diff is collapsed.
......@@ -625,13 +625,14 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// sets up the number of arguments in register rdi and the pointer
// to the first argument in register rsi.
//
// Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack
// accessible via StackSpaceOperand.
// Allocates arg_stack_space * kSystemPointerSize memory (not GCed) on the
// stack accessible via StackSpaceOperand.
void EnterExitFrame(int arg_stack_space = 0, bool save_doubles = false,
StackFrame::Type frame_type = StackFrame::EXIT);
// Enter specific kind of exit frame. Allocates arg_stack_space * kPointerSize
// memory (not GCed) on the stack accessible via StackSpaceOperand.
// Enter specific kind of exit frame. Allocates
// (arg_stack_space * kSystemPointerSize) memory (not GCed) on the stack
// accessible via StackSpaceOperand.
void EnterApiExitFrame(int arg_stack_space);
// Leave the current exit frame. Expects/provides the return value in
......@@ -712,8 +713,8 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// Converts, if necessary, a smi to a combination of number and
// multiplier to be used as a scaled index.
// The src register contains a *positive* smi value. The shift is the
// power of two to multiply the index value by (e.g.
// to index by smi-value * kPointerSize, pass the smi and kPointerSizeLog2).
// power of two to multiply the index value by (e.g. to index by
// smi-value * kSystemPointerSize, pass the smi and kSystemPointerSizeLog2).
// The returned index register may be either src or dst, depending
// on what is most efficient. If src and dst are different registers,
// src is always unchanged.
......@@ -889,8 +890,8 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
void EnterExitFramePrologue(bool save_rax, StackFrame::Type frame_type);
// Allocates arg_stack_space * kPointerSize memory (not GCed) on the stack
// accessible via StackSpaceOperand.
// Allocates arg_stack_space * kSystemPointerSize memory (not GCed) on the
// stack accessible via StackSpaceOperand.
void EnterExitFrameEpilogue(int arg_stack_space, bool save_doubles);
void LeaveExitFrameEpilogue();
......@@ -949,9 +950,9 @@ inline Operand NativeContextOperand() {
inline Operand StackSpaceOperand(int index) {
#ifdef _WIN64
const int kShaddowSpace = 4;
return Operand(rsp, (index + kShaddowSpace) * kPointerSize);
return Operand(rsp, (index + kShaddowSpace) * kSystemPointerSize);
#else
return Operand(rsp, index * kPointerSize);
return Operand(rsp, index * kSystemPointerSize);
#endif
}
......
This diff is collapsed.
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