On Wed, 26 Aug 2026 18:46:24 GMT, Stefan Karlsson <[email protected]> wrote:

>> The interface on oopDesc and the markWord w.r.t. the locking bits have grown 
>> overtime the names do not reflect what they actually do, there are multiple 
>> ways of asking for the same property.
>> 
>> The properties `is_locked` and `is_unlocked` are misleading. As the answer 
>> true of false does not necessarily reflect the locking state of the object. 
>> I suggest we use a single terminology `is_fast_locked` to mean the locking 
>> bits are locked using lightweight non-monitor locking and `is_neutral` to 
>> mean the locking bits are in the prototype state.
>> 
>> Using `is_fast_unlocked` could be an alternative to `is_neutral`, but 
>> `is_neutral` captures the state better of being an object which is currently 
>> not taking part in locking. However the name does not make it obvious that 
>> it is referring to the locking state / mark state. Not 100% on this naming, 
>> and how the comments and code which uses these constants in the 
>> MacroAssembler should name and deal with this.
>> 
>> Also cleaned up the C1 and C2 Valhalla header bits checks which were gated 
>> on the locking bits. There is not more displaced header so conditionally 
>> checking the prototype header in the Klass* is not needed.
>> 
>> Testing (in progress):
>> * Tier 1-5 Oracle supported platforms
>> * GHA
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/hotspot/share/opto/graphKit.cpp line 3926:
> 
>> 3924:   Node* mark_adr = basic_plus_adr(obj, 
>> oopDesc::mark_offset_in_bytes());
>> 3925:   Node* mark = make_load(nullptr, mark_adr, TypeX_X, 
>> TypeX_X->basic_type(), MemNode::unordered);
>> 3926:   if (check_lock && !UseCompactObjectHeaders) {
> 
> I thought we fixed the Valhalla code to check for the object monitor table 
> here.

Maybe this happened in some lworld merge when `UseObjectMonitorTable` was 
removed.

> src/hotspot/share/runtime/synchronizer.cpp line 1789:
> 
>> 1787: 
>> 1788:   markWord mark = object->mark();
>> 1789:   assert(mark.is_fast_locked() || mark.has_monitor(), "must be");
> 
> It's almost like we should have a function named `is_locked()` ...

The reason I do not like that is that locking on a monitor is either in the 
header or in the inflated monitor, which does not belong in `oopDesc`. But I am 
rewriting this to use `ObjectSynchronizer::current_thread_holds_lock` in the 
appropriate place. Also folding in the JNI check into the ObjectSynchronizer 
rather than the callers.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32544#discussion_r3871500201
PR Review Comment: https://git.openjdk.org/jdk/pull/32544#discussion_r3871523019

Reply via email to