< prev index next >

src/share/vm/classfile/compactHashtable.cpp

Print this page

@@ -45,12 +45,10 @@
   _buckets = NEW_C_HEAP_ARRAY(GrowableArray<Entry>*, _num_buckets, mtSymbol);
   for (int i=0; i<_num_buckets; i++) {
     _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray<Entry>(0, true, mtSymbol);
   }
 
-  stats->bucket_count = _num_buckets;
-  stats->bucket_bytes = (_num_buckets + 1) * (sizeof(u4));
   _stats = stats;
   _compact_buckets = NULL;
   _compact_entries = NULL;
   _num_empty_buckets = 0;
   _num_value_only_buckets = 0;

@@ -88,17 +86,17 @@
   if (entries_space & ~BUCKET_OFFSET_MASK) {
     vm_exit_during_initialization("CompactHashtableWriter::allocate_table: Overflow! "
                                   "Too many entries.");
   }
 
-  Thread* THREAD = VMThread::vm_thread();
-  ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
-  _compact_buckets = MetadataFactory::new_array<u4>(loader_data, _num_buckets + 1, THREAD);
-  _compact_entries = MetadataFactory::new_array<u4>(loader_data, entries_space, THREAD);
+  _compact_buckets = MetaspaceShared::new_ro_array<u4>(_num_buckets + 1);
+  _compact_entries = MetaspaceShared::new_ro_array<u4>(entries_space);
 
+  _stats->bucket_count    = _num_buckets;
+  _stats->bucket_bytes    = _compact_buckets->size() * BytesPerWord;
   _stats->hashentry_count = _num_entries;
-  _stats->hashentry_bytes = entries_space * sizeof(u4);
+  _stats->hashentry_bytes = _compact_entries->size() * BytesPerWord;
 }
 
 // Write the compact table's buckets
 void CompactHashtableWriter::dump_table(NumberSeq* summary) {
   u4 offset = 0;

@@ -174,16 +172,15 @@
 /////////////////////////////////////////////////////////////
 //
 // Customization for dumping Symbol and String tables
 
 void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) {
-  address base_address = address(MetaspaceShared::shared_rs()->base());
-
-  uintx deltax = address(symbol) - base_address;
-  // The symbols are in RO space, which is smaler than MAX_SHARED_DELTA.
-  // The assert below is just to be extra cautious.
-  assert(deltax <= MAX_SHARED_DELTA, "the delta is too large to encode");
+  uintx deltax = MetaspaceShared::object_delta(symbol);
+  // When the symbols are stored into the archive, we already check that
+  // they won't be more than MAX_SHARED_DELTA from the base address, or
+  // else the dumping would have been aborted.
+  assert(deltax <= MAX_SHARED_DELTA, "must not be");
   u4 delta = u4(deltax);
 
   CompactHashtableWriter::add(hash, delta);
 }
 
< prev index next >