RFR: 8310844: [AArch64] C1 compilation fails because monitor offset in OSR buffer is too large for immediate

Andrew Haley aph at openjdk.org
Thu Jan 4 14:11:25 UTC 2024


On Thu, 4 Jan 2024 12:39:18 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

> [JDK-8287349](https://bugs.openjdk.org/browse/JDK-8287349) changed the code in `LIR_Assembler::osr_entry()` to use a single `ldp` instruction instead of two `ldr` instructions to load the monitor lock and object from the OSR state. This is not correct because the `ldp` instruction only supports a [7-bit signed immediate value](https://developer.arm.com/documentation/den0024/a/The-A64-instruction-set/Memory-access-instructions/Accessing-multiple-memory-locations). If the offset is larger, for example due to a large number of locals as in `TestLargeMonitorOffset::test`, we hit the `Field too big for insn` guarantee.
> 
> I suggest to revert [JDK-8287349](https://bugs.openjdk.org/browse/JDK-8287349). 
> 
> I also found two unrelated bugs when working on the reproducer: [JDK-8322992](https://bugs.openjdk.org/browse/JDK-8322992) (javac) and [JDK-8322996](https://bugs.openjdk.org/browse/JDK-8322996) (C2).
> 
> Thanks,
> Tobias

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp line 289:

> 287:       __ ldr(r19, Address(OSR_buf, slot_offset + 1*BytesPerWord));
> 288:       __ str(r19, frame_map()->address_for_monitor_object(i));
> 289:     }

The macro assembler automagically fuses `ldr` pairs. It'd be better to fix this with:


--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
@@ -282,7 +282,8 @@ void LIR_Assembler::osr_entry() {
         __ bind(L);
       }
 #endif
-      __ ldp(r19, r20, Address(OSR_buf, slot_offset));
+      __ ldr(r19, Address(OSR_buf, slot_offset));
+      __ ldr(r20, Address(OSR_buf, slot_offset + BytesPerWord));
       __ str(r19, frame_map()->address_for_monitor_lock(i));
       __ str(r20, frame_map()->address_for_monitor_object(i));
     }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17266#discussion_r1441789599


More information about the hotspot-compiler-dev mailing list