comparison src/share/vm/runtime/safepoint.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 0ebca2e35ca5 d2a62e0f25eb
children 1baf7f1e3f23
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
21 * questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "classfile/symbolTable.hpp"
26 #include "classfile/systemDictionary.hpp" 27 #include "classfile/systemDictionary.hpp"
27 #include "code/codeCache.hpp" 28 #include "code/codeCache.hpp"
28 #include "code/icBuffer.hpp" 29 #include "code/icBuffer.hpp"
29 #include "code/nmethod.hpp" 30 #include "code/nmethod.hpp"
30 #include "code/pcDesc.hpp" 31 #include "code/pcDesc.hpp"
45 #include "runtime/signature.hpp" 46 #include "runtime/signature.hpp"
46 #include "runtime/stubCodeGenerator.hpp" 47 #include "runtime/stubCodeGenerator.hpp"
47 #include "runtime/stubRoutines.hpp" 48 #include "runtime/stubRoutines.hpp"
48 #include "runtime/sweeper.hpp" 49 #include "runtime/sweeper.hpp"
49 #include "runtime/synchronizer.hpp" 50 #include "runtime/synchronizer.hpp"
51 #include "services/memTracker.hpp"
50 #include "services/runtimeService.hpp" 52 #include "services/runtimeService.hpp"
51 #include "utilities/events.hpp" 53 #include "utilities/events.hpp"
52 #ifdef TARGET_ARCH_x86 54 #ifdef TARGET_ARCH_x86
53 # include "nativeInst_x86.hpp" 55 # include "nativeInst_x86.hpp"
54 # include "vmreg_x86.inline.hpp" 56 # include "vmreg_x86.inline.hpp"
217 int ncpus = os::processor_count() ; 219 int ncpus = os::processor_count() ;
218 220
219 #ifdef ASSERT 221 #ifdef ASSERT
220 for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) { 222 for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
221 assert(cur->safepoint_state()->is_running(), "Illegal initial state"); 223 assert(cur->safepoint_state()->is_running(), "Illegal initial state");
224 // Clear the visited flag to ensure that the critical counts are collected properly.
225 cur->set_visited_for_critical_count(false);
222 } 226 }
223 #endif // ASSERT 227 #endif // ASSERT
224 228
225 if (SafepointTimeout) 229 if (SafepointTimeout)
226 safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS; 230 safepoint_limit_time = os::javaTimeNanos() + (jlong)SafepointTimeoutDelay * MICROUNITS;
376 // Record state 380 // Record state
377 _state = _synchronized; 381 _state = _synchronized;
378 382
379 OrderAccess::fence(); 383 OrderAccess::fence();
380 384
385 #ifdef ASSERT
386 for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
387 // make sure all the threads were visited
388 assert(cur->was_visited_for_critical_count(), "missed a thread");
389 }
390 #endif // ASSERT
391
381 // Update the count of active JNI critical regions 392 // Update the count of active JNI critical regions
382 GC_locker::set_jni_lock_count(_current_jni_active_count); 393 GC_locker::set_jni_lock_count(_current_jni_active_count);
383 394
384 if (TraceSafepoint) { 395 if (TraceSafepoint) {
385 VM_Operation *op = VMThread::vm_operation(); 396 VM_Operation *op = VMThread::vm_operation();
515 { 526 {
516 TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime); 527 TraceTime t3("compilation policy safepoint handler", TraceSafepointCleanupTime);
517 CompilationPolicy::policy()->do_safepoint_work(); 528 CompilationPolicy::policy()->do_safepoint_work();
518 } 529 }
519 530
520 TraceTime t4("sweeping nmethods", TraceSafepointCleanupTime); 531 {
521 NMethodSweeper::scan_stacks(); 532 TraceTime t4("sweeping nmethods", TraceSafepointCleanupTime);
533 NMethodSweeper::scan_stacks();
534 }
535
536 if (SymbolTable::needs_rehashing()) {
537 TraceTime t5("rehashing symbol table", TraceSafepointCleanupTime);
538 SymbolTable::rehash_table();
539 }
540
541 if (StringTable::needs_rehashing()) {
542 TraceTime t6("rehashing string table", TraceSafepointCleanupTime);
543 StringTable::rehash_table();
544 }
522 545
523 // rotate log files? 546 // rotate log files?
524 if (UseGCLogFileRotation) { 547 if (UseGCLogFileRotation) {
525 gclog_or_tty->rotate_log(); 548 gclog_or_tty->rotate_log();
549 }
550
551 if (MemTracker::is_on()) {
552 MemTracker::sync();
526 } 553 }
527 } 554 }
528 555
529 556
530 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) { 557 bool SafepointSynchronize::safepoint_safe(JavaThread *thread, JavaThreadState state) {
624 // Decrement the number of threads to wait for and signal vm thread 651 // Decrement the number of threads to wait for and signal vm thread
625 assert(_waiting_to_block > 0, "sanity check"); 652 assert(_waiting_to_block > 0, "sanity check");
626 _waiting_to_block--; 653 _waiting_to_block--;
627 thread->safepoint_state()->set_has_called_back(true); 654 thread->safepoint_state()->set_has_called_back(true);
628 655
656 DEBUG_ONLY(thread->set_visited_for_critical_count(true));
629 if (thread->in_critical()) { 657 if (thread->in_critical()) {
630 // Notice that this thread is in a critical section 658 // Notice that this thread is in a critical section
631 increment_jni_active_count(); 659 increment_jni_active_count();
632 } 660 }
633 661
905 933
906 // Some JavaThread states have an initial safepoint state of 934 // Some JavaThread states have an initial safepoint state of
907 // running, but are actually at a safepoint. We will happily 935 // running, but are actually at a safepoint. We will happily
908 // agree and update the safepoint state here. 936 // agree and update the safepoint state here.
909 if (SafepointSynchronize::safepoint_safe(_thread, state)) { 937 if (SafepointSynchronize::safepoint_safe(_thread, state)) {
938 SafepointSynchronize::check_for_lazy_critical_native(_thread, state);
910 roll_forward(_at_safepoint); 939 roll_forward(_at_safepoint);
911 SafepointSynchronize::check_for_lazy_critical_native(_thread, state);
912 if (_thread->in_critical()) {
913 // Notice that this thread is in a critical section
914 SafepointSynchronize::increment_jni_active_count();
915 }
916 return; 940 return;
917 } 941 }
918 942
919 if (state == _thread_in_vm) { 943 if (state == _thread_in_vm) {
920 roll_forward(_call_back); 944 roll_forward(_call_back);
935 _type = type; 959 _type = type;
936 960
937 switch(_type) { 961 switch(_type) {
938 case _at_safepoint: 962 case _at_safepoint:
939 SafepointSynchronize::signal_thread_at_safepoint(); 963 SafepointSynchronize::signal_thread_at_safepoint();
964 DEBUG_ONLY(_thread->set_visited_for_critical_count(true));
965 if (_thread->in_critical()) {
966 // Notice that this thread is in a critical section
967 SafepointSynchronize::increment_jni_active_count();
968 }
940 break; 969 break;
941 970
942 case _call_back: 971 case _call_back:
943 set_has_called_back(false); 972 set_has_called_back(false);
944 break; 973 break;
1131 PrintSafepointStatistics = true; 1160 PrintSafepointStatistics = true;
1132 } else { 1161 } else {
1133 stats_array_size = PrintSafepointStatisticsCount; 1162 stats_array_size = PrintSafepointStatisticsCount;
1134 } 1163 }
1135 _safepoint_stats = (SafepointStats*)os::malloc(stats_array_size 1164 _safepoint_stats = (SafepointStats*)os::malloc(stats_array_size
1136 * sizeof(SafepointStats)); 1165 * sizeof(SafepointStats), mtInternal);
1137 guarantee(_safepoint_stats != NULL, 1166 guarantee(_safepoint_stats != NULL,
1138 "not enough memory for safepoint instrumentation data"); 1167 "not enough memory for safepoint instrumentation data");
1139 1168
1140 if (UseCompilerSafepoints && DeferPollingPageLoopCount >= 0) { 1169 if (UseCompilerSafepoints && DeferPollingPageLoopCount >= 0) {
1141 need_to_track_page_armed_status = true; 1170 need_to_track_page_armed_status = true;