< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page

 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_RUNTIME_THREAD_HPP
 27 #define SHARE_RUNTIME_THREAD_HPP
 28 
 29 #include "jni.h"
 30 #include "gc/shared/gcThreadLocalData.hpp"
 31 #include "gc/shared/threadLocalAllocBuffer.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "runtime/globals.hpp"

 35 #include "runtime/os.hpp"
 36 #include "runtime/threadHeapSampler.hpp"
 37 #include "runtime/threadLocalStorage.hpp"
 38 #include "runtime/threadStatisticalInfo.hpp"
 39 #include "runtime/unhandledOops.hpp"
 40 #include "utilities/globalDefinitions.hpp"
 41 #include "utilities/macros.hpp"
 42 #if INCLUDE_JFR
 43 #include "jfr/support/jfrThreadExtension.hpp"
 44 #endif
 45 
 46 class HandleArea;
 47 class HandleMark;
 48 class ICRefillVerifier;
 49 class JvmtiRawMonitor;
 50 class Metadata;
 51 class OSThread;
 52 class ParkEvent;
 53 class ResourceArea;
 54 class SafeThreadsListPtr;

590   void leaving_jvmti_env_iteration()             { --_jvmti_env_iteration_count; }
591   bool is_inside_jvmti_env_iteration()           { return _jvmti_env_iteration_count > 0; }
592 
593   // Code generation
594   static ByteSize exception_file_offset()        { return byte_offset_of(Thread, _exception_file); }
595   static ByteSize exception_line_offset()        { return byte_offset_of(Thread, _exception_line); }
596 
597   static ByteSize stack_base_offset()            { return byte_offset_of(Thread, _stack_base); }
598   static ByteSize stack_size_offset()            { return byte_offset_of(Thread, _stack_size); }
599 
600   static ByteSize tlab_start_offset()            { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::start_offset(); }
601   static ByteSize tlab_end_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::end_offset(); }
602   static ByteSize tlab_top_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::top_offset(); }
603   static ByteSize tlab_pf_top_offset()           { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::pf_top_offset(); }
604 
605   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
606 
607   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
608 
609  public:
610   ParkEvent * volatile _ParkEvent;            // for Object monitors, JVMTI raw monitors,
611                                               // and ObjectSynchronizer::read_stable_mark
612 
613   // Termination indicator used by the signal handler.
614   // _ParkEvent is just a convenient field we can NULL out after setting the JavaThread termination state
615   // (which can't itself be read from the signal handler if a signal hits during the Thread destructor).
616   bool has_terminated()                       { return Atomic::load(&_ParkEvent) == NULL; };
617 
618   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
619   jint _hashStateX;                           // thread-specific hashCode generator state
620   jint _hashStateY;
621   jint _hashStateZ;
622 










623   // Low-level leaf-lock primitives used to implement synchronization.
624   // Not for general synchronization use.
625   static void SpinAcquire(volatile int * Lock, const char * Name);
626   static void SpinRelease(volatile int * Lock);
627 
628 #if defined(__APPLE__) && defined(AARCH64)
629  private:
630   DEBUG_ONLY(bool _wx_init);
631   WXMode _wx_state;
632  public:
633   void init_wx();
634   WXMode enable_wx(WXMode new_state);
635 
636   void assert_wx_state(WXMode expected) {
637     assert(_wx_state == expected, "wrong state");
638   }
639 #endif // __APPLE__ && AARCH64
640 };
641 
642 // Inline implementation of Thread::current()

 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_RUNTIME_THREAD_HPP
 27 #define SHARE_RUNTIME_THREAD_HPP
 28 
 29 #include "jni.h"
 30 #include "gc/shared/gcThreadLocalData.hpp"
 31 #include "gc/shared/threadLocalAllocBuffer.hpp"
 32 #include "memory/allocation.hpp"
 33 #include "runtime/atomic.hpp"
 34 #include "runtime/globals.hpp"
 35 #include "runtime/lockStack.hpp"
 36 #include "runtime/os.hpp"
 37 #include "runtime/threadHeapSampler.hpp"
 38 #include "runtime/threadLocalStorage.hpp"
 39 #include "runtime/threadStatisticalInfo.hpp"
 40 #include "runtime/unhandledOops.hpp"
 41 #include "utilities/globalDefinitions.hpp"
 42 #include "utilities/macros.hpp"
 43 #if INCLUDE_JFR
 44 #include "jfr/support/jfrThreadExtension.hpp"
 45 #endif
 46 
 47 class HandleArea;
 48 class HandleMark;
 49 class ICRefillVerifier;
 50 class JvmtiRawMonitor;
 51 class Metadata;
 52 class OSThread;
 53 class ParkEvent;
 54 class ResourceArea;
 55 class SafeThreadsListPtr;

591   void leaving_jvmti_env_iteration()             { --_jvmti_env_iteration_count; }
592   bool is_inside_jvmti_env_iteration()           { return _jvmti_env_iteration_count > 0; }
593 
594   // Code generation
595   static ByteSize exception_file_offset()        { return byte_offset_of(Thread, _exception_file); }
596   static ByteSize exception_line_offset()        { return byte_offset_of(Thread, _exception_line); }
597 
598   static ByteSize stack_base_offset()            { return byte_offset_of(Thread, _stack_base); }
599   static ByteSize stack_size_offset()            { return byte_offset_of(Thread, _stack_size); }
600 
601   static ByteSize tlab_start_offset()            { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::start_offset(); }
602   static ByteSize tlab_end_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::end_offset(); }
603   static ByteSize tlab_top_offset()              { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::top_offset(); }
604   static ByteSize tlab_pf_top_offset()           { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::pf_top_offset(); }
605 
606   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
607 
608   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
609 
610  public:
611   ParkEvent * volatile _ParkEvent;            // for Object monitors and JVMTI raw monitors

612 
613   // Termination indicator used by the signal handler.
614   // _ParkEvent is just a convenient field we can NULL out after setting the JavaThread termination state
615   // (which can't itself be read from the signal handler if a signal hits during the Thread destructor).
616   bool has_terminated()                       { return Atomic::load(&_ParkEvent) == NULL; };
617 
618   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
619   jint _hashStateX;                           // thread-specific hashCode generator state
620   jint _hashStateY;
621   jint _hashStateZ;
622 
623 private:
624   LockStack _lock_stack;
625 
626 public:
627   LockStack& lock_stack() { return _lock_stack; }
628   const LockStack& lock_stack() const { return _lock_stack; }
629 
630   static ByteSize lock_stack_current_offset()    { return byte_offset_of(Thread, _lock_stack) + LockStack::current_offset(); }
631   static ByteSize lock_stack_limit_offset()    { return byte_offset_of(Thread, _lock_stack) + LockStack::limit_offset(); }
632 
633   // Low-level leaf-lock primitives used to implement synchronization.
634   // Not for general synchronization use.
635   static void SpinAcquire(volatile int * Lock, const char * Name);
636   static void SpinRelease(volatile int * Lock);
637 
638 #if defined(__APPLE__) && defined(AARCH64)
639  private:
640   DEBUG_ONLY(bool _wx_init);
641   WXMode _wx_state;
642  public:
643   void init_wx();
644   WXMode enable_wx(WXMode new_state);
645 
646   void assert_wx_state(WXMode expected) {
647     assert(_wx_state == expected, "wrong state");
648   }
649 #endif // __APPLE__ && AARCH64
650 };
651 
652 // Inline implementation of Thread::current()
< prev index next >