Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp @ 10185:d50cc62e94ff
8012715: G1: GraphKit accesses PtrQueue::_index as int but is size_t
Summary: In graphKit INT operations were generated to access PtrQueue::_index which has type size_t. This is 64 bit on 64-bit machines. No problems occur on little endian machines as long as the index fits into 32 bit, but on big endian machines the upper part is read, which is zero. This leads to unnecessary branches to the slow path in the runtime.
Reviewed-by: twisti, johnc
Contributed-by: Martin Doerr <martin.doerr@sap.com>
author | johnc |
---|---|
date | Wed, 24 Apr 2013 14:48:43 -0700 |
parents | a252e688abcf |
children | de6a9e811145 |
rev | line source |
---|---|
0 | 1 /* |
2365
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPTHREAD_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPTHREAD_HPP | |
27 | |
28 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" | |
29 #include "gc_implementation/shared/concurrentGCThread.hpp" | |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
3960
diff
changeset
|
30 #include "runtime/thread.inline.hpp" |
1972 | 31 |
0 | 32 class ConcurrentMarkSweepGeneration; |
33 class CMSCollector; | |
34 | |
2365
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
35 // The Concurrent Mark Sweep GC Thread |
0 | 36 class ConcurrentMarkSweepThread: public ConcurrentGCThread { |
37 friend class VMStructs; | |
38 friend class ConcurrentMarkSweepGeneration; // XXX should remove friendship | |
39 friend class CMSCollector; | |
40 public: | |
41 virtual void run(); | |
42 | |
43 private: | |
44 static ConcurrentMarkSweepThread* _cmst; | |
45 static CMSCollector* _collector; | |
46 static SurrogateLockerThread* _slt; | |
47 static SurrogateLockerThread::SLT_msg_type _sltBuffer; | |
48 static Monitor* _sltMonitor; | |
49 | |
50 static bool _should_terminate; | |
51 | |
52 enum CMS_flag_type { | |
53 CMS_nil = NoBits, | |
54 CMS_cms_wants_token = nth_bit(0), | |
55 CMS_cms_has_token = nth_bit(1), | |
56 CMS_vm_wants_token = nth_bit(2), | |
57 CMS_vm_has_token = nth_bit(3) | |
58 }; | |
59 | |
60 static int _CMS_flag; | |
61 | |
62 static bool CMS_flag_is_set(int b) { return (_CMS_flag & b) != 0; } | |
63 static bool set_CMS_flag(int b) { return (_CMS_flag |= b) != 0; } | |
64 static bool clear_CMS_flag(int b) { return (_CMS_flag &= ~b) != 0; } | |
65 void sleepBeforeNextCycle(); | |
66 | |
67 // CMS thread should yield for a young gen collection, direct allocation, | |
68 // and iCMS activity. | |
69 static char _pad_1[64 - sizeof(jint)]; // prevent cache-line sharing | |
70 static volatile jint _pending_yields; | |
71 static volatile jint _pending_decrements; // decrements to _pending_yields | |
72 static char _pad_2[64 - sizeof(jint)]; // prevent cache-line sharing | |
73 | |
74 // Tracing messages, enabled by CMSTraceThreadState. | |
75 static inline void trace_state(const char* desc); | |
76 | |
2365
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
77 static volatile int _icms_disabled; // a counter to track #iCMS disable & enable |
0 | 78 static volatile bool _should_run; // iCMS may run |
79 static volatile bool _should_stop; // iCMS should stop | |
80 | |
81 // debugging | |
82 void verify_ok_to_terminate() const PRODUCT_RETURN; | |
83 | |
84 public: | |
85 // Constructor | |
86 ConcurrentMarkSweepThread(CMSCollector* collector); | |
87 | |
88 static void makeSurrogateLockerThread(TRAPS); | |
89 static SurrogateLockerThread* slt() { return _slt; } | |
90 | |
91 // Tester | |
92 bool is_ConcurrentGC_thread() const { return true; } | |
93 | |
94 static void threads_do(ThreadClosure* tc); | |
95 | |
96 // Printing | |
97 void print_on(outputStream* st) const; | |
98 void print() const { print_on(tty); } | |
99 static void print_all_on(outputStream* st); | |
100 static void print_all() { print_all_on(tty); } | |
101 | |
102 // Returns the CMS Thread | |
103 static ConcurrentMarkSweepThread* cmst() { return _cmst; } | |
104 static CMSCollector* collector() { return _collector; } | |
105 | |
106 // Create and start the CMS Thread, or stop it on shutdown | |
107 static ConcurrentMarkSweepThread* start(CMSCollector* collector); | |
108 static void stop(); | |
109 static bool should_terminate() { return _should_terminate; } | |
110 | |
111 // Synchronization using CMS token | |
112 static void synchronize(bool is_cms_thread); | |
113 static void desynchronize(bool is_cms_thread); | |
114 static bool vm_thread_has_cms_token() { | |
115 return CMS_flag_is_set(CMS_vm_has_token); | |
116 } | |
117 static bool cms_thread_has_cms_token() { | |
118 return CMS_flag_is_set(CMS_cms_has_token); | |
119 } | |
120 static bool vm_thread_wants_cms_token() { | |
121 return CMS_flag_is_set(CMS_vm_wants_token); | |
122 } | |
123 static bool cms_thread_wants_cms_token() { | |
124 return CMS_flag_is_set(CMS_cms_wants_token); | |
125 } | |
126 | |
127 // Wait on CMS lock until the next synchronous GC | |
1887
cd3ef3fd20dd
6992998: CMSWaitDuration=0 causes hangs with +ExplicitGCInvokesConcurrent
ysr
parents:
1837
diff
changeset
|
128 // or given timeout, whichever is earlier. A timeout value |
cd3ef3fd20dd
6992998: CMSWaitDuration=0 causes hangs with +ExplicitGCInvokesConcurrent
ysr
parents:
1837
diff
changeset
|
129 // of 0 indicates that there is no upper bound on the wait time. |
cd3ef3fd20dd
6992998: CMSWaitDuration=0 causes hangs with +ExplicitGCInvokesConcurrent
ysr
parents:
1837
diff
changeset
|
130 // A concurrent full gc request terminates the wait. |
cd3ef3fd20dd
6992998: CMSWaitDuration=0 causes hangs with +ExplicitGCInvokesConcurrent
ysr
parents:
1837
diff
changeset
|
131 void wait_on_cms_lock(long t_millis); |
0 | 132 |
8679
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
133 // Wait on CMS lock until the next synchronous GC |
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
134 // or given timeout, whichever is earlier. A timeout value |
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
135 // of 0 indicates that there is no upper bound on the wait time. |
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
136 // A concurrent full gc request terminates the wait. |
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
137 void wait_on_cms_lock_for_scavenge(long t_millis); |
a252e688abcf
7189971: Implement CMSWaitDuration for non-incremental mode of CMS
jmasa
parents:
7180
diff
changeset
|
138 |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
139 // The CMS thread will yield during the work portion of its cycle |
0 | 140 // only when requested to. Both synchronous and asychronous requests |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
141 // are provided: |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
142 // (1) A synchronous request is used for young gen collections and |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
143 // for direct allocations. The requesting thread increments |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
144 // _pending_yields at the beginning of an operation, and decrements |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
145 // _pending_yields when that operation is completed. |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
146 // In turn, the CMS thread yields when _pending_yields is positive, |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
147 // and continues to yield until the value reverts to 0. |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
148 // (2) An asynchronous request, on the other hand, is used by iCMS |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
149 // for the stop_icms() operation. A single yield satisfies all of |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
150 // the outstanding asynch yield requests, of which there may |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
151 // occasionally be several in close succession. To accomplish |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
152 // this, an asynch-requesting thread atomically increments both |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
153 // _pending_yields and _pending_decrements. An asynchr requesting |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
154 // thread does not wait and "acknowledge" completion of an operation |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
155 // and deregister the request, like the synchronous version described |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
156 // above does. In turn, after yielding, the CMS thread decrements both |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
157 // _pending_yields and _pending_decrements by the value seen in |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
158 // _pending_decrements before the decrement. |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
159 // NOTE: The above scheme is isomorphic to having two request counters, |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
160 // one for async requests and one for sync requests, and for the CMS thread |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
161 // to check the sum of the two counters to decide whether it should yield |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
162 // and to clear only the async counter when it yields. However, it turns out |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
163 // to be more efficient for CMS code to just check a single counter |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
164 // _pending_yields that holds the sum (of both sync and async requests), and |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
165 // a second counter _pending_decrements that only holds the async requests, |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
166 // for greater efficiency, since in a typical CMS run, there are many more |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
167 // pontential (i.e. static) yield points than there are actual |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
168 // (i.e. dynamic) yields because of requests, which are few and far between. |
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
169 // |
0 | 170 // Note that, while "_pending_yields >= _pending_decrements" is an invariant, |
171 // we cannot easily test that invariant, since the counters are manipulated via | |
172 // atomic instructions without explicit locking and we cannot read | |
173 // the two counters atomically together: one suggestion is to | |
174 // use (for example) 16-bit counters so as to be able to read the | |
175 // two counters atomically even on 32-bit platforms. Notice that | |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
176 // the second assert in acknowledge_yield_request() below does indeed |
0 | 177 // check a form of the above invariant, albeit indirectly. |
178 | |
179 static void increment_pending_yields() { | |
180 Atomic::inc(&_pending_yields); | |
181 assert(_pending_yields >= 0, "can't be negative"); | |
182 } | |
183 static void decrement_pending_yields() { | |
184 Atomic::dec(&_pending_yields); | |
185 assert(_pending_yields >= 0, "can't be negative"); | |
186 } | |
187 static void asynchronous_yield_request() { | |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
188 assert(CMSIncrementalMode, "Currently only used w/iCMS"); |
0 | 189 increment_pending_yields(); |
190 Atomic::inc(&_pending_decrements); | |
191 assert(_pending_decrements >= 0, "can't be negative"); | |
192 } | |
193 static void acknowledge_yield_request() { | |
194 jint decrement = _pending_decrements; | |
195 if (decrement > 0) { | |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
196 assert(CMSIncrementalMode, "Currently only used w/iCMS"); |
0 | 197 // Order important to preserve: _pending_yields >= _pending_decrements |
198 Atomic::add(-decrement, &_pending_decrements); | |
199 Atomic::add(-decrement, &_pending_yields); | |
200 assert(_pending_decrements >= 0, "can't be negative"); | |
201 assert(_pending_yields >= 0, "can't be negative"); | |
202 } | |
203 } | |
204 static bool should_yield() { return _pending_yields > 0; } | |
205 | |
206 // CMS incremental mode. | |
207 static void start_icms(); // notify thread to start a quantum of work | |
208 static void stop_icms(); // request thread to stop working | |
209 void icms_wait(); // if asked to stop, wait until notified to start | |
210 | |
211 // Incremental mode is enabled globally by the flag CMSIncrementalMode. It | |
212 // must also be enabled/disabled dynamically to allow foreground collections. | |
2365
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
213 #define ICMS_ENABLING_ASSERT \ |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
214 assert((CMSIncrementalMode && _icms_disabled >= 0) || \ |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
215 (!CMSIncrementalMode && _icms_disabled <= 0), "Error") |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
216 |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
217 static inline void enable_icms() { |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
218 ICMS_ENABLING_ASSERT; |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
219 Atomic::dec(&_icms_disabled); |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
220 } |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
221 static inline void disable_icms() { |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
222 ICMS_ENABLING_ASSERT; |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
223 Atomic::inc(&_icms_disabled); |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
224 } |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
225 static inline bool icms_is_disabled() { |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
226 ICMS_ENABLING_ASSERT; |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
227 return _icms_disabled > 0; |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
228 } |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
229 static inline bool icms_is_enabled() { |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
230 return !icms_is_disabled(); |
a181f3a124dd
6987703: iCMS: Intermittent hang with gc/gctests/CallGC/CallGC01 and +ExplicitGCInvokesConcurrent
ysr
parents:
1972
diff
changeset
|
231 } |
0 | 232 }; |
233 | |
234 inline void ConcurrentMarkSweepThread::trace_state(const char* desc) { | |
235 if (CMSTraceThreadState) { | |
236 char buf[128]; | |
237 TimeStamp& ts = gclog_or_tty->time_stamp(); | |
238 if (!ts.is_updated()) { | |
239 ts.update(); | |
240 } | |
241 jio_snprintf(buf, sizeof(buf), " [%.3f: CMSThread %s] ", | |
242 ts.seconds(), desc); | |
243 buf[sizeof(buf) - 1] = '\0'; | |
244 gclog_or_tty->print(buf); | |
245 } | |
246 } | |
247 | |
1837
c99c53f07c14
6692906: CMS: parallel concurrent marking may be prone to hanging or stalling mutators for periods of time
ysr
parents:
1552
diff
changeset
|
248 // For scoped increment/decrement of (synchronous) yield requests |
0 | 249 class CMSSynchronousYieldRequest: public StackObj { |
250 public: | |
251 CMSSynchronousYieldRequest() { | |
252 ConcurrentMarkSweepThread::increment_pending_yields(); | |
253 } | |
254 ~CMSSynchronousYieldRequest() { | |
255 ConcurrentMarkSweepThread::decrement_pending_yields(); | |
256 } | |
257 }; | |
258 | |
259 // Used to emit a warning in case of unexpectedly excessive | |
260 // looping (in "apparently endless loops") in CMS code. | |
261 class CMSLoopCountWarn: public StackObj { | |
262 private: | |
263 const char* _src; | |
264 const char* _msg; | |
265 const intx _threshold; | |
266 intx _ticks; | |
267 | |
268 public: | |
269 inline CMSLoopCountWarn(const char* src, const char* msg, | |
270 const intx threshold) : | |
271 _src(src), _msg(msg), _threshold(threshold), _ticks(0) { } | |
272 | |
273 inline void tick() { | |
274 _ticks++; | |
275 if (CMSLoopWarn && _ticks % _threshold == 0) { | |
276 warning("%s has looped %d times %s", _src, _ticks, _msg); | |
277 } | |
278 } | |
279 }; | |
1972 | 280 |
281 #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPTHREAD_HPP |