mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-07 05:28:52 +00:00
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:
parent
811c84ba68
commit
aef52a6e3a
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user