@@ -154,9 +154,7 @@ void ArchiveBuilder::SourceObjList::relocate(int i, ArchiveBuilder* builder) {
154154ArchiveBuilder::ArchiveBuilder () :
155155 _current_dump_region(nullptr ),
156156 _buffer_bottom(nullptr ),
157- _last_verified_top(nullptr ),
158157 _num_dump_regions_used(0 ),
159- _other_region_used_bytes(0 ),
160158 _requested_static_archive_bottom(nullptr ),
161159 _requested_static_archive_top(nullptr ),
162160 _requested_dynamic_archive_bottom(nullptr ),
@@ -173,9 +171,7 @@ ArchiveBuilder::ArchiveBuilder() :
173171 _ro_src_objs(),
174172 _src_obj_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
175173 _buffered_to_src_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
176- _total_heap_region_size(0 ),
177- _estimated_metaspaceobj_bytes(0 ),
178- _estimated_hashtable_bytes(0 )
174+ _total_heap_region_size(0 )
179175{
180176 _klasses = new (mtClassShared) GrowableArray<Klass*>(4 * K, mtClassShared);
181177 _symbols = new (mtClassShared) GrowableArray<Symbol*>(256 * K, mtClassShared);
@@ -238,20 +234,13 @@ bool ArchiveBuilder::gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool re
238234 assert (klass->is_instance_klass (), " must be" );
239235 }
240236 }
241- // See RunTimeClassInfo::get_for(): make sure we have enough space for both maximum
242- // Klass alignment as well as the RuntimeInfo* pointer we will embed in front of a Klass.
243- _estimated_metaspaceobj_bytes += align_up (BytesPerWord, CompressedKlassPointers::klass_alignment_in_bytes ()) +
244- align_up (sizeof (void *), SharedSpaceObjectAlignment);
245237 } else if (ref->msotype () == MetaspaceObj::SymbolType) {
246238 // Make sure the symbol won't be GC'ed while we are dumping the archive.
247239 Symbol* sym = (Symbol*)ref->obj ();
248240 sym->increment_refcount ();
249241 _symbols->append (sym);
250242 }
251243
252- int bytes = ref->size () * BytesPerWord;
253- _estimated_metaspaceobj_bytes += align_up (bytes, SharedSpaceObjectAlignment);
254-
255244 return true ; // recurse
256245}
257246
@@ -294,10 +283,6 @@ void ArchiveBuilder::gather_klasses_and_symbols() {
294283 log_info (cds)(" Sorting symbols ... " );
295284 _symbols->sort (compare_symbols_by_address);
296285 sort_klasses ();
297-
298- // TODO -- we need a proper estimate for the archived modules, etc,
299- // but this should be enough for now
300- _estimated_metaspaceobj_bytes += 200 * 1024 * 1024 ;
301286 }
302287
303288 AOTClassLinker::add_candidates ();
@@ -321,39 +306,8 @@ void ArchiveBuilder::sort_klasses() {
321306 _klasses->sort (compare_klass_by_name);
322307}
323308
324- size_t ArchiveBuilder::estimate_archive_size () {
325- // size of the symbol table and two dictionaries, plus the RunTimeClassInfo's
326- size_t symbol_table_est = SymbolTable::estimate_size_for_archive ();
327- size_t dictionary_est = SystemDictionaryShared::estimate_size_for_archive ();
328- _estimated_hashtable_bytes = symbol_table_est + dictionary_est;
329-
330- if (CDSConfig::is_dumping_aot_linked_classes ()) {
331- // This is difficult to estimate when dumping the dynamic archive, as the
332- // AOTLinkedClassTable may need to contain classes in the static archive as well.
333- //
334- // Just give a generous estimate for now. We will remove estimate_archive_size()
335- // in JDK-8340416
336- _estimated_hashtable_bytes += 20 * 1024 * 1024 ;
337- }
338-
339- size_t total = 0 ;
340-
341- total += _estimated_metaspaceobj_bytes;
342- total += _estimated_hashtable_bytes;
343-
344- // allow fragmentation at the end of each dump region
345- total += _total_dump_regions * MetaspaceShared::core_region_alignment ();
346-
347- log_info (cds)(" _estimated_hashtable_bytes = " SIZE_FORMAT " + " SIZE_FORMAT " = " SIZE_FORMAT,
348- symbol_table_est, dictionary_est, _estimated_hashtable_bytes);
349- log_info (cds)(" _estimated_metaspaceobj_bytes = " SIZE_FORMAT, _estimated_metaspaceobj_bytes);
350- log_info (cds)(" total estimate bytes = " SIZE_FORMAT, total);
351-
352- return align_up (total, MetaspaceShared::core_region_alignment ());
353- }
354-
355309address ArchiveBuilder::reserve_buffer () {
356- size_t buffer_size = estimate_archive_size ( );
310+ size_t buffer_size = LP64_ONLY (CompressedClassSpaceSize) NOT_LP64 ( 256 * M );
357311 ReservedSpace rs = MemoryReserver::reserve (buffer_size,
358312 MetaspaceShared::core_region_alignment (),
359313 os::vm_page_size ());
@@ -370,10 +324,8 @@ address ArchiveBuilder::reserve_buffer() {
370324 _shared_rs = rs;
371325
372326 _buffer_bottom = buffer_bottom;
373- _last_verified_top = buffer_bottom;
374327 _current_dump_region = &_rw_region;
375328 _num_dump_regions_used = 1 ;
376- _other_region_used_bytes = 0 ;
377329 _current_dump_region->init (&_shared_rs, &_shared_vs);
378330
379331 ArchivePtrMarker::initialize (&_ptrmap, &_shared_vs);
@@ -592,28 +544,9 @@ ArchiveBuilder::FollowMode ArchiveBuilder::get_follow_mode(MetaspaceClosure::Ref
592544}
593545
594546void ArchiveBuilder::start_dump_region (DumpRegion* next) {
595- address bottom = _last_verified_top;
596- address top = (address)(current_dump_region ()->top ());
597- _other_region_used_bytes += size_t (top - bottom);
598-
599547 current_dump_region ()->pack (next);
600548 _current_dump_region = next;
601549 _num_dump_regions_used ++;
602-
603- _last_verified_top = (address)(current_dump_region ()->top ());
604- }
605-
606- void ArchiveBuilder::verify_estimate_size (size_t estimate, const char * which) {
607- address bottom = _last_verified_top;
608- address top = (address)(current_dump_region ()->top ());
609- size_t used = size_t (top - bottom) + _other_region_used_bytes;
610- int diff = int (estimate) - int (used);
611-
612- log_info (cds)(" %s estimate = " SIZE_FORMAT " used = " SIZE_FORMAT " ; diff = %d bytes" , which, estimate, used, diff);
613- assert (diff >= 0 , " Estimate is too small" );
614-
615- _last_verified_top = top;
616- _other_region_used_bytes = 0 ;
617550}
618551
619552char * ArchiveBuilder::ro_strdup (const char * s) {
0 commit comments