2111
2112 size_t G1CollectedHeap::capacity() const {
2113 return _hrm.length() * HeapRegion::GrainBytes;
2114 }
2115
2116 void G1CollectedHeap::reset_gc_time_stamps(HeapRegion* hr) {
2117 assert(!hr->is_continues_humongous(), "pre-condition");
2118 hr->reset_gc_time_stamp();
2119 if (hr->is_starts_humongous()) {
2120 uint first_index = hr->hrm_index() + 1;
2121 uint last_index = hr->last_hc_index();
2122 for (uint i = first_index; i < last_index; i += 1) {
2123 HeapRegion* chr = region_at(i);
2124 assert(chr->is_continues_humongous(), "sanity");
2125 chr->reset_gc_time_stamp();
2126 }
2127 }
2128 }
2129
2130 #ifndef PRODUCT
2131 class CheckGCTimeStampsHRClosure : public HeapRegionClosure {
2132 private:
2133 unsigned _gc_time_stamp;
2134 bool _failures;
2135
2136 public:
2137 CheckGCTimeStampsHRClosure(unsigned gc_time_stamp) :
2138 _gc_time_stamp(gc_time_stamp), _failures(false) { }
2139
2140 virtual bool doHeapRegion(HeapRegion* hr) {
2141 unsigned region_gc_time_stamp = hr->get_gc_time_stamp();
2142 if (_gc_time_stamp != region_gc_time_stamp) {
2143 gclog_or_tty->print_cr("Region "HR_FORMAT" has GC time stamp = %d, "
2144 "expected %d", HR_FORMAT_PARAMS(hr),
2145 region_gc_time_stamp, _gc_time_stamp);
2146 _failures = true;
2147 }
2148 return false;
2149 }
2150
3319
3320 ~PrintRSetsClosure() {
3321 gclog_or_tty->print_cr("Occupied Sum: "SIZE_FORMAT, _occupied_sum);
3322 gclog_or_tty->print_cr("========================================");
3323 gclog_or_tty->cr();
3324 }
3325 };
3326
3327 void G1CollectedHeap::print_cset_rsets() {
3328 PrintRSetsClosure cl("Printing CSet RSets");
3329 collection_set_iterate(&cl);
3330 }
3331
3332 void G1CollectedHeap::print_all_rsets() {
3333 PrintRSetsClosure cl("Printing All RSets");;
3334 heap_region_iterate(&cl);
3335 }
3336 #endif // PRODUCT
3337
3338 G1CollectedHeap* G1CollectedHeap::heap() {
3339 assert(_sh->kind() == CollectedHeap::G1CollectedHeap,
3340 "not a garbage-first heap");
3341 return _g1h;
3342 }
3343
3344 void G1CollectedHeap::gc_prologue(bool full /* Ignored */) {
3345 // always_do_update_barrier = false;
3346 assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");
3347 // Fill TLAB's and such
3348 accumulate_statistics_all_tlabs();
3349 ensure_parsability(true);
3350
3351 if (G1SummarizeRSetStats && (G1SummarizeRSetStatsPeriod > 0) &&
3352 (total_collections() % G1SummarizeRSetStatsPeriod == 0)) {
3353 g1_rem_set()->print_periodic_summary_info("Before GC RS summary");
3354 }
3355 }
3356
3357 void G1CollectedHeap::gc_epilogue(bool full) {
3358
3359 if (G1SummarizeRSetStats &&
3360 (G1SummarizeRSetStatsPeriod > 0) &&
6144
6145 if (G1ConcRegionFreeingVerbose) {
6146 gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
6147 "waiting for free regions");
6148 }
6149
6150 {
6151 MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
6152 while (free_regions_coming()) {
6153 SecondaryFreeList_lock->wait(Mutex::_no_safepoint_check_flag);
6154 }
6155 }
6156
6157 if (G1ConcRegionFreeingVerbose) {
6158 gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
6159 "done waiting for free regions");
6160 }
6161 }
6162
6163 void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) {
6164 assert(heap_lock_held_for_gc(),
6165 "the heap lock should already be held by or for this thread");
6166 _young_list->push_region(hr);
6167 }
6168
6169 class NoYoungRegionsClosure: public HeapRegionClosure {
6170 private:
6171 bool _success;
6172 public:
6173 NoYoungRegionsClosure() : _success(true) { }
6174 bool doHeapRegion(HeapRegion* r) {
6175 if (r->is_young()) {
6176 gclog_or_tty->print_cr("Region ["PTR_FORMAT", "PTR_FORMAT") tagged as young",
6177 r->bottom(), r->end());
6178 _success = false;
6179 }
6180 return false;
6181 }
6182 bool success() { return _success; }
6183 };
6184
6185 bool G1CollectedHeap::check_young_list_empty(bool check_heap, bool check_sample) {
|
2111
2112 size_t G1CollectedHeap::capacity() const {
2113 return _hrm.length() * HeapRegion::GrainBytes;
2114 }
2115
2116 void G1CollectedHeap::reset_gc_time_stamps(HeapRegion* hr) {
2117 assert(!hr->is_continues_humongous(), "pre-condition");
2118 hr->reset_gc_time_stamp();
2119 if (hr->is_starts_humongous()) {
2120 uint first_index = hr->hrm_index() + 1;
2121 uint last_index = hr->last_hc_index();
2122 for (uint i = first_index; i < last_index; i += 1) {
2123 HeapRegion* chr = region_at(i);
2124 assert(chr->is_continues_humongous(), "sanity");
2125 chr->reset_gc_time_stamp();
2126 }
2127 }
2128 }
2129
2130 #ifndef PRODUCT
2131
2132 class CheckGCTimeStampsHRClosure : public HeapRegionClosure {
2133 private:
2134 unsigned _gc_time_stamp;
2135 bool _failures;
2136
2137 public:
2138 CheckGCTimeStampsHRClosure(unsigned gc_time_stamp) :
2139 _gc_time_stamp(gc_time_stamp), _failures(false) { }
2140
2141 virtual bool doHeapRegion(HeapRegion* hr) {
2142 unsigned region_gc_time_stamp = hr->get_gc_time_stamp();
2143 if (_gc_time_stamp != region_gc_time_stamp) {
2144 gclog_or_tty->print_cr("Region "HR_FORMAT" has GC time stamp = %d, "
2145 "expected %d", HR_FORMAT_PARAMS(hr),
2146 region_gc_time_stamp, _gc_time_stamp);
2147 _failures = true;
2148 }
2149 return false;
2150 }
2151
3320
3321 ~PrintRSetsClosure() {
3322 gclog_or_tty->print_cr("Occupied Sum: "SIZE_FORMAT, _occupied_sum);
3323 gclog_or_tty->print_cr("========================================");
3324 gclog_or_tty->cr();
3325 }
3326 };
3327
3328 void G1CollectedHeap::print_cset_rsets() {
3329 PrintRSetsClosure cl("Printing CSet RSets");
3330 collection_set_iterate(&cl);
3331 }
3332
3333 void G1CollectedHeap::print_all_rsets() {
3334 PrintRSetsClosure cl("Printing All RSets");;
3335 heap_region_iterate(&cl);
3336 }
3337 #endif // PRODUCT
3338
3339 G1CollectedHeap* G1CollectedHeap::heap() {
3340 return _g1h;
3341 }
3342
3343 void G1CollectedHeap::gc_prologue(bool full /* Ignored */) {
3344 // always_do_update_barrier = false;
3345 assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");
3346 // Fill TLAB's and such
3347 accumulate_statistics_all_tlabs();
3348 ensure_parsability(true);
3349
3350 if (G1SummarizeRSetStats && (G1SummarizeRSetStatsPeriod > 0) &&
3351 (total_collections() % G1SummarizeRSetStatsPeriod == 0)) {
3352 g1_rem_set()->print_periodic_summary_info("Before GC RS summary");
3353 }
3354 }
3355
3356 void G1CollectedHeap::gc_epilogue(bool full) {
3357
3358 if (G1SummarizeRSetStats &&
3359 (G1SummarizeRSetStatsPeriod > 0) &&
6143
6144 if (G1ConcRegionFreeingVerbose) {
6145 gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
6146 "waiting for free regions");
6147 }
6148
6149 {
6150 MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
6151 while (free_regions_coming()) {
6152 SecondaryFreeList_lock->wait(Mutex::_no_safepoint_check_flag);
6153 }
6154 }
6155
6156 if (G1ConcRegionFreeingVerbose) {
6157 gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
6158 "done waiting for free regions");
6159 }
6160 }
6161
6162 void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) {
6163 _young_list->push_region(hr);
6164 }
6165
6166 class NoYoungRegionsClosure: public HeapRegionClosure {
6167 private:
6168 bool _success;
6169 public:
6170 NoYoungRegionsClosure() : _success(true) { }
6171 bool doHeapRegion(HeapRegion* r) {
6172 if (r->is_young()) {
6173 gclog_or_tty->print_cr("Region ["PTR_FORMAT", "PTR_FORMAT") tagged as young",
6174 r->bottom(), r->end());
6175 _success = false;
6176 }
6177 return false;
6178 }
6179 bool success() { return _success; }
6180 };
6181
6182 bool G1CollectedHeap::check_young_list_empty(bool check_heap, bool check_sample) {
|