-
Notifications
You must be signed in to change notification settings - Fork 143
8368274: [lworld] Unsafe.compareAndExchangeFlatValue() wrongly assumes padding bytes are the same for identical value objects #1734
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
base: lworld
Are you sure you want to change the base?
Conversation
|
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
|
@liach This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 4 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
…/unsafe-flat-cas
…/unsafe-flat-cas
Webrevs
|
| // compareAndExchange to flattened field in object, non-inline arguments to compare and set | ||
| @Test | ||
| public Object test70(Object expected, Object x) { | ||
| return U.compareAndExchangeFlatValue(this, TEST63_VT_OFFSET, 4, SmallValue.class, expected, x); |
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.
Aren't existing tests using compareAndExchangeFlatValue in test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java sufficient? If not, I'd suggest adding your test case there.
|
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
| } | ||
| } | ||
| Object[] array = newSpecialArray(valueType, 2, layout); | ||
| return compareAndSetFlatValueAsBytes(array, o, offset, layout, valueType, expected, x) ? x : array[0]; |
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.
This method should return array[0] in all cases.
|
@liach Please un-problem list |
…/unsafe-flat-cas
|
Should I keep TestCompareAndExchange any more? I don't know what's the best way to create a C2 test for this. |
|
Thanks. I just discussed with @chhagedorn offline and we think that it's sufficient to have |
|
Ran the VarHandleTestMethodHandleAccessValue test again with no failure. |
| putFlatValue(expectedArray, base, layout, valueType, expected); | ||
| putFlatValue(xArray, base, layout, valueType, x); | ||
|
|
||
| // array 0: witness (to translate to object), 1: x (to translate to raw) |
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.
This comment is hard to read, for a number of reasons:
- it uses 0/1, but then the code uses
base/base + scale(understandably so) - translate to object/translate to raw -- yes,
xstarts off as a value object and we use the array to derive its "raw" representation, whereas witness is always a "raw" value, and stored into the array so we can get it back "as a value". But since this is finicky logic, all this should be spelled out more. - the caller can "capture the witness" -- maybe "observe" the (last) witness would be more correct?
- "we must witness the raw value instead of the value object" -- well, even the old code was witnessing a raw value (of sort) -- the issue is how you compute such a raw value. The fix in this PR is that the raw value is accessed directly from memory (e.g. the content of
oat offsetoffset). E.g. it feels like you are "overloading" what "raw" means -- in some cases you mean "raw == numeric, or !value", in other cases you mean "raw as in -- as accessed from memory"
mcimadamore
left a comment
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 code changes look good (a test would be good tho). I left some comments to try and clarify the docs.
|
I have updated the comment. Please help proofread again. |
Use the raw value get as witness, because the flat value get may ignore garbage value and cause infinite loop as a result. Waiting for a test case.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1734/head:pull/1734$ git checkout pull/1734Update a local copy of the PR:
$ git checkout pull/1734$ git pull https://git.openjdk.org/valhalla.git pull/1734/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1734View PR using the GUI difftool:
$ git pr show -t 1734Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1734.diff
Using Webrev
Link to Webrev Comment