eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.23k stars 711 forks source link

Remove Q type checks in Valhalla code #18157

Open hangshao0 opened 9 months ago

hangshao0 commented 9 months ago

Currently many places in the VM rely on Q type check for the null-restricted value type. The Q type is going to be removed in the future. L type will be used for all value types, no matter it is null-restricted or not. For the fields, the Q type is going to be replaced with null-restricted attribute,

Also the keyword "primitive" is going to be removed.

The null restricted fields will be treated the same as Q type fields. For now, we need to add null-restricted attribute checks into the places where we are doing Q type field checks. After javac is updated, we can remove the Q type checks completely.

Some of our testing code is generating Q types and using "primitive", they need to be updated as well.

hangshao0 commented 9 months ago

Also the keyword "primitive" is going to be removed.

When "primitive" is removed, J9ROMCLASS_IS_PRIMITIVE_VALUE_TYPE() will always be false. With the new javac, we can use J9ROMCLASS_IS_VALUE() instead.

Since only null-restricted field can be potentially flattened, we can add a check of null restricted field (J9FieldFlagIsNullRestricted) in J9_IS_FIELD_FLATTENED().

dmitripivkine commented 9 months ago

I am not sure right away, but I can check what is used by GC for recognition of VT "leaf object" (does not introduce new object references). We are going to need the way to make "leaf object" detection for VT objects in order to have GC optimization running.

hangshao0 commented 9 months ago

Also the keyword "primitive" is going to be removed.

When "primitive" is removed, J9ROMCLASS_IS_PRIMITIVE_VALUE_TYPE() will always be false. With the new javac, we can use J9ROMCLASS_IS_VALUE() instead.

Not sure about the "_we can use J9ROMCLASS_ISVALUE() instead" part. There is a ACC_NON_ATOMIC flag introduced in the ImplicitCreation Attribute, do you know if that is introduced to the replace "primitive" keyword ? @TobiAjila

theresa-m commented 8 months ago

Before removing Q type checks I'm modifying existing Valhalla functional tests to be compatible as much as possible with the lw5 compiler.

edit: tests in src_lw5 compile with the latest version of lw5. Additional vm support is needed for them to pass.

No changes are needed for these files, they will remain in src:

These tests have been split into src_qtypes and src_lw5 and compile with lw5 commit dc715159feda32945d5c2351ede9c6be04a64d6f:

theresa-m commented 5 months ago

This is a new list of some of the vm tasks to be done once javac is updated for null restricted types. Aside from removing qtype and primitive references we will also need to:

Edit: given that q is removed in the current javac and null restricted support is not yet there tests in src_qtypes have been updated and no longer have dependencies on q.

This pr can be closed once all references to q and primitive are removed.

theresa-m commented 2 days ago

https://github.com/eclipse-openj9/openj9/pull/19799 will remove all remaining uses of 'q' and 'qtype' from OpenJ9. @a7ehuo is going to look at removing any q references from OMR.

The next step to close out this issue will be removing references to the old primitive flag for value types.

a7ehuo commented 2 days ago

@a7ehuo is going to look at removing any q references from OMR.

Opened https://github.com/eclipse/omr/pull/7399