RFR: 8322853: Should use ConditionalMutexLocker in NativeHeapTrimmerThread::print_state
David Holmes
dholmes at openjdk.org
Wed Jan 3 06:33:46 UTC 2024
On Wed, 3 Jan 2024 03:34:11 GMT, Denghui Dong <ddong at openjdk.org> wrote:
> Regarding _stop, I think the compiler can optimize out the second if branch(L127) if _stop is not volatile.
No it actually can't. The compiler is either ignorant of what `wait` does and so must assume it could modify `_stop` or it understands what `wait` (transitively) does and so finds a compiler barrier in the platform mutex code. Either way `_stop` must be re-loaded from memory. Otherwise all variables used in relation to "condition variables" would have to be declared `volatile`.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17226#issuecomment-1874905224
More information about the hotspot-runtime-dev
mailing list