thread.hpp revision 3863
869N/A * or visit www.oracle.com if you need additional information or have any
0N/A#define SHARE_VM_RUNTIME_THREAD_HPP
0N/A#include "memory/allocation.hpp"
0N/A#include "memory/threadLocalAllocBuffer.hpp"
0N/A#include "prims/jvmtiExport.hpp"
869N/A#include "runtime/javaFrameAnchor.hpp"
0N/A#include "runtime/jniHandles.hpp"
869N/A#include "runtime/mutexLocker.hpp"
869N/A#include "runtime/osThread.hpp"
869N/A#include "runtime/safepoint.hpp"
0N/A#include "runtime/stubRoutines.hpp"
869N/A#include "runtime/threadLocalStorage.hpp"
48N/A#include "runtime/unhandledOops.hpp"
869N/A#include "services/memRecorder.hpp"
0N/A#include "trace/tracing.hpp"
869N/A#include "utilities/exceptions.hpp"
0N/A#include "gc_implementation/g1/dirtyCardQueue.hpp"
0N/A#include "gc_implementation/g1/satbQueue.hpp"
983N/A#ifdef TARGET_ARCH_zero
1004N/A# include "stack_zero.hpp"
1004N/Aclass ThreadSafepointState;
0N/Aclass ThreadProfiler;
869N/Aclass JvmtiThreadState;
0N/Aclass ThreadStatistics;
0N/Aclass ConcurrentLocksDump;
869N/Aclass CompileThread;
65N/Aclass CompileLog;
65N/Aclass CompileTask;
65N/Aclass CompileQueue;
65N/Aclass CompilerCounters;
65N/Aclass vframeArray;
65N/Aclass DeoptResourceMark;
65N/Aclass GCTaskQueue;
65N/Aclass ThreadClosure;
65N/Aclass IdealGraphPrinter;
65N/Aclass WorkerThread;
868N/A void* _real_malloc_address;
868N/A void* operator new(size_t size, std::nothrow_t& nothrow_constant) { return allocate(size, false); }
868N/A // osThread.hpp).
869N/A enum SuspendFlags {
869N/A int _num_nested_signal;
869N/A // GC points in the VM can happen because of allocation, invoking a VM operation, or blocking on
869N/A // The two classes No_Safepoint_Verifier and No_Allocation_Verifier are used to set these counters.
869N/A friend class No_Alloc_Verifier;
869N/A friend class No_Safepoint_Verifier;
869N/A friend class Pause_No_Safepoint_Verifier;
869N/A friend class ThreadLocalStorage;
869N/A virtual bool is_VM_thread() const { return false; }
869N/A virtual bool is_Java_thread() const { return false; }
869N/A virtual bool is_Compiler_thread() const { return false; }
869N/A virtual bool is_hidden_from_external_view() const { return false; }
869N/A virtual bool is_jvmti_agent_thread() const { return false; }
869N/A virtual bool is_GC_task_thread() const { return false; }
869N/A virtual bool is_Watcher_thread() const { return false; }
869N/A virtual bool is_ConcurrentGC_thread() const { return false; }
869N/A virtual bool is_Named_thread() const { return false; }
869N/A virtual bool is_Worker_thread() const { return false; }
869N/A assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
868N/A void set_has_async_exception() {
868N/A void clear_has_async_exception() {
824N/A bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
869N/A void set_critical_native_unlock() {
869N/A void clear_critical_native_unlock() {
869N/A#ifdef CHECK_UNHANDLED_OOPS
0N/A void clear_unhandled_oops() {
0N/A void initialize_tlab() {
756N/A return allocated_bytes;
0N/A return _current_pending_monitor;
824N/A return _current_waiting_monitor;
869N/A bool set_as_starting_thread();
868N/A address stack_base() const { assert(_stack_base != NULL,"Sanity check"); return _stack_base; }
868N/A void record_stack_base_and_size();
869N/A bool owns_locks_but_compiled_lock() const;
0N/A volatile int _jvmti_env_iteration_count;
0N/A static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); }
869N/A// period. This is inlined in thread_<os_family>.inline.hpp.
0N/A NamedThread();
869N/A ~NamedThread();
869N/A virtual bool is_Named_thread() const { return true; }
868N/A virtual bool is_Worker_thread() const { return true; }
868N/A return (WorkerThread*) this;
0N/A enum SomeConstants {
0N/A bool is_Watcher_thread() const { return true; }
0N/Aclass CompilerThread;
869N/A int _java_call_counter;
0N/A void dec_java_call_counter() {
0N/A // and by JNI_MonitorEnter/Exit
0N/A enum AsyncRequests {
0N/A _no_async_condition = 0,
0N/A enum TerminatedTypes {
0N/A bool _do_not_unlock_if_synchronized; // Do not unlock the receiver of a synchronized method (since it was
0N/A enum JNIAttachStates {
0N/A enum StackGuardState {
869N/A // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
0N/A // used to temp. parsing values into and out of the runtime system during exception handling for compiled
0N/A volatile int _is_method_handle_return; // true (== 1) if the current exception PC is a MethodHandle call site.
0N/A bool _is_compiling; // is true if a compilation is active inthis thread (one compilation per thread possible)
0N/A int _depth_first_number;
0N/A int _jmp_ring_index;
869N/A void flush_barrier_queues();
0N/A friend class ThreadWaitTransition;
0N/A ~JavaThread();
0N/A void verify_not_published();
0N/A void cache_global_variables();
0N/A // Executes Shutdown.shutdown()
0N/A void invoke_shutdown_hooks();
869N/A virtual bool is_Java_thread() const { return true; }
0N/A bool is_terminated() { return _terminated != _not_terminated && _terminated != _thread_exiting; }
869N/A void block_if_vm_exited();
0N/A void java_suspend();
869N/A void java_resume();
0N/A int java_suspend_self();
0N/A void check_and_wait_while_suspended() {
0N/A bool do_self_suspend;
0N/A if (do_self_suspend) {
0N/A } while (do_self_suspend);
0N/A bool is_external_suspend() const {
1017N/A bool is_suspend_after_native() const {
0N/A bool is_ext_suspended() const {
0N/A bool is_external_suspend_with_lock() const {
0N/A return is_external_suspend();
0N/A bool is_being_ext_suspended() const {
869N/A bool has_async_condition() { return (_special_runtime_exit_condition != _no_async_condition); }
776N/A bool has_special_runtime_exit_condition() {
0N/A void set_pending_unsafe_access_error() { _special_runtime_exit_condition = _async_unsafe_access_error; }
0N/A GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred_locals() const { return _deferred_locals_updates; }
869N/A void set_deferred_locals(GrowableArray<jvmtiDeferredLocalVariableSet *>* vf) { _deferred_locals_updates = vf; }
0N/A { return (address)(stack_base() - (stack_size() - (stack_red_zone_size() + stack_yellow_zone_size()))); }
0N/A { return (a <= stack_red_zone_base()) && (a >= (address)((intptr_t)stack_base() - stack_size())); }
869N/A void create_stack_guard_pages();
0N/A void remove_stack_guard_pages();
0N/A void enable_stack_yellow_zone();
0N/A void disable_stack_yellow_zone();
0N/A void enable_stack_red_zone();
869N/A void disable_stack_red_zone();
0N/A inline bool stack_yellow_zone_disabled();
0N/A inline bool stack_yellow_zone_enabled();
0N/A bool reguard_stack(void);
0N/A static ByteSize jmp_ring_index_offset() { return byte_offset_of(JavaThread, _jmp_ring_index ); }
0N/A static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment ); }
0N/A static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); }
869N/A static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); }
0N/A static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); }
0N/A static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
0N/A static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); }
869N/A static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
0N/A static ByteSize satb_mark_queue_offset() { return byte_offset_of(JavaThread, _satb_mark_queue); }
869N/A static ByteSize dirty_card_queue_offset() { return byte_offset_of(JavaThread, _dirty_card_queue); }
869N/A JavaThread *thread_from_jni_env = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));
869N/A return thread_from_jni_env;
0N/A _jni_active_critical++; }
869N/A void dec_in_deopt_handler() {
0N/A void gc_epilogue();
0N/A void gc_prologue();
0N/A void print_value();
0N/A const char* get_thread_name() const;
0N/A const char* get_threadgroup_name() const;
0N/A const char* get_parent_name() const;
0N/A return pd_last_frame();
0N/A void validate_frame_layout() {
0N/A print_frame_layout(0, true);
0N/A void deoptimize();
0N/A void make_zombies();
0N/A void deoptimized_wrt_marked_nmethods();
0N/A // Profiling operation (see fprofile.cpp)
869N/A bool _safepoint_visible;
0N/A void thread_main_inner();
0N/A static ByteSize jvmti_thread_state_offset() { return byte_offset_of(JavaThread, _jvmti_thread_state); }
869N/A void set_jvmti_get_loaded_classes_closure(JvmtiGetLoadedClassesClosure* value) { _jvmti_get_loaded_classes_closure = value; }
0N/A JvmtiGetLoadedClassesClosure* get_jvmti_get_loaded_classes_closure() const { return _jvmti_get_loaded_classes_closure; }
0N/A enum PopCondition {
869N/A static ByteSize popframe_condition_offset() { return byte_offset_of(JavaThread, _popframe_condition); }
0N/A bool popframe_forcing_deopt_reexecution() { return (popframe_condition() & popframe_force_deopt_reexecution_bit) != 0; }
0N/A void clear_popframe_forcing_deopt_reexecution() { _popframe_condition &= ~popframe_force_deopt_reexecution_bit; }
869N/A bool pop_frame_in_process(void) { return ((_popframe_condition & popframe_processing_bit) != 0); }
0N/A void* _popframe_preserved_args;
0N/A void* popframe_preserved_args();
0N/A void popframe_free_preserved_args();
869N/A int _interp_only_mode;
0N/A static ByteSize interp_only_mode_offset() { return byte_offset_of(JavaThread, _interp_only_mode); }
0N/A // this gets set to reflect whether jvmtiExport::post_exception_throw would actually do anything
0N/A return _stack_size_at_create;
824N/A return _satb_mark_queue_set;
869N/A return _dirty_card_queue_set;
824N/A void initialize_queues();
869N/A void initialize_queues() { }
0N/A#ifdef TARGET_OS_ARCH_linux_x86
0N/A# include "thread_linux_x86.hpp"
0N/A# include "thread_linux_sparc.hpp"
869N/A# include "thread_linux_zero.hpp"
#ifdef TARGET_OS_ARCH_solaris_x86
# include "thread_solaris_x86.hpp"
#ifdef TARGET_OS_ARCH_solaris_sparc
# include "thread_solaris_sparc.hpp"
#ifdef TARGET_OS_ARCH_windows_x86
# include "thread_windows_x86.hpp"
#ifdef TARGET_OS_ARCH_linux_arm
# include "thread_linux_arm.hpp"
#ifdef TARGET_OS_ARCH_linux_ppc
# include "thread_linux_ppc.hpp"
#ifdef TARGET_OS_ARCH_bsd_x86
# include "thread_bsd_x86.hpp"
#ifdef TARGET_OS_ARCH_bsd_zero
# include "thread_bsd_zero.hpp"
bool blocked_on_compilation() {
return _blocked_on_compilation;
bool _blocked_on_compilation;
bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
int _claimed_par_id;
return (CompilerThread*)this;
#ifdef ASSERT
friend class VMStructs;
bool is_Compiler_thread() const { return true; }
bool is_hidden_from_external_view() const { return true; }
#ifndef PRODUCT
friend class VMStructs;
static int _number_of_threads;
static int _number_of_non_daemon_threads;
static int _return_code;
static void convert_vm_init_libraries_to_agents();
static void create_vm_init_libraries();
static void create_vm_init_agents();
static void shutdown_vm_agents();
static bool destroy_vm();
static void convert_hcode_pointers();
static void restore_hcode_pointers();
static void gc_epilogue();
static void gc_prologue();
static void verify();
static void print_on(outputStream* st, bool print_stacks, bool internal_format, bool print_concurrent_locks);
// this function is only used by debug.cpp
bool doLock);
static void deoptimized_wrt_marked_nmethods();
_thread = t;
~SignalHandlerMark() {