RFR: 8276789: Support C++ lambda in ResourceHashtable::iterate [v4]

Ioi Lam iklam at openjdk.java.net
Tue May 24 16:21:10 UTC 2022


On Tue, 24 May 2022 12:33:59 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   some clean up suggested by @stefank
>
> src/hotspot/share/utilities/resourceHash.hpp line 210:
> 
>> 208:     };
>> 209:     iterate(function);
>> 210:   }
> 
> Do you still have any usages of this? I'm a bit surprised that the compiler don't complain about not being able to disambiguate calls to this vs the new lambda enabled function.

This is still needed as there are many places that use the old style iteration. Also, when the body of the iteration is complex, it might be more readable to do it as a separate class. E.g., here in systemDictionaryShared.cpp:


    UnregisteredClassesDuplicationChecker dup_checker;
    _dumptime_table->iterate(&dup_checker);


I think there's no ambiguity because `iter->do_entry()` cannot be substituted with the other template, and `function(node->_key, node->_value)` in the other template cannot be substituted here. So by SFINAE the C++ compiler can pick the correct template.

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

PR: https://git.openjdk.java.net/jdk/pull/8761


More information about the hotspot-dev mailing list