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

Daniel D. Daugherty dcubed at openjdk.org
Wed Jan 31 15:00:04 UTC 2024


On Wed, 31 Jan 2024 13:21:13 GMT, Richard Reingruber <rrich at openjdk.org> wrote:

>> Axel Boldt-Christmas has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   More restrictive API
>
> `ObjectMonitor::enter(JavaThread* current)` is called near the end of `ObjectSynchronizer::enter()` like this: `monitor->enter(locking_thread)`. Here also the name `current` is not correct because `locking_thread` may be different from the current thread if nested locking was eliminated and the lock got inflated.
> 
> I see 2 solutions currently:
> 
> 1. Rename the parameter from `current` to `locking_thread` and assert before contention is handled that `locking_thread` is the current thread. You could introduce a local variable `JavaThread* current` to reduce the necessary changes.
> 2. Introduce a dedicated new method (`relock_for` or `enter_for`?) to fixup the state of the ObjectMonitor to be called from `Deoptimization::relock_objects`. It would assert that the ObjectMonitor isn't locked by another thread than `locking_thread`, set it as owner, and increment `_recursions` if necessary.
> 
> At the moment I'd favor 1.
> With 2. one would like also copy and adapt `ObjectSynchronizer::enter()`. Maybe that would be cleaner.
> 
> Thanks again Richard.

@reinrich -
> It is my impression that you hardly ever take the time that is necessary to look at the code and think about it before commenting.

@dholmes-ora is one of the most careful and thorough reviewers of code on this project.

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

PR Comment: https://git.openjdk.org/jdk/pull/17626#issuecomment-1919273675


More information about the hotspot-dev mailing list