hotspot/src/share/vm/utilities/hashtable.cpp
changeset 1551 b431de37a22c
parent 1 489c9b5090e2
child 1623 a0dd9009e992
--- a/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Nov 12 22:33:26 2008 -0800
+++ b/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Nov 12 23:26:45 2008 -0800
@@ -43,9 +43,11 @@
     entry = _free_list;
     _free_list = _free_list->next();
   } else {
-    const int block_size = 500;
-    if (_first_free_entry == _end_block) {
+    if (_first_free_entry + _entry_size >= _end_block) {
+      int block_size = MIN2(512, MAX2((int)_table_size / 2, (int)_number_of_entries));
       int len = _entry_size * block_size;
+      len = 1 << log2_intptr(len); // round down to power of 2
+      assert(len >= _entry_size, "");
       _first_free_entry = NEW_C_HEAP_ARRAY(char, len);
       _end_block = _first_free_entry + len;
     }
@@ -53,6 +55,7 @@
     _first_free_entry += _entry_size;
   }
 
+  assert(_entry_size % HeapWordSize == 0, "");
   entry->set_hash(hashValue);
   return entry;
 }