RFR: 8284816: Make markWord::has_monitor() more robust
Daniel D.Daugherty
dcubed at openjdk.java.net
Wed Apr 13 15:02:14 UTC 2022
On Wed, 13 Apr 2022 09:59:49 GMT, Roman Kennke <rkennke at openjdk.org> wrote:
> Currently, markWord::has_monitor() is implemented like this:
>
> ` return ((value() & monitor_value) != 0);`
>
> monitor value is `0b10`. This means that it also reports marked or forwarded objects (`0b11`) as having a monitor, which is wrong. As far as I can tell, it does not cause any problems because relevant code is either not affected by marked/forwarded objects, or by testing bits in an order that hides the problem.
>
> I suggest to test the bits properly to make it more robust and avoid potenial future bugs.
>
> Testing:
> - [x] tier1
> - [ ] tier2
> - [ ] tier3
Changes requested by dcubed (Reviewer).
src/hotspot/share/oops/markWord.hpp line 179:
> 177: }
> 178: bool has_monitor() const {
> 179: return ((value() & lock_mask_in_place) == monitor_value);
So I'm a bit confused:
src/hotspot/share/oops/markWord.hpp:
`static const uintptr_t monitor_value = 2;`
In the bug report you say:
> monitor value is 0b10
but that not what I'm seeing. What am I missing?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8219
More information about the hotspot-dev
mailing list