0N/A/*
4340N/A * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_RUNTIME_THREAD_HPP
1879N/A#define SHARE_VM_RUNTIME_THREAD_HPP
1879N/A
1879N/A#include "memory/allocation.hpp"
1879N/A#include "memory/threadLocalAllocBuffer.hpp"
1879N/A#include "oops/oop.hpp"
1879N/A#include "prims/jni.h"
1879N/A#include "prims/jvmtiExport.hpp"
1879N/A#include "runtime/frame.hpp"
1879N/A#include "runtime/javaFrameAnchor.hpp"
1879N/A#include "runtime/jniHandles.hpp"
1879N/A#include "runtime/mutexLocker.hpp"
1879N/A#include "runtime/os.hpp"
1879N/A#include "runtime/osThread.hpp"
1879N/A#include "runtime/park.hpp"
1879N/A#include "runtime/safepoint.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1879N/A#include "runtime/threadLocalStorage.hpp"
1879N/A#include "runtime/unhandledOops.hpp"
3863N/A#include "services/memRecorder.hpp"
4141N/A#include "trace/traceBackend.hpp"
4141N/A#include "trace/traceMacros.hpp"
1879N/A#include "utilities/exceptions.hpp"
1879N/A#include "utilities/top.hpp"
1879N/A#ifndef SERIALGC
1879N/A#include "gc_implementation/g1/dirtyCardQueue.hpp"
1879N/A#include "gc_implementation/g1/satbQueue.hpp"
1879N/A#endif
1879N/A#ifdef ZERO
1879N/A#ifdef TARGET_ARCH_zero
1879N/A# include "stack_zero.hpp"
1879N/A#endif
1879N/A#endif
1879N/A
0N/Aclass ThreadSafepointState;
0N/Aclass ThreadProfiler;
0N/A
0N/Aclass JvmtiThreadState;
0N/Aclass JvmtiGetLoadedClassesClosure;
0N/Aclass ThreadStatistics;
0N/Aclass ConcurrentLocksDump;
1988N/Aclass ParkEvent;
1798N/Aclass Parker;
0N/A
0N/Aclass ciEnv;
0N/Aclass CompileThread;
0N/Aclass CompileLog;
0N/Aclass CompileTask;
0N/Aclass CompileQueue;
0N/Aclass CompilerCounters;
0N/Aclass vframeArray;
0N/A
0N/Aclass DeoptResourceMark;
0N/Aclass jvmtiDeferredLocalVariableSet;
0N/A
0N/Aclass GCTaskQueue;
0N/Aclass ThreadClosure;
0N/Aclass IdealGraphPrinter;
0N/A
1881N/Aclass WorkerThread;
1881N/A
0N/A// Class hierarchy
0N/A// - Thread
1119N/A// - NamedThread
1119N/A// - VMThread
1119N/A// - ConcurrentGCThread
1119N/A// - WorkerThread
1119N/A// - GangWorker
1119N/A// - GCTaskThread
0N/A// - JavaThread
0N/A// - WatcherThread
0N/A
0N/Aclass Thread: public ThreadShadow {
0N/A friend class VMStructs;
0N/A private:
0N/A // Exception handling
0N/A // (Note: _pending_exception and friends are in ThreadShadow)
0N/A //oop _pending_exception; // pending exception for current thread
0N/A // const char* _exception_file; // file information for exception (debugging only)
0N/A // int _exception_line; // line information for exception (debugging only)
3863N/A protected:
0N/A // Support for forcing alignment of thread objects for biased locking
0N/A void* _real_malloc_address;
0N/A public:
3863N/A void* operator new(size_t size) { return allocate(size, true); }
3863N/A void* operator new(size_t size, std::nothrow_t& nothrow_constant) { return allocate(size, false); }
0N/A void operator delete(void* p);
3863N/A
3863N/A protected:
3863N/A static void* allocate(size_t size, bool throw_excpt, MEMFLAGS flags = mtThread);
0N/A private:
0N/A
0N/A // ***************************************************************
0N/A // Suspend and resume support
0N/A // ***************************************************************
0N/A //
0N/A // VM suspend/resume no longer exists - it was once used for various
0N/A // things including safepoints but was deprecated and finally removed
0N/A // in Java 7. Because VM suspension was considered "internal" Java-level
0N/A // suspension was considered "external", and this legacy naming scheme
0N/A // remains.
0N/A //
0N/A // External suspend/resume requests come from JVM_SuspendThread,
0N/A // JVM_ResumeThread, JVMTI SuspendThread, and finally JVMTI
0N/A // ResumeThread. External
0N/A // suspend requests cause _external_suspend to be set and external
0N/A // resume requests cause _external_suspend to be cleared.
0N/A // External suspend requests do not nest on top of other external
0N/A // suspend requests. The higher level APIs reject suspend requests
0N/A // for already suspended threads.
0N/A //
0N/A // The external_suspend
0N/A // flag is checked by has_special_runtime_exit_condition() and java thread
0N/A // will self-suspend when handle_special_runtime_exit_condition() is
0N/A // called. Most uses of the _thread_blocked state in JavaThreads are
0N/A // considered the same as being externally suspended; if the blocking
0N/A // condition lifts, the JavaThread will self-suspend. Other places
0N/A // where VM checks for external_suspend include:
0N/A // + mutex granting (do not enter monitors when thread is suspended)
0N/A // + state transitions from _thread_in_native
0N/A //
0N/A // In general, java_suspend() does not wait for an external suspend
0N/A // request to complete. When it returns, the only guarantee is that
0N/A // the _external_suspend field is true.
0N/A //
0N/A // wait_for_ext_suspend_completion() is used to wait for an external
0N/A // suspend request to complete. External suspend requests are usually
0N/A // followed by some other interface call that requires the thread to
0N/A // be quiescent, e.g., GetCallTrace(). By moving the "wait time" into
0N/A // the interface that requires quiescence, we give the JavaThread a
0N/A // chance to self-suspend before we need it to be quiescent. This
0N/A // improves overall suspend/query performance.
0N/A //
0N/A // _suspend_flags controls the behavior of java_ suspend/resume.
0N/A // It must be set under the protection of SR_lock. Read from the flag is
0N/A // OK without SR_lock as long as the value is only used as a hint.
0N/A // (e.g., check _external_suspend first without lock and then recheck
0N/A // inside SR_lock and finish the suspension)
0N/A //
0N/A // _suspend_flags is also overloaded for other "special conditions" so
0N/A // that a single check indicates whether any special action is needed
0N/A // eg. for async exceptions.
0N/A // -------------------------------------------------------------------
0N/A // Notes:
0N/A // 1. The suspend/resume logic no longer uses ThreadState in OSThread
0N/A // but we still update its value to keep other part of the system (mainly
0N/A // JVMTI) happy. ThreadState is legacy code (see notes in
0N/A // osThread.hpp).
0N/A //
0N/A // 2. It would be more natural if set_external_suspend() is private and
0N/A // part of java_suspend(), but that probably would affect the suspend/query
0N/A // performance. Need more investigation on this.
0N/A //
0N/A
0N/A // suspend/resume lock: used for self-suspend
1988N/A Monitor* _SR_lock;
0N/A
0N/A protected:
0N/A enum SuspendFlags {
0N/A // NOTE: avoid using the sign-bit as cc generates different test code
0N/A // when the sign-bit is used, and sometimes incorrectly - see CR 6398077
0N/A
0N/A _external_suspend = 0x20000000U, // thread is asked to self suspend
0N/A _ext_suspended = 0x40000000U, // thread has self-suspended
0N/A _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
0N/A
3158N/A _has_async_exception = 0x00000001U, // there is a pending async exception
3158N/A _critical_native_unlock = 0x00000002U // Must call back to unlock JNI critical lock
0N/A };
0N/A
0N/A // various suspension related flags - atomically updated
0N/A // overloaded for async exception checking in check_special_condition_for_native_trans.
0N/A volatile uint32_t _suspend_flags;
0N/A
0N/A private:
0N/A int _num_nested_signal;
0N/A
0N/A public:
0N/A void enter_signal_handler() { _num_nested_signal++; }
0N/A void leave_signal_handler() { _num_nested_signal--; }
1988N/A bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
0N/A
0N/A private:
0N/A // Debug tracing
0N/A static void trace(const char* msg, const Thread* const thread) PRODUCT_RETURN;
0N/A
0N/A // Active_handles points to a block of handles
0N/A JNIHandleBlock* _active_handles;
0N/A
0N/A // One-element thread local free list
0N/A JNIHandleBlock* _free_handle_block;
0N/A
0N/A // Point to the last handle mark
0N/A HandleMark* _last_handle_mark;
0N/A
0N/A // The parity of the last strong_roots iteration in which this thread was
0N/A // claimed as a task.
0N/A jint _oops_do_parity;
0N/A
0N/A public:
0N/A void set_last_handle_mark(HandleMark* mark) { _last_handle_mark = mark; }
1988N/A HandleMark* last_handle_mark() const { return _last_handle_mark; }
0N/A private:
0N/A
0N/A // debug support for checking if code does allow safepoints or not
0N/A // GC points in the VM can happen because of allocation, invoking a VM operation, or blocking on
0N/A // mutex, or blocking on an object synchronizer (Java locking).
0N/A // If !allow_safepoint(), then an assertion failure will happen in any of the above cases
0N/A // If !allow_allocation(), then an assertion failure will happen during allocation
0N/A // (Hence, !allow_safepoint() => !allow_allocation()).
0N/A //
0N/A // The two classes No_Safepoint_Verifier and No_Allocation_Verifier are used to set these counters.
0N/A //
1988N/A NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen
1988N/A debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
0N/A
806N/A // Used by SkipGCALot class.
1988N/A NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
806N/A
0N/A // Record when GC is locked out via the GC_locker mechanism
0N/A CHECK_UNHANDLED_OOPS_ONLY(int _gc_locked_out_count;)
0N/A
0N/A friend class No_Alloc_Verifier;
0N/A friend class No_Safepoint_Verifier;
0N/A friend class Pause_No_Safepoint_Verifier;
0N/A friend class ThreadLocalStorage;
0N/A friend class GC_locker;
0N/A
1988N/A ThreadLocalAllocBuffer _tlab; // Thread-local eden
1988N/A jlong _allocated_bytes; // Cumulative number of bytes allocated on
1988N/A // the Java heap
0N/A
4466N/A TRACE_DATA _trace_data; // Thread-local data for tracing
3081N/A
1988N/A int _vm_operation_started_count; // VM_Operation support
1988N/A int _vm_operation_completed_count; // VM_Operation support
0N/A
1988N/A ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
1988N/A // is waiting to lock
1988N/A bool _current_pending_monitor_is_from_java; // locking is from Java code
0N/A
0N/A // ObjectMonitor on which this thread called Object.wait()
0N/A ObjectMonitor* _current_waiting_monitor;
0N/A
0N/A // Private thread-local objectmonitor list - a simple cache organized as a SLL.
0N/A public:
1988N/A ObjectMonitor* omFreeList;
1988N/A int omFreeCount; // length of omFreeList
1988N/A int omFreeProvision; // reload chunk size
Error!

 

There was an error!

null

java.lang.NullPointerException