-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
None
Support for flattened empty inline classes has been requested by the language team for a while now, but they are still forbidden in the Valhalla implementation. This CR aims to add initial support for empty inline classes, not the most optimized solution.
The proposed approach is to use a single byte as a placeholder for flattened empty fields, because the JVM currently relies on being able to use a field offset as a key to lookup meta-data about this field.
The interpreter has a special handling of flattened empty fields or array elements: it recognizes them and when such empty value is read, it doesn't allocate a new instance (as with other inline classes) but simply returns a reference to the pre-allocated default instance of this empty inline class.
JITs have not been updated yet to avoid the allocation of new instances of empty inline classes, but this should occur rarely (only on de-opt or when calling interpreted code), and it has no impact on the rest of the JVM except a slight increase in Java heap memory consumption.
The proposed approach is to use a single byte as a placeholder for flattened empty fields, because the JVM currently relies on being able to use a field offset as a key to lookup meta-data about this field.
The interpreter has a special handling of flattened empty fields or array elements: it recognizes them and when such empty value is read, it doesn't allocate a new instance (as with other inline classes) but simply returns a reference to the pre-allocated default instance of this empty inline class.
JITs have not been updated yet to avoid the allocation of new instances of empty inline classes, but this should occur rarely (only on de-opt or when calling interpreted code), and it has no impact on the rest of the JVM except a slight increase in Java heap memory consumption.
- relates to
-
JDK-8231344 [lworld] JIT support for empty inline classes
-
- Closed
-