RFR: 8275874: [JVMCI] use volatile accessors for aligned reads in c2v_readFieldValue

Aleksey Shipilev shade at openjdk.java.net
Tue Oct 26 08:48:14 UTC 2021


On Mon, 25 Oct 2021 14:33:27 GMT, Doug Simon <dnsimon at openjdk.org> wrote:

> [JDK-8275645](https://bugs.openjdk.java.net/browse/JDK-8275645) resulted in loosing single-copy atomicity for reads in `c2v_readFieldValue`. This PR fixes that by using `<type>_field_acquire` accessors for all aligned reads and only using `<type>_field` accessors for unaligned reads.

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](https://bugs.openjdk.java.net/browse/JDK-8275645?focusedCommentId=14454416&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14454416) 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](https://github.com/openjdk/jdk/blob/3ff085e2967508ad312c9d32fa908807aefe69ee/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp#L1952-L1953), verifying that volatile accesses should always be aligned.

-------------

Changes requested by shade (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6109


More information about the hotspot-compiler-dev mailing list