-
Notifications
You must be signed in to change notification settings - Fork 728
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
Adjust arguments to Unsafe array operations while offheap is enabled #17969
Conversation
5912785
to
b090261
Compare
@zl-wang @VermaSh @vijaysun-omr @0xdaryl here is the fix for the UnsafeAPI issue! |
@midronij Thank you for working on this! Also, can you please add a commit to remove checks which were added to disable unsafe array operations for off heap. You can find those checks in [1-2]. [1] openj9/offHeapMemoryCommitAndDecommitFinal_combined_without_new_macro |
Does this fix |
b090261
to
5582097
Compare
@VermaSh I've added reversions of the following commits that are no longer necessary with the changes included in this PR: With these additions as well at the latest offheap changes, everything still works as expected: the IL trees include the array check and adjusted base address pointer/offset, and the UnsafeArrayGetTests are passing on all platforms. However, this contribution does not deal with |
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.
Just a few minor suggestions. Also, here's the GC/VM PR these changes depend on #14667
5582097
to
ecb1b69
Compare
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 will read more to comment further next week
7173054
to
5ee9b9c
Compare
@zl-wang I have finished addressing your review suggestions. As well, I have provided some examples of what the post-inlining IL trees will look like with my changes here. Please let me know if there is anything else I should address with these additions. Assuming everything looks good, I believe we are waiting on the following before we can merge this PR:
If there is anything that I've missed or that I'm mistaken about, please let me know! |
Works for the other Unsafe methods (if they are inlined in gencon ... this is certainly the condition) had better put up in a separate PR. I supposed merging this PR has no effect on running none-offheap policies. i.e. it is relatively safe to merge. every existing logics (for none-offheap) are still honoured. Comments on the first example IL: |
for the other two examples, i am wondering why we still generated the lowTag and class.class tests? are they necessary? at least, you should check against the ILs generated for gencon. maybe, they are needed for some reasons not welknown. |
the better question is: if there is an example without any checks? there must be |
For openj9/runtime/compiler/optimizer/InlinerTempForJ9.cpp Lines 1032 to 1102 in d3388e1
I'm not sure if there's a particular reason for that, or if it's simply because prior to my changes, we never actually checked if the object class was known at compile time. |
5ee9b9c
to
aca4d01
Compare
ffca738
to
7d492af
Compare
591c96e
to
016adea
Compare
016adea
to
cb75ed3
Compare
c687107
to
8ecd372
Compare
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 still need to review the changes to the code that calls genCodeForUnsafeGetPut
, but I wanted to pass along my review comments thus far.
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.
Most of my comments are pretty minor. Even the one about duplicated blocks might not need to be addressed, or if it does, it might be that it could be handled in a follow on change. . . .
a9a1c48
to
5608dae
Compare
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 think the changes look good. Just a couple of minor comments on some comments in the code.
Also, the Line endings check failed. May I ask you to take a look at that?
Finally, I had a few comments on the commit comments.
- Looking at the description of commit e7441f2, it states that it's reverting commit 58efdd7 - but looking at the two, it looks like the new commit is only reverting part of the x86 changes of that old commit. May I ask you to update the commit comment to describe the change more explicitly?
- For commit 5608dae, per the OpenJ9 Commit Guidelines, may I ask you to add a first line to the commit comment summarizing the commit?
- In the comment for commit 3a6a63f, a few of the lines are longer than 72 characters.
One more late comment: there is a block of comments before |
When Unsafe.get()/put() is called on an array and offheap changes are enabled, adjust arguments so that dataAddr is passed in as base address of object Signed-off-by: midronij <[email protected]>
When Unsafe.compareAndSwap() is called on an array and offheap changes are enabled, adjust arguments so that dataAddr is passed in as base address of object Signed-off-by: midronij <[email protected]>
When the type of the object being passed in to Unsafe.get()/put() is known at compile time, rather than generate runtime type checks, skip to determining and generating the appropriate access block. There are two cases in which we can do this: 1.) If the object is known to be an array, only generate the arrayDirectAccessBlock and directAccessBlock (in case NULLCHK fails). 2.) If the object is known to be non-array, non-java/lang/Class, and non-java/lang/Object, only generate the directAccessBlock. Signed-off-by: midronij <[email protected]>
For Unsafe.compareAndSwap(), do not generate array check IL or adjusted array access block if object type is known at compile time. Signed-off-by: midronij <[email protected]>
When offheap is enabled and the type of the object being operated on is unknown, there are three possible cases that need to be accounted for regarding the type of the object being operated on for Unsafe.get()/put(): 1.) array object 2.) java/lang/Class object 3.) none of the above Since case (3) is the most likely, we want the block corresponding to this case (directAccessBlock) to be on the fallthrough path. Signed-off-by: midronij <[email protected]>
Add comments and update existing documentation/explanations to reflect changes made to inlining of Unsafe.get()/put() and compareAndSwap() to accommodate cases where offheap allocation is enabled. Signed-off-by: midronij <[email protected]>
@hzongaro thank you for all of your feedback! I've made updates to address your most recent wave of suggested changes to both the comments in the code and the commit descriptions. Regarding the following:
Upon further inspection, I found that this commit was actually cancelled out by the very next one, 16af941, so I simply dropped both of them. If everything looks good, then I think we can move on to testing and merging! @zl-wang when you have a moment could you please get the CI tests started? |
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.
Looks good. Thanks!
Jenkins test sanity xlinux,aix jdk8,jdk21 |
Reverted as the suspected cause of #19947 I did a little internal testing on xmac with the change reverted and didn't see the failure. I'll go ahead with the revert and the builds tonight will confirm the failures are no longer seen. |
In this contribution, the following adjustments have been made to the arguments that are passed in to Unsafe.get(), Unsafe.put(), and Unsafe.compareAndSwap() when offheap/balanced GC policy is in use:
The array header size is subtracted from the offsetno longer necessary due to this change: Array base offset zero #19326
This is to account for the differing array shape under offheap/balanced GC policy as opposed to the default (gencon).
In addition, as a performance improvement for both the offheap and gencon cases, when the object type is known at compile time, we can eliminate unnecessary lowtag, class, and array checks that are currently performed at runtime for the following cases:
Depends on #18303