Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
          +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
↓ open down ↓ 32 lines elided ↑ open up ↑
  33   33  #ifdef TARGET_OS_FAMILY_solaris
  34   34  # include "thread_solaris.inline.hpp"
  35   35  #endif
  36   36  #ifdef TARGET_OS_FAMILY_windows
  37   37  # include "thread_windows.inline.hpp"
  38   38  #endif
  39   39  
  40   40  class ConcurrentMarkSweepGeneration;
  41   41  class CMSCollector;
  42   42  
  43      -// The Concurrent Mark Sweep GC Thread (could be several in the future).
       43 +// The Concurrent Mark Sweep GC Thread
  44   44  class ConcurrentMarkSweepThread: public ConcurrentGCThread {
  45   45    friend class VMStructs;
  46   46    friend class ConcurrentMarkSweepGeneration;   // XXX should remove friendship
  47   47    friend class CMSCollector;
  48   48   public:
  49   49    virtual void run();
  50   50  
  51   51   private:
  52   52    static ConcurrentMarkSweepThread*     _cmst;
  53   53    static CMSCollector*                  _collector;
  54   54    static SurrogateLockerThread*         _slt;
  55   55    static SurrogateLockerThread::SLT_msg_type _sltBuffer;
  56   56    static Monitor*                       _sltMonitor;
  57   57  
  58      -  ConcurrentMarkSweepThread*            _next;
  59      -
  60   58    static bool _should_terminate;
  61   59  
  62   60    enum CMS_flag_type {
  63   61      CMS_nil             = NoBits,
  64   62      CMS_cms_wants_token = nth_bit(0),
  65   63      CMS_cms_has_token   = nth_bit(1),
  66   64      CMS_vm_wants_token  = nth_bit(2),
  67   65      CMS_vm_has_token    = nth_bit(3)
  68   66    };
  69   67  
↓ open down ↓ 7 lines elided ↑ open up ↑
  77   75    // CMS thread should yield for a young gen collection, direct allocation,
  78   76    // and iCMS activity.
  79   77    static char _pad_1[64 - sizeof(jint)];    // prevent cache-line sharing
  80   78    static volatile jint _pending_yields;
  81   79    static volatile jint _pending_decrements; // decrements to _pending_yields
  82   80    static char _pad_2[64 - sizeof(jint)];    // prevent cache-line sharing
  83   81  
  84   82    // Tracing messages, enabled by CMSTraceThreadState.
  85   83    static inline void trace_state(const char* desc);
  86   84  
  87      -  static volatile bool _icms_enabled;   // iCMS enabled?
       85 +  static volatile int _icms_disabled;   // a counter to track #iCMS disable & enable
  88   86    static volatile bool _should_run;     // iCMS may run
  89   87    static volatile bool _should_stop;    // iCMS should stop
  90   88  
  91   89    // debugging
  92   90    void verify_ok_to_terminate() const PRODUCT_RETURN;
  93   91  
  94   92   public:
  95   93    // Constructor
  96   94    ConcurrentMarkSweepThread(CMSCollector* collector);
  97   95  
↓ open down ↓ 109 lines elided ↑ open up ↑
 207  205    }
 208  206    static bool should_yield()   { return _pending_yields > 0; }
 209  207  
 210  208    // CMS incremental mode.
 211  209    static void start_icms(); // notify thread to start a quantum of work
 212  210    static void stop_icms();  // request thread to stop working
 213  211    void icms_wait();         // if asked to stop, wait until notified to start
 214  212  
 215  213    // Incremental mode is enabled globally by the flag CMSIncrementalMode.  It
 216  214    // must also be enabled/disabled dynamically to allow foreground collections.
 217      -  static inline void enable_icms()              { _icms_enabled = true; }
 218      -  static inline void disable_icms()             { _icms_enabled = false; }
 219      -  static inline void set_icms_enabled(bool val) { _icms_enabled = val; }
 220      -  static inline bool icms_enabled()             { return _icms_enabled; }
      215 +#define ICMS_ENABLING_ASSERT                                                      \
      216 +          assert((CMSIncrementalMode  && _icms_disabled >= 0) ||                  \
      217 +                 (!CMSIncrementalMode && _icms_disabled <= 0), "Error")
      218 +
      219 +  static inline void enable_icms() {
      220 +    ICMS_ENABLING_ASSERT;
      221 +    Atomic::dec(&_icms_disabled);
      222 +  }
      223 +  static inline void disable_icms() {
      224 +   ICMS_ENABLING_ASSERT;
      225 +   Atomic::inc(&_icms_disabled);
      226 +  }
      227 +  static inline bool icms_is_disabled() {
      228 +   ICMS_ENABLING_ASSERT;
      229 +   return _icms_disabled > 0;
      230 +  }
      231 +  static inline bool icms_is_enabled() {
      232 +   return !icms_is_disabled();
      233 +  }
 221  234  };
 222  235  
 223  236  inline void ConcurrentMarkSweepThread::trace_state(const char* desc) {
 224  237    if (CMSTraceThreadState) {
 225  238      char buf[128];
 226  239      TimeStamp& ts = gclog_or_tty->time_stamp();
 227  240      if (!ts.is_updated()) {
 228  241        ts.update();
 229  242      }
 230  243      jio_snprintf(buf, sizeof(buf), " [%.3f:  CMSThread %s] ",
↓ open down ↓ 40 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX