< prev index next >

src/share/vm/gc/cms/vmCMSOperations.cpp

Print this page




  68   }
  69 }
  70 
  71 bool VM_CMS_Operation::lost_race() const {
  72   if (CMSCollector::abstract_state() == CMSCollector::Idling) {
  73     // We lost a race to a foreground collection
  74     // -- there's nothing to do
  75     return true;
  76   }
  77   assert(CMSCollector::abstract_state() == legal_state(),
  78          "Inconsistent collector state?");
  79   return false;
  80 }
  81 
  82 bool VM_CMS_Operation::doit_prologue() {
  83   assert(Thread::current()->is_ConcurrentGC_thread(), "just checking");
  84   assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock");
  85   assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
  86          "Possible deadlock");
  87 
  88   if (needs_pll()) {
  89     acquire_pending_list_lock();
  90   }
  91   // Get the Heap_lock after the pending_list_lock.
  92   Heap_lock->lock();
  93   if (lost_race()) {
  94     assert(_prologue_succeeded == false, "Initialized in c'tor");
  95     Heap_lock->unlock();
  96     if (needs_pll()) {
  97       release_and_notify_pending_list_lock();
  98     }
  99   } else {
 100     _prologue_succeeded = true;
 101   }
 102   return _prologue_succeeded;
 103 }
 104 
 105 void VM_CMS_Operation::doit_epilogue() {
 106   assert(Thread::current()->is_ConcurrentGC_thread(), "just checking");
 107   assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock");
 108   assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
 109          "Possible deadlock");
 110 
 111   // Release the Heap_lock first.
 112   Heap_lock->unlock();
 113   if (needs_pll()) {
 114     release_and_notify_pending_list_lock();
 115   }
 116 }
 117 
 118 //////////////////////////////////////////////////////////
 119 // Methods in class VM_CMS_Initial_Mark
 120 //////////////////////////////////////////////////////////
 121 void VM_CMS_Initial_Mark::doit() {
 122   if (lost_race()) {
 123     // Nothing to do.
 124     return;
 125   }
 126   HS_PRIVATE_CMS_INITMARK_BEGIN();
 127   GCIdMark gc_id_mark(_gc_id);
 128 
 129   _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark");
 130 
 131   GenCollectedHeap* gch = GenCollectedHeap::heap();
 132   GCCauseSetter gccs(gch, GCCause::_cms_initial_mark);
 133 




  68   }
  69 }
  70 
  71 bool VM_CMS_Operation::lost_race() const {
  72   if (CMSCollector::abstract_state() == CMSCollector::Idling) {
  73     // We lost a race to a foreground collection
  74     // -- there's nothing to do
  75     return true;
  76   }
  77   assert(CMSCollector::abstract_state() == legal_state(),
  78          "Inconsistent collector state?");
  79   return false;
  80 }
  81 
  82 bool VM_CMS_Operation::doit_prologue() {
  83   assert(Thread::current()->is_ConcurrentGC_thread(), "just checking");
  84   assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock");
  85   assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
  86          "Possible deadlock");
  87 
  88   if (needs_pending_list_lock()) {
  89     acquire_pending_list_lock();
  90   }
  91   // Get the Heap_lock after the pending_list_lock.
  92   Heap_lock->lock();
  93   if (lost_race()) {
  94     assert(_prologue_succeeded == false, "Initialized in c'tor");
  95     Heap_lock->unlock();
  96     if (needs_pending_list_lock()) {
  97       release_and_notify_pending_list_lock();
  98     }
  99   } else {
 100     _prologue_succeeded = true;
 101   }
 102   return _prologue_succeeded;
 103 }
 104 
 105 void VM_CMS_Operation::doit_epilogue() {
 106   assert(Thread::current()->is_ConcurrentGC_thread(), "just checking");
 107   assert(!CMSCollector::foregroundGCShouldWait(), "Possible deadlock");
 108   assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
 109          "Possible deadlock");
 110 
 111   // Release the Heap_lock first.
 112   Heap_lock->unlock();
 113   if (needs_pending_list_lock()) {
 114     release_and_notify_pending_list_lock();
 115   }
 116 }
 117 
 118 //////////////////////////////////////////////////////////
 119 // Methods in class VM_CMS_Initial_Mark
 120 //////////////////////////////////////////////////////////
 121 void VM_CMS_Initial_Mark::doit() {
 122   if (lost_race()) {
 123     // Nothing to do.
 124     return;
 125   }
 126   HS_PRIVATE_CMS_INITMARK_BEGIN();
 127   GCIdMark gc_id_mark(_gc_id);
 128 
 129   _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark");
 130 
 131   GenCollectedHeap* gch = GenCollectedHeap::heap();
 132   GCCauseSetter gccs(gch, GCCause::_cms_initial_mark);
 133 


< prev index next >