--- old/src/hotspot/share/memory/metaspaceShared.cpp 2018-11-16 19:18:37.061983352 -0800 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2018-11-16 19:18:36.793973152 -0800 @@ -64,6 +64,7 @@ #include "utilities/align.hpp" #include "utilities/bitMap.hpp" #include "utilities/defaultStream.hpp" +#include "utilities/hashtable.inline.hpp" #if INCLUDE_G1GC #include "gc/g1/g1CollectedHeap.hpp" #endif @@ -1070,23 +1071,13 @@ static DumpAllocStats* _alloc_stats; static SortedSymbolClosure* _ssc; - static unsigned my_hash(const address& a) { - return primitive_hash
(a); - } - static bool my_equals(const address& a0, const address& a1) { - return primitive_equals
(a0, a1); - } - typedef ResourceHashtable< - address, address, - ArchiveCompactor::my_hash, // solaris compiler doesn't like: primitive_hash
- ArchiveCompactor::my_equals, // solaris compiler doesn't like: primitive_equals
- 16384, ResourceObj::C_HEAP> RelocationTable; + typedef KVHashtable RelocationTable; static RelocationTable* _new_loc_table; public: static void initialize() { _alloc_stats = new(ResourceObj::C_HEAP, mtInternal)DumpAllocStats; - _new_loc_table = new(ResourceObj::C_HEAP, mtInternal)RelocationTable; + _new_loc_table = new RelocationTable(8087); } static DumpAllocStats* alloc_stats() { return _alloc_stats; @@ -1136,15 +1127,17 @@ newtop = _rw_region.top(); } memcpy(p, obj, bytes); - bool isnew = _new_loc_table->put(obj, (address)p); + assert(_new_loc_table->lookup(obj) == NULL, "each object can be relocated at most once"); + _new_loc_table->add(obj, (address)p); log_trace(cds)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(obj), p2i(p), bytes); - assert(isnew, "must be"); - + if (_new_loc_table->maybe_grow()) { + log_info(cds, hashtables)("Expanded _new_loc_table to %d", _new_loc_table->table_size()); + } _alloc_stats->record(ref->msotype(), int(newtop - oldtop), read_only); } static address get_new_loc(MetaspaceClosure::Ref* ref) { - address* pp = _new_loc_table->get(ref->obj()); + address* pp = _new_loc_table->lookup(ref->obj()); assert(pp != NULL, "must be"); return *pp; } @@ -1288,7 +1281,7 @@ static Klass* get_relocated_klass(Klass* orig_klass) { assert(DumpSharedSpaces, "dump time only"); - address* pp = _new_loc_table->get((address)orig_klass); + address* pp = _new_loc_table->lookup((address)orig_klass); assert(pp != NULL, "must be"); Klass* klass = (Klass*)(*pp); assert(klass->is_klass(), "must be");