RFR: 8276789: Support C++ lambda in ResourceHashtable::iterate

Ioi Lam iklam at openjdk.java.net
Tue May 17 23:47:16 UTC 2022


On Tue, 17 May 2022 23:37:52 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> I added two new template functions to reduce the boilerplate code when walking the entries in a ResourceHashtable
> 
> - `template<typename F> void ResourceHashtable::iterate(F f)`
> - `template<typename F> void ResourceHashtable::iterate_all(F f)`
> 
> I also modified a couple of places in systemDictionaryShared.cpp to use the new functionality.
> 
> Testing with tiers 1-4.

GCC 10.3.0 generates identical code for the following before and after this PR. So there should be no impact with existing code that uses the old style iterator.


class MyIter : StackObj {
public:
  int _count;
  MyIter() : _count(0) {}
  bool do_entry(InstanceKlass* k, DumpTimeClassInfo& info) {
    _count ++;
    return true; // keep on iterating
  }
};

int doit(DumpTimeSharedClassTable* dumptime_table) {
  MyIter myiter;
  dumptime_table->iterate(&myiter);
  return myiter._count;
}

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

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


More information about the hotspot-dev mailing list