@@ -154,9 +154,7 @@ void ArchiveBuilder::SourceObjList::relocate(int i, ArchiveBuilder* builder) {
154
154
ArchiveBuilder::ArchiveBuilder () :
155
155
_current_dump_region(nullptr ),
156
156
_buffer_bottom(nullptr ),
157
- _last_verified_top(nullptr ),
158
157
_num_dump_regions_used(0 ),
159
- _other_region_used_bytes(0 ),
160
158
_requested_static_archive_bottom(nullptr ),
161
159
_requested_static_archive_top(nullptr ),
162
160
_requested_dynamic_archive_bottom(nullptr ),
@@ -173,9 +171,7 @@ ArchiveBuilder::ArchiveBuilder() :
173
171
_ro_src_objs(),
174
172
_src_obj_table(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE),
175
173
_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 )
179
175
{
180
176
_klasses = new (mtClassShared) GrowableArray<Klass*>(4 * K, mtClassShared);
181
177
_symbols = new (mtClassShared) GrowableArray<Symbol*>(256 * K, mtClassShared);
@@ -238,20 +234,13 @@ bool ArchiveBuilder::gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool re
238
234
assert (klass->is_instance_klass (), " must be" );
239
235
}
240
236
}
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);
245
237
} else if (ref->msotype () == MetaspaceObj::SymbolType) {
246
238
// Make sure the symbol won't be GC'ed while we are dumping the archive.
247
239
Symbol* sym = (Symbol*)ref->obj ();
248
240
sym->increment_refcount ();
249
241
_symbols->append (sym);
250
242
}
251
243
252
- int bytes = ref->size () * BytesPerWord;
253
- _estimated_metaspaceobj_bytes += align_up (bytes, SharedSpaceObjectAlignment);
254
-
255
244
return true ; // recurse
256
245
}
257
246
@@ -294,10 +283,6 @@ void ArchiveBuilder::gather_klasses_and_symbols() {
294
283
log_info (cds)(" Sorting symbols ... " );
295
284
_symbols->sort (compare_symbols_by_address);
296
285
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 ;
301
286
}
302
287
303
288
AOTClassLinker::add_candidates ();
@@ -321,39 +306,8 @@ void ArchiveBuilder::sort_klasses() {
321
306
_klasses->sort (compare_klass_by_name);
322
307
}
323
308
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
-
355
309
address ArchiveBuilder::reserve_buffer () {
356
- size_t buffer_size = estimate_archive_size ( );
310
+ size_t buffer_size = LP64_ONLY (CompressedClassSpaceSize) NOT_LP64 ( 256 * M );
357
311
ReservedSpace rs = MemoryReserver::reserve (buffer_size,
358
312
MetaspaceShared::core_region_alignment (),
359
313
os::vm_page_size ());
@@ -370,10 +324,8 @@ address ArchiveBuilder::reserve_buffer() {
370
324
_shared_rs = rs;
371
325
372
326
_buffer_bottom = buffer_bottom;
373
- _last_verified_top = buffer_bottom;
374
327
_current_dump_region = &_rw_region;
375
328
_num_dump_regions_used = 1 ;
376
- _other_region_used_bytes = 0 ;
377
329
_current_dump_region->init (&_shared_rs, &_shared_vs);
378
330
379
331
ArchivePtrMarker::initialize (&_ptrmap, &_shared_vs);
@@ -592,28 +544,9 @@ ArchiveBuilder::FollowMode ArchiveBuilder::get_follow_mode(MetaspaceClosure::Ref
592
544
}
593
545
594
546
void 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
-
599
547
current_dump_region ()->pack (next);
600
548
_current_dump_region = next;
601
549
_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 ;
617
550
}
618
551
619
552
char * ArchiveBuilder::ro_strdup (const char * s) {
0 commit comments