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(){ 310 } 311 312 void ConcurrentMarkThread::stop_service() { 313 MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag); 314 CGC_lock->notify_all(); 315 } 316 317 void ConcurrentMarkThread::sleepBeforeNextCycle() { 318 // We join here because we don't want to do the "shouldConcurrentMark()" 319 // below while the world is otherwise stopped. 320 assert(!in_progress(), "should have been cleared"); 321 322 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 323 while (!started() && !_should_terminate) { 324 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 325 } 326 327 if (started()) { 328 set_in_progress(); 329 } 330 } 331 332 // Note: As is the case with CMS - this method, although exported 333 // by the ConcurrentMarkThread, which is a non-JavaThread, can only 334 // be called by a JavaThread. Currently this is done at vm creation 335 // time (post-vm-init) by the main/Primordial (Java)Thread. 336 // XXX Consider changing this in the future to allow the CM thread 337 // itself to create this thread? 338 void ConcurrentMarkThread::makeSurrogateLockerThread(TRAPS) { 339 assert(UseG1GC, "SLT thread needed only for concurrent GC"); 340 assert(THREAD->is_Java_thread(), "must be a Java thread"); 341 assert(_slt == NULL, "SLT already created"); 342 _slt = SurrogateLockerThread::make(THREAD); 343 } | 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(){ 307 } 308 309 void ConcurrentMarkThread::stop_service() { 310 MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag); 311 CGC_lock->notify_all(); 312 } 313 314 void ConcurrentMarkThread::sleepBeforeNextCycle() { 315 // We join here because we don't want to do the "shouldConcurrentMark()" 316 // below while the world is otherwise stopped. 317 assert(!in_progress(), "should have been cleared"); 318 319 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 320 while (!started() && !_should_terminate) { 321 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 322 } 323 324 if (started()) { 325 set_in_progress(); 326 } 327 } |