Mon, 16 Mar 2009 08:01:32 -0700
6817419: G1: Enable extensive verification for humongous regions
Summary: Enabled full verification for humongous regions. Also made sure that the VerifyAfterGC works with deferred updates and G1HRRSFlushLogBuffersOnVerify.
Reviewed-by: tonyp
1.1 --- a/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Sun Mar 15 22:03:38 2009 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Mon Mar 16 08:01:32 2009 -0700 1.3 @@ -145,14 +145,9 @@ 1.4 if (G1RSBarrierUseQueue) { 1.5 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 1.6 dcqs.abandon_logs(); 1.7 - if (_cg1rThread->do_traversal()) { 1.8 - _pya = PYA_restart; 1.9 - } else { 1.10 - _cg1rThread->set_do_traversal(true); 1.11 - // Reset the post-yield actions. 1.12 - _pya = PYA_continue; 1.13 - _last_pya = PYA_continue; 1.14 - } 1.15 + // Reset the post-yield actions. 1.16 + _pya = PYA_continue; 1.17 + _last_pya = PYA_continue; 1.18 } else { 1.19 _pya = PYA_restart; 1.20 }
2.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Sun Mar 15 22:03:38 2009 -0400 2.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Mar 16 08:01:32 2009 -0700 2.3 @@ -961,6 +961,7 @@ 2.4 if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) { 2.5 HandleMark hm; // Discard invalid handles created during verification 2.6 gclog_or_tty->print(" VerifyAfterGC:"); 2.7 + prepare_for_verify(); 2.8 Universe::verify(false); 2.9 } 2.10 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); 2.11 @@ -2135,15 +2136,7 @@ 2.12 bool doHeapRegion(HeapRegion* r) { 2.13 guarantee(_par || r->claim_value() == HeapRegion::InitialClaimValue, 2.14 "Should be unclaimed at verify points."); 2.15 - if (r->isHumongous()) { 2.16 - if (r->startsHumongous()) { 2.17 - // Verify the single H object. 2.18 - oop(r->bottom())->verify(); 2.19 - size_t word_sz = oop(r->bottom())->size(); 2.20 - guarantee(r->top() == r->bottom() + word_sz, 2.21 - "Only one object in a humongous region"); 2.22 - } 2.23 - } else { 2.24 + if (!r->continuesHumongous()) { 2.25 VerifyObjsInRegionClosure not_dead_yet_cl(r); 2.26 r->verify(_allow_dirty); 2.27 r->object_iterate(¬_dead_yet_cl); 2.28 @@ -2195,6 +2188,7 @@ 2.29 _g1h(g1h), _allow_dirty(allow_dirty) { } 2.30 2.31 void work(int worker_i) { 2.32 + HandleMark hm; 2.33 VerifyRegionClosure blk(_allow_dirty, true); 2.34 _g1h->heap_region_par_iterate_chunked(&blk, worker_i, 2.35 HeapRegion::ParVerifyClaimValue); 2.36 @@ -2713,6 +2707,7 @@ 2.37 if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) { 2.38 HandleMark hm; // Discard invalid handles created during verification 2.39 gclog_or_tty->print(" VerifyAfterGC:"); 2.40 + prepare_for_verify(); 2.41 Universe::verify(false); 2.42 } 2.43 2.44 @@ -2844,6 +2839,12 @@ 2.45 while (_gc_alloc_region_list != NULL) { 2.46 HeapRegion* r = _gc_alloc_region_list; 2.47 assert(r->is_gc_alloc_region(), "Invariant."); 2.48 + // We need HeapRegion::oops_on_card_seq_iterate_careful() to work on 2.49 + // newly allocated data in order to be able to apply deferred updates 2.50 + // before the GC is done for verification purposes (i.e to allow 2.51 + // G1HRRSFlushLogBuffersOnVerify). It's safe thing to do after the 2.52 + // collection. 2.53 + r->ContiguousSpace::set_saved_mark(); 2.54 _gc_alloc_region_list = r->next_gc_alloc_region(); 2.55 r->set_next_gc_alloc_region(NULL); 2.56 r->set_is_gc_alloc_region(false); 2.57 @@ -3738,7 +3739,9 @@ 2.58 CardTableModRefBS* ctbs() { return _ct_bs; } 2.59 2.60 void immediate_rs_update(HeapRegion* from, oop* p, int tid) { 2.61 - _g1_rem->par_write_ref(from, p, tid); 2.62 + if (!from->is_survivor()) { 2.63 + _g1_rem->par_write_ref(from, p, tid); 2.64 + } 2.65 } 2.66 2.67 void deferred_rs_update(HeapRegion* from, oop* p, int tid) {
3.1 --- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp Sun Mar 15 22:03:38 2009 -0400 3.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp Mon Mar 16 08:01:32 2009 -0700 3.3 @@ -716,8 +716,7 @@ 3.4 bool doHeapRegion(HeapRegion* r) { 3.5 if (!r->in_collection_set() && 3.6 !r->continuesHumongous() && 3.7 - !r->is_young() && 3.8 - !r->is_survivor()) { 3.9 + !r->is_young()) { 3.10 _update_rs_oop_cl.set_from(r); 3.11 UpdateRSObjectClosure update_rs_obj_cl(&_update_rs_oop_cl); 3.12 3.13 @@ -854,7 +853,7 @@ 3.14 // before all the cards on the region are dirtied. This is unlikely, 3.15 // and it doesn't happen often, but it can happen. So, the extra 3.16 // check below filters out those cards. 3.17 - if (r->is_young() || r->is_survivor()) { 3.18 + if (r->is_young()) { 3.19 return; 3.20 } 3.21 // While we are processing RSet buffers during the collection, we 3.22 @@ -1025,7 +1024,9 @@ 3.23 } 3.24 } 3.25 void HRInto_G1RemSet::prepare_for_verify() { 3.26 - if (G1HRRSFlushLogBuffersOnVerify && VerifyBeforeGC && !_g1->full_collection()) { 3.27 + if (G1HRRSFlushLogBuffersOnVerify && 3.28 + (VerifyBeforeGC || VerifyAfterGC) 3.29 + && !_g1->full_collection()) { 3.30 cleanupHRRS(); 3.31 _g1->set_refine_cte_cl_concurrency(false); 3.32 if (SafepointSynchronize::is_at_safepoint()) { 3.33 @@ -1036,5 +1037,7 @@ 3.34 _cg1r->set_use_cache(false); 3.35 updateRS(0); 3.36 _cg1r->set_use_cache(cg1r_use_cache); 3.37 + 3.38 + assert(JavaThread::dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed"); 3.39 } 3.40 }