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
8275874: [JVMCI] only support aligned reads in c2v_readFieldValue #6109
Conversation
|
Webrevs
|
@dougxc This change now passes all automated pre-integration checks. 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 16 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.
|
@shipilev , it would be great if you could review this. |
Isn't the title of this issue expressed incorrectly? |
Yes - thanks for pointing that out. |
/label remove build |
@magicus |
It definitely looks better than the current code, but I think my original concern still stands. If there is a caller code that does the non-aligned volatile access, that caller code is in error, and we should not silently downgrade it to non-aligned non-volatile access, like this patch does.
If I read your previous comments correctly, you mention here that Graal produces such accesses? If so, then Graal is in error, and this code should fail. Instead of waiting for SIGBUS
, though, we should probably reinstate the isVolatile
argument to this method, and add the alignment checks in the pre-check block, verifying that volatile accesses should always be aligned.
In other words, the SIGBUS
that you were getting is the valid failure, indicating the actual problem with the access. What this code needs is to verify the "volatile should be aligned" condition more precisely, and then callers have to fit this requirement.
I'm not so sure. The javadoc for
This implies there's no way someone can ask (in Java) for an unaligned volatile access. How about I clarify the javadoc for the
|
Yes. Note that In other words, if caller asks for volatile access, it should either get the volatile (atomic) access, or get the error if such access is not possible, or do some sort of atomic recovery (probably involves heavy locking, so this is seldom an option). The access handling code should not be allowed to decay bad volatile loads into "good" non-volatile loads to avoid the reasonable hardware exception. Instead, it should explicitly fail on bad accesses, thus communicating to the caller that the requested "volatility" property cannot be satisfied for non-aligned accesses. |
Expanding some more on this. I think expressing "volatility" in terms of "alignment" is a dubious API choice. Mostly because it loses the opportunity to check for explicitly- |
As I read the original change (4dec8fc) more, I am puzzled some more. Apart from fields that carry their |
Indeed, the problem here is not that the hardware is disallowing a volatile read at an unaligned address but that the compiler is being asked to generate a volatile read at an unaligned address. That is a symptom of the calling code either using an invalid layout, or otherwise computing an invalid offset. It's no good trying to fix that symptom because, as Aleksey says, there is no fix that will preserve both volatility and single-copy atomicity. The fix needs to be made to to the root problem i.e. correct whatever code determined that a volatile field could legitimately reside at an unaligned address. |
Thanks for the clarifications @shipilev and @adinn . I think the best thing to do is to constrain |
Thank you, this looks much safer to me. A few minor nits below.
return result.toArray(new Object[result.size()][]); | ||
} | ||
@DataProvider(name = "unalignedPrimitive") | ||
public static Object[][] getUnalingedPrimitiveJavaKinds() { |
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.
public static Object[][] getUnalingedPrimitiveJavaKinds() { | |
public static Object[][] getUnalignedPrimitiveJavaKinds() { |
@@ -37,7 +37,7 @@ | |||
* @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind | |||
* @throws IllegalArgumentException if the read is out of bounds of the object or {@code kind} | |||
* is {@link JavaKind#Void} or not {@linkplain JavaKind#isPrimitive() primitive} | |||
* kind or {@code bits} is not 8, 16, 32 or 64 | |||
* kind or {@code bits} is not 8, 16, 32 or 64 or the read is unaligned |
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.
* kind or {@code bits} is not 8, 16, 32 or 64 or the read is unaligned | |
* kind or {@code bits} is not 8, 16, 32 or 64, or the read is unaligned |
(not sure about this, but feels better with additional comma)
Also, synopsis had once again diverged from the direction this PR is going. |
I've updated the bug and PR description to match the current (final?) direction. I've also fixed the nits - thanks for your detailed eye! |
/integrate |
Going to push as commit 2448b3f.
Your commit was automatically rebased without conflicts. |
JDK-8275645 resulted in loosing single-copy atomicity for reads in
c2v_readFieldValue
. This PR fixes that only doing aligned reads inc2v_readFieldValue
.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6109/head:pull/6109
$ git checkout pull/6109
Update a local copy of the PR:
$ git checkout pull/6109
$ git pull https://git.openjdk.java.net/jdk pull/6109/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6109
View PR using the GUI difftool:
$ git pr show -t 6109
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6109.diff