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