< prev index next >

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Print this page

 494 void ParallelCompactData::verify_clear() {
 495   for (uint cur_idx = 0; cur_idx < region_count(); ++cur_idx) {
 496     if (!region(cur_idx)->is_clear()) {
 497       log_warning(gc)("Uncleared Region: %u", cur_idx);
 498       region(cur_idx)->verify_clear();
 499     }
 500   }
 501 }
 502 #endif  // #ifdef ASSERT
 503 
 504 STWGCTimer          PSParallelCompact::_gc_timer;
 505 ParallelOldTracer   PSParallelCompact::_gc_tracer;
 506 elapsedTimer        PSParallelCompact::_accumulated_time;
 507 unsigned int        PSParallelCompact::_maximum_compaction_gc_num = 0;
 508 CollectorCounters*  PSParallelCompact::_counters = nullptr;
 509 ParMarkBitMap       PSParallelCompact::_mark_bitmap;
 510 ParallelCompactData PSParallelCompact::_summary_data;
 511 
 512 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure;
 513 
 514 class PCAdjustPointerClosure: public BasicOopIterateClosure {
 515   template <typename T>
 516   void do_oop_work(T* p) { PSParallelCompact::adjust_pointer(p); }
 517 
 518 public:
 519   virtual void do_oop(oop* p)                { do_oop_work(p); }
 520   virtual void do_oop(narrowOop* p)          { do_oop_work(p); }
 521 
 522   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
 523 };
 524 
 525 static PCAdjustPointerClosure pc_adjust_pointer_closure;
 526 
 527 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
 528 
 529 void PSParallelCompact::post_initialize() {
 530   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 531   _span_based_discoverer.set_span(heap->reserved_region());
 532   _ref_processor =
 533     new ReferenceProcessor(&_span_based_discoverer,
 534                            ParallelGCThreads,   // mt processing degree
 535                            ParallelGCThreads,   // mt discovery degree
 536                            false,               // concurrent_discovery
 537                            &_is_alive_closure); // non-header is alive closure
 538 
 539   _counters = new CollectorCounters("Parallel full collection pauses", 1);
 540 
 541   // Initialize static fields in ParCompactionManager.
 542   ParCompactionManager::initialize(mark_bitmap());
 543 }
 544 
 545 bool PSParallelCompact::initialize_aux_data() {

 972     }
 973 
 974     // Let the size policy know we're starting
 975     size_policy->major_collection_begin();
 976 
 977 #ifdef COMPILER2
 978     DerivedPointerTable::clear();
 979 #endif // COMPILER2
 980 
 981     ref_processor()->start_discovery(clear_all_soft_refs);
 982 
 983     marking_phase(&_gc_tracer);
 984 
 985     summary_phase(should_do_max_compaction);
 986 
 987 #ifdef COMPILER2
 988     assert(DerivedPointerTable::is_active(), "Sanity");
 989     DerivedPointerTable::set_active(false);
 990 #endif // COMPILER2
 991 


 992     forward_to_new_addr();
 993 
 994     adjust_pointers();
 995 
 996     compact();
 997 


 998     ParCompactionManager::_preserved_marks_set->restore(&ParallelScavengeHeap::heap()->workers());
 999 
1000     ParCompactionManager::verify_all_region_stack_empty();
1001 
1002     // Reset the mark bitmap, summary data, and do other bookkeeping.  Must be
1003     // done before resizing.
1004     post_compact();
1005 
1006     size_policy->major_collection_end();
1007 
1008     size_policy->sample_old_gen_used_bytes(MAX2(pre_gc_values.old_gen_used(), old_gen->used_in_bytes()));
1009 
1010     if (UseAdaptiveSizePolicy) {
1011       heap->resize_after_full_gc();
1012     }
1013 
1014     heap->resize_all_tlabs();
1015 
1016     // Resize the metaspace capacity after a collection
1017     MetaspaceGC::compute_new_size();

