Value array flattening in L-world

John Rose john.r.rose at
Sat Feb 24 07:21:56 UTC 2018

On Feb 23, 2018, at 5:22 AM, forax at wrote:
> Playing with the MVT, i've develop a bytecode rewriter [1] that takes bytecode with L and insert Q if the class is tagged with the annotation @ValueCapableClass,
> so basically it's like writing the code in the R-world and having the bytecode rewritten to making it live in the MVT world. 
> One thing that surprise me first, is that it was hard to write the same code that work in the R-word and in the MVT world,
> the main offender is the behavior of array that are initialized with null in the R-world and a default value in the MVT world,
> i believe that if we want to support that a R-class can be changed to a Q-class, we have to have null to default value conversion in both direction when loading/storing array element.

Can I see some code examples of places where the two conversions
(unbox null to default, box default to null) seem to be needed?

If they really are needed, maybe there are only a few edge cases,
where javac can put in explicit casts (a la MethodHandles.explicitCast*)
where values come into and out of arrays of unknown flatness.

> The other solution i can see is to dynamically tranform an array of value type to an array of reference type when null is stored in it, a kind of buffering of the whole array by buffering all elements in it.

That's contradicts the goal of Valhalla, since it adds an extra indirection
to value arrays.  We are flattening them, so we can't deepen them.

— John

More information about the valhalla-dev mailing list