@@ -64,7 +64,6 @@ VM_G1TryInitiateConcMark::VM_G1TryInitiateConcMark(uint gc_count_before,
6464 _mark_in_progress(false ),
6565 _cycle_already_in_progress(false ),
6666 _whitebox_attached(false ),
67- _terminating(false ),
6867 _gc_succeeded(false )
6968{}
7069
@@ -83,19 +82,10 @@ void VM_G1TryInitiateConcMark::doit() {
8382
8483 GCCauseSetter x (g1h, _gc_cause);
8584
86- // Record for handling by caller.
87- _terminating = g1h->concurrent_mark_is_terminating ();
88-
8985 _mark_in_progress = g1h->collector_state ()->mark_in_progress ();
9086 _cycle_already_in_progress = g1h->concurrent_mark ()->cm_thread ()->in_progress ();
9187
92- if (_terminating && GCCause::is_user_requested_gc (_gc_cause)) {
93- // When terminating, the request to initiate a concurrent cycle will be
94- // ignored by do_collection_pause_at_safepoint; instead it will just do
95- // a young-only or mixed GC (depending on phase). For a user request
96- // there's no point in even doing that much, so done. For some non-user
97- // requests the alternative GC might still be needed.
98- } else if (!g1h->policy ()->force_concurrent_start_if_outside_cycle (_gc_cause)) {
88+ if (!g1h->policy ()->force_concurrent_start_if_outside_cycle (_gc_cause)) {
9989 // Failure to force the next GC pause to be a concurrent start indicates
10090 // there is already a concurrent marking cycle in progress. Flags to indicate
10191 // that were already set, so return immediately.
@@ -119,7 +109,6 @@ VM_G1CollectForAllocation::VM_G1CollectForAllocation(size_t word_size,
119109
120110void VM_G1CollectForAllocation::doit () {
121111 G1CollectedHeap* g1h = G1CollectedHeap::heap ();
122-
123112 GCCauseSetter x (g1h, _gc_cause);
124113 // Try a partial collection of some kind.
125114 g1h->do_collection_pause_at_safepoint ();
@@ -156,6 +145,14 @@ void VM_G1PauseConcurrent::doit() {
156145
157146bool VM_G1PauseConcurrent::doit_prologue () {
158147 Heap_lock->lock ();
148+ G1CollectedHeap* g1h = G1CollectedHeap::heap ();
149+ if (g1h->is_shutting_down ()) {
150+ Heap_lock->unlock ();
151+ // JVM shutdown has started. This ensures that any further operations will be properly aborted
152+ // and will not interfere with the shutdown process.
153+ g1h->concurrent_mark ()->abort_marking_threads ();
154+ return false ;
155+ }
159156 return true ;
160157}
161158
0 commit comments