1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp Thu Mar 03 11:35:50 2011 +0100 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp Mon Mar 14 21:52:24 2011 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -40,7 +40,7 @@ 1.11 class ConcurrentMarkSweepGeneration; 1.12 class CMSCollector; 1.13 1.14 -// The Concurrent Mark Sweep GC Thread (could be several in the future). 1.15 +// The Concurrent Mark Sweep GC Thread 1.16 class ConcurrentMarkSweepThread: public ConcurrentGCThread { 1.17 friend class VMStructs; 1.18 friend class ConcurrentMarkSweepGeneration; // XXX should remove friendship 1.19 @@ -55,8 +55,6 @@ 1.20 static SurrogateLockerThread::SLT_msg_type _sltBuffer; 1.21 static Monitor* _sltMonitor; 1.22 1.23 - ConcurrentMarkSweepThread* _next; 1.24 - 1.25 static bool _should_terminate; 1.26 1.27 enum CMS_flag_type { 1.28 @@ -84,7 +82,7 @@ 1.29 // Tracing messages, enabled by CMSTraceThreadState. 1.30 static inline void trace_state(const char* desc); 1.31 1.32 - static volatile bool _icms_enabled; // iCMS enabled? 1.33 + static volatile int _icms_disabled; // a counter to track #iCMS disable & enable 1.34 static volatile bool _should_run; // iCMS may run 1.35 static volatile bool _should_stop; // iCMS should stop 1.36 1.37 @@ -214,10 +212,25 @@ 1.38 1.39 // Incremental mode is enabled globally by the flag CMSIncrementalMode. It 1.40 // must also be enabled/disabled dynamically to allow foreground collections. 1.41 - static inline void enable_icms() { _icms_enabled = true; } 1.42 - static inline void disable_icms() { _icms_enabled = false; } 1.43 - static inline void set_icms_enabled(bool val) { _icms_enabled = val; } 1.44 - static inline bool icms_enabled() { return _icms_enabled; } 1.45 +#define ICMS_ENABLING_ASSERT \ 1.46 + assert((CMSIncrementalMode && _icms_disabled >= 0) || \ 1.47 + (!CMSIncrementalMode && _icms_disabled <= 0), "Error") 1.48 + 1.49 + static inline void enable_icms() { 1.50 + ICMS_ENABLING_ASSERT; 1.51 + Atomic::dec(&_icms_disabled); 1.52 + } 1.53 + static inline void disable_icms() { 1.54 + ICMS_ENABLING_ASSERT; 1.55 + Atomic::inc(&_icms_disabled); 1.56 + } 1.57 + static inline bool icms_is_disabled() { 1.58 + ICMS_ENABLING_ASSERT; 1.59 + return _icms_disabled > 0; 1.60 + } 1.61 + static inline bool icms_is_enabled() { 1.62 + return !icms_is_disabled(); 1.63 + } 1.64 }; 1.65 1.66 inline void ConcurrentMarkSweepThread::trace_state(const char* desc) {