[lworld] RFR: 8352647: [lworld] Remove larval InlineTypeNode in Unsafe intrinsics [v2]
Jatin Bhateja
jbhateja at openjdk.org
Sun Mar 30 08:02:40 UTC 2025
On Sun, 30 Mar 2025 07:33:59 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> > Exactly, MEET b/w two reference type results in a type which is LCA of both, and in the worst case it could be j.l.o
>
> No, it is wrong, from the verification type system, the highest reference type in the type hierarchy is `reference`, which comprises `java.lang.Object` and larval objects (`uninitialized`). Larval objects have their types being subtypes of `uninitialized` and non-larval objects have their types being subtypes of `java.lang.Object`. These 2 are separate under the bytecode verifier.
Bytecode verification should be same for larval and non-larval objects, you are mixing explicit and implicit larval here which is where the confusion arises.
MEET operation semantics are in accordance with semantics defined in following logic https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/opto/type.cpp#L4734
With UNSAFE we explicit transition the value to a mutable state and thus need to handle them at merge point if it meets a non-larval value.
Let's think through this and address it as your larger fix for https://github.com/openjdk/valhalla/pull/1405
>> Crashing is an acceptable outcome when you are dealing with Unsafe. Using Unsafe means you are lying to the VM about the >> actual thing you are doing and have to rely on your own verification to make sure the program is valid. If the program using >> Unsafe is invalid (e.g. writing arbitrary value to a reference field), there is nothing the VM can do.
Crash occurs at the state merge point. If you run following test with C1 compiler it works fine. So we need to address this crash in C2 compiler.
https://github.com/user-attachments/files/19501609/unsafe_access.txt
CPROMPT>java --enable-preview --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED -XX:TieredStopAtLevel=3 -cp . unsafe_access
10001399990
For now I am ok with your fix, please also emit the IR to set larval bit in mark word during allocation expansion.
-------------
PR Comment: https://git.openjdk.org/valhalla/pull/1406#issuecomment-2764438050
More information about the valhalla-dev
mailing list