2330 
2331 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
2332   assert(destination() != nullptr, "sanity");
2333   _source = addr;
2334 
2335   // The start_array must be updated even if the object is not moving.
2336   if (_start_array != nullptr) {
2337     _start_array->update_for_block(destination(), destination() + words);
2338   }
2339 
2340   // Avoid overflow
2341   words = MIN2(words, words_remaining());
2342   assert(words > 0, "inv");
2343 
2344   if (copy_destination() != source()) {
2345     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2346     assert(source() != destination(), "inv");
2347     assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2348     assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2349     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2350     cast_to_oop(copy_destination())->init_mark();
2351   }
2352 
2353   update_state(words);
2354 }
2355 
2356 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2357   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2358   // Record the shadow region index
2359   region_ptr->set_shadow_region(_shadow);
2360   // Mark the shadow region as filled to indicate the data is ready to be
2361   // copied back
2362   region_ptr->mark_filled();
2363   // Try to copy the content of the shadow region back to its corresponding
2364   // heap region if available; the GC thread that decreases the destination
2365   // count to zero will do the copying otherwise (see
2366   // PSParallelCompact::decrement_destination_counts).
2367   if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2368     region_ptr->set_completed();
2369     PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2370     ParCompactionManager::push_shadow_region_mt_safe(_shadow);

 494 void ParallelCompactData::verify_clear() {
 495   for (uint cur_idx = 0; cur_idx < region_count(); ++cur_idx) {
 496     if (!region(cur_idx)->is_clear()) {
 497       log_warning(gc)("Uncleared Region: %u", cur_idx);
 498       region(cur_idx)->verify_clear();
 499     }
 500   }
 501 }
 502 #endif  // #ifdef ASSERT
 503 
 504 STWGCTimer          PSParallelCompact::_gc_timer;
 505 ParallelOldTracer   PSParallelCompact::_gc_tracer;
 506 elapsedTimer        PSParallelCompact::_accumulated_time;
 507 unsigned int        PSParallelCompact::_maximum_compaction_gc_num = 0;
 508 CollectorCounters*  PSParallelCompact::_counters = nullptr;
 509 ParMarkBitMap       PSParallelCompact::_mark_bitmap;
 510 ParallelCompactData PSParallelCompact::_summary_data;
 511 
 512 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure;
 513 
 514 class PCAdjustPointerClosureNew: public BasicOopIterateClosure {
 515   template <typename T>
 516   void do_oop_work(T* p) { PSParallelCompact::adjust_pointer(p); }
 517 
 518 public:
 519   virtual void do_oop(oop* p)                { do_oop_work(p); }
 520   virtual void do_oop(narrowOop* p)          { do_oop_work(p); }
 521 
 522   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
 523 };
 524 
 525 static PCAdjustPointerClosureNew pc_adjust_pointer_closure;
 526 
 527 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); }
 528 
 529 void PSParallelCompact::post_initialize() {
 530   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 531   _span_based_discoverer.set_span(heap->reserved_region());
 532   _ref_processor =
 533     new ReferenceProcessor(&_span_based_discoverer,
 534                            ParallelGCThreads,   // mt processing degree
 535                            ParallelGCThreads,   // mt discovery degree
 536                            false,               // concurrent_discovery
 537                            &_is_alive_closure); // non-header is alive closure
 538 
 539   _counters = new CollectorCounters("Parallel full collection pauses", 1);
 540 
 541   // Initialize static fields in ParCompactionManager.
 542   ParCompactionManager::initialize(mark_bitmap());
 543 }
 544 
 545 bool PSParallelCompact::initialize_aux_data() {

 972     }
 973 
 974     // Let the size policy know we're starting
 975     size_policy->major_collection_begin();
 976 
 977 #ifdef COMPILER2
 978     DerivedPointerTable::clear();
 979 #endif // COMPILER2
 980 
 981     ref_processor()->start_discovery(clear_all_soft_refs);
 982 
 983     marking_phase(&_gc_tracer);
 984 
 985     summary_phase(should_do_max_compaction);
 986 
 987 #ifdef COMPILER2
 988     assert(DerivedPointerTable::is_active(), "Sanity");
 989     DerivedPointerTable::set_active(false);
 990 #endif // COMPILER2
 991 
 992     FullGCForwarding::begin();
 993 
 994     forward_to_new_addr();
 995 
 996     adjust_pointers();
 997 
 998     compact();
 999 
1000     FullGCForwarding::end();
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();

2334 
2335 void MoveAndUpdateClosure::do_addr(HeapWord* addr, size_t words) {
2336   assert(destination() != nullptr, "sanity");
2337   _source = addr;
2338 
2339   // The start_array must be updated even if the object is not moving.
2340   if (_start_array != nullptr) {
2341     _start_array->update_for_block(destination(), destination() + words);
2342   }
2343 
2344   // Avoid overflow
2345   words = MIN2(words, words_remaining());
2346   assert(words > 0, "inv");
2347 
2348   if (copy_destination() != source()) {
2349     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
2350     assert(source() != destination(), "inv");
2351     assert(FullGCForwarding::is_forwarded(cast_to_oop(source())), "inv");
2352     assert(FullGCForwarding::forwardee(cast_to_oop(source())) == cast_to_oop(destination()), "inv");
2353     Copy::aligned_conjoint_words(source(), copy_destination(), words);
2354     cast_to_oop(copy_destination())->reinit_mark();
2355   }
2356 
2357   update_state(words);
2358 }
2359 
2360 void MoveAndUpdateShadowClosure::complete_region(HeapWord* dest_addr, PSParallelCompact::RegionData* region_ptr) {
2361   assert(region_ptr->shadow_state() == ParallelCompactData::RegionData::ShadowRegion, "Region should be shadow");
2362   // Record the shadow region index
2363   region_ptr->set_shadow_region(_shadow);
2364   // Mark the shadow region as filled to indicate the data is ready to be
2365   // copied back
2366   region_ptr->mark_filled();
2367   // Try to copy the content of the shadow region back to its corresponding
2368   // heap region if available; the GC thread that decreases the destination
2369   // count to zero will do the copying otherwise (see
2370   // PSParallelCompact::decrement_destination_counts).
2371   if (((region_ptr->available() && region_ptr->claim()) || region_ptr->claimed()) && region_ptr->mark_copied()) {
2372     region_ptr->set_completed();
2373     PSParallelCompact::copy_back(PSParallelCompact::summary_data().region_to_addr(_shadow), dest_addr);
2374     ParCompactionManager::push_shadow_region_mt_safe(_shadow);
< prev index next >