@@ -1928,6 +1928,35 @@ bool G1CollectedHeap::try_collect_concurrently(GCCause::Cause cause,
19281928 }
19291929}
19301930
1931+ bool G1CollectedHeap::try_collect_fullgc (GCCause::Cause cause,
1932+ const G1GCCounters& counters_before) {
1933+ assert_heap_not_locked ();
1934+
1935+ while (true ) {
1936+ VM_G1CollectFull op (counters_before.total_collections (),
1937+ counters_before.total_full_collections (),
1938+ cause);
1939+ VMThread::execute (&op);
1940+
1941+ // Request is trivially finished.
1942+ if (!GCCause::is_explicit_full_gc (cause) || op.gc_succeeded ()) {
1943+ return op.gc_succeeded ();
1944+ }
1945+
1946+ {
1947+ MutexLocker ml (Heap_lock);
1948+ if (counters_before.total_full_collections () != total_full_collections ()) {
1949+ return true ;
1950+ }
1951+ }
1952+
1953+ if (GCLocker::is_active_and_needs_gc ()) {
1954+ // If GCLocker is active, wait until clear before retrying.
1955+ GCLocker::stall_until_clear ();
1956+ }
1957+ }
1958+ }
1959+
19311960bool G1CollectedHeap::try_collect (GCCause::Cause cause,
19321961 const G1GCCounters& counters_before) {
19331962 if (should_do_concurrent_full_gc (cause)) {
@@ -1951,11 +1980,7 @@ bool G1CollectedHeap::try_collect(GCCause::Cause cause,
19511980 return op.gc_succeeded ();
19521981 } else {
19531982 // Schedule a Full GC.
1954- VM_G1CollectFull op (counters_before.total_collections (),
1955- counters_before.total_full_collections (),
1956- cause);
1957- VMThread::execute (&op);
1958- return op.gc_succeeded ();
1983+ return try_collect_fullgc (cause, counters_before);
19591984 }
19601985}
19611986
0 commit comments