mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
8287418: riscv: Fix correctness issue of MacroAssembler::movptr
Reviewed-by: fjiang, yadongwang, fyang
This commit is contained in:
parent
a27ba1a3db
commit
447ae00616
5 changed files with 20 additions and 19 deletions
|
@ -1181,12 +1181,12 @@ static int patch_offset_in_pc_relative(address branch, int64_t offset) {
|
|||
|
||||
static int patch_addr_in_movptr(address branch, address target) {
|
||||
const int MOVPTR_INSTRUCTIONS_NUM = 6; // lui + addi + slli + addi + slli + addi/jalr/load
|
||||
int32_t lower = ((intptr_t)target << 36) >> 36;
|
||||
int64_t upper = ((intptr_t)target - lower) >> 28;
|
||||
Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[47:28] + target[27] ==> branch[31:12]
|
||||
Assembler::patch(branch + 4, 31, 20, (lower >> 16) & 0xfff); // Addi. target[27:16] ==> branch[31:20]
|
||||
Assembler::patch(branch + 12, 31, 20, (lower >> 5) & 0x7ff); // Addi. target[15: 5] ==> branch[31:20]
|
||||
Assembler::patch(branch + 20, 31, 20, lower & 0x1f); // Addi/Jalr/Load. target[ 4: 0] ==> branch[31:20]
|
||||
int32_t lower = ((intptr_t)target << 35) >> 35;
|
||||
int64_t upper = ((intptr_t)target - lower) >> 29;
|
||||
Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[48:29] + target[28] ==> branch[31:12]
|
||||
Assembler::patch(branch + 4, 31, 20, (lower >> 17) & 0xfff); // Addi. target[28:17] ==> branch[31:20]
|
||||
Assembler::patch(branch + 12, 31, 20, (lower >> 6) & 0x7ff); // Addi. target[16: 6] ==> branch[31:20]
|
||||
Assembler::patch(branch + 20, 31, 20, lower & 0x3f); // Addi/Jalr/Load. target[ 5: 0] ==> branch[31:20]
|
||||
return MOVPTR_INSTRUCTIONS_NUM * NativeInstruction::instruction_size;
|
||||
}
|
||||
|
||||
|
@ -1258,9 +1258,9 @@ static long get_offset_of_pc_relative(address insn_addr) {
|
|||
|
||||
static address get_target_of_movptr(address insn_addr) {
|
||||
assert_cond(insn_addr != NULL);
|
||||
intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 28; // Lui.
|
||||
target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 16; // Addi.
|
||||
target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 5; // Addi.
|
||||
intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 29; // Lui.
|
||||
target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 17; // Addi.
|
||||
target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 6; // Addi.
|
||||
target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)); // Addi/Jalr/Load.
|
||||
return (address) target_address;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue