Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp
          +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp
↓ open down ↓ 43 lines elided ↑ open up ↑
  44   44  
  45   45  ConcurrentMarkSweepThread*
  46   46       ConcurrentMarkSweepThread::_cmst     = NULL;
  47   47  CMSCollector* ConcurrentMarkSweepThread::_collector = NULL;
  48   48  bool ConcurrentMarkSweepThread::_should_terminate = false;
  49   49  int  ConcurrentMarkSweepThread::_CMS_flag         = CMS_nil;
  50   50  
  51   51  volatile jint ConcurrentMarkSweepThread::_pending_yields      = 0;
  52   52  volatile jint ConcurrentMarkSweepThread::_pending_decrements  = 0;
  53   53  
  54      -volatile bool ConcurrentMarkSweepThread::_icms_enabled   = false;
       54 +volatile jint ConcurrentMarkSweepThread::_icms_disabled   = 0;
  55   55  volatile bool ConcurrentMarkSweepThread::_should_run     = false;
  56   56  // When icms is enabled, the icms thread is stopped until explicitly
  57   57  // started.
  58   58  volatile bool ConcurrentMarkSweepThread::_should_stop    = true;
  59   59  
  60   60  SurrogateLockerThread*
  61   61       ConcurrentMarkSweepThread::_slt = NULL;
  62   62  SurrogateLockerThread::SLT_msg_type
  63   63       ConcurrentMarkSweepThread::_sltBuffer = SurrogateLockerThread::empty;
  64   64  Monitor*
↓ open down ↓ 12 lines elided ↑ open up ↑
  77   77    if (os::create_thread(this, os::cgc_thread)) {
  78   78      // XXX: need to set this to low priority
  79   79      // unless "agressive mode" set; priority
  80   80      // should be just less than that of VMThread.
  81   81      os::set_priority(this, NearMaxPriority);
  82   82      if (!DisableStartThread) {
  83   83        os::start_thread(this);
  84   84      }
  85   85    }
  86   86    _sltMonitor = SLT_lock;
  87      -  set_icms_enabled(CMSIncrementalMode);
       87 +  assert(!CMSIncrementalMode || icms_is_enabled(), "Error");
  88   88  }
  89   89  
  90   90  void ConcurrentMarkSweepThread::run() {
  91   91    assert(this == cmst(), "just checking");
  92   92  
  93   93    this->record_stack_base_and_size();
  94   94    this->initialize_thread_local_storage();
  95   95    this->set_active_handles(JNIHandleBlock::allocate_block());
  96   96    // From this time Thread::current() should be working.
  97   97    assert(this == Thread::current(), "just checking");
↓ open down ↓ 236 lines elided ↑ open up ↑
 334  334      trace_state("stop_icms");
 335  335      _should_stop = true;
 336  336      _should_run = false;
 337  337      asynchronous_yield_request();
 338  338      iCMS_lock->notify_all();
 339  339    }
 340  340  }
 341  341  
 342  342  void ConcurrentMarkSweepThread::icms_wait() {
 343  343    assert(UseConcMarkSweepGC && CMSIncrementalMode, "just checking");
 344      -  if (_should_stop && icms_enabled()) {
      344 +  if (_should_stop && icms_is_enabled()) {
 345  345      MutexLockerEx x(iCMS_lock, Mutex::_no_safepoint_check_flag);
 346  346      trace_state("pause_icms");
 347  347      _collector->stats().stop_cms_timer();
 348      -    while(!_should_run && icms_enabled()) {
      348 +    while(!_should_run && icms_is_enabled()) {
 349  349        iCMS_lock->wait(Mutex::_no_safepoint_check_flag);
 350  350      }
 351  351      _collector->stats().start_cms_timer();
 352  352      _should_stop = false;
 353  353      trace_state("pause_icms end");
 354  354    }
 355  355  }
 356  356  
 357  357  // Note: this method, although exported by the ConcurrentMarkSweepThread,
 358  358  // which is a non-JavaThread, can only be called by a JavaThread.
 359  359  // Currently this is done at vm creation time (post-vm-init) by the
 360  360  // main/Primordial (Java)Thread.
 361  361  // XXX Consider changing this in the future to allow the CMS thread
 362  362  // itself to create this thread?
 363  363  void ConcurrentMarkSweepThread::makeSurrogateLockerThread(TRAPS) {
 364  364    assert(UseConcMarkSweepGC, "SLT thread needed only for CMS GC");
 365  365    assert(_slt == NULL, "SLT already created");
 366  366    _slt = SurrogateLockerThread::make(THREAD);
 367  367  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX