ArrayStoreException: bug or expected behavior?

Michael Hoffer info at michaelhoffer.de
Fri Jul 26 12:09:34 UTC 2019


> It does not translate Point2D to Point2D? but simply allocates the inline type on the Java heap and
> stores a reference to it in the interface array.

That’s good news. So there are no conversion costs involved.

> If you are referring to the memory layout of a flattened array Point2D[] then yes, these are not
> available with your interface array.

Makes sense.

> Other than memory layout, one of the biggest optimization opportunities for inline types is that
> they can always be scalarized by the just in time compiler (i.e. passed in registers or on the stack).

Thanks. That helps a lot!

Regards,
Michael

--
Dr. Michael Hoffer

Web:    mihosoft.eu
Twitter: @mihosoft

Goethe-Zentrum für Wissenschaftliches Rechnen (G-CSC)
Goethe-Universität
Kettenhofweg 139
60325 Frankfurt am Main
phone: +49 69 798 25254
info at michaelhoffer.de

> Am 26.07.2019 um 13:54 schrieb Tobias Hartmann <tobias.hartmann at oracle.com>:
> 
> On 26.07.19 13:32, Michael Hoffer wrote:
>> A follow-up question: the following code automatically translates Point2D into Point2D?. Is this
>> assumption correct?
> 
> It does not translate Point2D to Point2D? but simply allocates the inline type on the Java heap and
> stores a reference to it in the interface array.
> 
>> Does this mean that the reduction in required memory and the cache optimal
>> layout are lost in this case?
> 
> If you are referring to the memory layout of a flattened array Point2D[] then yes, these are not
> available with your interface array.
> 
> In memory terms, this creates an array of pointers:
> 
>>         Point2DI[] points = new Point2DI[n];
> 
> And the following loop stores pointers to Point2D into that array:
> 
>>         for(int i = 0; i < points.length;i++) {
>>             points[i] = new Point2D(i, i);
>>         }
> 
> Other than memory layout, one of the biggest optimization opportunities for inline types is that
> they can always be scalarized by the just in time compiler (i.e. passed in registers or on the stack).
> 
> Hope that helps.
> 
> Best regards,
> Tobias




More information about the valhalla-dev mailing list