< prev index next >

src/hotspot/share/runtime/safepoint.cpp

Print this page

        

*** 22,32 **** * */ #include "precompiled.hpp" #include "classfile/classLoaderDataGraph.inline.hpp" - #include "classfile/dictionary.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" --- 22,31 ----
*** 65,74 **** --- 64,76 ---- #include "runtime/threadSMR.hpp" #include "runtime/timerTrace.hpp" #include "services/runtimeService.hpp" #include "utilities/events.hpp" #include "utilities/macros.hpp" + #ifdef COMPILER1 + #include "c1/c1_globals.hpp" + #endif static void post_safepoint_begin_event(EventSafepointBegin& event, uint64_t safepoint_id, int thread_count, int critical_thread_count) {
*** 182,199 **** } assert(a == still_running, "Must be the same"); } #endif // ASSERT ! static void back_off(int64_t start_time) { ! // We start with fine-grained nanosleeping until a millisecond has ! // passed, at which point we resort to plain naked_short_sleep. ! if (os::javaTimeNanos() - start_time < NANOSECS_PER_MILLISEC) { ! os::naked_short_nanosleep(10 * (NANOUNITS / MICROUNITS)); ! } else { ! os::naked_short_sleep(1); } } int SafepointSynchronize::synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running) { JavaThreadIteratorWithHandle jtiwh; --- 184,203 ---- } assert(a == still_running, "Must be the same"); } #endif // ASSERT ! static void back_off(int iteration) { ! // iteration will be 1 the first time we enter this spin back-off. ! // naked_short_nanosleep takes tenths of micros which means that ! // number of nanoseconds is irrelevant if it's below that. We do ! // 20 1 ns sleeps with a total cost of ~1 ms, then we do 1 ms sleeps. ! jlong sleep_ns = 1; ! if (iteration > 20) { ! sleep_ns = NANOUNITS / MILLIUNITS; // 1 ms } + os::naked_short_nanosleep(sleep_ns); } int SafepointSynchronize::synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running) { JavaThreadIteratorWithHandle jtiwh;
*** 223,242 **** DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) *initial_running = still_running; - // If there is no thread still running, we are already done. - if (still_running <= 0) { - assert(tss_head == NULL, "Must be empty"); - return 1; - } - int iterations = 1; // The first iteration is above. - int64_t start_time = os::javaTimeNanos(); ! do { // Check if this has taken too long: if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) { print_safepoint_timeout(); } if (int(iterations) == -1) { // overflow - something is wrong. --- 227,239 ---- DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) *initial_running = still_running; int iterations = 1; // The first iteration is above. ! while (still_running > 0) { // Check if this has taken too long: if (SafepointTimeout && safepoint_limit_time < os::javaTimeNanos()) { print_safepoint_timeout(); } if (int(iterations) == -1) { // overflow - something is wrong.
*** 265,279 **** } DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) if (still_running > 0) { ! back_off(start_time); } iterations++; ! } while (still_running > 0); assert(tss_head == NULL, "Must be empty"); return iterations; } --- 262,276 ---- } DEBUG_ONLY(assert_list_is_valid(tss_head, still_running);) if (still_running > 0) { ! back_off(iterations); } iterations++; ! } assert(tss_head == NULL, "Must be empty"); return iterations; }
*** 512,523 **** bool SafepointSynchronize::is_cleanup_needed() { // Need a safepoint if there are many monitors to deflate. if (ObjectSynchronizer::is_cleanup_needed()) return true; // Need a safepoint if some inline cache buffers is non-empty if (!InlineCacheBuffer::is_empty()) return true; - if (StringTable::needs_rehashing()) return true; - if (SymbolTable::needs_rehashing()) return true; return false; } class ParallelSPCleanupThreadClosure : public ThreadClosure { private: --- 509,518 ----
*** 606,636 **** post_safepoint_cleanup_task_event(event, safepoint_id, name); } } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_CLD_PURGE)) { ! if (ClassLoaderDataGraph::should_purge_and_reset()) { ! // CMS delays purging the CLDG until the beginning of the next safepoint and to ! // make sure concurrent sweep is done ! const char* name = "purging class loader data graph"; ! EventSafepointCleanupTask event; ! TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ! ClassLoaderDataGraph::purge(); ! post_safepoint_cleanup_task_event(event, safepoint_id, name); ! } } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) { ! if (Dictionary::does_any_dictionary_needs_resizing()) { ! const char* name = "resizing system dictionaries"; ! EventSafepointCleanupTask event; ! TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ! ClassLoaderDataGraph::resize_dictionaries(); ! post_safepoint_cleanup_task_event(event, safepoint_id, name); ! } } _subtasks.all_tasks_completed(_num_workers); } }; --- 601,627 ---- post_safepoint_cleanup_task_event(event, safepoint_id, name); } } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_CLD_PURGE)) { ! // CMS delays purging the CLDG until the beginning of the next safepoint and to ! // make sure concurrent sweep is done ! const char* name = "purging class loader data graph"; ! EventSafepointCleanupTask event; ! TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ! ClassLoaderDataGraph::purge_if_needed(); ! post_safepoint_cleanup_task_event(event, safepoint_id, name); } if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) { ! const char* name = "resizing system dictionaries"; ! EventSafepointCleanupTask event; ! TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ! ClassLoaderDataGraph::resize_if_needed(); ! post_safepoint_cleanup_task_event(event, safepoint_id, name); } _subtasks.all_tasks_completed(_num_workers); } };
*** 812,824 **** // Load dependent store, it must not pass loading of safepoint_id. thread->safepoint_state()->set_safepoint_id(safepoint_id); // Release store // This part we can skip if we notice we miss or are in a future safepoint. OrderAccess::storestore(); ! // Load in wait barrier should not float up ! thread->set_thread_state_fence(_thread_blocked); _wait_barrier->wait(static_cast<int>(safepoint_id)); assert(_state != _synchronized, "Can't be"); // If barrier is disarmed stop store from floating above loads in barrier. OrderAccess::loadstore(); --- 803,815 ---- // Load dependent store, it must not pass loading of safepoint_id. thread->safepoint_state()->set_safepoint_id(safepoint_id); // Release store // This part we can skip if we notice we miss or are in a future safepoint. OrderAccess::storestore(); ! thread->set_thread_state(_thread_blocked); + OrderAccess::fence(); // Load in wait barrier should not float up _wait_barrier->wait(static_cast<int>(safepoint_id)); assert(_state != _synchronized, "Can't be"); // If barrier is disarmed stop store from floating above loads in barrier. OrderAccess::loadstore();
*** 1039,1050 **** p2i(_thread), _thread->osthread()->thread_id(), s, _at_poll_safepoint); _thread->print_thread_state_on(st); } - void ThreadSafepointState::print() const { print_on(tty); } - // --------------------------------------------------------------------------------------------------------------------- // Block the thread at poll or poll return for safepoint/handshake. void ThreadSafepointState::handle_polling_page_exception() { --- 1030,1039 ----
< prev index next >