RFR: 8351655: Optimize ObjectMonitor::unlink_after_acquire()

Patricio Chilano Mateo pchilanomate at openjdk.org
Wed Mar 19 22:33:07 UTC 2025


On Mon, 17 Mar 2025 13:11:58 GMT, Fredrik Bredberg <fbredberg at openjdk.org> wrote:

> This PR implements an optimization of `ObjectMonitor::unlink_after_acquire()`. If it's possible it only converts the first part (the singly linked part) of the `entry_list` into a doubly linked list and leave the _entry_list_tail pointer untouched. 
> 
> It has passed tier1-tier8 tests.

Thanks for taking care of this follow up. Looks good to me, just minor comments.

src/hotspot/share/runtime/objectMonitor.cpp line 1265:

> 1263: // entry_list head after the entry_list was last converted into a
> 1264: // doubly linked list.
> 1265: void ObjectMonitor::entry_list_build_dll(JavaThread* current) {

We only call this from unlink_after_acquire() and exit() when we know the list is not empty, so why not assert that here and remove case 1?

src/hotspot/share/runtime/objectMonitor.cpp line 1284:

> 1282:     // We converted the entire entry_list from a singly linked list
> 1283:     // into a doubly linked list. Now we just need to set the tail
> 1284:     // pointer.

This could also be the empty list case so comment could be improved to separate those two cases. No need to change it if we assert list can’t be empty at the beginning.

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

PR Review: https://git.openjdk.org/jdk/pull/24078#pullrequestreview-2700420778
PR Review Comment: https://git.openjdk.org/jdk/pull/24078#discussion_r2004401490
PR Review Comment: https://git.openjdk.org/jdk/pull/24078#discussion_r2004406052


More information about the hotspot-runtime-dev mailing list