src/hotspot/share/runtime/thread.hpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 55005 9b70ebd131b4
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    60 class SafeThreadsListPtr;
    60 class SafeThreadsListPtr;
    61 class ThreadSafepointState;
    61 class ThreadSafepointState;
    62 class ThreadsList;
    62 class ThreadsList;
    63 class ThreadsSMRSupport;
    63 class ThreadsSMRSupport;
    64 
    64 
       
    65 class JvmtiRawMonitor;
    65 class JvmtiThreadState;
    66 class JvmtiThreadState;
    66 class ThreadStatistics;
    67 class ThreadStatistics;
    67 class ConcurrentLocksDump;
    68 class ConcurrentLocksDump;
    68 class ParkEvent;
    69 class ParkEvent;
    69 class Parker;
    70 class Parker;
    81 class javaVFrame;
    82 class javaVFrame;
    82 
    83 
    83 class DeoptResourceMark;
    84 class DeoptResourceMark;
    84 class jvmtiDeferredLocalVariableSet;
    85 class jvmtiDeferredLocalVariableSet;
    85 
    86 
    86 class GCTaskQueue;
       
    87 class ThreadClosure;
    87 class ThreadClosure;
    88 class ICRefillVerifier;
    88 class ICRefillVerifier;
    89 class IdealGraphPrinter;
    89 class IdealGraphPrinter;
    90 
    90 
    91 class JVMCIEnv;
    91 class JVMCIEnv;
   106 //     - NamedThread
   106 //     - NamedThread
   107 //       - VMThread
   107 //       - VMThread
   108 //       - ConcurrentGCThread
   108 //       - ConcurrentGCThread
   109 //       - WorkerThread
   109 //       - WorkerThread
   110 //         - GangWorker
   110 //         - GangWorker
   111 //         - GCTaskThread
       
   112 //     - WatcherThread
   111 //     - WatcherThread
   113 //     - JfrThreadSampler
   112 //     - JfrThreadSampler
   114 //
   113 //
   115 // All Thread subclasses must be either JavaThread or NonJavaThread.
   114 // All Thread subclasses must be either JavaThread or NonJavaThread.
   116 // This means !t->is_Java_thread() iff t is a NonJavaThread, or t is
   115 // This means !t->is_Java_thread() iff t is a NonJavaThread, or t is
   142   friend class JVMCIVMStructs;
   141   friend class JVMCIVMStructs;
   143  private:
   142  private:
   144 
   143 
   145 #ifndef USE_LIBRARY_BASED_TLS_ONLY
   144 #ifndef USE_LIBRARY_BASED_TLS_ONLY
   146   // Current thread is maintained as a thread-local variable
   145   // Current thread is maintained as a thread-local variable
   147   static THREAD_LOCAL_DECL Thread* _thr_current;
   146   static THREAD_LOCAL Thread* _thr_current;
   148 #endif
   147 #endif
   149 
   148 
   150   // Thread local data area available to the GC. The internal
   149   // Thread local data area available to the GC. The internal
   151   // structure and contents of this data area is GC-specific.
   150   // structure and contents of this data area is GC-specific.
   152   // Only GC and GC barrier code should access this data area.
   151   // Only GC and GC barrier code should access this data area.
   365   }
   364   }
   366 
   365 
   367   void set_missed_ic_stub_refill_verifier(ICRefillVerifier* verifier) {
   366   void set_missed_ic_stub_refill_verifier(ICRefillVerifier* verifier) {
   368     _missed_ic_stub_refill_verifier = verifier;
   367     _missed_ic_stub_refill_verifier = verifier;
   369   }
   368   }
   370 #endif
   369 #endif // ASSERT
   371 
   370 
   372  private:
   371  private:
   373 
   372 
   374   // debug support for checking if code does allow safepoints or not
   373   // Debug support for checking if code allows safepoints or not.
   375   // GC points in the VM can happen because of allocation, invoking a VM operation, or blocking on
   374   // Safepoints in the VM can happen because of allocation, invoking a VM operation, or blocking on
   376   // mutex, or blocking on an object synchronizer (Java locking).
   375   // mutex, or blocking on an object synchronizer (Java locking).
   377   // If !allow_safepoint(), then an assertion failure will happen in any of the above cases
   376   // If _no_safepoint_count is non-zero, then an assertion failure will happen in any of
   378   // If !allow_allocation(), then an assertion failure will happen during allocation
   377   // the above cases.
   379   // (Hence, !allow_safepoint() => !allow_allocation()).
       
   380   //
   378   //
   381   // The two classes NoSafepointVerifier and No_Allocation_Verifier are used to set these counters.
   379   // The class NoSafepointVerifier is used to set this counter.
   382   //
   380   //
   383   NOT_PRODUCT(int _allow_safepoint_count;)      // If 0, thread allow a safepoint to happen
   381   NOT_PRODUCT(int _no_safepoint_count;)         // If 0, thread allow a safepoint to happen
   384   debug_only(int _allow_allocation_count;)     // If 0, the thread is allowed to allocate oops.
   382 
   385 
   383  private:
   386   // Used by SkipGCALot class.
   384   // Used by SkipGCALot class.
   387   NOT_PRODUCT(bool _skip_gcalot;)               // Should we elide gc-a-lot?
   385   NOT_PRODUCT(bool _skip_gcalot;)               // Should we elide gc-a-lot?
   388 
   386 
   389   friend class NoAllocVerifier;
   387   friend class GCLocker;
   390   friend class NoSafepointVerifier;
   388   friend class NoSafepointVerifier;
   391   friend class PauseNoSafepointVerifier;
   389   friend class PauseNoSafepointVerifier;
   392   friend class GCLocker;
       
   393 
   390 
   394   volatile void* _polling_page;                 // Thread local polling page
   391   volatile void* _polling_page;                 // Thread local polling page
   395 
   392 
   396   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
   393   ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
   397   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
   394   jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
   406   int   _vm_operation_completed_count;          // VM_Operation support
   403   int   _vm_operation_completed_count;          // VM_Operation support
   407 
   404 
   408   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
   405   ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
   409                                                 // is waiting to lock
   406                                                 // is waiting to lock
   410   bool _current_pending_monitor_is_from_java;   // locking is from Java code
   407   bool _current_pending_monitor_is_from_java;   // locking is from Java code
       
   408   JvmtiRawMonitor* _current_pending_raw_monitor; // JvmtiRawMonitor this thread
       
   409                                                  // is waiting to lock
       
   410 
   411 
   411 
   412   // ObjectMonitor on which this thread called Object.wait()
   412   // ObjectMonitor on which this thread called Object.wait()
   413   ObjectMonitor* _current_waiting_monitor;
   413   ObjectMonitor* _current_waiting_monitor;
   414 
   414 
   415   // Private thread-local objectmonitor list - a simple cache organized as a SLL.
   415   // Per-thread ObjectMonitor lists:
   416  public:
   416  public:
   417   ObjectMonitor* omFreeList;
   417   ObjectMonitor* om_free_list;                  // SLL of free ObjectMonitors
   418   int omFreeCount;                              // length of omFreeList
   418   int om_free_count;                            // # on om_free_list
   419   int omFreeProvision;                          // reload chunk size
   419   int om_free_provision;                        // # to try to allocate next
   420   ObjectMonitor* omInUseList;                   // SLL to track monitors in circulation
   420   ObjectMonitor* om_in_use_list;                // SLL of in-use ObjectMonitors
   421   int omInUseCount;                             // length of omInUseList
   421   int om_in_use_count;                          // # on om_in_use_list
   422 
   422 
   423 #ifdef ASSERT
   423 #ifdef ASSERT
   424  private:
   424  private:
   425   volatile uint64_t _visited_for_critical_count;
   425   volatile uint64_t _visited_for_critical_count;
   426 
   426 
   492   virtual bool is_Worker_thread() const              { return false; }
   492   virtual bool is_Worker_thread() const              { return false; }
   493 
   493 
   494   // Can this thread make Java upcalls
   494   // Can this thread make Java upcalls
   495   virtual bool can_call_java() const                 { return false; }
   495   virtual bool can_call_java() const                 { return false; }
   496 
   496 
       
   497   // Is this a JavaThread that is on the VM's current ThreadsList?
       
   498   // If so it must participate in the safepoint protocol.
       
   499   virtual bool is_active_Java_thread() const         { return false; }
       
   500 
   497   // Casts
   501   // Casts
   498   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
   502   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
   499 
   503 
   500   virtual char* name() const { return (char*)"Unknown thread"; }
   504   virtual char* name() const { return (char*)"Unknown thread"; }
   501 
   505 
   512   static void check_for_dangling_thread_pointer(Thread *thread);
   516   static void check_for_dangling_thread_pointer(Thread *thread);
   513 #endif
   517 #endif
   514   static void set_priority(Thread* thread, ThreadPriority priority);
   518   static void set_priority(Thread* thread, ThreadPriority priority);
   515   static ThreadPriority get_priority(const Thread* const thread);
   519   static ThreadPriority get_priority(const Thread* const thread);
   516   static void start(Thread* thread);
   520   static void start(Thread* thread);
   517   static void interrupt(Thread* thr);
       
   518   static bool is_interrupted(Thread* thr, bool clear_interrupted);
       
   519 
   521 
   520   void set_native_thread_name(const char *name) {
   522   void set_native_thread_name(const char *name) {
   521     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
   523     assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
   522     os::set_native_thread_name(name);
   524     os::set_native_thread_name(name);
   523   }
   525   }
   524 
   526 
   525   ObjectMonitor** omInUseList_addr()             { return (ObjectMonitor **)&omInUseList; }
   527   ObjectMonitor** om_in_use_list_addr()          { return (ObjectMonitor **)&om_in_use_list; }
   526   Monitor* SR_lock() const                       { return _SR_lock; }
   528   Monitor* SR_lock() const                       { return _SR_lock; }
   527 
   529 
   528   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
   530   bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
   529 
   531 
   530   inline void set_suspend_flag(SuspendFlags f);
   532   inline void set_suspend_flag(SuspendFlags f);
   638   ObjectMonitor* current_waiting_monitor() {
   640   ObjectMonitor* current_waiting_monitor() {
   639     return _current_waiting_monitor;
   641     return _current_waiting_monitor;
   640   }
   642   }
   641   void set_current_waiting_monitor(ObjectMonitor* monitor) {
   643   void set_current_waiting_monitor(ObjectMonitor* monitor) {
   642     _current_waiting_monitor = monitor;
   644     _current_waiting_monitor = monitor;
       
   645   }
       
   646 
       
   647   // For tracking the Jvmti raw monitor the thread is pending on.
       
   648   JvmtiRawMonitor* current_pending_raw_monitor() {
       
   649     return _current_pending_raw_monitor;
       
   650   }
       
   651   void set_current_pending_raw_monitor(JvmtiRawMonitor* monitor) {
       
   652     _current_pending_raw_monitor = monitor;
   643   }
   653   }
   644 
   654 
   645   // GC support
   655   // GC support
   646   // Apply "f->do_oop" to all root oops in "this".
   656   // Apply "f->do_oop" to all root oops in "this".
   647   //   Used by JavaThread::oops_do.
   657   //   Used by JavaThread::oops_do.
   701   GrowableArray<Metadata*>* _metadata_handles;
   711   GrowableArray<Metadata*>* _metadata_handles;
   702 
   712 
   703   // Support for stack overflow handling, get_thread, etc.
   713   // Support for stack overflow handling, get_thread, etc.
   704   address          _stack_base;
   714   address          _stack_base;
   705   size_t           _stack_size;
   715   size_t           _stack_size;
   706   uintptr_t        _self_raw_id;      // used by get_thread (mutable)
       
   707   int              _lgrp_id;
   716   int              _lgrp_id;
   708 
   717 
   709   volatile void** polling_page_addr() { return &_polling_page; }
   718   volatile void** polling_page_addr() { return &_polling_page; }
   710 
   719 
   711  public:
   720  public:
   721   bool    on_local_stack(address adr) const {
   730   bool    on_local_stack(address adr) const {
   722     // QQQ this has knowledge of direction, ought to be a stack method
   731     // QQQ this has knowledge of direction, ought to be a stack method
   723     return (_stack_base >= adr && adr >= stack_end());
   732     return (_stack_base >= adr && adr >= stack_end());
   724   }
   733   }
   725 
   734 
   726   uintptr_t self_raw_id()                    { return _self_raw_id; }
       
   727   void      set_self_raw_id(uintptr_t value) { _self_raw_id = value; }
       
   728 
       
   729   int     lgrp_id() const        { return _lgrp_id; }
   735   int     lgrp_id() const        { return _lgrp_id; }
   730   void    set_lgrp_id(int value) { _lgrp_id = value; }
   736   void    set_lgrp_id(int value) { _lgrp_id = value; }
   731 
   737 
   732   // Printing
   738   // Printing
   733   void print_on(outputStream* st, bool print_extended_info) const;
   739   void print_on(outputStream* st, bool print_extended_info) const;
   738 
   744 
   739   // Debug-only code
   745   // Debug-only code
   740 #ifdef ASSERT
   746 #ifdef ASSERT
   741  private:
   747  private:
   742   // Deadlock detection support for Mutex locks. List of locks own by thread.
   748   // Deadlock detection support for Mutex locks. List of locks own by thread.
   743   Monitor* _owned_locks;
   749   Mutex* _owned_locks;
   744   // Mutex::set_owner_implementation is the only place where _owned_locks is modified,
   750   // Mutex::set_owner_implementation is the only place where _owned_locks is modified,
   745   // thus the friendship
   751   // thus the friendship
   746   friend class Mutex;
   752   friend class Mutex;
   747   friend class Monitor;
   753   friend class Monitor;
   748 
   754 
   749  public:
   755  public:
   750   void print_owned_locks_on(outputStream* st) const;
   756   void print_owned_locks_on(outputStream* st) const;
   751   void print_owned_locks() const                 { print_owned_locks_on(tty);    }
   757   void print_owned_locks() const                 { print_owned_locks_on(tty);    }
   752   Monitor* owned_locks() const                   { return _owned_locks;          }
   758   Mutex* owned_locks() const                     { return _owned_locks;          }
   753   bool owns_locks() const                        { return owned_locks() != NULL; }
   759   bool owns_locks() const                        { return owned_locks() != NULL; }
   754   bool owns_locks_but_compiled_lock() const;
       
   755 
   760 
   756   // Deadlock detection
   761   // Deadlock detection
   757   bool allow_allocation()                        { return _allow_allocation_count == 0; }
       
   758   ResourceMark* current_resource_mark()          { return _current_resource_mark; }
   762   ResourceMark* current_resource_mark()          { return _current_resource_mark; }
   759   void set_current_resource_mark(ResourceMark* rm) { _current_resource_mark = rm; }
   763   void set_current_resource_mark(ResourceMark* rm) { _current_resource_mark = rm; }
   760 #endif
   764 #endif // ASSERT
   761 
   765 
   762   void check_for_valid_safepoint_state(bool potential_vm_operation) PRODUCT_RETURN;
   766   // These functions check conditions on a JavaThread before possibly going to a safepoint,
       
   767   // including NoSafepointVerifier.
       
   768   void check_for_valid_safepoint_state() NOT_DEBUG_RETURN;
       
   769   void check_possible_safepoint() NOT_DEBUG_RETURN;
   763 
   770 
   764  private:
   771  private:
   765   volatile int _jvmti_env_iteration_count;
   772   volatile int _jvmti_env_iteration_count;
   766 
   773 
   767  public:
   774  public:
   789   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
   796   JFR_ONLY(DEFINE_THREAD_LOCAL_OFFSET_JFR;)
   790 
   797 
   791  public:
   798  public:
   792   volatile intptr_t _Stalled;
   799   volatile intptr_t _Stalled;
   793   volatile int _TypeTag;
   800   volatile int _TypeTag;
   794   ParkEvent * _ParkEvent;                     // for synchronized()
   801   ParkEvent * _ParkEvent;                     // for Object monitors and JVMTI raw monitors
   795   ParkEvent * _SleepEvent;                    // for Thread.sleep
       
   796   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
   802   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
   797   int NativeSyncRecursion;                    // diagnostic
   803   int NativeSyncRecursion;                    // diagnostic
   798 
   804 
   799   volatile int _OnTrap;                       // Resume-at IP delta
   805   volatile int _OnTrap;                       // Resume-at IP delta
   800   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
   806   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
   806   // and native monitor-mutex infrastructure.
   812   // and native monitor-mutex infrastructure.
   807   // Not for general synchronization use.
   813   // Not for general synchronization use.
   808   static void SpinAcquire(volatile int * Lock, const char * Name);
   814   static void SpinAcquire(volatile int * Lock, const char * Name);
   809   static void SpinRelease(volatile int * Lock);
   815   static void SpinRelease(volatile int * Lock);
   810   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
   816   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
   811   static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev);
       
   812   static void muxRelease(volatile intptr_t * Lock);
   817   static void muxRelease(volatile intptr_t * Lock);
   813 };
   818 };
   814 
   819 
   815 // Inline implementation of Thread::current()
   820 // Inline implementation of Thread::current()
   816 inline Thread* Thread::current() {
   821 inline Thread* Thread::current() {
  1015   JNIEnv        _jni_environment;
  1020   JNIEnv        _jni_environment;
  1016 
  1021 
  1017   // Deopt support
  1022   // Deopt support
  1018   DeoptResourceMark*  _deopt_mark;               // Holds special ResourceMark for deoptimization
  1023   DeoptResourceMark*  _deopt_mark;               // Holds special ResourceMark for deoptimization
  1019 
  1024 
  1020   intptr_t*      _must_deopt_id;                 // id of frame that needs to be deopted once we
       
  1021                                                  // transition out of native
       
  1022   CompiledMethod*       _deopt_nmethod;         // CompiledMethod that is currently being deoptimized
  1025   CompiledMethod*       _deopt_nmethod;         // CompiledMethod that is currently being deoptimized
  1023   vframeArray*  _vframe_array_head;              // Holds the heap of the active vframeArrays
  1026   vframeArray*  _vframe_array_head;              // Holds the heap of the active vframeArrays
  1024   vframeArray*  _vframe_array_last;              // Holds last vFrameArray we popped
  1027   vframeArray*  _vframe_array_last;              // Holds last vFrameArray we popped
  1025   // Because deoptimization is lazy we must save jvmti requests to set locals
  1028   // Because deoptimization is lazy we must save jvmti requests to set locals
  1026   // in compiled frames until we deoptimize and we have an interpreter frame.
  1029   // in compiled frames until we deoptimize and we have an interpreter frame.
  1150   jlong*    _jvmci_counters;
  1153   jlong*    _jvmci_counters;
  1151 
  1154 
  1152  public:
  1155  public:
  1153   static jlong* _jvmci_old_thread_counters;
  1156   static jlong* _jvmci_old_thread_counters;
  1154   static void collect_counters(jlong* array, int length);
  1157   static void collect_counters(jlong* array, int length);
       
  1158   void resize_counters(int current_size, int new_size);
       
  1159   static void resize_all_jvmci_counters(int new_size);
       
  1160 
  1155  private:
  1161  private:
  1156 #endif // INCLUDE_JVMCI
  1162 #endif // INCLUDE_JVMCI
  1157 
  1163 
  1158   StackGuardState  _stack_guard_state;
  1164   StackGuardState  _stack_guard_state;
  1159 
  1165 
  1188   // and during exception propagation, pop the top
  1194   // and during exception propagation, pop the top
  1189   // _frames_to_pop_failed_realloc frames, the ones that reference
  1195   // _frames_to_pop_failed_realloc frames, the ones that reference
  1190   // failed reallocations.
  1196   // failed reallocations.
  1191   int _frames_to_pop_failed_realloc;
  1197   int _frames_to_pop_failed_realloc;
  1192 
  1198 
  1193 #ifndef PRODUCT
       
  1194   int _jmp_ring_index;
       
  1195   struct {
       
  1196     // We use intptr_t instead of address so debugger doesn't try and display strings
       
  1197     intptr_t _target;
       
  1198     intptr_t _instruction;
       
  1199     const char*  _file;
       
  1200     int _line;
       
  1201   }   _jmp_ring[jump_ring_buffer_size];
       
  1202 #endif // PRODUCT
       
  1203 
       
  1204   friend class VMThread;
  1199   friend class VMThread;
  1205   friend class ThreadWaitTransition;
  1200   friend class ThreadWaitTransition;
  1206   friend class VM_Exit;
  1201   friend class VM_Exit;
  1207 
  1202 
  1208   void initialize();                             // Initialized the instance variables
  1203   void initialize();                             // Initialized the instance variables
  1214   ~JavaThread();
  1209   ~JavaThread();
  1215 
  1210 
  1216 #ifdef ASSERT
  1211 #ifdef ASSERT
  1217   // verify this JavaThread hasn't be published in the Threads::list yet
  1212   // verify this JavaThread hasn't be published in the Threads::list yet
  1218   void verify_not_published();
  1213   void verify_not_published();
  1219 #endif
  1214 #endif // ASSERT
  1220 
  1215 
  1221   //JNI functiontable getter/setter for JVMTI jni function table interception API.
  1216   //JNI functiontable getter/setter for JVMTI jni function table interception API.
  1222   void set_jni_functions(struct JNINativeInterface_* functionTable) {
  1217   void set_jni_functions(struct JNINativeInterface_* functionTable) {
  1223     _jni_environment.functions = functionTable;
  1218     _jni_environment.functions = functionTable;
  1224   }
  1219   }
  1244 
  1239 
  1245   // Testers
  1240   // Testers
  1246   virtual bool is_Java_thread() const            { return true;  }
  1241   virtual bool is_Java_thread() const            { return true;  }
  1247   virtual bool can_call_java() const             { return true; }
  1242   virtual bool can_call_java() const             { return true; }
  1248 
  1243 
       
  1244   virtual bool is_active_Java_thread() const {
       
  1245     return on_thread_list() && !is_terminated();
       
  1246   }
       
  1247 
  1249   // Thread oop. threadObj() can be NULL for initial JavaThread
  1248   // Thread oop. threadObj() can be NULL for initial JavaThread
  1250   // (or for threads attached via JNI)
  1249   // (or for threads attached via JNI)
  1251   oop threadObj() const                          { return _threadObj; }
  1250   oop threadObj() const                          { return _threadObj; }
  1252   void set_threadObj(oop p)                      { _threadObj = p; }
  1251   void set_threadObj(oop p)                      { _threadObj = p; }
  1253 
       
  1254   ThreadPriority java_priority() const;          // Read from threadObj()
       
  1255 
  1252 
  1256   // Prepare thread and add to priority queue.  If a priority is
  1253   // Prepare thread and add to priority queue.  If a priority is
  1257   // not specified, use the priority of the thread object. Threads_lock
  1254   // not specified, use the priority of the thread object. Threads_lock
  1258   // must be held while this function is called.
  1255   // must be held while this function is called.
  1259   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
  1256   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
  1505 
  1502 
  1506   // The special resourceMark used during deoptimization
  1503   // The special resourceMark used during deoptimization
  1507 
  1504 
  1508   void set_deopt_mark(DeoptResourceMark* value)  { _deopt_mark = value; }
  1505   void set_deopt_mark(DeoptResourceMark* value)  { _deopt_mark = value; }
  1509   DeoptResourceMark* deopt_mark(void)            { return _deopt_mark; }
  1506   DeoptResourceMark* deopt_mark(void)            { return _deopt_mark; }
  1510 
       
  1511   intptr_t* must_deopt_id()                      { return _must_deopt_id; }
       
  1512   void     set_must_deopt_id(intptr_t* id)       { _must_deopt_id = id; }
       
  1513   void     clear_must_deopt_id()                 { _must_deopt_id = NULL; }
       
  1514 
  1507 
  1515   void set_deopt_compiled_method(CompiledMethod* nm)  { _deopt_nmethod = nm; }
  1508   void set_deopt_compiled_method(CompiledMethod* nm)  { _deopt_nmethod = nm; }
  1516   CompiledMethod* deopt_compiled_method()        { return _deopt_nmethod; }
  1509   CompiledMethod* deopt_compiled_method()        { return _deopt_nmethod; }
  1517 
  1510 
  1518   Method*    callee_target() const               { return _callee_target; }
  1511   Method*    callee_target() const               { return _callee_target; }
  1737   // Misc. accessors/mutators
  1730   // Misc. accessors/mutators
  1738   void set_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = true; }
  1731   void set_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = true; }
  1739   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
  1732   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
  1740   bool do_not_unlock(void)                       { return _do_not_unlock_if_synchronized; }
  1733   bool do_not_unlock(void)                       { return _do_not_unlock_if_synchronized; }
  1741 
  1734 
  1742 #ifndef PRODUCT
       
  1743   void record_jump(address target, address instr, const char* file, int line);
       
  1744 #endif // PRODUCT
       
  1745 
       
  1746   // For assembly stub generation
  1735   // For assembly stub generation
  1747   static ByteSize threadObj_offset()             { return byte_offset_of(JavaThread, _threadObj); }
  1736   static ByteSize threadObj_offset()             { return byte_offset_of(JavaThread, _threadObj); }
  1748 #ifndef PRODUCT
       
  1749   static ByteSize jmp_ring_index_offset()        { return byte_offset_of(JavaThread, _jmp_ring_index); }
       
  1750   static ByteSize jmp_ring_offset()              { return byte_offset_of(JavaThread, _jmp_ring); }
       
  1751 #endif // PRODUCT
       
  1752   static ByteSize jni_environment_offset()       { return byte_offset_of(JavaThread, _jni_environment); }
  1737   static ByteSize jni_environment_offset()       { return byte_offset_of(JavaThread, _jni_environment); }
  1753   static ByteSize pending_jni_exception_check_fn_offset() {
  1738   static ByteSize pending_jni_exception_check_fn_offset() {
  1754     return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
  1739     return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
  1755   }
  1740   }
  1756   static ByteSize last_Java_sp_offset() {
  1741   static ByteSize last_Java_sp_offset() {
  1787 
  1772 
  1788   static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
  1773   static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); }
  1789   static ByteSize should_post_on_exceptions_flag_offset() {
  1774   static ByteSize should_post_on_exceptions_flag_offset() {
  1790     return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
  1775     return byte_offset_of(JavaThread, _should_post_on_exceptions_flag);
  1791   }
  1776   }
       
  1777   static ByteSize doing_unsafe_access_offset() { return byte_offset_of(JavaThread, _doing_unsafe_access); }
  1792 
  1778 
  1793   // Returns the jni environment for this thread
  1779   // Returns the jni environment for this thread
  1794   JNIEnv* jni_environment()                      { return &_jni_environment; }
  1780   JNIEnv* jni_environment()                      { return &_jni_environment; }
  1795 
  1781 
  1796   static JavaThread* thread_from_jni_environment(JNIEnv* env) {
  1782   static JavaThread* thread_from_jni_environment(JNIEnv* env) {
  1868   // Misc. operations
  1854   // Misc. operations
  1869   char* name() const { return (char*)get_thread_name(); }
  1855   char* name() const { return (char*)get_thread_name(); }
  1870   void print_on(outputStream* st, bool print_extended_info) const;
  1856   void print_on(outputStream* st, bool print_extended_info) const;
  1871   void print_on(outputStream* st) const { print_on(st, false); }
  1857   void print_on(outputStream* st) const { print_on(st, false); }
  1872   void print() const;
  1858   void print() const;
  1873   void print_value();
       
  1874   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
  1859   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
  1875   void print_thread_state() const                      PRODUCT_RETURN;
       
  1876   void print_on_error(outputStream* st, char* buf, int buflen) const;
  1860   void print_on_error(outputStream* st, char* buf, int buflen) const;
  1877   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
  1861   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
  1878   void verify();
  1862   void verify();
  1879   const char* get_thread_name() const;
  1863   const char* get_thread_name() const;
  1880  protected:
  1864  protected:
  1881   // factor out low-level mechanics for use in both normal and error cases
  1865   // factor out low-level mechanics for use in both normal and error cases
  1882   virtual const char* get_thread_name_string(char* buf = NULL, int buflen = 0) const;
  1866   virtual const char* get_thread_name_string(char* buf = NULL, int buflen = 0) const;
  1883  public:
  1867  public:
  1884   const char* get_threadgroup_name() const;
       
  1885   const char* get_parent_name() const;
       
  1886 
       
  1887   // Accessing frames
  1868   // Accessing frames
  1888   frame last_frame() {
  1869   frame last_frame() {
  1889     _anchor.make_walkable(this);
  1870     _anchor.make_walkable(this);
  1890     return pd_last_frame();
  1871     return pd_last_frame();
  1891   }
  1872   }
  1901 
  1882 
  1902   // Print stack traces in various internal formats
  1883   // Print stack traces in various internal formats
  1903   void trace_stack()                             PRODUCT_RETURN;
  1884   void trace_stack()                             PRODUCT_RETURN;
  1904   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
  1885   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
  1905   void trace_frames()                            PRODUCT_RETURN;
  1886   void trace_frames()                            PRODUCT_RETURN;
  1906   void trace_oops()                              PRODUCT_RETURN;
       
  1907 
  1887 
  1908   // Print an annotated view of the stack frames
  1888   // Print an annotated view of the stack frames
  1909   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
  1889   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
  1910   void validate_frame_layout() {
  1890   void validate_frame_layout() {
  1911     print_frame_layout(0, true);
  1891     print_frame_layout(0, true);
  1912   }
  1892   }
  1913 
  1893 
  1914   // Returns the number of stack frames on the stack
       
  1915   int depth() const;
       
  1916 
       
  1917   // Function for testing deoptimization
  1894   // Function for testing deoptimization
  1918   void deoptimize();
  1895   void deoptimize();
  1919   void make_zombies();
  1896   void make_zombies();
  1920 
  1897 
  1921   void deoptimize_marked_methods(bool in_handshake);
  1898   void deoptimize_marked_methods();
  1922 
  1899 
  1923  public:
  1900  public:
  1924   // Returns the running thread as a JavaThread
  1901   // Returns the running thread as a JavaThread
  1925   static inline JavaThread* current();
  1902   static inline JavaThread* current();
  1926 
  1903 
  2055   }
  2032   }
  2056 
  2033 
  2057   // Machine dependent stuff
  2034   // Machine dependent stuff
  2058 #include OS_CPU_HEADER(thread)
  2035 #include OS_CPU_HEADER(thread)
  2059 
  2036 
  2060  public:
       
  2061   void set_blocked_on_compilation(bool value) {
       
  2062     _blocked_on_compilation = value;
       
  2063   }
       
  2064 
       
  2065   bool blocked_on_compilation() {
       
  2066     return _blocked_on_compilation;
       
  2067   }
       
  2068  protected:
       
  2069   bool         _blocked_on_compilation;
       
  2070 
       
  2071 
       
  2072   // JSR166 per-thread parker
  2037   // JSR166 per-thread parker
  2073  private:
  2038  private:
  2074   Parker*    _parker;
  2039   Parker*    _parker;
  2075  public:
  2040  public:
  2076   Parker*     parker() { return _parker; }
  2041   Parker*     parker() { return _parker; }
  2093   void set_class_to_be_initialized(InstanceKlass* k);
  2058   void set_class_to_be_initialized(InstanceKlass* k);
  2094   InstanceKlass* class_to_be_initialized() const;
  2059   InstanceKlass* class_to_be_initialized() const;
  2095 
  2060 
  2096 private:
  2061 private:
  2097   InstanceKlass* _class_to_be_initialized;
  2062   InstanceKlass* _class_to_be_initialized;
       
  2063 
       
  2064   // java.lang.Thread.sleep support
       
  2065   ParkEvent * _SleepEvent;
       
  2066 public:
       
  2067   bool sleep(jlong millis);
       
  2068 
       
  2069   // java.lang.Thread interruption support
       
  2070   void interrupt();
       
  2071   bool is_interrupted(bool clear_interrupted);
  2098 
  2072 
  2099 };
  2073 };
  2100 
  2074 
  2101 // Inline implementation of JavaThread::current
  2075 // Inline implementation of JavaThread::current
  2102 inline JavaThread* JavaThread::current() {
  2076 inline JavaThread* JavaThread::current() {
  2267   // This version may only be called by sequential code.
  2241   // This version may only be called by sequential code.
  2268   static void oops_do(OopClosure* f, CodeBlobClosure* cf);
  2242   static void oops_do(OopClosure* f, CodeBlobClosure* cf);
  2269   // This version may be called by sequential or parallel code.
  2243   // This version may be called by sequential or parallel code.
  2270   static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf);
  2244   static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf);
  2271 
  2245 
  2272   // Apply "f->do_oop" to roots in all threads that
       
  2273   // are part of compiled frames
       
  2274   static void compiled_frame_oops_do(OopClosure* f, CodeBlobClosure* cf);
       
  2275 
       
  2276   static void convert_hcode_pointers();
       
  2277   static void restore_hcode_pointers();
       
  2278 
       
  2279   // Sweeper
  2246   // Sweeper
  2280   static void nmethods_do(CodeBlobClosure* cf);
  2247   static void nmethods_do(CodeBlobClosure* cf);
  2281 
  2248 
  2282   // RedefineClasses support
  2249   // RedefineClasses support
  2283   static void metadata_do(MetadataClosure* f);
  2250   static void metadata_do(MetadataClosure* f);