2242 size_t _used;
2243 public:
2244 SumUsedClosure() : _used(0) {}
2245 bool doHeapRegion(HeapRegion* r) {
2246 _used += r->used();
2247 return false;
2248 }
2249 size_t result() { return _used; }
2250 };
2251
2252 size_t G1CollectedHeap::recalculate_used() const {
2253 double recalculate_used_start = os::elapsedTime();
2254
2255 SumUsedClosure blk;
2256 heap_region_iterate(&blk);
2257
2258 g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
2259 return blk.result();
2260 }
2261
2262 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
2263 switch (cause) {
2264 case GCCause::_gc_locker: return GCLockerInvokesConcurrent;
2265 case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent;
2266 case GCCause::_dcmd_gc_run: return ExplicitGCInvokesConcurrent;
2267 case GCCause::_g1_humongous_allocation: return true;
2268 case GCCause::_update_allocation_context_stats_inc: return true;
2269 case GCCause::_wb_conc_mark: return true;
2270 default: return false;
2271 }
2272 }
2273
2274 #ifndef PRODUCT
2275 void G1CollectedHeap::allocate_dummy_regions() {
2276 // Let's fill up most of the region
2277 size_t word_size = HeapRegion::GrainWords - 1024;
2278 // And as a result the region we'll allocate will be humongous.
2279 guarantee(is_humongous(word_size), "sanity");
2280
2281 // _filler_array_max_size is set to humongous object threshold
2282 // but temporarily change it to use CollectedHeap::fill_with_object().
2283 SizeTFlagSetting fs(_filler_array_max_size, word_size);
2284
2285 for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
2286 // Let's use the existing mechanism for the allocation
2287 HeapWord* dummy_obj = humongous_obj_allocate(word_size,
2288 AllocationContext::system());
2289 if (dummy_obj != NULL) {
2290 MemRegion mr(dummy_obj, word_size);
|
2242 size_t _used;
2243 public:
2244 SumUsedClosure() : _used(0) {}
2245 bool doHeapRegion(HeapRegion* r) {
2246 _used += r->used();
2247 return false;
2248 }
2249 size_t result() { return _used; }
2250 };
2251
2252 size_t G1CollectedHeap::recalculate_used() const {
2253 double recalculate_used_start = os::elapsedTime();
2254
2255 SumUsedClosure blk;
2256 heap_region_iterate(&blk);
2257
2258 g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
2259 return blk.result();
2260 }
2261
2262 bool G1CollectedHeap::user_requested_concurrent_full_gc(GCCause::Cause cause) {
2263 switch (cause) {
2264 case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent;
2265 case GCCause::_dcmd_gc_run: return ExplicitGCInvokesConcurrent;
2266 case GCCause::_update_allocation_context_stats_inc: return true;
2267 case GCCause::_wb_conc_mark: return true;
2268 default : return false;
2269 }
2270 }
2271
2272 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
2273 switch (cause) {
2274 case GCCause::_gc_locker: return GCLockerInvokesConcurrent;
2275 case GCCause::_g1_humongous_allocation: return true;
2276 default: return user_requested_concurrent_full_gc(cause);
2277 }
2278 }
2279
2280 #ifndef PRODUCT
2281 void G1CollectedHeap::allocate_dummy_regions() {
2282 // Let's fill up most of the region
2283 size_t word_size = HeapRegion::GrainWords - 1024;
2284 // And as a result the region we'll allocate will be humongous.
2285 guarantee(is_humongous(word_size), "sanity");
2286
2287 // _filler_array_max_size is set to humongous object threshold
2288 // but temporarily change it to use CollectedHeap::fill_with_object().
2289 SizeTFlagSetting fs(_filler_array_max_size, word_size);
2290
2291 for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
2292 // Let's use the existing mechanism for the allocation
2293 HeapWord* dummy_obj = humongous_obj_allocate(word_size,
2294 AllocationContext::system());
2295 if (dummy_obj != NULL) {
2296 MemRegion mr(dummy_obj, word_size);
|