/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. *
*/
// // Safepoint synchronization //// // The VMThread uses the SafepointSynchronize::begin/end // methods to enter/exit a safepoint region. The begin method will roll // all JavaThreads forward to a safepoint. // // JavaThreads must use the ThreadSafepointState abstraction (defined in // thread.hpp) to indicate that that they are at a safepoint. // // The Mutex/Condition variable and ObjectLocker classes calls the enter/ // exit safepoint methods, when a thread is blocked/restarted. Hence, all mutex exter/ // exit points *must* be at a safepoint.
// // Implements roll-forward to safepoint (safepoint synchronization) // class SafepointSynchronize : AllStatic { public: enum SynchronizeState {
_not_synchronized = 0, // Threads not synchronized at a safepoint. Keep this value 0.
_synchronizing = 1, // Synchronizing in progress
_synchronized = 2 // All Java threads are running in native, blocked in OS or stopped at safepoint. // VM thread and any NonJavaThread may be running.
};
// The enums are listed in the order of the tasks when done serially. enum SafepointCleanupTasks {
SAFEPOINT_CLEANUP_LAZY_ROOT_PROCESSING,
SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES,
SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH,
SAFEPOINT_CLEANUP_STRING_TABLE_REHASH,
SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP, // Leave this one last.
SAFEPOINT_CLEANUP_NUM_TASKS
};
// Threads might read this flag directly, without acquiring the Threads_lock: staticvolatile SynchronizeState _state; // Number of threads we are waiting for to block: staticint _waiting_to_block; // Counts the number of active critical natives during the safepoint: staticint _current_jni_active_count;
// This counter is used for fast versions of jni_Get<Primitive>Field. // An even value means there are no ongoing safepoint operations. // The counter is incremented ONLY at the beginning and end of each // safepoint. staticvolatile uint64_t _safepoint_counter;
// A change in this counter or a change in the result of // is_at_safepoint() are used by SafepointStateTracker:: // safepoint_state_changed() to determine its answer. static uint64_t _safepoint_id;
// JavaThreads that need to block for the safepoint will stop on the // _wait_barrier, where they can quickly be started again. static WaitBarrier* _wait_barrier; static julong _coalesced_vmop_count; // coalesced vmop count
// For debug long safepoint staticvoid print_safepoint_timeout();
// Used in safepoint_safe to do a stable load of the thread state. staticbool try_stable_load_state(JavaThreadState *state,
JavaThread *thread,
uint64_t safepoint_count);
// Called when a thread voluntarily blocks staticvoid block(JavaThread *thread);
// Called from VMThread during handshakes. // If true the VMThread may safely process the handshake operation for the JavaThread. staticbool handshake_safe(JavaThread *thread);
// Roll all threads forward to safepoint. Must be called by the VMThread. staticvoid begin(); staticvoid end(); // Start all suspended threads again...
// The value for a not set safepoint id. staticconst uint64_t InactiveSafepointCounter;
// Only used for making sure that no safepoint has happened in // JNI_FastGetField. Therefore only the low 32-bits are needed // even if this is a 64-bit counter. static address safepoint_counter_addr() { #ifdef VM_LITTLE_ENDIAN return (address)&_safepoint_counter; #else/* BIG */ // Return pointer to the 32 LSB: return (address) (((uint32_t*)(&_safepoint_counter)) + 1); #endif
}
};
// Some helper assert macros for safepoint checks.
#define assert_at_safepoint() \
assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint")
// State class for a thread suspended at a safepoint class ThreadSafepointState: public CHeapObj<mtThread> { private: // At polling page safepoint (NOT a poll return safepoint): volatilebool _at_poll_safepoint;
JavaThread* _thread; bool _safepoint_safe; volatile uint64_t _safepoint_id;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.