[lworld] RFR: 8352647: [lworld] Remove larval InlineTypeNode in Unsafe intrinsics [v2]

Jatin Bhateja jbhateja at openjdk.org
Sun Mar 30 22:31:43 UTC 2025


On Sun, 30 Mar 2025 13:49:31 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   comments, set and unset larval bit
>
> Not asking to address in this patch, but what if we return a larval value to caller ? i.e. value returned by makePrivateBuffer is returned from a method since the return type will still be a concrete value type; hence, the caller will expect to receive the arguments in scalarized form. 
> https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/opto/graphKit.cpp#L2009

> @jatin-bhateja FYI the default value of a value class is created in a previous round of experiment when we have to construct a value object with `aconst_init` and `withfield`. With the introduction of larval objects the notion of default value is no longer necessary and is in progress of removal (#1389). Additionally, all objects value or not are created at the bytecode `new` with their default value and they are still `uninitialized`.
> 
With the new scheme, we no longer use the factory constructor, and construction is aligned with the identity instance.
[@ImplicitlyConstructible](https://github.com/openjdk/valhalla/blob/lworld/src/java.base/share/classes/jdk/internal/vm/annotation/ImplicitlyConstructible.java#L31) annotations can still be used to enforces default value initialization 

Refer to the following comment in instanceKlass.hpp

  // Query if this class can be implicitly constructed, meaning the VM is allowed
  // to create instances without calling a constructor
  // Applies to inline classes and their super types

https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/oops/instanceKlass.hpp#L423

Just noticed that https://github.com/openjdk/valhalla/pull/1389 is in draft state.

> > Not asking to address in this patch, but what if we return a larval value to the caller?
> 
> `uninitialized` is not a valid operand for `areturn` so a normal larval object cannot be returned from a method. As a result, returning an object created by `Unsafe::makePrivateBuffer` should also not allowed to be returned without invoking `Unsafe::finishPrivateBuffer` first.

We need to enforce these semantics in C2,  I feel that a better place to document these is https://bugs.openjdk.org/browse/JDK-8046159

All execution engines must then adhere to clearly spelled semantics.

Similar to "areturn" ,  comparing uninitialized values using "acmp" is also undefined.

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

PR Comment: https://git.openjdk.org/valhalla/pull/1406#issuecomment-2764776433


More information about the valhalla-dev mailing list