RFR: 8275874: [JVMCI] use volatile accessors for aligned reads in c2v_readFieldValue
Aleksey Shipilev
shade at openjdk.java.net
Tue Oct 26 09:53:13 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.
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-`volatile`-but-accidentally-misaligned accesses. The code that was removed in the original change (https://github.com/openjdk/jdk/commit/4dec8fc4cc2b1762fba554d0401da8be0d6d1166) looked reasonable: volatile fields are accessed with explicit volatility. If it turns out their offsets are unaligned, this code should throw the error. But with this patch, such a malformed access would just be silently downgraded. I am disliking this part.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6109
More information about the hotspot-compiler-dev
mailing list