Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8230482

Initial support for empty inline classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • hotspot
    • 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.

            fparain Frederic Parain
            fparain Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: