RFR: 8345067: C2: enable implicit null checks for ZGC reads [v5]

Andrew Haley aph at openjdk.org
Sat May 17 09:06:54 UTC 2025


On Fri, 16 May 2025 14:59:18 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

>> src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad line 131:
>> 
>>> 129:              !MacroAssembler::legitimize_address_requires_lea(ref_addr, size),
>>> 130:              "an instruction that can be used for implicit null checking should emit the candidate memory access first");
>>> 131:       ref_addr = __ legitimize_address(ref_addr, size, rscratch2);
>> 
>> I just saw this. I think it might be simpler and better to handle this case in the segfault handler.
>
> OK. C2 does not currently support creating exception table entries with arbitrary offsets relative to the start address of the code emitted for a Mach node, so that support would have to be added. I prototyped this support [here](https://github.com/openjdk/jdk/compare/master...robcasloz:jdk:JDK-implicit-null-checks), see calls to `record_exception_pc_offset()`. I don't think it is, overall, simpler than the approach proposed in this PR - definitely not from a `PhaseOutput`/`C2_MacroAssembler` perspective. But if you still think it is worth exploring, I will create a new prototype with the `record_exception_pc_offset()` on top of this PR to make it easier to compare.

I don't think you have to do that. I think you only have to mark both the lea and the memory access with an exception table entry. The segfault handler sees the two entries, deduces that this access is split into two instructions, and does the right thing.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25066#discussion_r2094064464


More information about the hotspot-gc-dev mailing list