From 775f07e67190dc848cf4e466673090311d168015 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 11 Mar 2026 16:37:46 +0000 Subject: [PATCH] 8379435: More proposed cleanups for JDK-8373595 A new ObjectMonitorTable implementation Reviewed-by: coleenp, fbredberg --- .../share/runtime/objectMonitorTable.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/runtime/objectMonitorTable.cpp b/src/hotspot/share/runtime/objectMonitorTable.cpp index 1b79d1bf1c4..bc173992d7a 100644 --- a/src/hotspot/share/runtime/objectMonitorTable.cpp +++ b/src/hotspot/share/runtime/objectMonitorTable.cpp @@ -69,7 +69,7 @@ // allocate a new table (twice as large as the old one), and then copy all the // old monitor pointers from the old table to the new. // -// But since the OMT is a concurrent hash table and things needs to work for +// But since the OMT is a concurrent hash table and things need to work for // other clients of the OMT while we grow it, it gets a bit more // complicated. // @@ -125,7 +125,7 @@ class ObjectMonitorTable::Table : public CHeapObj { DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0); const size_t _capacity_mask; // One less than its power-of-two capacity - Atomic _prev; // Set while rehashing + Atomic _prev; // Set while growing/rebuilding Atomic* _buckets; // The payload DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(_capacity_mask) + sizeof(_prev) + sizeof(_buckets)); Atomic _items_count; @@ -251,8 +251,8 @@ public: assert(index != start_index, "invariant"); } - // Rehashing could have started by now, but if a monitor has been inserted in a - // newer table, it was inserted after the get linearization point. + // Rebuilding could have started by now, but if a monitor has been inserted + // in a newer table, it was inserted after the get linearization point. return nullptr; } @@ -278,7 +278,7 @@ public: // To avoid concurrent inserts succeeding, place a tombstone here. Entry result = bucket.compare_exchange(entry, tombstone(), memory_order_relaxed); if (result == entry) { - // Success! Nobody will try to insert here again, except reinsert from rehashing. + // Success! Nobody will try to insert here again, except reinsert from rebuilding. return nullptr; } entry = result; @@ -333,11 +333,11 @@ public: dec_items_count(); entry = result; } else { - // Out of allowance; leaving place for rehashing to succeed. + // Out of allowance; leave space for rebuilding to succeed. // To avoid concurrent inserts succeeding, place a tombstone here. Entry result = bucket.compare_exchange(entry, tombstone(), memory_order_acq_rel); if (result == entry) { - // Success; nobody will try to insert here again, except reinsert from rehashing. + // Success; nobody will try to insert here again, except reinsert from rebuilding. return nullptr; } entry = result; @@ -558,7 +558,7 @@ ObjectMonitorTable::Table* ObjectMonitorTable::grow_table(Table* curr) { } } - // Somebody else started rehashing; restart in new table. + // Somebody else started rebuilding; restart in their new table. delete new_table; return result; @@ -591,7 +591,7 @@ void ObjectMonitorTable::remove_monitor_entry(ObjectMonitor* monitor) { assert(monitor_get(obj) != monitor, "should have been removed"); } -// Before handshake; rehash and unlink tables. +// Before handshake; rebuild and unlink tables. void ObjectMonitorTable::rebuild(GrowableArray* delete_list) { Table* new_table; { @@ -629,7 +629,7 @@ void ObjectMonitorTable::rebuild(GrowableArray* delete_list) { new_table = new Table(new_capacity, curr); Table* result = _curr.compare_exchange(curr, new_table, memory_order_acq_rel); if (result != curr) { - // Somebody else racingly started rehashing. Delete the + // Somebody else racingly started rebuilding. Delete the // new_table and treat somebody else's table as the new one. delete new_table; new_table = result;