< prev index next >

src/share/vm/gc/g1/concurrentMarkThread.cpp

Print this page




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "gc/g1/concurrentMarkThread.inline.hpp"
  27 #include "gc/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc/g1/g1CollectorPolicy.hpp"
  29 #include "gc/g1/g1MMUTracker.hpp"
  30 #include "gc/g1/suspendibleThreadSet.hpp"
  31 #include "gc/g1/vm_operations_g1.hpp"
  32 #include "gc/shared/gcId.hpp"
  33 #include "gc/shared/gcTrace.hpp"
  34 #include "gc/shared/gcTraceTime.inline.hpp"
  35 #include "logging/log.hpp"
  36 #include "memory/resourceArea.hpp"
  37 #include "runtime/vmThread.hpp"
  38 
  39 // ======= Concurrent Mark Thread ========
  40 
  41 // The CM thread is created when the G1 garbage collector is used
  42 
  43 SurrogateLockerThread*
  44      ConcurrentMarkThread::_slt = NULL;
  45 


 116 void ConcurrentMarkThread::run_service() {
 117   _vtime_start = os::elapsedVTime();
 118 
 119   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 120   G1CollectorPolicy* g1_policy = g1h->g1_policy();
 121 
 122   while (!_should_terminate) {
 123     // wait until started is set.
 124     sleepBeforeNextCycle();
 125     if (_should_terminate) {
 126       _cm->root_regions()->cancel_scan();
 127       break;
 128     }
 129 
 130     assert(GCId::current() != GCId::undefined(), "GC id should have been set up by the initial mark GC.");
 131     {
 132       ResourceMark rm;
 133       HandleMark   hm;
 134       double cycle_start = os::elapsedVTime();
 135 





 136       // We have to ensure that we finish scanning the root regions
 137       // before the next GC takes place. To ensure this we have to
 138       // make sure that we do not join the STS until the root regions
 139       // have been scanned. If we did then it's possible that a
 140       // subsequent GC could block us from joining the STS and proceed
 141       // without the root regions have been scanned which would be a
 142       // correctness issue.
 143 
 144       if (_cm->root_regions()->scan_in_progress()) {
 145         assert(!cm()->has_aborted(), "Aborting before root region scanning is finished not supported.");
 146         GCConcPhaseTimer(_cm, "Concurrent Root Region Scanning");
 147         _cm->scanRootRegions();
 148       }
 149 
 150       // It would be nice to use the GCTraceConcTime class here but
 151       // the "end" logging is inside the loop and not at the end of
 152       // a scope. Mimicking the same log output as GCTraceConcTime instead.
 153       jlong mark_start = os::elapsed_counter();
 154       log_info(gc)("Concurrent Mark (%.3fs)", TimeHelper::counter_to_seconds(mark_start));
 155 
 156       int iter = 0;
 157       do {
 158         iter++;
 159         if (!cm()->has_aborted()) {
 160           GCConcPhaseTimer(_cm, "Concurrent Mark");
 161           _cm->markFromRoots();
 162         }
 163 
 164         double mark_end_time = os::elapsedVTime();
 165         jlong mark_end = os::elapsed_counter();




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.hpp"
  27 #include "gc/g1/concurrentMarkThread.inline.hpp"
  28 #include "gc/g1/g1CollectedHeap.inline.hpp"
  29 #include "gc/g1/g1CollectorPolicy.hpp"
  30 #include "gc/g1/g1MMUTracker.hpp"
  31 #include "gc/g1/suspendibleThreadSet.hpp"
  32 #include "gc/g1/vm_operations_g1.hpp"
  33 #include "gc/shared/gcId.hpp"
  34 #include "gc/shared/gcTrace.hpp"
  35 #include "gc/shared/gcTraceTime.inline.hpp"
  36 #include "logging/log.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "runtime/vmThread.hpp"
  39 
  40 // ======= Concurrent Mark Thread ========
  41 
  42 // The CM thread is created when the G1 garbage collector is used
  43 
  44 SurrogateLockerThread*
  45      ConcurrentMarkThread::_slt = NULL;
  46 


 117 void ConcurrentMarkThread::run_service() {
 118   _vtime_start = os::elapsedVTime();
 119 
 120   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 121   G1CollectorPolicy* g1_policy = g1h->g1_policy();
 122 
 123   while (!_should_terminate) {
 124     // wait until started is set.
 125     sleepBeforeNextCycle();
 126     if (_should_terminate) {
 127       _cm->root_regions()->cancel_scan();
 128       break;
 129     }
 130 
 131     assert(GCId::current() != GCId::undefined(), "GC id should have been set up by the initial mark GC.");
 132     {
 133       ResourceMark rm;
 134       HandleMark   hm;
 135       double cycle_start = os::elapsedVTime();
 136 
 137       {
 138         GCConcPhaseTimer(_cm, "Concurrent Clearing of Claimed Marks");
 139         ClassLoaderDataGraph::clear_claimed_marks();
 140       }
 141 
 142       // We have to ensure that we finish scanning the root regions
 143       // before the next GC takes place. To ensure this we have to
 144       // make sure that we do not join the STS until the root regions
 145       // have been scanned. If we did then it's possible that a
 146       // subsequent GC could block us from joining the STS and proceed
 147       // without the root regions have been scanned which would be a
 148       // correctness issue.
 149 
 150       {

 151         GCConcPhaseTimer(_cm, "Concurrent Root Region Scanning");
 152         _cm->scanRootRegions();
 153       }
 154 
 155       // It would be nice to use the GCTraceConcTime class here but
 156       // the "end" logging is inside the loop and not at the end of
 157       // a scope. Mimicking the same log output as GCTraceConcTime instead.
 158       jlong mark_start = os::elapsed_counter();
 159       log_info(gc)("Concurrent Mark (%.3fs)", TimeHelper::counter_to_seconds(mark_start));
 160 
 161       int iter = 0;
 162       do {
 163         iter++;
 164         if (!cm()->has_aborted()) {
 165           GCConcPhaseTimer(_cm, "Concurrent Mark");
 166           _cm->markFromRoots();
 167         }
 168 
 169         double mark_end_time = os::elapsedVTime();
 170         jlong mark_end = os::elapsed_counter();


< prev index next >