Skip to content

Commit 1e270ea

Browse files
author
Andrew Haley
committed
8290780: AArch64: Crash in c2 nmethod running RunThese30M.java
Reviewed-by: dlong
1 parent b17269a commit 1e270ea

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,12 @@ class Patcher : public RelocActions {
310310
ptrdiff_t offset = target - insn_addr;
311311
instructions = 2;
312312
precond(inner != nullptr);
313-
uintptr_t dest = (uintptr_t)target;
313+
// Give the inner reloc a chance to modify the target.
314+
address adjusted_target = target;
315+
instructions = (*inner)(insn_addr, adjusted_target);
314316
uintptr_t pc_page = (uintptr_t)insn_addr >> 12;
315-
uintptr_t adr_page = (uintptr_t)target >> 12;
317+
uintptr_t adr_page = (uintptr_t)adjusted_target >> 12;
316318
offset = adr_page - pc_page;
317-
instructions = (*inner)(insn_addr, target);
318-
// Now we extract the lower 21 bits of the signed offset field for
319-
// the ADRP.
320-
offset = offset << (64-21) >> (64-21);
321319
int offset_lo = offset & 3;
322320
offset >>= 2;
323321
Instruction_aarch64::spatch(insn_addr, 23, 5, offset);
@@ -340,8 +338,10 @@ class Patcher : public RelocActions {
340338
return 2;
341339
}
342340
static int adrpMovk_impl(address insn_addr, address &target) {
343-
uintptr_t dest = (uintptr_t)target;
341+
uintptr_t dest = uintptr_t(target);
344342
Instruction_aarch64::patch(insn_addr + sizeof (uint32_t), 20, 5, (uintptr_t)target >> 32);
343+
dest = (dest & 0xffffffffULL) | (uintptr_t(insn_addr) & 0xffff00000000ULL);
344+
target = address(dest);
345345
return 2;
346346
}
347347
virtual int immediate(address insn_addr, address &target) {
@@ -457,7 +457,7 @@ class Decoder : public RelocActions {
457457
static int adrpMovk_impl(address insn_addr, address &target) {
458458
uint32_t insn2 = insn_at(insn_addr, 1);
459459
uint64_t dest = uint64_t(target);
460-
dest = (dest & 0xffffffff) |
460+
dest = (dest & 0xffff0000ffffffff) |
461461
((uint64_t)Instruction_aarch64::extract(insn2, 20, 5) << 32);
462462
target = address(dest);
463463

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6949,22 +6949,6 @@ class StubGenerator: public StubCodeGenerator {
69496949

69506950
__ leave();
69516951

6952-
#ifdef ASSERT
6953-
{
6954-
// Stress relocs for adrp() by trying to reach a page beyond
6955-
// the range of a simple ADRP instruction.
6956-
ExternalAddress longWayAway(__ pc() - (1ll << 34));
6957-
if (! __ is_valid_AArch64_address(longWayAway.target())) {
6958-
longWayAway = ExternalAddress(__ pc() + (1ll << 34));
6959-
}
6960-
if (__ is_valid_AArch64_address(longWayAway.target())) {
6961-
uint64_t offset;
6962-
__ adrp(rscratch1, longWayAway, offset);
6963-
__ add(rscratch1, rscratch1, offset);
6964-
}
6965-
}
6966-
#endif // ASSERT
6967-
69686952
// check for pending exceptions
69696953
#ifdef ASSERT
69706954
Label L;

0 commit comments

Comments
 (0)