RFR: 8269004 Implement ResizableResourceHashtable [v2]

Kim Barrett kbarrett at openjdk.java.net
Wed Jun 30 13:04:02 UTC 2021


On Tue, 29 Jun 2021 03:48:12 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> src/hotspot/share/utilities/resourceHash.hpp line 38:
>> 
>>> 36:     MEMFLAGS MEM_TYPE
>>> 37:     >
>>> 38: class ResourceHashtableBase : public ResourceObj {
>> 
>> Rather than a CRTP base class, I think it might be simpler to have a base class that has a type template parameter that provides the sizing/resizing policy. That type might be used either to specify the type of a new member or even a further base class (to benefit from EBO in the size-is-constant case). The derived class constructor would call the base class constructor with a policy object as an argument.
>
> Per Kim's suggestion, I moved the storage management code to two base classes: FixedResourceHashtableStorage and ResizeableResourceHashtableStorage. 
> 
> Now the `ResourceHashtable::_table[]` is in-line allocated (same as as before this PR). I checked with gcc and it generates identical code as before this PR.

It's kind of unfortunate / confusing that ResourceHashtableBase has two "incompatible" constructors as a result of factoring out the storage, but otherwise I like this.  One consequence is that the two derived types actually need to be classes with different constructors, and can't just be type aliases of the base.

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

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


More information about the hotspot-dev mailing list