RFR: 8301136: Improve unlink() and unlink_all() of ResourceHashtableBase [v2]

Ioi Lam iklam at openjdk.org
Thu Jan 26 17:25:17 UTC 2023


On Thu, 26 Jan 2023 17:14:42 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> 1. Apply the same idea of JDK-8300184 to unlink().
>> 2. Because ResourceHashtableBase doesn't support copy constructor and copy assignment, client of it has to purge all elements first. We would like provide a specialized version called 'unlink_all()'. 
>> We don't need to update each node's _next in this case. We only nullify all buckets. We also use unlink_all() in destructor. Despite this isn't the optimal code for a destructor, we reduce maintenance cost.
>
> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Quit early if cnt is zero.

Changes requested by iklam (Reviewer).

src/hotspot/share/utilities/resourceHash.hpp line 282:

> 280: 
> 281:     while (_number_of_entries > 0 && bucket < bucket_at(sz)) {
> 282:       Node* node = *bucket;

Instead of having two loops for unlinking, I would suggest using the same pattern as iterate/iterate_all so you can share the same loop for the different APIs. This will also allow you to use C++ Lambda for unlinking.

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

PR: https://git.openjdk.org/jdk/pull/12213


More information about the hotspot-dev mailing list