/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "code/pcDesc.hpp"
#include "code/scopeDesc.hpp"
#include "gc_interface/collectedHeap.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
#include "runtime/compilationPolicy.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/interfaceSupport.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/osThread.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/synchronizer.hpp"
#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
#include "utilities/events.hpp"
#ifdef TARGET_ARCH_x86
# include "nativeInst_x86.hpp"
# include "vmreg_x86.inline.hpp"
#endif
#ifdef TARGET_ARCH_sparc
# include "nativeInst_sparc.hpp"
# include "vmreg_sparc.inline.hpp"
#endif
#ifdef TARGET_ARCH_zero
# include "nativeInst_zero.hpp"
# include "vmreg_zero.inline.hpp"
#endif
#ifdef TARGET_ARCH_arm
# include "nativeInst_arm.hpp"
# include "vmreg_arm.inline.hpp"
#endif
#ifdef TARGET_ARCH_ppc
# include "nativeInst_ppc.hpp"
# include "vmreg_ppc.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_linux
# include "thread_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "thread_solaris.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_windows
# include "thread_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "thread_bsd.inline.hpp"
#endif
#ifndef SERIALGC
#include "gc_implementation/shared/concurrentGCThread.hpp"
#endif
#ifdef COMPILER1
#include "c1/c1_globals.hpp"
#endif
// --------------------------------------------------------------------------------------------------
SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized;
static bool timeout_error_printed = false;
// Roll all threads forward to a safepoint and suspend them all
if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) {
}
#ifndef SERIALGC
if (UseConcMarkSweepGC) {
// In the future we should investigate whether CMS can use the
// more-general mechanism below. DLD (01/05).
ConcurrentMarkSweepThread::synchronize(false);
} else if (UseG1GC) {
}
#endif // SERIALGC
// By getting the Threads_lock, we assure that no threads are about to start or
// exit. It is released again in SafepointSynchronize::end().
Threads_lock->lock();
if (TraceSafepoint) {
}
// Reset the count of active JNI critical threads
// Set number of threads to wait for, before we initiate the callbacks
TryingToBlock = 0 ;
// Save the starting time, so that it can be compared to see if this has taken
// too long to complete.
timeout_error_printed = false;
// PrintSafepointStatisticsTimeout can be specified separately. When
// specified, PrintSafepointStatistics will be set to true in
// deferred_initialize_stat method. The initialization has to be done
// early enough to avoid any races. See bug 6880029 for details.
if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) {
}
// Begin the process of bringing the system to a safepoint.
// Java threads can be in several different states and are
// stopped by different mechanisms:
//
// 1. Running interpreted
// The interpeter dispatch table is changed to force it to
// check for a safepoint condition between bytecodes.
// 2. Running in native code
// When returning from the native code, a Java thread must check
// the safepoint _state to see if we must block. If the
// VM thread sees a Java thread in native, it does
// not wait for this thread to block. The order of the memory
// writes and reads of both the safepoint state and the Java
// threads state is critical. In order to guarantee that the
// memory writes are serialized with respect to each other,
// the VM thread issues a memory barrier instruction
// (on MP systems). In order to avoid the overhead of issuing
// a memory barrier for each Java thread making native calls, each Java
// thread performs a write to a single memory page after changing
// the thread state. The VM thread performs a sequence of
// mprotect OS calls which forces all previous writes from all
// Java threads to be serialized. This is done in the
// os::serialize_thread_states() call. This has proven to be
// much more efficient than executing a membar instruction
// on every call to native code.
// 3. Running compiled Code
// Compiled code reads a global (Safepoint Polling) page that
// is set to fault if we are trying to get to a safepoint.
// 4. Blocked
// A thread which is blocked will not be allowed to return from the
// block condition until the safepoint operation is complete.
// 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.
//
OrderAccess::fence();
// Flush all thread states to memory
if (!UseMembar) {
}
// Make interpreter safepoint aware
if (UseCompilerSafepoints && DeferPollingPageLoopCount < 0) {
// Make polling safepoint aware
PageArmed = 1 ;
}
// Consider using active_processor_count() ... but that call is expensive.
#ifdef ASSERT
// Clear the visited flag to ensure that the critical counts are collected properly.
cur->set_visited_for_critical_count(false);
}
#endif // ASSERT
if (SafepointTimeout)
// Iterate through all threads until it have been determined how to stop them all at a safepoint
unsigned int iterations = 0;
int steps = 0 ;
while(still_running > 0) {
if (cur_state->is_running()) {
if (!cur_state->is_running()) {
// consider adjusting steps downward:
// steps = 0
// steps -= NNN
// steps >>= 1
// steps = MIN(steps, 2000-100)
// if (iterations != 0) steps -= NNN
}
}
}
if (PrintSafepointStatistics && iterations == 0) {
}
if (still_running > 0) {
// Check for if it takes to long
}
// Spin to avoid context switching.
// There's a tension between allowing the mutators to run (and rendezvous)
// vs spinning. As the VM thread spins, wasting cycles, it consumes CPU that
// a mutator might otherwise use profitably to reach a safepoint. Excessive
// spinning by the VM thread on a saturated system can increase rendezvous latency.
// Blocking or yielding incur their own penalties in the form of context switching
// and the resultant loss of $ residency.
//
// Further complicating matters is that yield() does not work as naively expected
// on many platforms -- yield() does not guarantee that any other ready threads
// will run. As such we revert yield_all() after some number of iterations.
// Yield_all() is implemented as a short unconditional sleep on some platforms.
// Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping
// can actually increase the time it takes the VM thread to detect that a system-wide
// stop-the-world safepoint has been reached. In a pathological scenario such as that
// described in CR6415670 the VMthread may sleep just before the mutator(s) become safe.
// In that case the mutators will be stalled waiting for the safepoint to complete and the
// the VMthread will be sleeping, waiting for the mutators to rendezvous. The VMthread
// will eventually wake up and detect that all mutators are safe, at which point
// we'll again make progress.
//
// Beware too that that the VMThread typically runs at elevated priority.
// Its default priority is higher than the default mutator priority.
// Obviously, this complicates spinning.
//
// Note too that on Windows XP SwitchThreadTo() has quite different behavior than Sleep(0).
// Sleep(0) will _not yield to lower priority threads, while SwitchThreadTo() will.
//
// See the comments in synchronizer.cpp for additional remarks on spinning.
//
// In the future we might:
// 1. Modify the safepoint scheme to avoid potentally unbounded spinning.
// This is tricky as the path used by a thread exiting the JVM (say on
// on JNI call-out) simply stores into its state field. The burden
// is placed on the VM thread, which must poll (spin).
// 2. Find something useful to do while spinning. If the safepoint is GC-related
// we might aggressively scan the stacks of threads that are already safe.
// 3. Use Solaris schedctl to examine the state of the still-running mutators.
// If all the mutators are ONPROC there's no reason to sleep or yield.
// 4. YieldTo() any still-running mutators that are ready but OFFPROC.
// 5. Check system saturation. If the system is not fully saturated then
// 6. As still-running mutators rendezvous they could unpark the sleeping
// VMthread. This works well for still-running mutators that become
// safe. The VMthread must still poll for mutators that call-out.
// 7. Drive the policy on time-since-begin instead of iterations.
// 8. Consider making the spin duration a function of the # of CPUs:
// Spin = (((ncpus-1) * M) + K) + F(still_running)
// Alternately, instead of counting iterations of the outer loop
// we could count the # of threads visited in the inner loop, above.
// 9. On windows consider using the return value from SwitchThreadTo()
// to drive subsequent spin/SwitchThreadTo()/Sleep(N) decisions.
PageArmed = 1 ;
}
// Instead of (ncpus > 1) consider either (still_running < (ncpus + EPSILON)) or
// ((still_running + _waiting_to_block - TryingToBlock)) < ncpus)
++steps ;
SpinPause() ; // MP-Polite spin
} else
if (steps < DeferThrSuspendLoopCount) {
os::NakedYield() ;
} else {
// Alternately, the VM thread could transiently depress its scheduling priority or
// transiently increase the priority of the tardy mutator(s).
}
iterations ++ ;
}
}
if (PrintSafepointStatistics) {
}
// wait until all threads are stopped
while (_waiting_to_block > 0) {
if (!SafepointTimeout || timeout_error_printed) {
} else {
// Compute remaining time
// If there is no remaining time, then there is an error
}
}
}
#ifndef PRODUCT
if (SafepointTimeout) {
if (safepoint_limit_time < current_time) {
}
}
#endif
// Record state
OrderAccess::fence();
#ifdef ASSERT
// make sure all the threads were visited
}
#endif // ASSERT
// Update the count of active JNI critical regions
if (TraceSafepoint) {
}
if (PrintSafepointStatistics) {
}
// Call stuff that needs to be run when a safepoint is just about to be completed
if (PrintSafepointStatistics) {
// Record how much time spend on the above cleanup tasks
}
}
// Wake up all threads, so they are ready to resume execution after the safepoint
// operation has been carried out
// memory fence isn't required here since an odd _safepoint_counter
// value can do no harm and a fence is issued below anyway.
if (PrintSafepointStatistics) {
}
#ifdef ASSERT
// A pending_exception cannot be installed during a safepoint. The threads
// may install an async exception after they come back from a safepoint into
// pending_exception after they unblock. But that should happen later.
"safepoint installed a pending exception");
}
#endif // ASSERT
if (PageArmed) {
// Make polling safepoint aware
PageArmed = 0 ;
}
// Remove safepoint check from interpreter
{
// Set to not synchronized, so the threads will not go into the signal_thread_blocked method
// when they get restarted.
OrderAccess::fence();
if (TraceSafepoint) {
}
// Start suspended threads
// A problem occurring on Solaris is when attempting to restart threads
// the first #cpus - 1 go well, but then the VMThread is preempted when we get
// to the next one (since it has been running the longest). We then have
// to wait for a cpu to become available before we can continue restarting
// threads.
// FIXME: This causes the performance of the VM to degrade when active and with
// large numbers of threads. Apparently this is due to the synchronous nature
// of suspending threads.
//
// TODO-FIXME: the comments above are vestigial and no longer apply.
// Furthermore, using solaris' schedctl in this particular context confers no benefit
if (VMThreadHintNoPreempt) {
os::hint_no_preempt();
}
}
// blocked in signal_thread_blocked
Threads_lock->unlock();
}
#ifndef SERIALGC
// If there are any concurrent GC threads resume them.
if (UseConcMarkSweepGC) {
ConcurrentMarkSweepThread::desynchronize(false);
} else if (UseG1GC) {
}
#endif // SERIALGC
// record this time so VMThread can keep track how much time has elasped
// since last safepoint.
}
// Need a safepoint if some inline cache buffers is non-empty
if (!InlineCacheBuffer::is_empty()) return true;
return false;
}
// Various cleaning tasks that should be done periodically at safepoints
{
}
{
}
{
}
{
}
if (SymbolTable::needs_rehashing()) {
}
if (StringTable::needs_rehashing()) {
}
// rotate log files?
if (UseGCLogFileRotation) {
}
if (MemTracker::is_on()) {
MemTracker::sync();
}
}
switch(state) {
case _thread_in_native:
// native threads are safe if they have no java stack or have walkable stack
// blocked threads should have already have walkable stack
case _thread_blocked:
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "blocked and not walkable");
return true;
default:
return false;
}
}
// See if the thread is running inside a lazy critical native and
// update the thread critical count if so. Also set a suspend flag to
// cause the native wrapper to return into the JVM to do the unlock
// once the native finishes.
void SafepointSynchronize::check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state) {
if (state == _thread_in_native &&
thread->has_last_Java_frame() &&
// This thread might be in a critical native nmethod so look at
// the top of the stack and increment the critical count if it
// is.
stub_cb->is_nmethod() &&
// A thread could potentially be in a critical native across
// more than one safepoint, so only update the critical state on
// the first one. When it returns it will perform the unlock.
if (!thread->do_critical_native_unlock()) {
#ifdef ASSERT
if (!thread->in_critical()) {
}
#endif
thread->enter_critical();
// Make sure the native wrapper calls back on return to
// perform the needed critical unlock.
}
}
}
}
// -------------------------------------------------------------------------------------------------------
// Implementation of Safepoint callback point
// Threads shouldn't block if they are in the middle of printing, but...
// Only bail from the block() call if the thread is gone from the
// thread list; starting to exit should still block.
if (thread->is_terminated()) {
// block current thread if we come here from native code when VM is gone
// otherwise do nothing
return;
}
// Check that we have a valid thread_state at this point
switch(state) {
case _thread_in_vm_trans:
case _thread_in_Java: // From compiled code
// We are highly likely to block on the Safepoint_lock. In order to avoid blocking in this case,
// we pretend we are still in the VM.
if (is_synchronizing()) {
}
// We will always be holding the Safepoint_lock when we are examine the state
// of a thread. Hence, the instructions between the Safepoint_lock->lock() and
// Safepoint_lock->unlock() are happening atomic with regards to the safepoint code
if (is_synchronizing()) {
// Decrement the number of threads to wait for and signal vm thread
if (thread->in_critical()) {
// Notice that this thread is in a critical section
}
// Consider (_waiting_to_block < 2) to pipeline the wakeup of the VM thread
if (_waiting_to_block == 0) {
}
}
// We transition the thread to state _thread_blocked here, but
// we can't do our usual check for external suspension and then
// self-suspend after the lock_without_safepoint_check() call
// below because we are often called during transitions while
// we hold different locks. That would leave us suspended while
// holding a resource which results in deadlocks.
Safepoint_lock->unlock();
// We now try to acquire the threads lock. Since this lock is hold by the VM thread during
// the entire safepoint, the threads will all line up here during the safepoint.
// restore original state. This is important if the thread comes from compiled code, so it
// will continue to execute with the _thread_in_Java state.
Threads_lock->unlock();
break;
case _thread_in_native_trans:
case _thread_blocked_trans:
case _thread_new_trans:
fatal("Deadlock in safepoint code. "
"Should have called back to the VM before blocking.");
}
// We transition the thread to state _thread_blocked here, but
// we can't do our usual check for external suspension and then
// self-suspend after the lock_without_safepoint_check() call
// below because we are often called during transitions while
// we hold different locks. That would leave us suspended while
// holding a resource which results in deadlocks.
// It is not safe to suspend a thread if we discover it is in _thread_in_native_trans. Hence,
// the safepoint code might still be waiting for it to block. We need to change the state here,
// so it can see that it is at a safepoint.
// Block until the safepoint operation is completed.
// Restore state
Threads_lock->unlock();
break;
default:
}
// Check for pending. async. exceptions or suspends - except if the
// thread was blocked inside the VM. has_special_runtime_exit_condition()
// is called last since it grabs a lock and we only want to do that when
// we must.
//
// Note: we never deliver an async exception at a polling point as the
// compiler may not have an exception handler for it. The polling
// code will notice the async and deoptimize and the exception will
// be delivered. (Polling at a return point is ok though). Sure is
// a lot of bother for a deprecated feature...
//
// We don't deliver an async exception if the thread state is
// _thread_in_native_trans so JNI functions won't be called with
// a surprising pending exception. If the thread state is going back to java,
// async exception is checked in check_special_condition_for_native_trans().
if (state != _thread_blocked_trans &&
state != _thread_in_vm_trans &&
}
}
// ------------------------------------------------------------------------------------------------------
// Exception handlers
#ifndef PRODUCT
#ifdef _LP64
#else
#endif
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
}
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
}
#ifdef SPARC
#ifdef _LP64
#else
#endif
for( int i=0; i<16; i++ ) {
tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
tty->print(" G1 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G3 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G4 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G5 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print_cr(" FSR |"PTR_FORMAT" "PTR64_FORMAT" "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp);
// Skip the floats
tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
}
#endif // SPARC
#endif // PRODUCT
assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
// Sparc safepoint-blob frame structure.
/*
intptr_t* sp = thread->last_Java_sp();
intptr_t stack_copy[150];
for( int i=0; i<150; i++ ) stack_copy[i] = sp[i];
bool was_oops[150];
for( int i=0; i<150; i++ )
was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false;
*/
if (ShowSafepointMsgs) {
}
if (PrintSafepointStatistics) {
}
// print_me(sp,stack_copy,was_oops);
}
if (!timeout_error_printed) {
timeout_error_printed = true;
// Print out the thread infor which didn't reach the safepoint for debugging
// purposes (useful when there are lots of threads in the debugger).
if (reason == _spinning_timeout) {
} else if (reason == _blocking_timeout) {
}
cur_thread->print();
}
}
}
// To debug the long safepoint, specify both DieOnSafepointTimeout &
// ShowMessageBoxOnError.
if (DieOnSafepointTimeout) {
}
}
// -------------------------------------------------------------------------------------------------------
// Implementation of ThreadSafepointState
_has_called_back = false;
_at_poll_safepoint = false;
}
}
if (thread->safepoint_state()) {
delete(thread->safepoint_state());
}
}
// Save the state at the start of safepoint processing.
// Check for a thread that is suspended. Note that thread resume tries
// to grab the Threads_lock which we own here, so a thread cannot be
// resumed during safepoint synchronization.
// We check to see if this thread is suspended without locking to
// avoid deadlocking with a third thread that is waiting for this
// thread to be suspended. The third thread can notice the safepoint
// that we're trying to start at the beginning of its SR_lock->wait()
// call. If that happens, then the third thread will block on the
// safepoint while still holding the underlying SR_lock. We won't be
// able to get the SR_lock and we'll deadlock.
//
// We don't need to grab the SR_lock here for two reasons:
// 1) The suspend flags are both volatile and are set with an
// Atomic::cmpxchg() call so we should see the suspended
// state right away.
// 2) We're being called from the safepoint polling loop; if
// we don't see the suspended state on this iteration, then
// we'll come around again.
//
if (is_suspended) {
return;
}
// Some JavaThread states have an initial safepoint state of
// running, but are actually at a safepoint. We will happily
// agree and update the safepoint state here.
return;
}
if (state == _thread_in_vm) {
return;
}
// All other thread states will continue to run until they
// transition and self-block in state _blocked
// Safepoint polling in compiled code causes the Java threads to do the same.
// Note: new threads may require a malloc so they must be allowed to finish
return;
}
// Returns true is thread could not be rolled forward at present position.
switch(_type) {
case _at_safepoint:
if (_thread->in_critical()) {
// Notice that this thread is in a critical section
}
break;
case _call_back:
set_has_called_back(false);
break;
case _running:
default:
}
}
switch(type()) {
case _at_safepoint:
case _call_back:
break;
case _running:
default:
}
set_has_called_back(false);
}
const char *s;
switch(_type) {
case _running : s = "_running"; break;
case _at_safepoint : s = "_at_safepoint"; break;
case _call_back : s = "_call_back"; break;
default:
}
" [0x%2x] State: %s _has_called_back %d _at_poll_safepoint %d",
}
// ---------------------------------------------------------------------------------------------------------------------
// Block the thread at the safepoint poll or poll return.
// Check state. block() will set thread state to thread_in_vm which will
// cause the safepoint state _type to become _call_back.
"polling page exception on thread not running state");
// Step 1: Find the nmethod from the return address
if (ShowSafepointMsgs && Verbose) {
}
// Find frame of caller
// Should only be poll_return or poll
// This is a poll immediately before a return. The exception handling code
// has already had the effect of causing the return to occur, so the execution
// will continue immediately after the call. In addition, the oopmap at the
// return point does not mark the return value as an oop (if it is), so
// it needs a handle here to be updated.
// See if return type is an oop.
if (return_oop) {
// The oop result has been saved on the stack together with all
// the other registers. In order to preserve it over GCs we need
// to keep it in a handle.
}
// Block the thread
// restore oop result, if any
if (return_oop) {
}
}
// This is a safepoint poll. Verify the return address and block.
else {
set_at_poll_safepoint(true);
// verify the blob built the "return address" correctly
// Block the thread
set_at_poll_safepoint(false);
// If we have a pending async exception deoptimize the frame
// as otherwise we may never deliver it.
if (thread()->has_async_condition()) {
}
// If an exception has been installed we must check for a pending deoptimization
// Deoptimize frame if exception has been thrown.
if (thread()->has_pending_exception() ) {
if (caller_fr.is_deoptimized_frame()) {
// The exception patch will destroy registers that are still
// live and will be needed during deoptimization. Defer the
// Async exception should have defered the exception until the
// next safepoint which will be detected when we get into
// the interpreter so if we have an exception now things
// are messed up.
fatal("Exception installed and deoptimization is pending");
}
}
}
}
//
// Statistics & Instrumentations
//
static bool need_to_track_page_armed_status = false;
static bool init_done = false;
// Helper method to print the header.
static void print_header() {
"[threads: total initially_running wait_to_block] ");
// no page armed status printed out if it is always armed.
}
}
if (init_done) return;
if (PrintSafepointStatisticsCount <= 0) {
fatal("Wrong PrintSafepointStatisticsCount");
}
// If PrintSafepointStatisticsTimeout is specified, the statistics data will
// be printed right away, in which case, _safepoint_stats will regress to
// a single element array. Otherwise, it is a circular ring buffer with default
// size of PrintSafepointStatisticsCount.
int stats_array_size;
if (PrintSafepointStatisticsTimeout > 0) {
stats_array_size = 1;
PrintSafepointStatistics = true;
} else {
}
* sizeof(SafepointStats), mtInternal);
"not enough memory for safepoint instrumentation data");
if (UseCompilerSafepoints && DeferPollingPageLoopCount >= 0) {
need_to_track_page_armed_status = true;
}
init_done = true;
}
}
// Records the start time of spinning. The real time spent on spinning
// will be adjusted when spin is done. Same trick is applied for time
// spent on waiting for threads to block.
if (nof_running != 0) {
} else {
spstat->_time_to_spin = 0;
}
}
if (spstat->_nof_initial_running_threads != 0) {
}
}
// Records the start time of waiting for to block. Updated when block is done.
if (_waiting_to_block != 0) {
} else {
spstat->_time_to_wait_to_block = 0;
}
}
if (spstat->_nof_threads_wait_to_block != 0) {
}
// Records the end time of sync which will be used to calculate the total
// vm operation time. Again, the real time spending in syncing will be deducted
// from the start of the sync time later when end_statistics is called.
}
}
// Record how long spent in cleanup tasks.
}
// Update the vm operation time.
}
// Only the sync time longer than the specified
// PrintSafepointStatisticsTimeout will be printed out right away.
// By default, it is -1 meaning all samples will be put into the list.
if ( PrintSafepointStatisticsTimeout > 0) {
}
} else {
// The safepoint statistics will be printed out when the _safepoin_stats
// array fills up.
_cur_stat_index = 0;
} else {
}
}
}
if (index % 30 == 0) {
print_header();
}
" ] ",
// "/ MICROUNITS " is to convert the unit from nanos to millis.
}
}
}
// This method will be called when VM exits. It will first call
// print_statistics to print out the rest of the sampling. Then
// it tries to summarize the sampling.
if (_safepoint_stats == NULL) return;
// During VM exit, end_statistics may not get called and in that
// case, if the sync time is less than PrintSafepointStatisticsTimeout,
// don't print it out.
// Approximate the vm op time.
if ( PrintSafepointStatisticsTimeout < 0 ||
}
// Print out polling page sampling status.
if (!need_to_track_page_armed_status) {
if (UseCompilerSafepoints) {
}
} else {
}
if (_safepoint_reasons[index] != 0) {
}
}
}
// ------------------------------------------------------------------------------------------------
// Non-product code
#ifndef PRODUCT
if (_state == _not_synchronized) {
"synchronized");
}
}
}
if (ShowSafepointMsgs) {
}
}
#endif // !PRODUCT