8215228: Use a constant hash table size in order to enable compiler optimization

Remove a field from KlassInfoTable to allow compiler optimizations

Reviewed-by: phh, aph
This commit is contained in:
Lin Zang 2018-12-11 10:23:15 -08:00 committed by Jean Christophe Beyler
parent 811c84ba68
commit aef52a6e3a
2 changed files with 6 additions and 9 deletions

View File

@ -168,14 +168,12 @@ public:
KlassInfoTable::KlassInfoTable(bool add_all_classes) {
_size_of_instances_in_words = 0;
_size = 0;
_ref = (HeapWord*) Universe::boolArrayKlassObj();
_buckets =
(KlassInfoBucket*) AllocateHeap(sizeof(KlassInfoBucket) * _num_buckets,
mtInternal, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
if (_buckets != NULL) {
_size = _num_buckets;
for (int index = 0; index < _size; index++) {
for (int index = 0; index < _num_buckets; index++) {
_buckets[index].initialize();
}
if (add_all_classes) {
@ -187,11 +185,11 @@ KlassInfoTable::KlassInfoTable(bool add_all_classes) {
KlassInfoTable::~KlassInfoTable() {
if (_buckets != NULL) {
for (int index = 0; index < _size; index++) {
for (int index = 0; index < _num_buckets; index++) {
_buckets[index].empty();
}
FREE_C_HEAP_ARRAY(KlassInfoBucket, _buckets);
_size = 0;
_buckets = NULL;
}
}
@ -200,7 +198,7 @@ uint KlassInfoTable::hash(const Klass* p) {
}
KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
uint idx = hash(k) % _size;
uint idx = hash(k) % _num_buckets;
assert(_buckets != NULL, "Allocation failure should have been caught");
KlassInfoEntry* e = _buckets[idx].lookup(k);
// Lookup may fail if this is a new klass for which we
@ -227,8 +225,8 @@ bool KlassInfoTable::record_instance(const oop obj) {
}
void KlassInfoTable::iterate(KlassInfoClosure* cic) {
assert(_size == 0 || _buckets != NULL, "Allocation failure should have been caught");
for (int index = 0; index < _size; index++) {
assert(_buckets != NULL, "Allocation failure should have been caught");
for (int index = 0; index < _num_buckets; index++) {
_buckets[index].iterate(cic);
}
}

View File

@ -234,7 +234,6 @@ class KlassInfoBucket: public CHeapObj<mtInternal> {
class KlassInfoTable: public StackObj {
private:
int _size;
static const int _num_buckets = 20011;
size_t _size_of_instances_in_words;