Skip to content

[0.46.0] Inline Class.getComponentType and refactor IL generation to access classDepthAndFlags field of j9Class #19606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

hzongaro
Copy link
Member

@hzongaro hzongaro commented Jun 3, 2024

This change generates inline IL in Value Propagation for references to Class.getComponentType(). That method was previously only inlined if the Class was known at compile-time. If the Class is known to be an array class at compile-time, the generated IL will load the <componentClass> from the j9ArrayClass; otherwise, it will generate a run-time test of whether the Class is an array class before returning the <componentClass> or a null reference.

Calls to Object.getClass() are also marked as non-null during IL generation as that method is known to always return a non-null reference. That exposes opportunities to optimize uses of Class objects that require the reference to be known to be non-null, including inlining calls to Class.getComponentType() in Value Propagation.

Also, there are several places in the JIT compiler that generate IL to access the classDepthAndFlags field of j9class. This introduces methods in TR_J9VMBase to do that, as has previously been done with some methods that generate IL to access the classFlags field.

Finally, this change also deals with some typos in methods that refer to classDepthAndFlags incorrectly as classAndDepthFlags. One instance, J9::SymbolReferenceTable::findOrCreateClassAndDepthFlagsSymbolRef, will remain until its upstream use in J9_PROJECT_SPECIFIC code in OMR is removed in pull request eclipse-omr/omr#7334.

This pull request is a port of pull request #19558 to the v0.46.0-release branch.

hzongaro added 3 commits June 3, 2024 07:22
Several methods in the JIT compiler use the name of the
classDepthAndFlags field of J9Class in their names, but they incorrectly
refer to it as classAndDepthFlags.  This commit corrects the
typographical errors in the naming of those methods, but keeps one
instance that is used upstream in J9_PROJECT_SPECIFIC code in OMR until
that can be removed.
Various places in the compiler need to generate IL to load the
classDepthAndFlags field of j9class.  Those locations need to take into
account whether the target platform is 32-bit or 64-bit, as it affects
the width of the field.  Introducing methods in TR_J9VMBase to load
the field and potentially test the settings of bits in it hides some of
that.
Check for the opportunity to inline calls to Class.getComponentType,
using the underlying j9ArrayClass.  In particular, if the Class is known
to be an array class, the test for the J9AccClassArray flag in the
classDepthAndFlags field can be skipped.

Also, mark Object.getClass() as non-null during IL Generation.  That
prevents a NULLCHK from being being generated for the Class reference in
an expression like o.getClass().getComponentType().  The presence of the
NULLCHK would inhibit this transformation.
@hzongaro hzongaro requested a review from vijaysun-omr June 3, 2024 15:09
@hzongaro hzongaro requested a review from dsouzai as a code owner June 3, 2024 15:09
@hzongaro
Copy link
Member Author

hzongaro commented Jun 3, 2024

@vijaysun-omr, may I ask you to consider this for the 0.46.0 release of OpenJ9?

@vijaysun-omr
Copy link
Contributor

fyi @pshipton. This was delivered in the head stream last week. I won't be able to review this till later in the afternoon at the earliest

@vijaysun-omr
Copy link
Contributor

Reviewed vs what was in the head stream PR last week. Merging.

@vijaysun-omr vijaysun-omr merged commit 747e541 into eclipse-openj9:v0.46.0-release Jun 3, 2024
@hzongaro hzongaro deleted the inline-getComponentType-access-classDepthAndFlags-0.46.0 branch June 3, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants