RFR: 8324881: ObjectSynchronizer::inflate(Thread* current...) is invoked for non-current thread [v2]

Axel Boldt-Christmas aboldtch at openjdk.org
Wed Jan 31 07:28:01 UTC 2024


On Wed, 31 Jan 2024 01:30:15 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Maybe this would make more sense to me as Thread* current staying the first parameter, and the second parameter is fast_locking_thread which can be nullptr.
>
> I agree this doesn't quite makes sense to me. `locking_thread` is really `presumed_owner_thread` - we aren't trying to lock here, we are inflating an already locked object, where the passed in thread is the owner.

I very much agree. This stems from the same issue that cause me to type

> `inflate` care about a `locking_thread` is a little unpleasant in my opinion

Inflate in all locking modes has nothing to do with what is inflating. It is just that in LM_LIGHTWEIGHT it is also given the responsibility to fix the owner and the lock stack if the `current` thread is the owner. Because the idea is that modifying the lock stack and moving the owner field from anonymous is only done from the owning thread. This is true everywhere except for re-lock, which is the only place that must enter on behalf of another thread. Which means that it must also inflate, but it must set the correct owner, so it must inflate as if it is inflated from another thread.

`presumed_owner_thread` is not really correct either.

`Inflate` just means create an `ObjectMonitor` if it does not exist and return the `ObjectMonitor*` associated with this object. Regardless if it is locked or not. 

I like the idea of having `inflate_for`, I think the name can be clearer  this is an API that is exclusively needed for LM_LIGHTWEIGHT.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17626#discussion_r1472401232


More information about the hotspot-dev mailing list