498 void ParallelCompactData::verify_clear() {
499 for (uint cur_idx = 0; cur_idx < region_count(); ++cur_idx) {
500 if (!region(cur_idx)->is_clear()) {
501 log_warning(gc)("Uncleared Region: %u", cur_idx);
502 region(cur_idx)->verify_clear();
503 }
504 }
505 }
506 #endif // #ifdef ASSERT
507
508 STWGCTimer PSParallelCompact::_gc_timer;
509 ParallelOldTracer PSParallelCompact::_gc_tracer;
510 elapsedTimer PSParallelCompact::_accumulated_time;
511 unsigned int PSParallelCompact::_maximum_compaction_gc_num = 0;
512 CollectorCounters* PSParallelCompact::_counters = nullptr;
513 ParMarkBitMap PSParallelCompact::_mark_bitmap;
514 ParallelCompactData PSParallelCompact::_summary_data;
515
516 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure;
517
518 class PCAdjustPointerClosure: public BasicOopIterateClosure {
519 template <typename T>
520 void do_oop_work(T* p) { PSParallelCompact::adjust_pointer(p); }
521
522 public:
523 virtual void do_oop(oop* p) { do_oop_work(p); }
524 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
525
526 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
527 };
528
529 static PCAdjustPointerClosure pc_adjust_pointer_closure;
530
531 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
532
533 void PSParallelCompact::post_initialize() {
534 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
535 _span_based_discoverer.set_span(heap->reserved_region());
536 _ref_processor =
537 new ReferenceProcessor(&_span_based_discoverer,
538 ParallelGCThreads, // mt processing degree
539 ParallelGCThreads, // mt discovery degree
540 false, // concurrent_discovery
541 &_is_alive_closure); // non-header is alive closure
542
543 _counters = new CollectorCounters("Parallel full collection pauses", 1);
544
545 // Initialize static fields in ParCompactionManager.
546 ParCompactionManager::initialize(mark_bitmap());
547 }
548
549 bool PSParallelCompact::initialize_aux_data() {
976 }
977
978 // Let the size policy know we're starting
979 size_policy->major_collection_begin();
980
981 #if COMPILER2_OR_JVMCI
982 DerivedPointerTable::clear();
983 #endif
984
985 ref_processor()->start_discovery(clear_all_soft_refs);
986
987 marking_phase(&_gc_tracer);
988
989 summary_phase(should_do_max_compaction);
990
991 #if COMPILER2_OR_JVMCI
992 assert(DerivedPointerTable::is_active(), "Sanity");
993 DerivedPointerTable::set_active(false);
994 #endif
995
996 forward_to_new_addr();
997
998 adjust_pointers();
999
1000 compact();
1001
1002 ParCompactionManager::_preserved_marks_set->restore(&ParallelScavengeHeap::heap()->workers());
1003
1004 ParCompactionManager::verify_all_region_stack_empty();
1005
1006 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be
1007 // done before resizing.
1008 post_compact();
1009
1010 size_policy->major_collection_end();
1011
1012 size_policy->sample_old_gen_used_bytes(MAX2(pre_gc_values.old_gen_used(), old_gen->used_in_bytes()));
1013
1014 if (UseAdaptiveSizePolicy) {
1015 heap->resize_after_full_gc();
1016 }
1017
1018 heap->resize_all_tlabs();
1019
1020 // Resize the metaspace capacity after a collection
1021 MetaspaceGC::compute_new_size();
2352
2353 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
2354 assert(destination() != nullptr, "sanity");
2355 _source = addr;
2356
2357 // The start_array must be updated even if the object is not moving.
2358 if (_start_array != nullptr) {
2359 _start_array->update_for_block(destination(), destination() + words);
2360 }
2361
2362 // Avoid overflow
2363 words = MIN2(words, words_remaining());
2364 assert(words > 0, "inv");
2365
2366 if (copy_destination() != source()) {
2367 DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2368 assert(source() != destination(), "inv");
2369 assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2370 assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2371 Copy::aligned_conjoint_words(source(), copy_destination(), words);
2372 cast_to_oop(copy_destination())->init_mark();
2373 }
2374
2375 update_state(words);
2376 }
2377
2378 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2379 assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2380 // Record the shadow region index
2381 region_ptr->set_shadow_region(_shadow);
2382 // Mark the shadow region as filled to indicate the data is ready to be
2383 // copied back
2384 region_ptr->mark_filled();
2385 // Try to copy the content of the shadow region back to its corresponding
2386 // heap region if available; the GC thread that decreases the destination
2387 // count to zero will do the copying otherwise (see
2388 // PSParallelCompact::decrement_destination_counts).
2389 if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2390 region_ptr->set_completed();
2391 PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2392 ParCompactionManager::push_shadow_region_mt_safe(_shadow);
|
498 void ParallelCompactData::verify_clear() {
499 for (uint cur_idx = 0; cur_idx < region_count(); ++cur_idx) {
500 if (!region(cur_idx)->is_clear()) {
501 log_warning(gc)("Uncleared Region: %u", cur_idx);
502 region(cur_idx)->verify_clear();
503 }
504 }
505 }
506 #endif // #ifdef ASSERT
507
508 STWGCTimer PSParallelCompact::_gc_timer;
509 ParallelOldTracer PSParallelCompact::_gc_tracer;
510 elapsedTimer PSParallelCompact::_accumulated_time;
511 unsigned int PSParallelCompact::_maximum_compaction_gc_num = 0;
512 CollectorCounters* PSParallelCompact::_counters = nullptr;
513 ParMarkBitMap PSParallelCompact::_mark_bitmap;
514 ParallelCompactData PSParallelCompact::_summary_data;
515
516 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure;
517
518 class PCAdjustPointerClosureNew: public BasicOopIterateClosure {
519 template <typename T>
520 void do_oop_work(T* p) { PSParallelCompact::adjust_pointer(p); }
521
522 public:
523 virtual void do_oop(oop* p) { do_oop_work(p); }
524 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
525
526 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
527 };
528
529 static PCAdjustPointerClosureNew pc_adjust_pointer_closure;
530
531 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
532
533 void PSParallelCompact::post_initialize() {
534 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
535 _span_based_discoverer.set_span(heap->reserved_region());
536 _ref_processor =
537 new ReferenceProcessor(&_span_based_discoverer,
538 ParallelGCThreads, // mt processing degree
539 ParallelGCThreads, // mt discovery degree
540 false, // concurrent_discovery
541 &_is_alive_closure); // non-header is alive closure
542
543 _counters = new CollectorCounters("Parallel full collection pauses", 1);
544
545 // Initialize static fields in ParCompactionManager.
546 ParCompactionManager::initialize(mark_bitmap());
547 }
548
549 bool PSParallelCompact::initialize_aux_data() {
976 }
977
978 // Let the size policy know we're starting
979 size_policy->major_collection_begin();
980
981 #if COMPILER2_OR_JVMCI
982 DerivedPointerTable::clear();
983 #endif
984
985 ref_processor()->start_discovery(clear_all_soft_refs);
986
987 marking_phase(&_gc_tracer);
988
989 summary_phase(should_do_max_compaction);
990
991 #if COMPILER2_OR_JVMCI
992 assert(DerivedPointerTable::is_active(), "Sanity");
993 DerivedPointerTable::set_active(false);
994 #endif
995
996 FullGCForwarding::begin();
997
998 forward_to_new_addr();
999
1000 adjust_pointers();
1001
1002 compact();
1003
1004 FullGCForwarding::end();
1005
1006 ParCompactionManager::_preserved_marks_set->restore(&ParallelScavengeHeap::heap()->workers());
1007
1008 ParCompactionManager::verify_all_region_stack_empty();
1009
1010 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be
1011 // done before resizing.
1012 post_compact();
1013
1014 size_policy->major_collection_end();
1015
1016 size_policy->sample_old_gen_used_bytes(MAX2(pre_gc_values.old_gen_used(), old_gen->used_in_bytes()));
1017
1018 if (UseAdaptiveSizePolicy) {
1019 heap->resize_after_full_gc();
1020 }
1021
1022 heap->resize_all_tlabs();
1023
1024 // Resize the metaspace capacity after a collection
1025 MetaspaceGC::compute_new_size();
2356
2357 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
2358 assert(destination() != nullptr, "sanity");
2359 _source = addr;
2360
2361 // The start_array must be updated even if the object is not moving.
2362 if (_start_array != nullptr) {
2363 _start_array->update_for_block(destination(), destination() + words);
2364 }
2365
2366 // Avoid overflow
2367 words = MIN2(words, words_remaining());
2368 assert(words > 0, "inv");
2369
2370 if (copy_destination() != source()) {
2371 DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2372 assert(source() != destination(), "inv");
2373 assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2374 assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2375 Copy::aligned_conjoint_words(source(), copy_destination(), words);
2376 cast_to_oop(copy_destination())->reinit_mark();
2377 }
2378
2379 update_state(words);
2380 }
2381
2382 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2383 assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2384 // Record the shadow region index
2385 region_ptr->set_shadow_region(_shadow);
2386 // Mark the shadow region as filled to indicate the data is ready to be
2387 // copied back
2388 region_ptr->mark_filled();
2389 // Try to copy the content of the shadow region back to its corresponding
2390 // heap region if available; the GC thread that decreases the destination
2391 // count to zero will do the copying otherwise (see
2392 // PSParallelCompact::decrement_destination_counts).
2393 if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2394 region_ptr->set_completed();
2395 PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2396 ParCompactionManager::push_shadow_region_mt_safe(_shadow);
|