We have code that uses ResourceHashtable as a HashSet. E.g., in the following code, the bool value is always ignored. We just need to check if the oop key is in the table
https://github.com/openjdk/jdk/blob/6e248279cfb44cf6a1b5156a41200bf9c166388f/src/hotspot/share/cds/heapShared.hpp#L323-L327
typedef ResourceHashtable<oop, bool,
15889, // prime number
ResourceObj::C_HEAP,
mtClassShared,
HeapShared::oop_hash> SeenObjectsTable;
ResourceHashtable should be refactored to also support HashSet operations, where the value is not used.
This is more space efficient. It also makes the code faster and clearer when the key type has complex behavior inside its constructor/destructor.
https://github.com/openjdk/jdk/blob/6e248279cfb44cf6a1b5156a41200bf9c166388f/src/hotspot/share/cds/heapShared.hpp#L323-L327
typedef ResourceHashtable<oop, bool,
15889, // prime number
ResourceObj::C_HEAP,
mtClassShared,
HeapShared::oop_hash> SeenObjectsTable;
ResourceHashtable should be refactored to also support HashSet operations, where the value is not used.
This is more space efficient. It also makes the code faster and clearer when the key type has complex behavior inside its constructor/destructor.