176 HeapRegionRemSet* hrrs = rem_set();
177 if (locked) {
178 hrrs->clear_locked();
179 } else {
180 hrrs->clear();
181 }
182 }
183 zero_marked_bytes();
184
185 _offsets.resize(HeapRegion::GrainWords);
186 init_top_at_mark_start();
187 if (clear_space) clear(SpaceDecorator::Mangle);
188 }
189
190 void HeapRegion::par_clear() {
191 assert(used() == 0, "the region should have been already cleared");
192 assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
193 HeapRegionRemSet* hrrs = rem_set();
194 hrrs->clear();
195 CardTableModRefBS* ct_bs =
196 (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set();
197 ct_bs->clear(MemRegion(bottom(), end()));
198 }
199
200 void HeapRegion::calc_gc_efficiency() {
201 // GC efficiency is the ratio of how much space would be
202 // reclaimed over how long we predict it would take to reclaim it.
203 G1CollectedHeap* g1h = G1CollectedHeap::heap();
204 G1CollectorPolicy* g1p = g1h->g1_policy();
205
206 // Retrieve a prediction of the elapsed time for this region for
207 // a mixed gc because the region will only be evacuated during a
208 // mixed gc.
209 double region_elapsed_time_ms =
210 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */);
211 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms;
212 }
213
214 void HeapRegion::set_starts_humongous(HeapWord* new_top, HeapWord* new_end) {
215 assert(!is_humongous(), "sanity / pre-condition");
216 assert(end() == orig_end(),
626 st->print(" ");
627 st->print(" TS %5d", _gc_time_stamp);
628 st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
629 prev_top_at_mark_start(), next_top_at_mark_start());
630 G1OffsetTableContigSpace::print_on(st);
631 }
632
633 class VerifyLiveClosure: public OopClosure {
634 private:
635 G1CollectedHeap* _g1h;
636 CardTableModRefBS* _bs;
637 oop _containing_obj;
638 bool _failures;
639 int _n_failures;
640 VerifyOption _vo;
641 public:
642 // _vo == UsePrevMarking -> use "prev" marking information,
643 // _vo == UseNextMarking -> use "next" marking information,
644 // _vo == UseMarkWord -> use mark word from object header.
645 VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) :
646 _g1h(g1h), _bs(NULL), _containing_obj(NULL),
647 _failures(false), _n_failures(0), _vo(vo)
648 {
649 BarrierSet* bs = _g1h->barrier_set();
650 if (bs->is_a(BarrierSet::CardTableModRef))
651 _bs = (CardTableModRefBS*)bs;
652 }
653
654 void set_containing_obj(oop obj) {
655 _containing_obj = obj;
656 }
657
658 bool failures() { return _failures; }
659 int n_failures() { return _n_failures; }
660
661 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
662 virtual void do_oop( oop* p) { do_oop_work(p); }
663
664 void print_object(outputStream* out, oop obj) {
665 #ifdef PRODUCT
666 Klass* k = obj->klass();
667 const char* class_name = InstanceKlass::cast(k)->external_name();
668 out->print_cr("class name %s", class_name);
669 #else // PRODUCT
670 obj->print_on(out);
671 #endif // PRODUCT
672 }
|
176 HeapRegionRemSet* hrrs = rem_set();
177 if (locked) {
178 hrrs->clear_locked();
179 } else {
180 hrrs->clear();
181 }
182 }
183 zero_marked_bytes();
184
185 _offsets.resize(HeapRegion::GrainWords);
186 init_top_at_mark_start();
187 if (clear_space) clear(SpaceDecorator::Mangle);
188 }
189
190 void HeapRegion::par_clear() {
191 assert(used() == 0, "the region should have been already cleared");
192 assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
193 HeapRegionRemSet* hrrs = rem_set();
194 hrrs->clear();
195 CardTableModRefBS* ct_bs =
196 barrier_set_cast<CardTableModRefBS>(G1CollectedHeap::heap()->barrier_set());
197 ct_bs->clear(MemRegion(bottom(), end()));
198 }
199
200 void HeapRegion::calc_gc_efficiency() {
201 // GC efficiency is the ratio of how much space would be
202 // reclaimed over how long we predict it would take to reclaim it.
203 G1CollectedHeap* g1h = G1CollectedHeap::heap();
204 G1CollectorPolicy* g1p = g1h->g1_policy();
205
206 // Retrieve a prediction of the elapsed time for this region for
207 // a mixed gc because the region will only be evacuated during a
208 // mixed gc.
209 double region_elapsed_time_ms =
210 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */);
211 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms;
212 }
213
214 void HeapRegion::set_starts_humongous(HeapWord* new_top, HeapWord* new_end) {
215 assert(!is_humongous(), "sanity / pre-condition");
216 assert(end() == orig_end(),
626 st->print(" ");
627 st->print(" TS %5d", _gc_time_stamp);
628 st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
629 prev_top_at_mark_start(), next_top_at_mark_start());
630 G1OffsetTableContigSpace::print_on(st);
631 }
632
633 class VerifyLiveClosure: public OopClosure {
634 private:
635 G1CollectedHeap* _g1h;
636 CardTableModRefBS* _bs;
637 oop _containing_obj;
638 bool _failures;
639 int _n_failures;
640 VerifyOption _vo;
641 public:
642 // _vo == UsePrevMarking -> use "prev" marking information,
643 // _vo == UseNextMarking -> use "next" marking information,
644 // _vo == UseMarkWord -> use mark word from object header.
645 VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) :
646 _g1h(g1h), _bs(barrier_set_cast<CardTableModRefBS>(g1h->barrier_set())),
647 _containing_obj(NULL), _failures(false), _n_failures(0), _vo(vo)
648 { }
649
650 void set_containing_obj(oop obj) {
651 _containing_obj = obj;
652 }
653
654 bool failures() { return _failures; }
655 int n_failures() { return _n_failures; }
656
657 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
658 virtual void do_oop( oop* p) { do_oop_work(p); }
659
660 void print_object(outputStream* out, oop obj) {
661 #ifdef PRODUCT
662 Klass* k = obj->klass();
663 const char* class_name = InstanceKlass::cast(k)->external_name();
664 out->print_cr("class name %s", class_name);
665 #else // PRODUCT
666 obj->print_on(out);
667 #endif // PRODUCT
668 }
|