-
Notifications
You must be signed in to change notification settings - Fork 737
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
Add null/array checks for OffHeap NotStaticField atomic case #20889
Conversation
* n96n lload <temp slot 3> | ||
* n97n iload <temp slot 4> | ||
*/ | ||
// Create another helper call that loads from ramStatics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least, this example seemed contradictory to the setting of isNotStaticField
(i.e. definitely true
if it is an atomic call ... this example is under isNotStaticField
being false
). overdoing something here? plus, it sounded like an existing bug for gencon anyway? (previously, it needs to handle ramStatics too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part is moved not added, I guess its confusing given that the other code between the if-condition and that comment have moved out to a shared path. But the comment only talks about the subsequent section of code.
https://github.com/eclipse-openj9/openj9/blob/v0.49.0-release/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp#L774-L808
I'll try to clean-up the code more making it less-confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comments, ready for review
i still had impression i reviewed @midronij fix for off-heap in this very area ... i think it was merged. could it be in omr side instead? remember she worked on fixing |
@zl-wang I believe this is the PR you're referring to: #20333 Maybe Abdul can confirm if this is the case, but from what I can tell at least, I think the issue is that my changes linked above only take effect when
So in the case where it is known at compile time that the object is NOT a static field (i.e.: However, offheap adds a third case: if the object is a non-NULL array, then |
Yes, the issue is with It seems that it wasn't an issue as |
Updated a bunch of comments for better understanding. |
To explain a bit, the code generates the necessary check blocks, then inserts and connects these blocks together. In the generating checks section, under In the connecting blocks case, it was only for |
yes | ||
isObjectNull [A] ------------------------------------------> | ||
| | | ||
| no | | ||
#if OffHeap | | ||
| yes | | ||
isArray [I] ------------------------> | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I supposed array-class(es) don't have associated static fields. otherwise, it seems possible that isArray & isLowTagged are true at the same time? then, this scheme might not work. i.e. this scheme assumes: when isArray is true, isLowTagged cannot be true. the assumption is reasonable to me, you had better double-check to be sure with @tajila
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments look good!
In general, it seems like the way this is handled is very similar to Unsafe.get()
and Unsafe.put()
(performing a NULL test, array test, and then lowtag test at runtime to determine how the dst/src address should be calculated), so unless there is some key difference between those and Unsafe.getAndAdd()
, I think it should be safe to assume that isLowTagged and isArray can't be true at the same time. But as Julian said, Tobi is probably the best person to answer that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jenkins test sanity aix,plinux,xlinux,zlinux jdk8,jdk23 |
When current code transforms an atomic call from the
java/util/concurrent/atomic/
package into an intrinsic, it skips generating the static check given that it's known to not be a static field being accessed (flagged byisNotStaticField
). But with OffHeap a null and array checks are still required to check if loading thedataAddrPtr
is necessary for correct address calculation.Current code adds the OffHeap checks except for
java/util/concurrent/atomic/
calls which was fine in some JDK levels as it uses VarHandles but for JDK8 it still usesprocessUnsafeAtomicCall()
and without the OffHeap check its targeting the wrong address.This PR adds inserting the OffHeap null and array checks to the
isNotStaticField
case.I tried sharing some code between the case with and without
isNotStaticField
but some are copied over as it would need a larger re-write ofprocessUnsafeAtomicCall()
Explanation of the code change: