Flattening large atomic objects inside frozen arrays

Piotr Tarsa piotr.tarsa at gmail.com
Fri Apr 7 20:31:08 UTC 2023


Hi,

In thread "B3, default values, and implicit initialization"
https://mail.openjdk.org/pipermail/valhalla-spec-observers/2023-March/002206.html
there are following statements about optimizations related to value
classes:

> Framed this way, the Valhalla performance story simplifies to:
>  - Give up identity, get flattening on the stack;
>  - Further give up explicit initialization, get flattening for small objects on the heap;
>  - Further give up atomicity, get flattening for larger objects on the heap.

The optimizations are all driven by definition site attributes of a
class (whether it is an identity class, has optional constructor, is
atomic, etc - according to current terminology at least), so there is
no flexibility at use site.

There could be a possibility to enable flattening optimizations at use
site too. "JEP draft: Frozen Arrays (Preview)"
https://openjdk.org/jeps/8261007 describes frozen arrays which are
immutable (and can't be unfrozen i.e. made mutable), so they could
safely hold large flattened objects, even if they aren't marked as
atomic at class definition site. As for examples, that JEP already
mentions some situations where frozen arrays could help, so a subset
of that situations could possibly benefit further from enhanced
flattening of large objects.

Regards,
Piotr


More information about the valhalla-spec-comments mailing list