--- old/src/hotspot/share/classfile/classListParser.hpp 2018-11-16 19:19:37.256274301 -0800 +++ new/src/hotspot/share/classfile/classListParser.hpp 2018-11-16 19:19:36.992264253 -0800 @@ -28,11 +28,11 @@ #include "utilities/exceptions.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" -#include "utilities/hashtable.hpp" +#include "utilities/hashtable.inline.hpp" -class ID2KlassTable : public KVHashtable { +class ID2KlassTable : public KVHashtable { public: - ID2KlassTable() : KVHashtable(1987) {} + ID2KlassTable() : KVHashtable(1987) {} }; class ClassListParser : public StackObj { --- old/src/hotspot/share/memory/metaspaceClosure.hpp 2018-11-16 19:19:37.776294093 -0800 +++ new/src/hotspot/share/memory/metaspaceClosure.hpp 2018-11-16 19:19:37.508283893 -0800 @@ -29,7 +29,7 @@ #include "memory/allocation.hpp" #include "oops/array.hpp" #include "utilities/growableArray.hpp" -#include "utilities/hashtable.hpp" +#include "utilities/hashtable.inline.hpp" // The metadata hierarchy is separate from the oop hierarchy class MetaspaceObj; // no C++ vtable @@ -267,7 +267,7 @@ UniqueMetaspaceClosure() : _has_been_visited(15889) {} private: - KVHashtable _has_been_visited; + KVHashtable _has_been_visited; }; #endif // SHARE_VM_MEMORY_METASPACE_ITERATOR_HPP --- old/src/hotspot/share/memory/metaspaceShared.cpp 2018-11-16 19:19:38.296313884 -0800 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2018-11-16 19:19:38.032303836 -0800 @@ -64,7 +64,7 @@ #include "utilities/align.hpp" #include "utilities/bitMap.hpp" #include "utilities/defaultStream.hpp" -#include "utilities/hashtable.hpp" +#include "utilities/hashtable.inline.hpp" #if INCLUDE_G1GC #include "gc/g1/g1CollectedHeap.hpp" #endif @@ -1071,8 +1071,7 @@ static DumpAllocStats* _alloc_stats; static SortedSymbolClosure* _ssc; - typedef KVHashtable< - address, address> RelocationTable; + typedef KVHashtable RelocationTable; static RelocationTable* _new_loc_table; public: --- old/src/hotspot/share/utilities/hashtable.cpp 2018-11-16 19:19:38.832334285 -0800 +++ new/src/hotspot/share/utilities/hashtable.cpp 2018-11-16 19:19:38.568324237 -0800 @@ -65,6 +65,7 @@ len = 1 << log2_intptr(len); // round down to power of 2 assert(len >= _entry_size, ""); _first_free_entry = NEW_C_HEAP_ARRAY2(char, len, F, CURRENT_PC); + _entry_blocks->append(_first_free_entry); _end_block = _first_free_entry + len; } entry = (BasicHashtableEntry*)_first_free_entry; --- old/src/hotspot/share/utilities/hashtable.hpp 2018-11-16 19:19:39.352354077 -0800 +++ new/src/hotspot/share/utilities/hashtable.hpp 2018-11-16 19:19:39.088344029 -0800 @@ -29,6 +29,7 @@ #include "oops/oop.hpp" #include "oops/symbol.hpp" #include "runtime/handles.hpp" +#include "utilities/growableArray.hpp" // This is a generic hashtable, designed to be used for the symbol // and string tables. @@ -145,6 +146,7 @@ BasicHashtable(int table_size, int entry_size); BasicHashtable(int table_size, int entry_size, HashtableBucket* buckets, int number_of_entries); + ~BasicHashtable(); // Bucket handling int hash_to_index(unsigned int full_hash) const { @@ -162,6 +164,7 @@ char* _end_block; int _entry_size; volatile int _number_of_entries; + GrowableArray* _entry_blocks; protected: @@ -291,8 +294,7 @@ // A subclass of BasicHashtable that allows you to do a simple K -> V mapping // without using tons of boilerplate code. template< - typename K, typename V, - MEMFLAGS F = mtInternal, + typename K, typename V, MEMFLAGS F, unsigned (*HASH) (K const&) = primitive_hash, bool (*EQUALS)(K const&, K const&) = primitive_equals > --- old/src/hotspot/share/utilities/hashtable.inline.hpp 2018-11-16 19:19:39.872373869 -0800 +++ new/src/hotspot/share/utilities/hashtable.inline.hpp 2018-11-16 19:19:39.604363668 -0800 @@ -54,6 +54,13 @@ _buckets = buckets; } +template inline BasicHashtable::~BasicHashtable() { + for (int i = 0; i < _entry_blocks->length(); i++) { + FREE_C_HEAP_ARRAY(char, _entry_blocks->at(i)); + } + delete _entry_blocks; + free_buckets(); +} template inline void BasicHashtable::initialize(int table_size, int entry_size, int number_of_entries) { @@ -64,6 +71,7 @@ _first_free_entry = NULL; _end_block = NULL; _number_of_entries = number_of_entries; + _entry_blocks = new(ResourceObj::C_HEAP, F) GrowableArray(4, true, F); }