347 {
348 MonitorLocker ml(RootRegionScan_lock, Mutex::_no_safepoint_check_flag);
349 while (scan_in_progress()) {
350 ml.wait();
351 }
352 }
353 return true;
354 }
355
356 G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
357 G1RegionToSpaceMapper* prev_bitmap_storage,
358 G1RegionToSpaceMapper* next_bitmap_storage) :
359 // _cm_thread set inside the constructor
360 _g1h(g1h),
361
362 _mark_bitmap_1(),
363 _mark_bitmap_2(),
364 _prev_mark_bitmap(&_mark_bitmap_1),
365 _next_mark_bitmap(&_mark_bitmap_2),
366
367 _heap(_g1h->reserved_region()),
368
369 _root_regions(_g1h->max_regions()),
370
371 _global_mark_stack(),
372
373 // _finger set in set_non_marking_state
374
375 _worker_id_offset(G1DirtyCardQueueSet::num_par_ids() + G1ConcRefinementThreads),
376 _max_num_tasks(ParallelGCThreads),
377 // _num_active_tasks set in set_non_marking_state()
378 // _tasks set inside the constructor
379
380 _task_queues(new G1CMTaskQueueSet((int) _max_num_tasks)),
381 _terminator((int) _max_num_tasks, _task_queues),
382
383 _first_overflow_barrier_sync(),
384 _second_overflow_barrier_sync(),
385
386 _has_overflown(false),
387 _concurrent(false),
393 // _verbose_level set below
394
395 _init_times(),
396 _remark_times(),
397 _remark_mark_times(),
398 _remark_weak_ref_times(),
399 _cleanup_times(),
400 _total_cleanup_time(0.0),
401
402 _accum_task_vtime(NULL),
403
404 _concurrent_workers(NULL),
405 _num_concurrent_workers(0),
406 _max_concurrent_workers(0),
407
408 _region_mark_stats(NEW_C_HEAP_ARRAY(G1RegionMarkStats, _g1h->max_regions(), mtGC)),
409 _top_at_rebuild_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_regions(), mtGC))
410 {
411 assert(CGC_lock != NULL, "CGC_lock must be initialized");
412
413 _mark_bitmap_1.initialize(g1h->reserved_region(), prev_bitmap_storage);
414 _mark_bitmap_2.initialize(g1h->reserved_region(), next_bitmap_storage);
415
416 // Create & start ConcurrentMark thread.
417 _cm_thread = new G1ConcurrentMarkThread(this);
418 if (_cm_thread->osthread() == NULL) {
419 vm_shutdown_during_initialization("Could not create ConcurrentMarkThread");
420 }
421
422 log_debug(gc)("ConcGCThreads: %u offset %u", ConcGCThreads, _worker_id_offset);
423 log_debug(gc)("ParallelGCThreads: %u", ParallelGCThreads);
424
425 _num_concurrent_workers = ConcGCThreads;
426 _max_concurrent_workers = _num_concurrent_workers;
427
428 _concurrent_workers = new WorkGang("G1 Conc", _max_concurrent_workers, false, true);
429 _concurrent_workers->initialize_workers();
430
431 if (!_global_mark_stack.initialize(MarkStackSize, MarkStackSizeMax)) {
432 vm_exit_during_initialization("Failed to allocate initial concurrent mark overflow mark stack.");
433 }
434
2876 #define G1PPRL_BYTE_H_FORMAT " %9s"
2877 #define G1PPRL_DOUBLE_FORMAT " %14.1f"
2878 #define G1PPRL_DOUBLE_H_FORMAT " %14s"
2879
2880 // For summary info
2881 #define G1PPRL_SUM_ADDR_FORMAT(tag) " " tag ":" G1PPRL_ADDR_BASE_FORMAT
2882 #define G1PPRL_SUM_BYTE_FORMAT(tag) " " tag ": " SIZE_FORMAT
2883 #define G1PPRL_SUM_MB_FORMAT(tag) " " tag ": %1.2f MB"
2884 #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag) " / %1.2f %%"
2885
2886 G1PrintRegionLivenessInfoClosure::G1PrintRegionLivenessInfoClosure(const char* phase_name) :
2887 _total_used_bytes(0), _total_capacity_bytes(0),
2888 _total_prev_live_bytes(0), _total_next_live_bytes(0),
2889 _total_remset_bytes(0), _total_strong_code_roots_bytes(0)
2890 {
2891 if (!log_is_enabled(Trace, gc, liveness)) {
2892 return;
2893 }
2894
2895 G1CollectedHeap* g1h = G1CollectedHeap::heap();
2896 MemRegion reserved = g1h->reserved_region();
2897 double now = os::elapsedTime();
2898
2899 // Print the header of the output.
2900 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
2901 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" HEAP"
2902 G1PPRL_SUM_ADDR_FORMAT("reserved")
2903 G1PPRL_SUM_BYTE_FORMAT("region-size"),
2904 p2i(reserved.start()), p2i(reserved.end()),
2905 HeapRegion::GrainBytes);
2906 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
2907 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
2908 G1PPRL_TYPE_H_FORMAT
2909 G1PPRL_ADDR_BASE_H_FORMAT
2910 G1PPRL_BYTE_H_FORMAT
2911 G1PPRL_BYTE_H_FORMAT
2912 G1PPRL_BYTE_H_FORMAT
2913 G1PPRL_DOUBLE_H_FORMAT
2914 G1PPRL_BYTE_H_FORMAT
2915 G1PPRL_STATE_H_FORMAT
2916 G1PPRL_BYTE_H_FORMAT,
|
347 {
348 MonitorLocker ml(RootRegionScan_lock, Mutex::_no_safepoint_check_flag);
349 while (scan_in_progress()) {
350 ml.wait();
351 }
352 }
353 return true;
354 }
355
356 G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
357 G1RegionToSpaceMapper* prev_bitmap_storage,
358 G1RegionToSpaceMapper* next_bitmap_storage) :
359 // _cm_thread set inside the constructor
360 _g1h(g1h),
361
362 _mark_bitmap_1(),
363 _mark_bitmap_2(),
364 _prev_mark_bitmap(&_mark_bitmap_1),
365 _next_mark_bitmap(&_mark_bitmap_2),
366
367 _heap(_g1h->reserved()),
368
369 _root_regions(_g1h->max_regions()),
370
371 _global_mark_stack(),
372
373 // _finger set in set_non_marking_state
374
375 _worker_id_offset(G1DirtyCardQueueSet::num_par_ids() + G1ConcRefinementThreads),
376 _max_num_tasks(ParallelGCThreads),
377 // _num_active_tasks set in set_non_marking_state()
378 // _tasks set inside the constructor
379
380 _task_queues(new G1CMTaskQueueSet((int) _max_num_tasks)),
381 _terminator((int) _max_num_tasks, _task_queues),
382
383 _first_overflow_barrier_sync(),
384 _second_overflow_barrier_sync(),
385
386 _has_overflown(false),
387 _concurrent(false),
393 // _verbose_level set below
394
395 _init_times(),
396 _remark_times(),
397 _remark_mark_times(),
398 _remark_weak_ref_times(),
399 _cleanup_times(),
400 _total_cleanup_time(0.0),
401
402 _accum_task_vtime(NULL),
403
404 _concurrent_workers(NULL),
405 _num_concurrent_workers(0),
406 _max_concurrent_workers(0),
407
408 _region_mark_stats(NEW_C_HEAP_ARRAY(G1RegionMarkStats, _g1h->max_regions(), mtGC)),
409 _top_at_rebuild_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_regions(), mtGC))
410 {
411 assert(CGC_lock != NULL, "CGC_lock must be initialized");
412
413 _mark_bitmap_1.initialize(g1h->reserved(), prev_bitmap_storage);
414 _mark_bitmap_2.initialize(g1h->reserved(), next_bitmap_storage);
415
416 // Create & start ConcurrentMark thread.
417 _cm_thread = new G1ConcurrentMarkThread(this);
418 if (_cm_thread->osthread() == NULL) {
419 vm_shutdown_during_initialization("Could not create ConcurrentMarkThread");
420 }
421
422 log_debug(gc)("ConcGCThreads: %u offset %u", ConcGCThreads, _worker_id_offset);
423 log_debug(gc)("ParallelGCThreads: %u", ParallelGCThreads);
424
425 _num_concurrent_workers = ConcGCThreads;
426 _max_concurrent_workers = _num_concurrent_workers;
427
428 _concurrent_workers = new WorkGang("G1 Conc", _max_concurrent_workers, false, true);
429 _concurrent_workers->initialize_workers();
430
431 if (!_global_mark_stack.initialize(MarkStackSize, MarkStackSizeMax)) {
432 vm_exit_during_initialization("Failed to allocate initial concurrent mark overflow mark stack.");
433 }
434
2876 #define G1PPRL_BYTE_H_FORMAT " %9s"
2877 #define G1PPRL_DOUBLE_FORMAT " %14.1f"
2878 #define G1PPRL_DOUBLE_H_FORMAT " %14s"
2879
2880 // For summary info
2881 #define G1PPRL_SUM_ADDR_FORMAT(tag) " " tag ":" G1PPRL_ADDR_BASE_FORMAT
2882 #define G1PPRL_SUM_BYTE_FORMAT(tag) " " tag ": " SIZE_FORMAT
2883 #define G1PPRL_SUM_MB_FORMAT(tag) " " tag ": %1.2f MB"
2884 #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag) " / %1.2f %%"
2885
2886 G1PrintRegionLivenessInfoClosure::G1PrintRegionLivenessInfoClosure(const char* phase_name) :
2887 _total_used_bytes(0), _total_capacity_bytes(0),
2888 _total_prev_live_bytes(0), _total_next_live_bytes(0),
2889 _total_remset_bytes(0), _total_strong_code_roots_bytes(0)
2890 {
2891 if (!log_is_enabled(Trace, gc, liveness)) {
2892 return;
2893 }
2894
2895 G1CollectedHeap* g1h = G1CollectedHeap::heap();
2896 MemRegion reserved = g1h->reserved();
2897 double now = os::elapsedTime();
2898
2899 // Print the header of the output.
2900 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
2901 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" HEAP"
2902 G1PPRL_SUM_ADDR_FORMAT("reserved")
2903 G1PPRL_SUM_BYTE_FORMAT("region-size"),
2904 p2i(reserved.start()), p2i(reserved.end()),
2905 HeapRegion::GrainBytes);
2906 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
2907 log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
2908 G1PPRL_TYPE_H_FORMAT
2909 G1PPRL_ADDR_BASE_H_FORMAT
2910 G1PPRL_BYTE_H_FORMAT
2911 G1PPRL_BYTE_H_FORMAT
2912 G1PPRL_BYTE_H_FORMAT
2913 G1PPRL_DOUBLE_H_FORMAT
2914 G1PPRL_BYTE_H_FORMAT
2915 G1PPRL_STATE_H_FORMAT
2916 G1PPRL_BYTE_H_FORMAT,
|