< prev index next >

src/share/vm/runtime/safepoint.cpp

Print this page

        

*** 30,40 **** --- 30,42 ---- #include "code/nmethod.hpp" #include "code/pcDesc.hpp" #include "code/scopeDesc.hpp" #include "gc_interface/collectedHeap.hpp" #include "interpreter/interpreter.hpp" + #if INCLUDE_JFR #include "jfr/jfrEvents.hpp" + #endif #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" #include "runtime/compilationPolicy.hpp"
*** 88,97 **** --- 90,100 ---- static void set_current_safepoint_id(E* event, int adjustment = 0) { assert(event != NULL, "invariant"); event->set_safepointId(SafepointSynchronize::safepoint_counter() + adjustment); } + #if INCLUDE_JFR static void post_safepoint_begin_event(EventSafepointBegin* event, int thread_count, int critical_thread_count) { assert(event != NULL, "invariant"); assert(event->should_commit(), "invariant");
*** 148,157 **** --- 151,161 ---- // Group this event together with the ones committed before the counter increased set_current_safepoint_id(event, -1); event->commit(); } } + #endif // -------------------------------------------------------------------------------------------------- // Implementation of Safepoint begin/end SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized;
*** 163,173 **** --- 167,179 ---- static volatile int TryingToBlock = 0 ; // proximate value -- for advisory use only static bool timeout_error_printed = false; // Roll all threads forward to a safepoint and suspend them all void SafepointSynchronize::begin() { + #if INCLUDE_JFR EventSafepointBegin begin_event; + #endif Thread* myThread = Thread::current(); assert(myThread->is_VM_thread(), "Only VM thread may execute a safepoint"); if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) { _safepoint_begin_time = os::javaTimeNanos();
*** 255,265 **** --- 261,273 ---- // 5. In VM or Transitioning between states // If a Java thread is currently running in the VM or transitioning // between states, the safepointing code will wait for the thread to // block itself when it attempts transitions to a new state. // + #if INCLUDE_JFR EventSafepointStateSynchronization sync_event; + #endif int initial_running = 0; _state = _synchronizing; OrderAccess::fence();
*** 408,424 **** --- 416,436 ---- if (PrintSafepointStatistics) { update_statistics_on_spin_end(); } + #if INCLUDE_JFR if (sync_event.should_commit()) { post_safepoint_synchronize_event(&sync_event, initial_running, _waiting_to_block, iterations); } + #endif // wait until all threads are stopped { + #if INCLUDE_JFR EventSafepointWaitBlocked wait_blocked_event; + #endif int initial_waiting_to_block = _waiting_to_block; while (_waiting_to_block > 0) { if (TraceSafepoint) tty->print_cr("Waiting for %d thread(s) to block", _waiting_to_block); if (!SafepointTimeout || timeout_error_printed) {
*** 454,466 **** --- 466,480 ---- // Record state _state = _synchronized; OrderAccess::fence(); + #if INCLUDE_JFR if (wait_blocked_event.should_commit()) { post_safepoint_wait_blocked_event(&wait_blocked_event, initial_waiting_to_block); } + #endif } #ifdef ASSERT for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) { // make sure all the threads were visited
*** 481,514 **** --- 495,536 ---- update_statistics_on_sync_end(os::javaTimeNanos()); } // Call stuff that needs to be run when a safepoint is just about to be completed { + #if INCLUDE_JFR EventSafepointCleanup cleanup_event; + #endif do_cleanup_tasks(); + #if INCLUDE_JFR if (cleanup_event.should_commit()) { post_safepoint_cleanup_event(&cleanup_event); } + #endif } if (PrintSafepointStatistics) { // Record how much time spend on the above cleanup tasks update_statistics_on_cleanup_end(os::javaTimeNanos()); } + #if INCLUDE_JFR if (begin_event.should_commit()) { post_safepoint_begin_event(&begin_event, nof_threads, _current_jni_active_count); } + #endif } // Wake up all threads, so they are ready to resume execution after the safepoint // operation has been carried out void SafepointSynchronize::end() { assert(Threads_lock->owned_by_self(), "must hold Threads_lock"); assert((_safepoint_counter & 0x1) == 1, "must be odd"); + #if INCLUDE_JFR EventSafepointEnd event; + #endif _safepoint_counter ++; // memory fence isn't required here since an odd _safepoint_counter // value can do no harm and a fence is issued below anyway. DEBUG_ONLY(Thread* myThread = Thread::current();)
*** 590,602 **** --- 612,626 ---- } #endif // INCLUDE_ALL_GCS // record this time so VMThread can keep track how much time has elasped // since last safepoint. _end_of_last_safepoint = os::javaTimeMillis(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_end_event(&event); } + #endif } bool SafepointSynchronize::is_cleanup_needed() { // Need a safepoint if some inline cache buffers is non-empty if (!InlineCacheBuffer::is_empty()) return true;
*** 607,671 **** --- 631,719 ---- // Various cleaning tasks that should be done periodically at safepoints void SafepointSynchronize::do_cleanup_tasks() { { const char* name = "deflating idle monitors"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t1(name, TraceSafepointCleanupTime); ObjectSynchronizer::deflate_idle_monitors(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } { const char* name = "updating inline caches"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t2(name, TraceSafepointCleanupTime); InlineCacheBuffer::update_inline_caches(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } { const char* name = "compilation policy safepoint handler"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t3(name, TraceSafepointCleanupTime); CompilationPolicy::policy()->do_safepoint_work(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } { const char* name = "mark nmethods"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t4(name, TraceSafepointCleanupTime); NMethodSweeper::mark_active_nmethods(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } if (SymbolTable::needs_rehashing()) { const char* name = "rehashing symbol table"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t5(name, TraceSafepointCleanupTime); SymbolTable::rehash_table(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } if (StringTable::needs_rehashing()) { const char* name = "rehashing string table"; + #if INCLUDE_JFR EventSafepointCleanupTask event; + #endif TraceTime t6(name, TraceSafepointCleanupTime); StringTable::rehash_table(); + #if INCLUDE_JFR if (event.should_commit()) { post_safepoint_cleanup_task_event(&event, name); } + #endif } // rotate log files? if (UseGCLogFileRotation) { gclog_or_tty->rotate_log(false);
< prev index next >