RFR: 8238174: migrate ObjectMonitor::_owner field away from C++ volatile semantics

David Holmes dholmes at openjdk.java.net
Wed Nov 18 01:56:10 UTC 2020


On Tue, 17 Nov 2020 22:44:11 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

> Drop volatile from the ObjectMonitor::_owner field. Update all naked
> field loads to use the new owner_raw() accessor or the existing
> owner_is_DEFLATER_MARKER() accessor.

Looks good!
One nit and one suggestion for your consideration.
Thanks,
David

src/hotspot/share/runtime/objectMonitor.inline.hpp line 58:

> 56: // Returns NULL if DEFLATER_MARKER is observed.
> 57: inline void* ObjectMonitor::owner() const {
> 58:   void* owner = owner_raw();

There is an inconsistency with `owner()` and `owner_is_DEFLATER_MARKER()` where one delegates to `owner_raw()` and the other repeats the `Atomic::load(&_owner)`. They should both do the same thing - probably better to use `owner_raw()`.

src/hotspot/share/runtime/objectMonitor.inline.hpp line 34:

> 32: 
> 33: inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
> 34:   if (THREAD == owner_raw() || THREAD->is_lock_owned((address) owner_raw())) {

Suggestion: add a local to avoid two calls to `owner_raw()`.

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

Marked as reviewed by dholmes (Reviewer).

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


More information about the hotspot-runtime-dev mailing list