8292448: Convert BitMapFragmentTable to ResourceHashtable
Reviewed-by: iklam, rehn
This commit is contained in:
parent
f75da2235a
commit
e230719ad3
@ -278,7 +278,6 @@ template class BasicHashtable<mtCode>;
|
||||
template class BasicHashtable<mtInternal>;
|
||||
template class BasicHashtable<mtModule>;
|
||||
template class BasicHashtable<mtCompiler>;
|
||||
template class BasicHashtable<mtTracing>;
|
||||
template class BasicHashtable<mtServiceability>;
|
||||
template class BasicHashtable<mtLogging>;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "oops/oop.hpp"
|
||||
#include "oops/oopsHierarchy.hpp"
|
||||
#include "utilities/bitMap.hpp"
|
||||
#include "utilities/hashtable.hpp"
|
||||
#include "utilities/resizeableResourceHash.hpp"
|
||||
|
||||
class MemRegion;
|
||||
|
||||
@ -47,37 +47,13 @@ class ObjectBitSet : public CHeapObj<F> {
|
||||
|
||||
class BitMapFragment;
|
||||
|
||||
class BitMapFragmentTable : public BasicHashtable<F> {
|
||||
class Entry : public BasicHashtableEntry<F> {
|
||||
public:
|
||||
uintptr_t _key;
|
||||
CHeapBitMap* _value;
|
||||
static unsigned hash_segment(const uintptr_t& key) {
|
||||
unsigned hash = (unsigned)key;
|
||||
return hash ^ (hash >> 3);
|
||||
}
|
||||
|
||||
Entry* next() {
|
||||
return (Entry*)BasicHashtableEntry<F>::next();
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
Entry* bucket(int i) const;
|
||||
|
||||
Entry* new_entry(unsigned int hashValue, uintptr_t key, CHeapBitMap* value);
|
||||
|
||||
unsigned hash_segment(uintptr_t key) {
|
||||
unsigned hash = (unsigned)key;
|
||||
return hash ^ (hash >> 3);
|
||||
}
|
||||
|
||||
unsigned hash_to_index(unsigned hash) {
|
||||
return hash & (BasicHashtable<F>::table_size() - 1);
|
||||
}
|
||||
|
||||
public:
|
||||
BitMapFragmentTable(int table_size) : BasicHashtable<F>(table_size, sizeof(Entry)) {}
|
||||
~BitMapFragmentTable();
|
||||
void add(uintptr_t key, CHeapBitMap* value);
|
||||
CHeapBitMap** lookup(uintptr_t key);
|
||||
};
|
||||
typedef ResizeableResourceHashtable<uintptr_t, CHeapBitMap*, ResourceObj::C_HEAP, F,
|
||||
hash_segment> BitMapFragmentTable;
|
||||
|
||||
CHeapBitMap* get_fragment_bits(uintptr_t addr);
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "memory/memRegion.hpp"
|
||||
#include "utilities/bitMap.inline.hpp"
|
||||
#include "utilities/hashtable.inline.hpp"
|
||||
|
||||
template<MEMFLAGS F>
|
||||
ObjectBitSet<F>::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next) :
|
||||
@ -39,7 +38,7 @@ ObjectBitSet<F>::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragmen
|
||||
|
||||
template<MEMFLAGS F>
|
||||
ObjectBitSet<F>::ObjectBitSet() :
|
||||
_bitmap_fragments(32),
|
||||
_bitmap_fragments(32, 8*K),
|
||||
_fragment_list(NULL),
|
||||
_last_fragment_bits(NULL),
|
||||
_last_fragment_granule(UINTPTR_MAX) {
|
||||
@ -53,52 +52,8 @@ ObjectBitSet<F>::~ObjectBitSet() {
|
||||
delete current;
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
ObjectBitSet<F>::BitMapFragmentTable::~BitMapFragmentTable() {
|
||||
for (int index = 0; index < BasicHashtable<F>::table_size(); index ++) {
|
||||
Entry* e = bucket(index);
|
||||
while (e != nullptr) {
|
||||
Entry* tmp = e;
|
||||
e = e->next();
|
||||
BasicHashtable<F>::free_entry(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
inline typename ObjectBitSet<F>::BitMapFragmentTable::Entry* ObjectBitSet<F>::BitMapFragmentTable::bucket(int i) const {
|
||||
return (Entry*)BasicHashtable<F>::bucket(i);
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
inline typename ObjectBitSet<F>::BitMapFragmentTable::Entry*
|
||||
ObjectBitSet<F>::BitMapFragmentTable::new_entry(unsigned int hash, uintptr_t key, CHeapBitMap* value) {
|
||||
|
||||
Entry* entry = (Entry*)BasicHashtable<F>::new_entry(hash);
|
||||
entry->_key = key;
|
||||
entry->_value = value;
|
||||
return entry;
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
inline void ObjectBitSet<F>::BitMapFragmentTable::add(uintptr_t key, CHeapBitMap* value) {
|
||||
unsigned hash = hash_segment(key);
|
||||
Entry* entry = new_entry(hash, key, value);
|
||||
BasicHashtable<F>::add_entry(hash_to_index(hash), entry);
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
inline CHeapBitMap** ObjectBitSet<F>::BitMapFragmentTable::lookup(uintptr_t key) {
|
||||
unsigned hash = hash_segment(key);
|
||||
int index = hash_to_index(hash);
|
||||
for (Entry* e = bucket(index); e != NULL; e = e->next()) {
|
||||
if (e->hash() == hash && e->_key == key) {
|
||||
return &(e->_value);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
// destructors for ResourceHashtable base deletes nodes, and
|
||||
// ResizeableResourceHashtableStorage deletes the table.
|
||||
}
|
||||
|
||||
template<MEMFLAGS F>
|
||||
@ -114,17 +69,15 @@ inline CHeapBitMap* ObjectBitSet<F>::get_fragment_bits(uintptr_t addr) {
|
||||
}
|
||||
CHeapBitMap* bits = NULL;
|
||||
|
||||
CHeapBitMap** found = _bitmap_fragments.lookup(granule);
|
||||
CHeapBitMap** found = _bitmap_fragments.get(granule);
|
||||
if (found != NULL) {
|
||||
bits = *found;
|
||||
} else {
|
||||
BitMapFragment* fragment = new BitMapFragment(granule, _fragment_list);
|
||||
bits = fragment->bits();
|
||||
_fragment_list = fragment;
|
||||
if (_bitmap_fragments.number_of_entries() * 100 / _bitmap_fragments.table_size() > 25) {
|
||||
_bitmap_fragments.resize(_bitmap_fragments.table_size() * 2);
|
||||
}
|
||||
_bitmap_fragments.add(granule, bits);
|
||||
_bitmap_fragments.put(granule, bits);
|
||||
_bitmap_fragments.maybe_grow();
|
||||
}
|
||||
|
||||
_last_fragment_bits = bits;
|
||||
|
Loading…
Reference in New Issue
Block a user