18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "code/codeCache.hpp"
30 #include "code/icBuffer.hpp"
31 #include "code/nmethod.hpp"
32 #include "code/pcDesc.hpp"
33 #include "code/scopeDesc.hpp"
34 #include "gc/shared/collectedHeap.hpp"
35 #include "gc/shared/gcLocker.inline.hpp"
36 #include "interpreter/interpreter.hpp"
37 #include "logging/log.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "memory/universe.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 #include "oops/symbol.hpp"
42 #include "runtime/atomic.hpp"
43 #include "runtime/compilationPolicy.hpp"
44 #include "runtime/deoptimization.hpp"
45 #include "runtime/frame.inline.hpp"
46 #include "runtime/interfaceSupport.hpp"
47 #include "runtime/mutexLocker.hpp"
48 #include "runtime/orderAccess.inline.hpp"
49 #include "runtime/osThread.hpp"
50 #include "runtime/safepoint.hpp"
51 #include "runtime/signature.hpp"
52 #include "runtime/stubCodeGenerator.hpp"
53 #include "runtime/stubRoutines.hpp"
54 #include "runtime/sweeper.hpp"
55 #include "runtime/synchronizer.hpp"
56 #include "runtime/thread.inline.hpp"
57 #include "runtime/timerTrace.hpp"
209 safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS;
210
211 // Iterate through all threads until it have been determined how to stop them all at a safepoint
212 unsigned int iterations = 0;
213 int steps = 0 ;
214 while(still_running > 0) {
215 for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
216 assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended");
217 ThreadSafepointState *cur_state = cur->safepoint_state();
218 if (cur_state->is_running()) {
219 cur_state->examine_state_of_thread();
220 if (!cur_state->is_running()) {
221 still_running--;
222 // consider adjusting steps downward:
223 // steps = 0
224 // steps -= NNN
225 // steps >>= 1
226 // steps = MIN(steps, 2000-100)
227 // if (iterations != 0) steps -= NNN
228 }
229 if (log_is_enabled(Trace, safepoint)) {
230 ResourceMark rm;
231 cur_state->print_on(Log(safepoint)::trace_stream());
232 }
233 }
234 }
235
236 if (iterations == 0) {
237 initial_running = still_running;
238 if (PrintSafepointStatistics) {
239 begin_statistics(nof_threads, still_running);
240 }
241 }
242
243 if (still_running > 0) {
244 // Check for if it takes to long
245 if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) {
246 print_safepoint_timeout(_spinning_timeout);
247 }
248
249 // Spin to avoid context switching.
250 // There's a tension between allowing the mutators to run (and rendezvous)
251 // vs spinning. As the VM thread spins, wasting cycles, it consumes CPU that
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "code/codeCache.hpp"
30 #include "code/icBuffer.hpp"
31 #include "code/nmethod.hpp"
32 #include "code/pcDesc.hpp"
33 #include "code/scopeDesc.hpp"
34 #include "gc/shared/collectedHeap.hpp"
35 #include "gc/shared/gcLocker.inline.hpp"
36 #include "interpreter/interpreter.hpp"
37 #include "logging/log.hpp"
38 #include "logging/logStream.hpp"
39 #include "memory/resourceArea.hpp"
40 #include "memory/universe.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "oops/symbol.hpp"
43 #include "runtime/atomic.hpp"
44 #include "runtime/compilationPolicy.hpp"
45 #include "runtime/deoptimization.hpp"
46 #include "runtime/frame.inline.hpp"
47 #include "runtime/interfaceSupport.hpp"
48 #include "runtime/mutexLocker.hpp"
49 #include "runtime/orderAccess.inline.hpp"
50 #include "runtime/osThread.hpp"
51 #include "runtime/safepoint.hpp"
52 #include "runtime/signature.hpp"
53 #include "runtime/stubCodeGenerator.hpp"
54 #include "runtime/stubRoutines.hpp"
55 #include "runtime/sweeper.hpp"
56 #include "runtime/synchronizer.hpp"
57 #include "runtime/thread.inline.hpp"
58 #include "runtime/timerTrace.hpp"
210 safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS;
211
212 // Iterate through all threads until it have been determined how to stop them all at a safepoint
213 unsigned int iterations = 0;
214 int steps = 0 ;
215 while(still_running > 0) {
216 for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
217 assert(!cur->is_ConcurrentGC_thread(), "A concurrent GC thread is unexpectly being suspended");
218 ThreadSafepointState *cur_state = cur->safepoint_state();
219 if (cur_state->is_running()) {
220 cur_state->examine_state_of_thread();
221 if (!cur_state->is_running()) {
222 still_running--;
223 // consider adjusting steps downward:
224 // steps = 0
225 // steps -= NNN
226 // steps >>= 1
227 // steps = MIN(steps, 2000-100)
228 // if (iterations != 0) steps -= NNN
229 }
230 LogTarget(Trace, safepoint) lt;
231 if (lt.is_enabled()) {
232 ResourceMark rm;
233 LogStream ls(lt);
234 cur_state->print_on(&ls);
235 }
236 }
237 }
238
239 if (iterations == 0) {
240 initial_running = still_running;
241 if (PrintSafepointStatistics) {
242 begin_statistics(nof_threads, still_running);
243 }
244 }
245
246 if (still_running > 0) {
247 // Check for if it takes to long
248 if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) {
249 print_safepoint_timeout(_spinning_timeout);
250 }
251
252 // Spin to avoid context switching.
253 // There's a tension between allowing the mutators to run (and rendezvous)
254 // vs spinning. As the VM thread spins, wasting cycles, it consumes CPU that
|