[lworld] RFR: 8331964: [lworld] C2: Support abstract value class fields [v4]

Tobias Hartmann thartmann at openjdk.org
Thu Sep 5 11:00:05 UTC 2024


On Thu, 5 Sep 2024 10:52:19 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> This patch adds support for abstract value class fields. To make it work, it required fixes in various places. The two main things to change was to account for fields in abstract value classes when collecting/accessing all fields which was not expected before and updating the way we handle larvals.
>> 
>> ## Updated Larval Handling
>> ### Previous Larval Initialization
>> Before this change, larvals were always updated inside a single concrete value class constructor. It could have been done directly:
>> 
>> new MyValue -> MyValue.<init> (initialization here) -> Object.<init>
>> 
>> or by first delegating to another value type constructor inside the same value class which does the initiliazation:
>> 
>> new MyValue -> MyValue.<init> -> MyValue.<init> (initialization here) -> Object.<init>
>> 
>> It was not possible to distribute the initialization of an inline type to multiple constructors (i.e. at value class constructor cannot do a partial initialization).
>> 
>> Therefore, we could just detect any call from a value class constructor to an abstract constructor or the `Object` constructor with the same receiver and then mark the inline type as non-larval since it's completely initialized before calling the super constructor (abstract classes and `Object.<init>` cannot modify the inline type anymore). The only thing required after the call was to detect if we actually inlined another constructor with the same receiver within the same concrete value class. If that's the case, we need to update the exit map to propagate the initialized receiver to the caller.
>> 
>> This now changes: With fields in abstract value classes, a larval is not completely initialized after the concrete value class constructor is complete. We therefore needed to find a new way to ensure the correct initialization of larvals.
>> 
>> ### New Larval Initialization with Fields in Abstract Classes
>> #### Problems
>> - A larval _could_ be fully initialized after calling the concrete value class constructor. But we could also have a situation where we still need to initialize a field in an abstract value class. Therefore, we cannot eagerly mark an inline type as non-larval once the concrete value class constructor is completed nor when an abstract value class constructor is completed (there could be multiple).
>> - The currently parsed method only has the map/JVM state from the direct caller. We therefore cannot simply detect the call to the `Object.<init>()` call at the end of chained value class construct...
>
> Christian Hagedorn has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix build

That looks good, thanks for the updates!

src/hotspot/share/opto/graphKit.cpp line 1907:

> 1905:       // We always need to buffer inline types when they are escaping. However, we can skip the actual initialization
> 1906:       // of the buffer if the inline type is a larval because we are going to update the buffer anyway which requires
> 1907:       // us to create a one. But there is one special case where we are still required to initialize the buffer: When

Suggestion:

      // us to create a new one. But there is one special case where we are still required to initialize the buffer: When

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

Marked as reviewed by thartmann (Committer).

PR Review: https://git.openjdk.org/valhalla/pull/1236#pullrequestreview-2282574172
PR Review Comment: https://git.openjdk.org/valhalla/pull/1236#discussion_r1745248057


More information about the valhalla-dev mailing list