RFR: 8322996: BoxLockNode creation fails with assert(reg < CHUNK_SIZE) failed: sanity

Daniel Lundén dlunden at openjdk.org
Thu Jan 11 13:51:25 UTC 2024


On Thu, 11 Jan 2024 12:34:28 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

>> This changeset fixes an issue where deeply nested synchronized statements triggered an assert in C2.
>> 
>> Changes:
>> - Bail out on compilation when we create a `BoxLockNode` with a slot index that cannot fit in a `RegMask`. This is similar to how we handle the case when we do not have space to represent arguments in [`opto/matcher.cpp`](https://github.com/openjdk/jdk/blob/58b01dce054c50bcb5a28aad4c1b574acaa90f6d/src/hotspot/share/opto/matcher.cpp#L314-L318)
>> - Add a regression test.
>> 
>> Testing:
>> - [GitHub Actions](https://github.com/dlunde/jdk/actions/runs/7446998688)
>> - tier1, tier2, tier3, tier4, and tier5 on windows-x64, linux-x64, linux-aarch64, macosx-x64, and macosx-aarch64
>
> src/hotspot/share/opto/locknode.cpp line 47:
> 
>> 45:   init_flags(Flag_rematerialize);
>> 46:   OptoReg::Name reg = OptoReg::stack2reg(_slot);
>> 47:   if (!RegMask::can_represent_arg(reg)) {
> 
> I am not very familiar with this code, but would it be possible to use `!RegMask::can_represent(reg)` instead of `!RegMask::can_represent_arg(reg)` here? Or is it necessary to use the latter (which is stricter) for correctness?

That is a fair question, and I'm not sure what is the preferred solution.

The number of stack slots for a monitor seems to be determined by [`sync_stack_slots`](https://github.com/dlunde/jdk/blob/06d6b4be9750a326f87acf04a3dc717e307d14d5/src/hotspot/share/opto/compile.hpp#L1166-L1167). If I'm not mistaken the value of `sync_stack_slots()` varies between platforms (on my machine it is `int Compile::sync_stack_slots() const { return 2; }`). Therefore, I don't think `can_represent` always works. However, we should maybe have a new function `can_represent_sync_entry` (or similar) instead of `can_represent_arg`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17370#discussion_r1448893468


More information about the hotspot-compiler-dev mailing list