< prev index next >

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Print this page
rev 57464 : [mq]: fix
   1  /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


2132 bool G1CollectedHeap::try_collect_concurrently(GCCause::Cause cause,
2133                                                uint gc_counter,
2134                                                uint old_marking_started_before) {
2135   assert_heap_not_locked();
2136   assert(should_do_concurrent_full_gc(cause),
2137          "Non-concurrent cause %s", GCCause::to_string(cause));
2138 
2139   for (uint i = 1; true; ++i) {
2140     // Try to schedule an initial-mark evacuation pause that will
2141     // start a concurrent cycle.
2142     LOG_COLLECT_CONCURRENTLY(cause, "attempt %u", i);
2143     VM_G1TryInitiateConcMark op(gc_counter,
2144                                 cause,
2145                                 policy()->max_pause_time_ms());
2146     VMThread::execute(&op);
2147 
2148     // Request is trivially finished.
2149     if (cause == GCCause::_g1_periodic_collection) {
2150       LOG_COLLECT_CONCURRENTLY_COMPLETE(cause, op.gc_succeeded());
2151       return op.gc_succeeded();







2152     }
2153 
2154     // Lock to get consistent set of values.
2155     uint old_marking_started_after;
2156     uint old_marking_completed_after;
2157     {
2158       MutexLocker ml(Heap_lock);
2159       // Update gc_counter for retrying VMOp if needed. Captured here to be
2160       // consistent with the values we use below for termination tests.  If
2161       // a retry is needed after a possible wait, and another collection
2162       // occurs in the meantime, it will cause our retry to be skipped and
2163       // we'll recheck for termination with updated conditions from that
2164       // more recent collection.  That's what we want, rather than having
2165       // our retry possibly perform an unnecessary collection.
2166       gc_counter = total_collections();
2167       old_marking_started_after = _old_marking_cycles_started;
2168       old_marking_completed_after = _old_marking_cycles_completed;
2169     }
2170 
2171     if (!GCCause::is_user_requested_gc(cause)) {


   1 /*
   2  * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


2132 bool G1CollectedHeap::try_collect_concurrently(GCCause::Cause cause,
2133                                                uint gc_counter,
2134                                                uint old_marking_started_before) {
2135   assert_heap_not_locked();
2136   assert(should_do_concurrent_full_gc(cause),
2137          "Non-concurrent cause %s", GCCause::to_string(cause));
2138 
2139   for (uint i = 1; true; ++i) {
2140     // Try to schedule an initial-mark evacuation pause that will
2141     // start a concurrent cycle.
2142     LOG_COLLECT_CONCURRENTLY(cause, "attempt %u", i);
2143     VM_G1TryInitiateConcMark op(gc_counter,
2144                                 cause,
2145                                 policy()->max_pause_time_ms());
2146     VMThread::execute(&op);
2147 
2148     // Request is trivially finished.
2149     if (cause == GCCause::_g1_periodic_collection) {
2150       LOG_COLLECT_CONCURRENTLY_COMPLETE(cause, op.gc_succeeded());
2151       return op.gc_succeeded();
2152     }
2153 
2154     // If VMOp skipped initiating concurrent marking cycle because
2155     // we're terminating, then we're done.
2156     if (op.terminating()) {
2157       LOG_COLLECT_CONCURRENTLY(cause, "skipped: terminating");
2158       return false;
2159     }
2160 
2161     // Lock to get consistent set of values.
2162     uint old_marking_started_after;
2163     uint old_marking_completed_after;
2164     {
2165       MutexLocker ml(Heap_lock);
2166       // Update gc_counter for retrying VMOp if needed. Captured here to be
2167       // consistent with the values we use below for termination tests.  If
2168       // a retry is needed after a possible wait, and another collection
2169       // occurs in the meantime, it will cause our retry to be skipped and
2170       // we'll recheck for termination with updated conditions from that
2171       // more recent collection.  That's what we want, rather than having
2172       // our retry possibly perform an unnecessary collection.
2173       gc_counter = total_collections();
2174       old_marking_started_after = _old_marking_cycles_started;
2175       old_marking_completed_after = _old_marking_cycles_completed;
2176     }
2177 
2178     if (!GCCause::is_user_requested_gc(cause)) {


< prev index next >