[lworld] RFR: 8352647: [lworld] Remove larval InlineTypeNode in Unsafe intrinsics
Jatin Bhateja
jbhateja at openjdk.org
Sun Mar 30 07:19:17 UTC 2025
On Sun, 30 Mar 2025 02:57:54 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> > Yes, I agree, this should be seen on the lines of a primitive (value) meeting an identity object (boxes),
>
> I think you are misunderstanding, the type `reference` here refers to a verification type that represents the most general reference type, it is even higher than `java.lang.Object`. From the JVMS:
>
> ```
> Verification type hierarchy:
>
> top
> ____________/____________
> / \
> / \
> oneWord twoWord
> / | \ / \
> / | \ / \
> int float reference long double <--- meeting of a larval value and a non-larval value results in the `reference` type here
> / \
> / _____________
> / \
> / \
> uninitialized +------------------+ <--- larval objects have their verification type being `uninitialized`
> / \ | Java reference | <--- `java.lang.Object` and its subclasses are here
> / \ | type hierarchy |
> uninitializedThis uninitialized(Offset) +------------------+
> |
> |
> null
> ```
>
> > Thus, here at merge point, MyValue should be buffered, since this is MEETing a larval value so new oop (Phi) should be larval, similar to following
>
> Note that this implicit boxing and unboxing only happens at the language level, `javac` will automatically translate `ret = genInt(val)` into `ret = Integer.valueOf(genInt(val))`. So, at the VM level, we do not ever encounter a meet of a `java.lang.Integer` and an `int`. As a result, C2 does not have to take auto boxing and unboxing into consideration.
Exactly, MEET b/w two reference type results in a type which is LCA of both, and in the worst cast it could be j.l.o
Here, we are dealing with larval and non-larval values, which are different representations of same value type instance.
Our discussion context is around the VM model as language semantics are clear on make/finishPrivate buffer semantics.
In the above example, I drew an analogy b/w boxes as larval values VS primitives as value type instances.
public static Point micro(int val) throws Exception {
Point p = new Point(val, val + 10);
if (val > 50000) {
p = UNSAFE.makePrivateBuffer(p);
UNSAFE.putInt(p, UNSAFE.objectFieldOffset(Point.class.getDeclaredField("f1")), val + 10);
}
last_hash = p.hashCode();
if (val > 50000) {
p = UNSAFE.finishPrivateBuffer(p);
}
return p;
}
>> "Merging a larval object and a non-larval object is undefined behaviour, and crashing should be an acceptable outcome then. "
Please mention your strategy to handle the above case and what you mean by crash as an acceptable outcome.
We can think through this as address this as a larger fix in PR 1405, for now I am ok with you fix and if can checkin the test and add it to ProblemList.txt
-------------
PR Comment: https://git.openjdk.org/valhalla/pull/1406#issuecomment-2764424519
More information about the valhalla-dev
mailing list