Commit 750ce1e7 authored by Sreten Kovacevic's avatar Sreten Kovacevic Committed by Commit Bot

[mips64] Deprecate use of J and JAL instructions

Since trampolines and long branches are now PIC, these instructions
are not used anymore. Hence 256 MB alignment requirement can be
removed.

Change-Id: Ibdc51631a8c5efc97f058f09b809d3dc13a9f933
Reviewed-on: https://chromium-review.googlesource.com/1219022
Commit-Queue: Sreten Kovacevic <skovacevic@wavecomp.com>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarIvica Bogosavljevic <ibogosavljevic@wavecomp.com>
Cr-Commit-Position: refs/heads/master@{#55852}
parent 4544e18b
......@@ -254,10 +254,6 @@ void* OS::GetRandomMmapAddr() {
// Little-endian Linux: 46 bits of virtual addressing.
raw_addr &= uint64_t{0x3FFFFFFF0000};
#endif
#elif V8_TARGET_ARCH_MIPS64
// We allocate code in 256 MB aligned segments because of optimizations using
// J instruction that require that all code is within a single 256 MB segment
raw_addr &= uint64_t{0x3FFFE0000000};
#elif V8_TARGET_ARCH_S390X
// Linux on Z uses bits 22-32 for Region Indexing, which translates to 42 bits
// of virtual addressing. Truncate to 40 bits to allow kernel chance to
......
......@@ -162,13 +162,7 @@ constexpr intptr_t kIntptrSignBit =
static_cast<intptr_t>(uintptr_t{0x8000000000000000});
constexpr uintptr_t kUintptrAllBitsSet = uintptr_t{0xFFFFFFFFFFFFFFFF};
constexpr bool kRequiresCodeRange = true;
#if V8_TARGET_ARCH_MIPS64
// To use pseudo-relative jumps such as j/jal instructions which have 28-bit
// encoded immediate, the addresses have to be in range of 256MB aligned
// region. Used only for large object space.
constexpr size_t kMaximalCodeRangeSize = 256 * MB;
constexpr size_t kCodeRangeAreaAlignment = 256 * MB;
#elif V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX
#if V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX
constexpr size_t kMaximalCodeRangeSize = 512 * MB;
constexpr size_t kCodeRangeAreaAlignment = 64 * KB; // OS page on PPC Linux
#elif V8_TARGET_ARCH_ARM64
......
......@@ -1819,35 +1819,25 @@ void Assembler::bnezc(Register rs, int32_t offset) {
void Assembler::j(int64_t target) {
BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrJump(J, static_cast<uint32_t>(target >> 2) & kImm26Mask);
BlockTrampolinePoolFor(1); // For associated delay slot.
// Deprecated. Use PC-relative jumps instead.
UNREACHABLE();
}
void Assembler::j(Label* target) {
uint64_t imm = jump_offset(target);
if (target->is_bound()) {
BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrJump(static_cast<Opcode>(kJRawMark),
static_cast<uint32_t>(imm >> 2) & kImm26Mask);
BlockTrampolinePoolFor(1); // For associated delay slot.
} else {
j(imm);
}
// Deprecated. Use PC-relative jumps instead.
UNREACHABLE();
}
void Assembler::jal(Label* target) {
uint64_t imm = jump_offset(target);
if (target->is_bound()) {
BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrJump(static_cast<Opcode>(kJalRawMark),
static_cast<uint32_t>(imm >> 2) & kImm26Mask);
BlockTrampolinePoolFor(1); // For associated delay slot.
} else {
jal(imm);
}
// Deprecated. Use PC-relative jumps instead.
UNREACHABLE();
}
void Assembler::jal(int64_t target) {
// Deprecated. Use PC-relative jumps instead.
UNREACHABLE();
}
......@@ -1862,13 +1852,6 @@ void Assembler::jr(Register rs) {
}
void Assembler::jal(int64_t target) {
BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrJump(JAL, static_cast<uint32_t>(target >> 2) & kImm26Mask);
BlockTrampolinePoolFor(1); // For associated delay slot.
}
void Assembler::jalr(Register rs, Register rd) {
DCHECK(rs.code() != rd.code());
BlockTrampolinePoolScope block_trampoline_pool(this);
......
......@@ -820,16 +820,17 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Never use the int16_t b(l)cond version with a branch offset
// instead of using the Label* version.
// Jump targets must be in the current 256 MB-aligned region. i.e. 28 bits.
void j(int64_t target);
void jal(int64_t target);
void j(Label* target);
void jal(Label* target);
void jalr(Register rs, Register rd = ra);
void jr(Register target);
void jic(Register rt, int16_t offset);
void jialc(Register rt, int16_t offset);
// Following instructions are deprecated and require 256 MB
// code alignment. Use PC-relative instructions instead.
void j(int64_t target);
void jal(int64_t target);
void j(Label* target);
void jal(Label* target);
// -------Data-processing-instructions---------
......
......@@ -1177,19 +1177,6 @@ TEST(Type3) {
COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767",
32767);
int64_t pc_region;
GET_PC_REGION(pc_region);
int64_t target = pc_region | 0x4;
COMPARE_PC_JUMP(j(target), "08000001 j ", target);
target = pc_region | 0xFFFFFFC;
COMPARE_PC_JUMP(j(target), "0bffffff j ", target);
target = pc_region | 0x4;
COMPARE_PC_JUMP(jal(target), "0c000001 jal ", target);
target = pc_region | 0xFFFFFFC;
COMPARE_PC_JUMP(jal(target), "0fffffff jal ", target);
VERIFY_RUN();
}
......
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