Skip to content
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

Allow Value Propagation to transform an array store if the value assigned is known not to be a value type #13403

Merged
merged 5 commits into from
Nov 11, 2021

Conversation

hzongaro
Copy link
Member

If the value stored in a call to jitStoreFlattenableArrayElement is known not to be a value type, the call can be transformed by Value Propagation to inline IL for an ordinary array store even if the component type of the array is not known not to be a value type. That's because, if the component type of the array actually is a value type, the ArrayStoreCHK added as part of the array element store sequence would throw an ArrayStoreException - there is no need to deal with a potential store to a flattened value type array element.

The one special case that needs to be handled in the inline IL that's generated is the case where the value that is being stored could be a null reference. The prototype support for value types does not permit a null reference to be stored into an element of a value type array, and ArrayStoreCHK never throws an exception if the value is a null reference. A call to a non-helper symbol, <nonNullableArrayNullStoreCheck>, is added to the IL to handle that case. During the Tree Lowering optimization, the call to that non-helepr is expanded to IL that will throw a NullPointerException if the value is a null reference and the component type of the array is a value type.

Some older prototype code in Tree Lowering that overloaded ArrayStoreCHK to do this special handling to check for a null reference is now redundant, and removed.

Delivering these changes on behalf of Annabelle Huo @a7ehuo and myself.

@hzongaro hzongaro added comp:jit perf project:valhalla Used to track Project Valhalla related work labels Aug 27, 2021
@hzongaro hzongaro marked this pull request as draft August 27, 2021 13:20
@hzongaro
Copy link
Member Author

Marking this as a draft, as the definition of the <nonNullableArrayNullStoreCheck> symbol in OMR hasn't made it to openj9-omr yet.

Although I've marked it as a draft, I don't expect the content of the pull request to change, so it's reasonable review whenever you have time, Vijay @vijaysun-omr and Daryl @0xdaryl.

@hzongaro hzongaro marked this pull request as ready for review September 1, 2021 14:25
@hzongaro
Copy link
Member Author

hzongaro commented Sep 1, 2021

Marking as ready-for-review now that OMR pull request #6139 has been merged into OpenJ9-OMR.

@vijaysun-omr
Copy link
Contributor

I'd also appreciate a review from @jdmpapin on this PR.

@vijaysun-omr
Copy link
Contributor

jenkins test sanity all jdk17,jdk11

@hzongaro
Copy link
Member Author

I forgot this change hasn't been merged. Devin @jdmpapin, have you had a chance to review this?

Copy link
Contributor

@jdmpapin jdmpapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one (I think) important comment about the non-null constraint condition, and my other comments are pretty minor

I left in a couple of comments that were addressed in the next commit just to show my thought process reading each commit in turn. IMO series should generally be structured to avoid introducing and then fixing a problem. Just pointing it out - not that you necessarily need to revise this series for that

runtime/compiler/optimizer/TreeLowering.cpp Show resolved Hide resolved
runtime/compiler/optimizer/TreeLowering.cpp Show resolved Hide resolved
runtime/compiler/optimizer/TreeLowering.cpp Show resolved Hide resolved
runtime/compiler/optimizer/TreeLowering.cpp Outdated Show resolved Hide resolved
runtime/compiler/optimizer/TreeLowering.cpp Outdated Show resolved Hide resolved
runtime/compiler/optimizer/J9ValuePropagation.cpp Outdated Show resolved Hide resolved
@hzongaro
Copy link
Member Author

Thanks for reviewing, Devin @jdmpapin. I've pushed commits e70d3eb23bba7b842ac81bf859799b8c380ee443 and 04f40a818c05a06187c94bbc2ed6e5e5f627af4d with the necessary changes.

Copy link
Contributor

@jdmpapin jdmpapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please don't forget to squash the review feedback commits

hzongaro and others added 5 commits October 29, 2021 11:17
Define a new method to find or create a symbol reference for a non-
helper method that will be used to check whether an array is a
value-types array, and if so, whether a null value is being stored
to one of its elements.  If so, a NullPointerException will be
thrown.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
If a value that is to be stored to an array element via a call to the
jitStoreFlattenableArrayElement helper is not a value type, value
propagation can transform it to use inline code.  If the array has a
value type as its component type, an ArrayStoreCheckException or a
NullPointerException will result, so there is no need to use the helper
to handle the possibility of a flattenable array.

The test is represented in the IL with a call to the
nonNullableArrayStoreNullCheck non-helper, which is expanded in the
Tree Lowering optimization into an actual test of the whether the
component type of the array is a value type guarding a NULLCHK of
the value.

This renders obsolete prototype code that overloaded the ArrayStoreCHK
opcode to perform this additional checking, so logic Tree Lowering for
ArrayStoreCHK is also removed.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
When generating inline IL for nonNullableArrayNullStoreCheck in the Tree
Lowering optimization, rather than checking whether the component type
of an array is a value type and then checking whether the value being
stored is null, it should typically be faster to check first whether the
value is null.  That avoids the double indirection to access the class
flags of the component type if the value that's being assigned is non-
null.

Also added missing edges to CFG for branches around NULLCHK.

Authored-by: Annabelle Huo <Annabelle.Huo@ibm.com>
Co-authored-by: Henry Zongaro <zongaro@ca.ibm.com>

Signed-off-by: Henry Zongaro <zongaro@ca.ibm.com>
If Value Propagation or Tree Lowering generate BNDCHK or ArrayStoreCHK
operations, the alias sets for the checking symbol reference might not
have been constructed.  Mark alias sets as invalid so they can be
rebuilt if they are needed after those optimizations.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
When Value Propagation determines that a call to
<jitStoreFlattenableArrayElement> can be transformed due to constraints
associated with the value that is being stored, it should determine
whether the value is known to be non-null by checking the constraint
associated with the value rather than calling isNonNull() on the node.

Signed-off-by:  Henry Zongaro <zongaro@ca.ibm.com>
@hzongaro
Copy link
Member Author

Please don't forget to squash the review feedback commits

Thanks! Squashed less interesting commits.

@hzongaro
Copy link
Member Author

hzongaro commented Nov 4, 2021

Vijay @vijaysun-omr, I just wanted to check whether we're OK to move forward on this one.

@vijaysun-omr
Copy link
Contributor

Yes I am fine with this series of commits now.

@jdmpapin jdmpapin self-assigned this Nov 8, 2021
@jdmpapin
Copy link
Contributor

jdmpapin commented Nov 8, 2021

Jenkins test sanity xlinuxval,xlinuxvalst jdk17

@jdmpapin
Copy link
Contributor

jdmpapin commented Nov 8, 2021

Jenkins test sanity xlinuxval,xlinuxvalst jdknext

@jdmpapin
Copy link
Contributor

jdmpapin commented Nov 8, 2021

Jenkins test sanity all jdk17

@jdmpapin
Copy link
Contributor

jdmpapin commented Nov 9, 2021

@0xdaryl, would you mind taking a look since your review was requested above?

@jdmpapin jdmpapin merged commit c4bbd37 into eclipse-openj9:master Nov 11, 2021
@hzongaro hzongaro deleted the check-aastore-value-is-VT-PR branch December 2, 2021 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jit perf project:valhalla Used to track Project Valhalla related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants