8368274: [lworld] Unsafe.compareAndExchangeFlatValue() wrongly assumes padding bytes are the same for identical value objects#1734
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 no new commits pushed to the ➡️ 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.
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.
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.
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.
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. |
| // caller pass the array so it can capture the witness if needed | ||
| // we must witness the raw value instead of the value object, otherwise | ||
| // garbage value can cause failure | ||
| // We can convert between a value object and a binary value (of suitable size) using array elements. |
|
@liach this pull request can not be integrated into git checkout fix/unsafe-flat-cas
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push |
|
|
||
| # valhalla | ||
| build/CheckFiles.java 8376088 generic-all | ||
| java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessValue.java 8367346 generic-all |
There was a problem hiding this comment.
This PR's bugID is 8368274 while the ProblemList entry's bugID is 8367346.
It looks like JDK-8367346 is closed as a duplicate of JDK-8368274 so all the
accounting is good here, but I wanted to document what we've done.
|
Thanks for the reviews! /integrate |
|
Going to push as commit ccb0ca8. |
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