comparison src/share/vm/gc_implementation/g1/g1RemSet.cpp @ 1960:878b57474103

6978187: G1: assert(ParallelGCThreads> 1 || n_yielded() == _hrrs->occupied()) strikes again Summary: An evacuation failure while copying the roots caused an object, A, to be forwarded to itself. During the subsequent RSet updating a reference to A was processed causing the reference to be added to the RSet of A's heap region. As a result of adding to the remembered set we ran into the issue described in 6930581 - the sparse table expanded and the RSet scanning code walked the cards in one instance of RHashTable (_cur) while the occupied() counts the cards in the expanded table (_next). Reviewed-by: tonyp, iveresov
author johnc
date Tue, 16 Nov 2010 14:07:33 -0800
parents c32059ef4dc0
children f95d63e2154a
comparison
equal deleted inserted replaced
1954:e3e1fb85e50a 1960:878b57474103
114 114
115 G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) 115 G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs)
116 : _g1(g1), _conc_refine_cards(0), 116 : _g1(g1), _conc_refine_cards(0),
117 _ct_bs(ct_bs), _g1p(_g1->g1_policy()), 117 _ct_bs(ct_bs), _g1p(_g1->g1_policy()),
118 _cg1r(g1->concurrent_g1_refine()), 118 _cg1r(g1->concurrent_g1_refine()),
119 _traversal_in_progress(false),
120 _cset_rs_update_cl(NULL), 119 _cset_rs_update_cl(NULL),
121 _cards_scanned(NULL), _total_cards_scanned(0) 120 _cards_scanned(NULL), _total_cards_scanned(0)
122 { 121 {
123 _seq_task = new SubTasksDone(NumSeqTasks); 122 _seq_task = new SubTasksDone(NumSeqTasks);
124 guarantee(n_workers() > 0, "There should be some workers"); 123 guarantee(n_workers() > 0, "There should be some workers");
510 ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine(); 509 ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine();
511 _g1->set_refine_cte_cl_concurrency(false); 510 _g1->set_refine_cte_cl_concurrency(false);
512 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 511 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
513 dcqs.concatenate_logs(); 512 dcqs.concatenate_logs();
514 513
515 assert(!_traversal_in_progress, "Invariant between iterations.");
516 set_traversal(true);
517 if (ParallelGCThreads > 0) { 514 if (ParallelGCThreads > 0) {
518 _seq_task->set_n_threads((int)n_workers()); 515 _seq_task->set_n_threads((int)n_workers());
519 } 516 }
520 guarantee( _cards_scanned == NULL, "invariant" ); 517 guarantee( _cards_scanned == NULL, "invariant" );
521 _cards_scanned = NEW_C_HEAP_ARRAY(size_t, n_workers()); 518 _cards_scanned = NEW_C_HEAP_ARRAY(size_t, n_workers());
537 // This closure, applied to a DirtyCardQueueSet, is used to immediately 534 // This closure, applied to a DirtyCardQueueSet, is used to immediately
538 // update the RSets for the regions in the CSet. For each card it iterates 535 // update the RSets for the regions in the CSet. For each card it iterates
539 // through the oops which coincide with that card. It scans the reference 536 // through the oops which coincide with that card. It scans the reference
540 // fields in each oop; when it finds an oop that points into the collection 537 // fields in each oop; when it finds an oop that points into the collection
541 // set, the RSet for the region containing the referenced object is updated. 538 // set, the RSet for the region containing the referenced object is updated.
542 // Note: _par_traversal_in_progress in the G1RemSet must be FALSE; otherwise
543 // the UpdateRSetImmediate closure will cause cards to be enqueued on to
544 // the DCQS that we're iterating over, causing an infinite loop.
545 class UpdateRSetCardTableEntryIntoCSetClosure: public CardTableEntryClosure { 539 class UpdateRSetCardTableEntryIntoCSetClosure: public CardTableEntryClosure {
546 G1CollectedHeap* _g1; 540 G1CollectedHeap* _g1;
547 CardTableModRefBS* _ct_bs; 541 CardTableModRefBS* _ct_bs;
548 public: 542 public:
549 UpdateRSetCardTableEntryIntoCSetClosure(G1CollectedHeap* g1, 543 UpdateRSetCardTableEntryIntoCSetClosure(G1CollectedHeap* g1,
609 cleanUpIteratorsClosure iterClosure; 603 cleanUpIteratorsClosure iterClosure;
610 _g1->collection_set_iterate(&iterClosure); 604 _g1->collection_set_iterate(&iterClosure);
611 // Set all cards back to clean. 605 // Set all cards back to clean.
612 _g1->cleanUpCardTable(); 606 _g1->cleanUpCardTable();
613 607
614 set_traversal(false);
615
616 DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set(); 608 DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set();
617 int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num(); 609 int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num();
618 610
619 if (_g1->evacuation_failed()) { 611 if (_g1->evacuation_failed()) {
620 // Restore remembered sets for the regions pointing into the collection set. 612 // Restore remembered sets for the regions pointing into the collection set.
643 // which contain references that point into the collection. 635 // which contain references that point into the collection.
644 _g1->into_cset_dirty_card_queue_set().clear(); 636 _g1->into_cset_dirty_card_queue_set().clear();
645 assert(_g1->into_cset_dirty_card_queue_set().completed_buffers_num() == 0, 637 assert(_g1->into_cset_dirty_card_queue_set().completed_buffers_num() == 0,
646 "all buffers should be freed"); 638 "all buffers should be freed");
647 _g1->into_cset_dirty_card_queue_set().clear_n_completed_buffers(); 639 _g1->into_cset_dirty_card_queue_set().clear_n_completed_buffers();
648 640 }
649 assert(!_traversal_in_progress, "Invariant between iterations.");
650 }
651
652 class UpdateRSObjectClosure: public ObjectClosure {
653 UpdateRSOopClosure* _update_rs_oop_cl;
654 public:
655 UpdateRSObjectClosure(UpdateRSOopClosure* update_rs_oop_cl) :
656 _update_rs_oop_cl(update_rs_oop_cl) {}
657 void do_object(oop obj) {
658 obj->oop_iterate(_update_rs_oop_cl);
659 }
660
661 };
662 641
663 class ScrubRSClosure: public HeapRegionClosure { 642 class ScrubRSClosure: public HeapRegionClosure {
664 G1CollectedHeap* _g1h; 643 G1CollectedHeap* _g1h;
665 BitMap* _region_bm; 644 BitMap* _region_bm;
666 BitMap* _card_bm; 645 BitMap* _card_bm;
747 #if CARD_REPEAT_HISTO 726 #if CARD_REPEAT_HISTO
748 init_ct_freq_table(_g1->g1_reserved_obj_bytes()); 727 init_ct_freq_table(_g1->g1_reserved_obj_bytes());
749 ct_freq_note_card(_ct_bs->index_for(start)); 728 ct_freq_note_card(_ct_bs->index_for(start));
750 #endif 729 #endif
751 730
752 UpdateRSOopClosure update_rs_oop_cl(this, worker_i); 731 assert(!check_for_refs_into_cset || _cset_rs_update_cl[worker_i] != NULL, "sanity");
732 UpdateRSOrPushRefOopClosure update_rs_oop_cl(_g1,
733 _g1->g1_rem_set(),
734 _cset_rs_update_cl[worker_i],
735 check_for_refs_into_cset,
736 worker_i);
753 update_rs_oop_cl.set_from(r); 737 update_rs_oop_cl.set_from(r);
754 738
755 TriggerClosure trigger_cl; 739 TriggerClosure trigger_cl;
756 FilterIntoCSClosure into_cs_cl(NULL, _g1, &trigger_cl); 740 FilterIntoCSClosure into_cs_cl(NULL, _g1, &trigger_cl);
757 InvokeIfNotTriggeredClosure invoke_cl(&trigger_cl, &into_cs_cl); 741 InvokeIfNotTriggeredClosure invoke_cl(&trigger_cl, &into_cs_cl);