< prev index next >

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

Print this page
rev 9489 : 8143251: HeapRetentionTest.java Test is failing on jdk9/dev
Reviewed-by: tschatzl, david


2251   size_t _used;
2252 public:
2253   SumUsedClosure() : _used(0) {}
2254   bool doHeapRegion(HeapRegion* r) {
2255     _used += r->used();
2256     return false;
2257   }
2258   size_t result() { return _used; }
2259 };
2260 
2261 size_t G1CollectedHeap::recalculate_used() const {
2262   double recalculate_used_start = os::elapsedTime();
2263 
2264   SumUsedClosure blk;
2265   heap_region_iterate(&blk);
2266 
2267   g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
2268   return blk.result();
2269 }
2270 
2271 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
2272   switch (cause) {
2273     case GCCause::_gc_locker:               return GCLockerInvokesConcurrent;
2274     case GCCause::_java_lang_system_gc:     return ExplicitGCInvokesConcurrent;
2275     case GCCause::_dcmd_gc_run:             return ExplicitGCInvokesConcurrent;
2276     case GCCause::_g1_humongous_allocation: return true;
2277     case GCCause::_update_allocation_context_stats_inc: return true;
2278     case GCCause::_wb_conc_mark:            return true;
2279     default:                                return false;








2280   }
2281 }
2282 
2283 #ifndef PRODUCT
2284 void G1CollectedHeap::allocate_dummy_regions() {
2285   // Let's fill up most of the region
2286   size_t word_size = HeapRegion::GrainWords - 1024;
2287   // And as a result the region we'll allocate will be humongous.
2288   guarantee(is_humongous(word_size), "sanity");
2289 
2290   // _filler_array_max_size is set to humongous object threshold
2291   // but temporarily change it to use CollectedHeap::fill_with_object().
2292   SizeTFlagSetting fs(_filler_array_max_size, word_size);
2293 
2294   for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
2295     // Let's use the existing mechanism for the allocation
2296     HeapWord* dummy_obj = humongous_obj_allocate(word_size,
2297                                                  AllocationContext::system());
2298     if (dummy_obj != NULL) {
2299       MemRegion mr(dummy_obj, word_size);




2251   size_t _used;
2252 public:
2253   SumUsedClosure() : _used(0) {}
2254   bool doHeapRegion(HeapRegion* r) {
2255     _used += r->used();
2256     return false;
2257   }
2258   size_t result() { return _used; }
2259 };
2260 
2261 size_t G1CollectedHeap::recalculate_used() const {
2262   double recalculate_used_start = os::elapsedTime();
2263 
2264   SumUsedClosure blk;
2265   heap_region_iterate(&blk);
2266 
2267   g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
2268   return blk.result();
2269 }
2270 
2271 bool  G1CollectedHeap::is_user_requested_concurrent_full_gc(GCCause::Cause cause) {
2272   switch (cause) {

2273     case GCCause::_java_lang_system_gc:                 return ExplicitGCInvokesConcurrent;
2274     case GCCause::_dcmd_gc_run:                         return ExplicitGCInvokesConcurrent;

2275     case GCCause::_update_allocation_context_stats_inc: return true;
2276     case GCCause::_wb_conc_mark:                        return true;
2277     default :                                           return false;
2278   }
2279 }
2280 
2281 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
2282   switch (cause) {
2283     case GCCause::_gc_locker:               return GCLockerInvokesConcurrent;
2284     case GCCause::_g1_humongous_allocation: return true;
2285     default:                                return is_user_requested_concurrent_full_gc(cause);
2286   }
2287 }
2288 
2289 #ifndef PRODUCT
2290 void G1CollectedHeap::allocate_dummy_regions() {
2291   // Let's fill up most of the region
2292   size_t word_size = HeapRegion::GrainWords - 1024;
2293   // And as a result the region we'll allocate will be humongous.
2294   guarantee(is_humongous(word_size), "sanity");
2295 
2296   // _filler_array_max_size is set to humongous object threshold
2297   // but temporarily change it to use CollectedHeap::fill_with_object().
2298   SizeTFlagSetting fs(_filler_array_max_size, word_size);
2299 
2300   for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
2301     // Let's use the existing mechanism for the allocation
2302     HeapWord* dummy_obj = humongous_obj_allocate(word_size,
2303                                                  AllocationContext::system());
2304     if (dummy_obj != NULL) {
2305       MemRegion mr(dummy_obj, word_size);


< prev index next >