< prev index next >

src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 7471 : 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
Summary: Evaluate and improve object copy time by micro-optimizations and splitting out slow and fast paths aggressively.
Reviewed-by:
Contributed-by: Tony Printezis <tprintezis@twitter.com>, Thomas Schatzl <thomas.schatzl@oracle.com>
rev 7472 : [mq]: 8060025-mikael-review1


2746 
2747 void G1CollectedHeap::prepare_for_verify() {
2748   if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
2749     ensure_parsability(false);
2750   }
2751   g1_rem_set()->prepare_for_verify();
2752 }
2753 
2754 bool G1CollectedHeap::allocated_since_marking(oop obj, HeapRegion* hr,
2755                                               VerifyOption vo) {
2756   switch (vo) {
2757   case VerifyOption_G1UsePrevMarking:
2758     return hr->obj_allocated_since_prev_marking(obj);
2759   case VerifyOption_G1UseNextMarking:
2760     return hr->obj_allocated_since_next_marking(obj);
2761   case VerifyOption_G1UseMarkWord:
2762     return false;
2763   default:
2764     ShouldNotReachHere();
2765   }
2766   return false; // keep some compilers happy
2767 }
2768 
2769 HeapWord* G1CollectedHeap::top_at_mark_start(HeapRegion* hr, VerifyOption vo) {
2770   switch (vo) {
2771   case VerifyOption_G1UsePrevMarking: return hr->prev_top_at_mark_start();
2772   case VerifyOption_G1UseNextMarking: return hr->next_top_at_mark_start();
2773   case VerifyOption_G1UseMarkWord:    return NULL;
2774   default:                            ShouldNotReachHere();
2775   }
2776   return NULL; // keep some compilers happy
2777 }
2778 
2779 bool G1CollectedHeap::is_marked(oop obj, VerifyOption vo) {
2780   switch (vo) {
2781   case VerifyOption_G1UsePrevMarking: return isMarkedPrev(obj);
2782   case VerifyOption_G1UseNextMarking: return isMarkedNext(obj);
2783   case VerifyOption_G1UseMarkWord:    return obj->is_gc_marked();
2784   default:                            ShouldNotReachHere();
2785   }
2786   return false; // keep some compilers happy


5752   G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs,
5753                      G1CollectedHeap* g1h) :
5754     AbstractGangTask("G1 Par Cleanup CT Task"),
5755     _ct_bs(ct_bs), _g1h(g1h) { }
5756 
5757   void work(uint worker_id) {
5758     HeapRegion* r;
5759     while (r = _g1h->pop_dirty_cards_region()) {
5760       clear_cards(r);
5761     }
5762   }
5763 
5764   void clear_cards(HeapRegion* r) {
5765     // Cards of the survivors should have already been dirtied.
5766     if (!r->is_survivor()) {
5767       _ct_bs->clear(MemRegion(r->bottom(), r->end()));
5768     }
5769   }
5770 };
5771 
5772 #ifdef PRODUCT
5773 bool G1CollectedHeap::check_cset_fast_test() { return true; }
5774 #else
5775 class G1VerifyCardTableCleanup: public HeapRegionClosure {
5776   G1CollectedHeap* _g1h;
5777   G1SATBCardTableModRefBS* _ct_bs;
5778 public:
5779   G1VerifyCardTableCleanup(G1CollectedHeap* g1h, G1SATBCardTableModRefBS* ct_bs)
5780     : _g1h(g1h), _ct_bs(ct_bs) { }
5781   virtual bool doHeapRegion(HeapRegion* r) {
5782     if (r->is_survivor()) {
5783       _g1h->verify_dirty_region(r);
5784     } else {
5785       _g1h->verify_not_dirty_region(r);
5786     }
5787     return false;
5788   }
5789 };
5790 
5791 void G1CollectedHeap::verify_not_dirty_region(HeapRegion* hr) {
5792   // All of the region should be clean.
5793   G1SATBCardTableModRefBS* ct_bs = g1_barrier_set();
5794   MemRegion mr(hr->bottom(), hr->end());




2746 
2747 void G1CollectedHeap::prepare_for_verify() {
2748   if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
2749     ensure_parsability(false);
2750   }
2751   g1_rem_set()->prepare_for_verify();
2752 }
2753 
2754 bool G1CollectedHeap::allocated_since_marking(oop obj, HeapRegion* hr,
2755                                               VerifyOption vo) {
2756   switch (vo) {
2757   case VerifyOption_G1UsePrevMarking:
2758     return hr->obj_allocated_since_prev_marking(obj);
2759   case VerifyOption_G1UseNextMarking:
2760     return hr->obj_allocated_since_next_marking(obj);
2761   case VerifyOption_G1UseMarkWord:
2762     return false;
2763   default:
2764     ShouldNotReachHere();
2765   }
2766   return false; // Keep some compilers happy
2767 }
2768 
2769 HeapWord* G1CollectedHeap::top_at_mark_start(HeapRegion* hr, VerifyOption vo) {
2770   switch (vo) {
2771   case VerifyOption_G1UsePrevMarking: return hr->prev_top_at_mark_start();
2772   case VerifyOption_G1UseNextMarking: return hr->next_top_at_mark_start();
2773   case VerifyOption_G1UseMarkWord:    return NULL;
2774   default:                            ShouldNotReachHere();
2775   }
2776   return NULL; // keep some compilers happy
2777 }
2778 
2779 bool G1CollectedHeap::is_marked(oop obj, VerifyOption vo) {
2780   switch (vo) {
2781   case VerifyOption_G1UsePrevMarking: return isMarkedPrev(obj);
2782   case VerifyOption_G1UseNextMarking: return isMarkedNext(obj);
2783   case VerifyOption_G1UseMarkWord:    return obj->is_gc_marked();
2784   default:                            ShouldNotReachHere();
2785   }
2786   return false; // keep some compilers happy


5752   G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs,
5753                      G1CollectedHeap* g1h) :
5754     AbstractGangTask("G1 Par Cleanup CT Task"),
5755     _ct_bs(ct_bs), _g1h(g1h) { }
5756 
5757   void work(uint worker_id) {
5758     HeapRegion* r;
5759     while (r = _g1h->pop_dirty_cards_region()) {
5760       clear_cards(r);
5761     }
5762   }
5763 
5764   void clear_cards(HeapRegion* r) {
5765     // Cards of the survivors should have already been dirtied.
5766     if (!r->is_survivor()) {
5767       _ct_bs->clear(MemRegion(r->bottom(), r->end()));
5768     }
5769   }
5770 };
5771 
5772 #ifndef PRODUCT


5773 class G1VerifyCardTableCleanup: public HeapRegionClosure {
5774   G1CollectedHeap* _g1h;
5775   G1SATBCardTableModRefBS* _ct_bs;
5776 public:
5777   G1VerifyCardTableCleanup(G1CollectedHeap* g1h, G1SATBCardTableModRefBS* ct_bs)
5778     : _g1h(g1h), _ct_bs(ct_bs) { }
5779   virtual bool doHeapRegion(HeapRegion* r) {
5780     if (r->is_survivor()) {
5781       _g1h->verify_dirty_region(r);
5782     } else {
5783       _g1h->verify_not_dirty_region(r);
5784     }
5785     return false;
5786   }
5787 };
5788 
5789 void G1CollectedHeap::verify_not_dirty_region(HeapRegion* hr) {
5790   // All of the region should be clean.
5791   G1SATBCardTableModRefBS* ct_bs = g1_barrier_set();
5792   MemRegion mr(hr->bottom(), hr->end());


< prev index next >