41 // The caller may block while communicating 42 // with the SLT thread in order to acquire/release the PLL. 43 SurrogateLockerThread* slt = ConcurrentMarkSweepThread::slt(); 44 if (slt != NULL) { 45 slt->manipulatePLL(SurrogateLockerThread::acquirePLL); 46 } else { 47 SurrogateLockerThread::report_missing_slt(); 48 } 49 } 50 51 void VM_CMS_Operation::release_and_notify_pending_list_lock() { 52 // The caller may block while communicating 53 // with the SLT thread in order to acquire/release the PLL. 54 ConcurrentMarkSweepThread::slt()-> 55 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL); 56 } 57 58 void VM_CMS_Operation::verify_before_gc() { 59 if (VerifyBeforeGC && 60 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 61 GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); 62 HandleMark hm; 63 FreelistLocker x(_collector); 64 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); 65 GenCollectedHeap::heap()->prepare_for_verify(); 66 Universe::verify(); 67 } 68 } 69 70 void VM_CMS_Operation::verify_after_gc() { 71 if (VerifyAfterGC && 72 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 73 GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); 74 HandleMark hm; 75 FreelistLocker x(_collector); 76 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); 77 Universe::verify(); 78 } 79 } 80 81 bool VM_CMS_Operation::lost_race() const { 82 if (CMSCollector::abstract_state() == CMSCollector::Idling) { 83 // We lost a race to a foreground collection 84 // -- there's nothing to do 85 return true; 86 } 87 assert(CMSCollector::abstract_state() == legal_state(), 88 "Inconsistent collector state?"); 89 return false; 90 } 91 92 bool VM_CMS_Operation::doit_prologue() { 93 assert(Thread::current()->is_ConcurrentGC_thread(), "just checking"); 117 assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock"); 118 assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), 119 "Possible deadlock"); 120 121 // Release the Heap_lock first. 122 Heap_lock->unlock(); 123 if (needs_pll()) { 124 release_and_notify_pending_list_lock(); 125 } 126 } 127 128 ////////////////////////////////////////////////////////// 129 // Methods in class VM_CMS_Initial_Mark 130 ////////////////////////////////////////////////////////// 131 void VM_CMS_Initial_Mark::doit() { 132 if (lost_race()) { 133 // Nothing to do. 134 return; 135 } 136 HS_PRIVATE_CMS_INITMARK_BEGIN(); 137 138 _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark"); 139 140 GenCollectedHeap* gch = GenCollectedHeap::heap(); 141 GCCauseSetter gccs(gch, GCCause::_cms_initial_mark); 142 143 VM_CMS_Operation::verify_before_gc(); 144 145 IsGCActiveMark x; // stop-world GC active 146 _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial, gch->gc_cause()); 147 148 VM_CMS_Operation::verify_after_gc(); 149 150 _collector->_gc_timer_cm->register_gc_pause_end(); 151 152 HS_PRIVATE_CMS_INITMARK_END(); 153 } 154 155 ////////////////////////////////////////////////////////// 156 // Methods in class VM_CMS_Final_Remark_Operation 157 ////////////////////////////////////////////////////////// 158 void VM_CMS_Final_Remark::doit() { 159 if (lost_race()) { 160 // Nothing to do. 161 return; 162 } 163 HS_PRIVATE_CMS_REMARK_BEGIN(); 164 165 _collector->_gc_timer_cm->register_gc_pause_start("Final Mark"); 166 167 GenCollectedHeap* gch = GenCollectedHeap::heap(); 168 GCCauseSetter gccs(gch, GCCause::_cms_final_remark); 169 170 VM_CMS_Operation::verify_before_gc(); 171 172 IsGCActiveMark x; // stop-world GC active 173 _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal, gch->gc_cause()); 174 175 VM_CMS_Operation::verify_after_gc(); 176 177 _collector->save_heap_summary(); 178 _collector->_gc_timer_cm->register_gc_pause_end(); 179 180 HS_PRIVATE_CMS_REMARK_END(); 181 } 182 183 // VM operation to invoke a concurrent collection of a | 41 // The caller may block while communicating 42 // with the SLT thread in order to acquire/release the PLL. 43 SurrogateLockerThread* slt = ConcurrentMarkSweepThread::slt(); 44 if (slt != NULL) { 45 slt->manipulatePLL(SurrogateLockerThread::acquirePLL); 46 } else { 47 SurrogateLockerThread::report_missing_slt(); 48 } 49 } 50 51 void VM_CMS_Operation::release_and_notify_pending_list_lock() { 52 // The caller may block while communicating 53 // with the SLT thread in order to acquire/release the PLL. 54 ConcurrentMarkSweepThread::slt()-> 55 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL); 56 } 57 58 void VM_CMS_Operation::verify_before_gc() { 59 if (VerifyBeforeGC && 60 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 61 GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm); 62 HandleMark hm; 63 FreelistLocker x(_collector); 64 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); 65 GenCollectedHeap::heap()->prepare_for_verify(); 66 Universe::verify(); 67 } 68 } 69 70 void VM_CMS_Operation::verify_after_gc() { 71 if (VerifyAfterGC && 72 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 73 GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm); 74 HandleMark hm; 75 FreelistLocker x(_collector); 76 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); 77 Universe::verify(); 78 } 79 } 80 81 bool VM_CMS_Operation::lost_race() const { 82 if (CMSCollector::abstract_state() == CMSCollector::Idling) { 83 // We lost a race to a foreground collection 84 // -- there's nothing to do 85 return true; 86 } 87 assert(CMSCollector::abstract_state() == legal_state(), 88 "Inconsistent collector state?"); 89 return false; 90 } 91 92 bool VM_CMS_Operation::doit_prologue() { 93 assert(Thread::current()->is_ConcurrentGC_thread(), "just checking"); 117 assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock"); 118 assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(), 119 "Possible deadlock"); 120 121 // Release the Heap_lock first. 122 Heap_lock->unlock(); 123 if (needs_pll()) { 124 release_and_notify_pending_list_lock(); 125 } 126 } 127 128 ////////////////////////////////////////////////////////// 129 // Methods in class VM_CMS_Initial_Mark 130 ////////////////////////////////////////////////////////// 131 void VM_CMS_Initial_Mark::doit() { 132 if (lost_race()) { 133 // Nothing to do. 134 return; 135 } 136 HS_PRIVATE_CMS_INITMARK_BEGIN(); 137 GCIdMark gc_id_mark(_gc_id); 138 139 _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark"); 140 141 GenCollectedHeap* gch = GenCollectedHeap::heap(); 142 GCCauseSetter gccs(gch, GCCause::_cms_initial_mark); 143 144 VM_CMS_Operation::verify_before_gc(); 145 146 IsGCActiveMark x; // stop-world GC active 147 _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial, gch->gc_cause()); 148 149 VM_CMS_Operation::verify_after_gc(); 150 151 _collector->_gc_timer_cm->register_gc_pause_end(); 152 153 HS_PRIVATE_CMS_INITMARK_END(); 154 } 155 156 ////////////////////////////////////////////////////////// 157 // Methods in class VM_CMS_Final_Remark_Operation 158 ////////////////////////////////////////////////////////// 159 void VM_CMS_Final_Remark::doit() { 160 if (lost_race()) { 161 // Nothing to do. 162 return; 163 } 164 HS_PRIVATE_CMS_REMARK_BEGIN(); 165 GCIdMark gc_id_mark(_gc_id); 166 167 _collector->_gc_timer_cm->register_gc_pause_start("Final Mark"); 168 169 GenCollectedHeap* gch = GenCollectedHeap::heap(); 170 GCCauseSetter gccs(gch, GCCause::_cms_final_remark); 171 172 VM_CMS_Operation::verify_before_gc(); 173 174 IsGCActiveMark x; // stop-world GC active 175 _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal, gch->gc_cause()); 176 177 VM_CMS_Operation::verify_after_gc(); 178 179 _collector->save_heap_summary(); 180 _collector->_gc_timer_cm->register_gc_pause_end(); 181 182 HS_PRIVATE_CMS_REMARK_END(); 183 } 184 185 // VM operation to invoke a concurrent collection of a |