36 ConcurrentGCThread(),
37 _full_gc_lock(Mutex::leaf, "ShenandoahFullGC_lock", true, Monitor::_safepoint_check_always),
38 _do_full_gc(false),
39 _graceful_shutdown(0)
40 {
41 create_and_start();
42 }
43
44 ShenandoahConcurrentThread::~ShenandoahConcurrentThread() {
45 // This is here so that super is called.
46 }
47
48 void ShenandoahConcurrentThread::run_service() {
49 ShenandoahHeap* heap = ShenandoahHeap::heap();
50
51 while (!should_terminate()) {
52 if (in_graceful_shutdown()) {
53 break;
54 } else if (is_full_gc()) {
55 service_fullgc_cycle();
56 } else if (heap->shenandoahPolicy()->should_start_concurrent_mark(heap->used(), heap->capacity())) {
57 service_normal_cycle();
58 if (heap->is_evacuation_in_progress()) {
59 heap->set_evacuation_in_progress_concurrently(false);
60 }
61 } else {
62 Thread::current()->_ParkEvent->park(10);
63 }
64 heap->monitoring_support()->update_counters();
65
66 // Make sure the _do_full_gc flag changes are seen.
67 OrderAccess::storeload();
68 }
69
70 // Wait for the actual stop(), can't leave run_service() earlier.
71 while (!should_terminate()) {
72 Thread::current()->_ParkEvent->park(10);
73 }
74 }
75
76 void ShenandoahConcurrentThread::service_normal_cycle() {
77 if (check_cancellation()) return;
78
79 ShenandoahHeap* heap = ShenandoahHeap::heap();
80
81 GCTimer* gc_timer = heap->gc_timer();
82
83 gc_timer->register_gc_start();
84
85 heap->shenandoahPolicy()->increase_cycle_counter();
86
87 GCIdMark gc_id_mark;
88 TraceCollectorStats tcs(heap->monitoring_support()->concurrent_collection_counters());
89 TraceMemoryManagerStats tmms(false, GCCause::_no_cause_specified);
90
91 // Start initial mark under STW:
92 {
93 // Workers are setup by VM_ShenandoahInitMark
|
36 ConcurrentGCThread(),
37 _full_gc_lock(Mutex::leaf, "ShenandoahFullGC_lock", true, Monitor::_safepoint_check_always),
38 _do_full_gc(false),
39 _graceful_shutdown(0)
40 {
41 create_and_start();
42 }
43
44 ShenandoahConcurrentThread::~ShenandoahConcurrentThread() {
45 // This is here so that super is called.
46 }
47
48 void ShenandoahConcurrentThread::run_service() {
49 ShenandoahHeap* heap = ShenandoahHeap::heap();
50
51 while (!should_terminate()) {
52 if (in_graceful_shutdown()) {
53 break;
54 } else if (is_full_gc()) {
55 service_fullgc_cycle();
56 } else if (heap->shenandoahPolicy()->should_start_partial_gc()) {
57 service_partial_cycle();
58 } else if (heap->shenandoahPolicy()->should_start_concurrent_mark(heap->used(), heap->capacity())) {
59 service_normal_cycle();
60 if (heap->is_evacuation_in_progress()) {
61 heap->set_evacuation_in_progress_concurrently(false);
62 }
63 } else {
64 Thread::current()->_ParkEvent->park(10);
65 }
66 heap->monitoring_support()->update_counters();
67
68 // Make sure the _do_full_gc flag changes are seen.
69 OrderAccess::storeload();
70 }
71
72 // Wait for the actual stop(), can't leave run_service() earlier.
73 while (!should_terminate()) {
74 Thread::current()->_ParkEvent->park(10);
75 }
76 }
77
78 void ShenandoahConcurrentThread::service_partial_cycle() {
79 GCIdMark gc_id_mark;
80 VM_ShenandoahPartialGC partial_gc;
81 VMThread::execute(&partial_gc);
82 }
83
84 void ShenandoahConcurrentThread::service_normal_cycle() {
85 if (check_cancellation()) return;
86
87 ShenandoahHeap* heap = ShenandoahHeap::heap();
88
89 GCTimer* gc_timer = heap->gc_timer();
90
91 gc_timer->register_gc_start();
92
93 heap->shenandoahPolicy()->increase_cycle_counter();
94
95 GCIdMark gc_id_mark;
96 TraceCollectorStats tcs(heap->monitoring_support()->concurrent_collection_counters());
97 TraceMemoryManagerStats tmms(false, GCCause::_no_cause_specified);
98
99 // Start initial mark under STW:
100 {
101 // Workers are setup by VM_ShenandoahInitMark
|