RFR: 8275874: [JVMCI] use volatile accessors for aligned reads in c2v_readFieldValue
Doug Simon
dnsimon at openjdk.java.net
Tue Oct 26 13:58:11 UTC 2021
On Tue, 26 Oct 2021 10:01:48 GMT, Aleksey Shipilev <shade 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.
>
> As I read the original change (https://github.com/openjdk/jdk/commit/4dec8fc4cc2b1762fba554d0401da8be0d6d1166) more, I am puzzled some more. Apart from fields that carry their `isVolatile` properties, some other things, like constants, were accessed as volatiles unconditionally. Assuming the volatility is indeed needed there, then what this patch does is breaking that property for constants that reside at unfortunate (unaligned) offsets, right? That does not seem correct.
Thanks for the clarifications @shipilev and @adinn .
I think the best thing to do is to constrain `CompilerToVM.readFieldValue` to only support aligned reads, the only use case that really matters. I've just pushed a change that implements and tests this.
Graal already handles attempts to read that violate the sanity checks done by JVMCI.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6109
More information about the hotspot-compiler-dev
mailing list