src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
Print this page
@@ -38,11 +38,11 @@
#endif
class ConcurrentMarkSweepGeneration;
class CMSCollector;
-// The Concurrent Mark Sweep GC Thread (could be several in the future).
+// The Concurrent Mark Sweep GC Thread
class ConcurrentMarkSweepThread: public ConcurrentGCThread {
friend class VMStructs;
friend class ConcurrentMarkSweepGeneration; // XXX should remove friendship
friend class CMSCollector;
public:
@@ -53,12 +53,10 @@
static CMSCollector* _collector;
static SurrogateLockerThread* _slt;
static SurrogateLockerThread::SLT_msg_type _sltBuffer;
static Monitor* _sltMonitor;
- ConcurrentMarkSweepThread* _next;
-
static bool _should_terminate;
enum CMS_flag_type {
CMS_nil = NoBits,
CMS_cms_wants_token = nth_bit(0),
@@ -82,11 +80,11 @@
static char _pad_2[64 - sizeof(jint)]; // prevent cache-line sharing
// Tracing messages, enabled by CMSTraceThreadState.
static inline void trace_state(const char* desc);
- static volatile bool _icms_enabled; // iCMS enabled?
+ static volatile int _icms_disabled; // a counter to track #iCMS disable & enable
static volatile bool _should_run; // iCMS may run
static volatile bool _should_stop; // iCMS should stop
// debugging
void verify_ok_to_terminate() const PRODUCT_RETURN;
@@ -212,14 +210,29 @@
static void stop_icms(); // request thread to stop working
void icms_wait(); // if asked to stop, wait until notified to start
// Incremental mode is enabled globally by the flag CMSIncrementalMode. It
// must also be enabled/disabled dynamically to allow foreground collections.
- static inline void enable_icms() { _icms_enabled = true; }
- static inline void disable_icms() { _icms_enabled = false; }
- static inline void set_icms_enabled(bool val) { _icms_enabled = val; }
- static inline bool icms_enabled() { return _icms_enabled; }
+#define ICMS_ENABLING_ASSERT \
+ assert((CMSIncrementalMode && _icms_disabled >= 0) || \
+ (!CMSIncrementalMode && _icms_disabled <= 0), "Error")
+
+ static inline void enable_icms() {
+ ICMS_ENABLING_ASSERT;
+ Atomic::dec(&_icms_disabled);
+ }
+ static inline void disable_icms() {
+ ICMS_ENABLING_ASSERT;
+ Atomic::inc(&_icms_disabled);
+ }
+ static inline bool icms_is_disabled() {
+ ICMS_ENABLING_ASSERT;
+ return _icms_disabled > 0;
+ }
+ static inline bool icms_is_enabled() {
+ return !icms_is_disabled();
+ }
};
inline void ConcurrentMarkSweepThread::trace_state(const char* desc) {
if (CMSTraceThreadState) {
char buf[128];