RFR: 8371418: Methods in AdapterHandlerLibrary use HashtableBase iterate method incorrectly
Ashutosh Mehra
asmehra at openjdk.org
Fri Nov 7 16:15:06 UTC 2025
On Fri, 7 Nov 2025 16:00:35 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
>> The closure passed to `HashTable::iterate` in `AdapterHandlerLibrary::contains` and `AdapterHandlerLibrary::print_handler_on` is returning incorrect value. If the search is successful, it should return false to terminate the iteration, but it is returning true. This patch fixes the return value of these closures.
>> In addition, I noticed `CompactHashTable::iterate` goes through all entries unconditionally, which is not optimal for cases where we may want to terminate the iteration when some condition is met. This is the case in `AdapterHandlerLibrary::contains` and `AdapterHandlerLibrary::print_handler_on` when it iterates over `_aot_adapter_handler_table`. This patch updates `CompactHashTable::iterate` to be the same as `HashTAble::iterate` by using return value of the closure to determine if the iteration should continue or abort. It also adds `CompactHashTable::iterate_all` to iterate all the values unconditionally and the users of `CompactHashTable::iterate` are updated to use `CompactHashTable::iterate_all`.
>
> src/hotspot/share/runtime/sharedRuntime.cpp line 3415:
>
>> 3413: #endif // INCLUDE_CDS
>> 3414: if (!found) {
>> 3415: auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* handler) {
>
> Why do you need to pass `AdapterFingerPrint* key` argument which is not used here?
This is because the `function` passed to `HashTable::iterate` is called with both key and value: https://github.com/openjdk/jdk/blob/c8656449c28581ae9c3d815105e338e42253bb43/src/hotspot/share/utilities/hashTable.hpp#L272
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28197#discussion_r2504370778
More information about the hotspot-dev
mailing list