RFR: 8325467: Support methods with many arguments in C2 [v17]

Daniel Lundén dlunden at openjdk.org
Wed Apr 23 12:36:59 UTC 2025


On Tue, 22 Apr 2025 17:09:13 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Daniel Lundén has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Refactor and improve TestNestedSynchronize.java
>
> src/hotspot/share/opto/chaitin.cpp line 1648:
> 
>> 1646:     // If we fail to color and the AllStack flag is set, trigger
>> 1647:     // a chunk-rollover event
>> 1648:     if (!OptoReg::is_valid(reg) && is_allstack) {
> 
> Control question: here we seem to have passed `-chunk`. And we used to check `chunk != 0` in lots of places. What was the significance to negative chunk? Did you think about that?

Yes, I've considered this at length! Keeping track of all these `chunk` additions and subtractions as we did previously would have been infeasible with my changes, as the chunk size becomes dynamic (rather than statically known). I therefore opted to move all the "chunk" logic internally in the register mask data structure. That's all the offset stuff that you've likely seen already in `regmask.hpp`.

Originally for `OptoReg`s in `Select`, we had to keep track of in which "space" the register was in: the space offset by `chunk` or the non-offset space. The non-offset space is what we needed if we actually wanted to index the register mask, but it is not always the "real" space (as the register mask may represent a `chunk`-offsetted view of the register space). If you look in `find_first_set` and `find_first_elem`, you see that they return `OptoReg::Bad` to indicate that a chunk change is needed. However, in `bias_color`, we returned these values added together with `chunk`. That's why we needed to apply `-chunk` at the location you refer to, to figure out if the actual value returned was `OptoReg::Bad` 😅.

After my changes, all references to `OptoReg`s in `Select` (and methods called from there) are to the real, offsetted space (i.e., the actual registers). Indexing register masks with these registers is now handled internally in register masks, so we do not require any external chunk arithmetic.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20404#discussion_r2055950302


More information about the hotspot-compiler-dev mailing list