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 47 ConcurrentMarkThread::ConcurrentMarkThread(G1ConcurrentMark* cm) : 48 ConcurrentGCThread(), 49 _cm(cm), 50 _state(Idle), 51 _vtime_accum(0.0), 52 _vtime_mark_accum(0.0) { 53 54 set_name("G1 Main Marker"); 55 create_and_start(); 56 } 57 58 class CMCheckpointRootsFinalClosure: public VoidClosure { 59 60 G1ConcurrentMark* _cm; 61 public: 62 63 CMCheckpointRootsFinalClosure(G1ConcurrentMark* cm) : 64 _cm(cm) {} 65 66 void do_void(){ 285 } 286 287 void ConcurrentMarkThread::stop_service() { 288 MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag); 289 CGC_lock->notify_all(); 290 } 291 292 void ConcurrentMarkThread::sleepBeforeNextCycle() { 293 // We join here because we don't want to do the "shouldConcurrentMark()" 294 // below while the world is otherwise stopped. 295 assert(!in_progress(), "should have been cleared"); 296 297 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 298 while (!started() && !should_terminate()) { 299 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 300 } 301 302 if (started()) { 303 set_in_progress(); 304 } 305 } 306 307 // Note: As is the case with CMS - this method, although exported 308 // by the ConcurrentMarkThread, which is a non-JavaThread, can only 309 // be called by a JavaThread. Currently this is done at vm creation 310 // time (post-vm-init) by the main/Primordial (Java)Thread. 311 // XXX Consider changing this in the future to allow the CM thread 312 // itself to create this thread? 313 void ConcurrentMarkThread::makeSurrogateLockerThread(TRAPS) { 314 assert(UseG1GC, "SLT thread needed only for concurrent GC"); 315 assert(THREAD->is_Java_thread(), "must be a Java thread"); 316 assert(_slt == NULL, "SLT already created"); 317 _slt = SurrogateLockerThread::make(THREAD); 318 } | 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 ConcurrentMarkThread::ConcurrentMarkThread(G1ConcurrentMark* cm) : 45 ConcurrentGCThread(), 46 _cm(cm), 47 _state(Idle), 48 _vtime_accum(0.0), 49 _vtime_mark_accum(0.0) { 50 51 set_name("G1 Main Marker"); 52 create_and_start(); 53 } 54 55 class CMCheckpointRootsFinalClosure: public VoidClosure { 56 57 G1ConcurrentMark* _cm; 58 public: 59 60 CMCheckpointRootsFinalClosure(G1ConcurrentMark* cm) : 61 _cm(cm) {} 62 63 void do_void(){ 282 } 283 284 void ConcurrentMarkThread::stop_service() { 285 MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag); 286 CGC_lock->notify_all(); 287 } 288 289 void ConcurrentMarkThread::sleepBeforeNextCycle() { 290 // We join here because we don't want to do the "shouldConcurrentMark()" 291 // below while the world is otherwise stopped. 292 assert(!in_progress(), "should have been cleared"); 293 294 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 295 while (!started() && !should_terminate()) { 296 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 297 } 298 299 if (started()) { 300 set_in_progress(); 301 } 302 } |