src/hotspot/share/memory/heapInspection.cpp
changeset 53035 0e5c83bf4ff7
parent 51959 db0c3952de52
child 54274 a7358438d463
--- a/src/hotspot/share/memory/heapInspection.cpp	Mon Dec 17 11:37:40 2018 +0100
+++ b/src/hotspot/share/memory/heapInspection.cpp	Tue Dec 11 10:23:15 2018 -0800
@@ -168,14 +168,12 @@
 
 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() {
   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 @@
 }
 
 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 @@
 }
 
 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);
   }
 }