/*
* 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.
*
*/
#ifndef SHARE_VM_RUNTIME_SAFEPOINT_HPP
#define SHARE_VM_RUNTIME_SAFEPOINT_HPP
#include "asm/assembler.hpp"
#include "code/nmethod.hpp"
#include "memory/allocation.hpp"
#include "runtime/extendedPC.hpp"
#include "runtime/mutexLocker.hpp"
#include "utilities/ostream.hpp"
//
// Safepoint synchronization
////
// 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.
//
// exit points *must* be at a safepoint.
class ThreadSafepointState;
class SnippetCache;
class nmethod;
//
// Implements roll-forward to safepoint (safepoint synchronization)
//
public:
enum SynchronizeState {
// Keep this value 0. See the coment in do_call_back()
};
enum SafepointingThread {
_null_thread = 0,
};
enum SafepointTimeoutReason {
_spinning_timeout = 0,
};
typedef struct {
private:
static volatile SynchronizeState _state; // Threads might read this flag directly, without acquireing the Threads_lock
static int _current_jni_active_count; // Counts the number of active critical natives during the safepoint
// This counter is used for fast versions of jni_Get<Primitive>Field.
// An even value means there is no ongoing safepoint operations.
// The counter is incremented ONLY at the beginning and end of each
// safepoint. The fact that Threads_lock is held throughout each pair of
// increments (at the beginning and end of each safepoint) guarantees
// race freedom.
public:
static volatile int _safepoint_counter;
private:
// statistics
static void update_statistics_on_spin_end();
static void print_statistics();
inline static void inc_page_trap_count() {
}
// For debug long safepoint
public:
// Main entry points
// Roll all threads forward to safepoint. Must be called by the
// VMThread or CMS_thread.
static void begin();
static void end(); // Start all suspended threads again...
// Query
inline static bool do_call_back() {
return (_state != _not_synchronized);
}
inline static void increment_jni_active_count() {
}
// Called when a thread volantary blocks
// Exception handling for page polling
// VM Thread interface for determining safepoint rate
static long last_non_safepoint_interval() {
}
static long end_of_last_safepoint() {
return _end_of_last_safepoint;
}
static bool is_cleanup_needed();
static void do_cleanup_tasks();
// debugging
static void deferred_initialize_stat();
static void print_stat_on_exit();
// assembly support
};
// State class for a thread suspended at a safepoint
public:
// These states are maintained by VM thread while threads are being brought
// to a safepoint. After SafepointSynchronize::end(), they are reset to
// _running.
enum suspend_type {
};
private:
// Thread has called back the safepoint code (for debugging)
bool _has_called_back;
public:
void examine_state_of_thread();
void restart();
// Query
// Support for safepoint timeout (debugging)
void handle_polling_page_exception();
// debugging
// Initialize
if (ShowSafepointMsgs) {
}
}
};
#endif // SHARE_VM_RUNTIME_SAFEPOINT_HPP