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

Xin Liu xliu at openjdk.org
Fri Jan 27 17:36:17 UTC 2023


On Fri, 27 Jan 2023 13:46:31 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> src/hotspot/share/utilities/resourceHash.hpp line 282:
>> 
>>> 280:   template<class ITER>
>>> 281:   void unlink(ITER* iter) {
>>> 282:     auto wrapper = [&](Node* const node, Node**& ptr) {
>> 
>> I wanted unlink to be lambda enabled, not an unlink_impl.  Can you just make unlink_all be something that provides a "return true" lambda and call unlink with that?
>
> Or rather, first have a patch to add  unlink that takes a lambda and convert the uses to that.  I don't see the motivation for this change.

hi, @coleenp 

My primary goal is 'unlink_all()'. I can create a Simple Iterator and use unlink() to implement that, but it would be sub-optimal(eg. [jvmtiTagMapTable::clear](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/prims/jvmtiTagMapTable.cpp#L71)). When I roll it, I just realize that there are common logic among unlink(), unlink_all() and dtor. 'unlink_impl' is a template. It's not an API here. 

We can provide a lambda version of 'unlink()' in a new JBS issue, but I don't think we need to replace it with unlink(Iter*) completely. Functor and Lambda have different advantages. Functor is more formal and can be stateful. eg. 
`PurgeUnloadedConstraints` is big and deserve indents and comments. 'ResolutionErrorDeleteIterate' captures 'ConstantPool* p' for do_entry(). Can we do this is a separate JBS?

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

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


More information about the hotspot-dev mailing list