< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page




  93 class WorkerThread;
  94 
  95 // Class hierarchy
  96 // - Thread
  97 //   - JavaThread
  98 //     - various subclasses eg CompilerThread, ServiceThread
  99 //   - NonJavaThread
 100 //     - NamedThread
 101 //       - VMThread
 102 //       - ConcurrentGCThread
 103 //       - WorkerThread
 104 //         - GangWorker
 105 //         - GCTaskThread
 106 //     - WatcherThread
 107 //     - JfrThreadSampler
 108 //
 109 // All Thread subclasses must be either JavaThread or NonJavaThread.
 110 // This means !t->is_Java_thread() iff t is a NonJavaThread, or t is
 111 // a partially constructed/destroyed Thread.
 112 





















 113 class Thread: public ThreadShadow {
 114   friend class VMStructs;
 115   friend class JVMCIVMStructs;
 116  private:
 117 
 118 #ifndef USE_LIBRARY_BASED_TLS_ONLY
 119   // Current thread is maintained as a thread-local variable
 120   static THREAD_LOCAL_DECL Thread* _thr_current;
 121 #endif
 122 
 123  private:
 124   // Thread local data area available to the GC. The internal
 125   // structure and contents of this data area is GC-specific.
 126   // Only GC and GC barrier code should access this data area.
 127   GCThreadLocalData _gc_data;
 128 
 129  public:
 130   static ByteSize gc_data_offset() {
 131     return byte_offset_of(Thread, _gc_data);
 132   }
 133 
 134   template <typename T> T* gc_data() {
 135     STATIC_ASSERT(sizeof(T) <= sizeof(_gc_data));
 136     return reinterpret_cast<T*>(&_gc_data);
 137   }
 138 
 139   // Exception handling
 140   // (Note: _pending_exception and friends are in ThreadShadow)
 141   //oop       _pending_exception;                // pending exception for current thread
 142   // const char* _exception_file;                   // file information for exception (debugging only)
 143   // int         _exception_line;                   // line information for exception (debugging only)
 144  protected:



 145   // Support for forcing alignment of thread objects for biased locking
 146   void*       _real_malloc_address;
 147 
 148   // JavaThread lifecycle support:
 149   friend class SafeThreadsListPtr;  // for _threads_list_ptr, cmpxchg_threads_hazard_ptr(), {dec_,inc_,}nested_threads_hazard_ptr_cnt(), {g,s}et_threads_hazard_ptr(), inc_nested_handle_cnt(), tag_hazard_ptr() access
 150   friend class ScanHazardPtrGatherProtectedThreadsClosure;  // for cmpxchg_threads_hazard_ptr(), get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
 151   friend class ScanHazardPtrGatherThreadsListClosure;  // for get_threads_hazard_ptr(), untag_hazard_ptr() access
 152   friend class ScanHazardPtrPrintMatchingThreadsClosure;  // for get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
 153   friend class ThreadsSMRSupport;  // for _nested_threads_hazard_ptr_cnt, _threads_hazard_ptr, _threads_list_ptr access
 154 
 155   ThreadsList* volatile _threads_hazard_ptr;
 156   SafeThreadsListPtr*   _threads_list_ptr;
 157   ThreadsList*          cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value);
 158   ThreadsList*          get_threads_hazard_ptr();
 159   void                  set_threads_hazard_ptr(ThreadsList* new_list);
 160   static bool           is_hazard_ptr_tagged(ThreadsList* list) {
 161     return (intptr_t(list) & intptr_t(1)) == intptr_t(1);
 162   }
 163   static ThreadsList*   tag_hazard_ptr(ThreadsList* list) {
 164     return (ThreadsList*)(intptr_t(list) | intptr_t(1));


 401   void set_visited_for_critical_count(bool z) { _visited_for_critical_count = z; }
 402   bool was_visited_for_critical_count() const   { return _visited_for_critical_count; }
 403 #endif
 404 
 405  public:
 406   enum {
 407     is_definitely_current_thread = true
 408   };
 409 
 410   // Constructor
 411   Thread();
 412   virtual ~Thread() = 0;        // Thread is abstract.
 413 
 414   // Manage Thread::current()
 415   void initialize_thread_current();
 416   static void clear_thread_current(); // TLS cleanup needed before threads terminate
 417 
 418  protected:
 419   // To be implemented by children.
 420   virtual void run() = 0;















 421 
 422  public:
 423   // invokes <ChildThreadClass>::run(), with common preparations and cleanups.
 424   void call_run();
 425 
 426   // Testers
 427   virtual bool is_VM_thread()       const            { return false; }
 428   virtual bool is_Java_thread()     const            { return false; }
 429   virtual bool is_Compiler_thread() const            { return false; }
 430   virtual bool is_Code_cache_sweeper_thread() const  { return false; }
 431   virtual bool is_hidden_from_external_view() const  { return false; }
 432   virtual bool is_jvmti_agent_thread() const         { return false; }
 433   // True iff the thread can perform GC operations at a safepoint.
 434   // Generally will be true only of VM thread and parallel GC WorkGang
 435   // threads.
 436   virtual bool is_GC_task_thread() const             { return false; }
 437   virtual bool is_Watcher_thread() const             { return false; }
 438   virtual bool is_ConcurrentGC_thread() const        { return false; }
 439   virtual bool is_Named_thread() const               { return false; }
 440   virtual bool is_Worker_thread() const              { return false; }


 779   }
 780   return NULL;
 781 #endif
 782 }
 783 
 784 inline Thread* Thread::current_or_null_safe() {
 785   if (ThreadLocalStorage::is_initialized()) {
 786     return ThreadLocalStorage::thread();
 787   }
 788   return NULL;
 789 }
 790 
 791 class NonJavaThread: public Thread {
 792   friend class VMStructs;
 793 
 794   NonJavaThread* volatile _next;
 795 
 796   class List;
 797   static List _the_list;
 798 







 799  public:
 800   NonJavaThread();
 801   ~NonJavaThread();
 802 
 803   class Iterator;
 804 };
 805 
 806 // Provides iteration over the list of NonJavaThreads.  Because list
 807 // management occurs in the NonJavaThread constructor and destructor,
 808 // entries in the list may not be fully constructed instances of a
 809 // derived class.  Threads created after an iterator is constructed
 810 // will not be visited by the iterator.  The scope of an iterator is a
 811 // critical section; there must be no safepoint checks in that scope.
 812 class NonJavaThread::Iterator : public StackObj {
 813   uint _protect_enter;
 814   NonJavaThread* _current;
 815 
 816   // Noncopyable.
 817   Iterator(const Iterator&);
 818   Iterator& operator=(const Iterator&);
 819 
 820 public:
 821   Iterator();
 822   ~Iterator();
 823 
 824   bool end() const { return _current == NULL; }
 825   NonJavaThread* current() const { return _current; }
 826   void step();
 827 };
 828 
 829 // Name support for threads.  non-JavaThread subclasses with multiple
 830 // uniquely named instances should derive from this.
 831 class NamedThread: public NonJavaThread {
 832   friend class VMStructs;
 833   enum {
 834     max_name_len = 64
 835   };
 836  private:
 837   char* _name;
 838   // log JavaThread being processed by oops_do
 839   JavaThread* _processed_thread;
 840   uint _gc_id; // The current GC id when a thread takes part in GC
 841 
 842  public:
 843   NamedThread();
 844   ~NamedThread();
 845   // May only be called once per thread.
 846   void set_name(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3);
 847   void initialize_named_thread();
 848   virtual bool is_Named_thread() const { return true; }
 849   virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; }
 850   JavaThread *processed_thread() { return _processed_thread; }
 851   void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
 852   virtual void print_on(outputStream* st) const;
 853 
 854   void set_gc_id(uint gc_id) { _gc_id = gc_id; }
 855   uint gc_id() { return _gc_id; }
 856 };
 857 
 858 // Worker threads are named and have an id of an assigned work.
 859 class WorkerThread: public NamedThread {
 860  private:
 861   uint _id;
 862  public:
 863   WorkerThread() : _id(0)               { }
 864   virtual bool is_Worker_thread() const { return true; }
 865 
 866   virtual WorkerThread* as_Worker_thread() const {
 867     assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
 868     return (WorkerThread*) this;
 869   }
 870 
 871   void set_id(uint work_id)             { _id = work_id; }
 872   uint id() const                       { return _id; }
 873 };
 874 
 875 // A single WatcherThread is used for simulating timer interrupts.
 876 class WatcherThread: public NonJavaThread {
 877   friend class VMStructs;
 878  public:
 879   virtual void run();
 880 
 881  private:
 882   static WatcherThread* _watcher_thread;
 883 
 884   static bool _startable;
 885   // volatile due to at least one lock-free read
 886   volatile static bool _should_terminate;
 887  public:
 888   enum SomeConstants {
 889     delay_interval = 10                          // interrupt delay in milliseconds
 890   };
 891 
 892   // Constructor
 893   WatcherThread();
 894 
 895   // No destruction allowed
 896   ~WatcherThread() {
 897     guarantee(false, "WatcherThread deletion must fix the race with VM termination");
 898   }


1815   // Memory operations
1816   void oops_do(OopClosure* f, CodeBlobClosure* cf);
1817 
1818   // Sweeper operations
1819   virtual void nmethods_do(CodeBlobClosure* cf);
1820 
1821   // RedefineClasses Support
1822   void metadata_do(void f(Metadata*));
1823 
1824   // Misc. operations
1825   char* name() const { return (char*)get_thread_name(); }
1826   void print_on(outputStream* st, bool print_extended_info) const;
1827   void print_on(outputStream* st) const { print_on(st, false); }
1828   void print_value();
1829   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
1830   void print_thread_state() const                      PRODUCT_RETURN;
1831   void print_on_error(outputStream* st, char* buf, int buflen) const;
1832   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
1833   void verify();
1834   const char* get_thread_name() const;
1835  private:
1836   // factor out low-level mechanics for use in both normal and error cases
1837   const char* get_thread_name_string(char* buf = NULL, int buflen = 0) const;
1838  public:
1839   const char* get_threadgroup_name() const;
1840   const char* get_parent_name() const;
1841 
1842   // Accessing frames
1843   frame last_frame() {
1844     _anchor.make_walkable(this);
1845     return pd_last_frame();
1846   }
1847   javaVFrame* last_java_vframe(RegisterMap* reg_map);
1848 
1849   // Returns method at 'depth' java or native frames down the stack
1850   // Used for security checks
1851   Klass* security_get_caller_class(int depth);
1852 
1853   // Print stack trace in external format
1854   void print_stack_on(outputStream* st);
1855   void print_stack() { print_stack_on(tty); }
1856 
1857   // Print stack traces in various internal formats


1870   int depth() const;
1871 
1872   // Function for testing deoptimization
1873   void deoptimize();
1874   void make_zombies();
1875 
1876   void deoptimized_wrt_marked_nmethods();
1877 
1878  public:
1879   // Returns the running thread as a JavaThread
1880   static inline JavaThread* current();
1881 
1882   // Returns the active Java thread.  Do not use this if you know you are calling
1883   // from a JavaThread, as it's slower than JavaThread::current.  If called from
1884   // the VMThread, it also returns the JavaThread that instigated the VMThread's
1885   // operation.  You may not want that either.
1886   static JavaThread* active();
1887 
1888   inline CompilerThread* as_CompilerThread();
1889 
1890  public:

1891   virtual void run();
1892   void thread_main_inner();


1893 
1894  private:
1895   GrowableArray<oop>* _array_for_gc;
1896  public:
1897 
1898   void register_array_for_gc(GrowableArray<oop>* array) { _array_for_gc = array; }
1899 
1900  public:
1901   // Thread local information maintained by JVMTI.
1902   void set_jvmti_thread_state(JvmtiThreadState *value)                           { _jvmti_thread_state = value; }
1903   // A JvmtiThreadState is lazily allocated. This jvmti_thread_state()
1904   // getter is used to get this JavaThread's JvmtiThreadState if it has
1905   // one which means NULL can be returned. JvmtiThreadState::state_for()
1906   // is used to get the specified JavaThread's JvmtiThreadState if it has
1907   // one or it allocates a new JvmtiThreadState for the JavaThread and
1908   // returns it. JvmtiThreadState::state_for() will return NULL only if
1909   // the specified JavaThread is exiting.
1910   JvmtiThreadState *jvmti_thread_state() const                                   { return _jvmti_thread_state; }
1911   static ByteSize jvmti_thread_state_offset()                                    { return byte_offset_of(JavaThread, _jvmti_thread_state); }
1912 




  93 class WorkerThread;
  94 
  95 // Class hierarchy
  96 // - Thread
  97 //   - JavaThread
  98 //     - various subclasses eg CompilerThread, ServiceThread
  99 //   - NonJavaThread
 100 //     - NamedThread
 101 //       - VMThread
 102 //       - ConcurrentGCThread
 103 //       - WorkerThread
 104 //         - GangWorker
 105 //         - GCTaskThread
 106 //     - WatcherThread
 107 //     - JfrThreadSampler
 108 //
 109 // All Thread subclasses must be either JavaThread or NonJavaThread.
 110 // This means !t->is_Java_thread() iff t is a NonJavaThread, or t is
 111 // a partially constructed/destroyed Thread.
 112 
 113 // Thread execution sequence and actions:
 114 // All threads:
 115 //  - thread_native_entry  // per-OS native entry point
 116 //    - stack initialization
 117 //    - other OS-level initialization (signal masks etc)
 118 //    - handshake with creating thread (if not started suspended)
 119 //    - this->call_run()  // common shared entry point
 120 //      - shared common initialization
 121 //      - this->pre_run()  // virtual per-thread-type initialization
 122 //      - this->run()      // virtual per-thread-type "main" logic
 123 //      - shared common tear-down
 124 //      - this->post_run()  // virtual per-thread-type tear-down
 125 //      - // 'this' no longer referenceable
 126 //    - OS-level tear-down (minimal)
 127 //    - final logging
 128 //
 129 // For JavaThread:
 130 //   - this->run()  // virtual but not normally overridden
 131 //     - this->thread_main_inner()  // extra call level to ensure correct stack calculations
 132 //       - this->entry_point()  // set differently for each kind of JavaThread
 133 
 134 class Thread: public ThreadShadow {
 135   friend class VMStructs;
 136   friend class JVMCIVMStructs;
 137  private:
 138 
 139 #ifndef USE_LIBRARY_BASED_TLS_ONLY
 140   // Current thread is maintained as a thread-local variable
 141   static THREAD_LOCAL_DECL Thread* _thr_current;
 142 #endif
 143 

 144   // Thread local data area available to the GC. The internal
 145   // structure and contents of this data area is GC-specific.
 146   // Only GC and GC barrier code should access this data area.
 147   GCThreadLocalData _gc_data;
 148 
 149  public:
 150   static ByteSize gc_data_offset() {
 151     return byte_offset_of(Thread, _gc_data);
 152   }
 153 
 154   template <typename T> T* gc_data() {
 155     STATIC_ASSERT(sizeof(T) <= sizeof(_gc_data));
 156     return reinterpret_cast<T*>(&_gc_data);
 157   }
 158 
 159   // Exception handling
 160   // (Note: _pending_exception and friends are in ThreadShadow)
 161   //oop       _pending_exception;                // pending exception for current thread
 162   // const char* _exception_file;                   // file information for exception (debugging only)
 163   // int         _exception_line;                   // line information for exception (debugging only)
 164  protected:
 165 
 166   DEBUG_ONLY(static Thread* _starting_thread;)
 167 
 168   // Support for forcing alignment of thread objects for biased locking
 169   void*       _real_malloc_address;
 170 
 171   // JavaThread lifecycle support:
 172   friend class SafeThreadsListPtr;  // for _threads_list_ptr, cmpxchg_threads_hazard_ptr(), {dec_,inc_,}nested_threads_hazard_ptr_cnt(), {g,s}et_threads_hazard_ptr(), inc_nested_handle_cnt(), tag_hazard_ptr() access
 173   friend class ScanHazardPtrGatherProtectedThreadsClosure;  // for cmpxchg_threads_hazard_ptr(), get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
 174   friend class ScanHazardPtrGatherThreadsListClosure;  // for get_threads_hazard_ptr(), untag_hazard_ptr() access
 175   friend class ScanHazardPtrPrintMatchingThreadsClosure;  // for get_threads_hazard_ptr(), is_hazard_ptr_tagged() access
 176   friend class ThreadsSMRSupport;  // for _nested_threads_hazard_ptr_cnt, _threads_hazard_ptr, _threads_list_ptr access
 177 
 178   ThreadsList* volatile _threads_hazard_ptr;
 179   SafeThreadsListPtr*   _threads_list_ptr;
 180   ThreadsList*          cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value);
 181   ThreadsList*          get_threads_hazard_ptr();
 182   void                  set_threads_hazard_ptr(ThreadsList* new_list);
 183   static bool           is_hazard_ptr_tagged(ThreadsList* list) {
 184     return (intptr_t(list) & intptr_t(1)) == intptr_t(1);
 185   }
 186   static ThreadsList*   tag_hazard_ptr(ThreadsList* list) {
 187     return (ThreadsList*)(intptr_t(list) | intptr_t(1));


 424   void set_visited_for_critical_count(bool z) { _visited_for_critical_count = z; }
 425   bool was_visited_for_critical_count() const   { return _visited_for_critical_count; }
 426 #endif
 427 
 428  public:
 429   enum {
 430     is_definitely_current_thread = true
 431   };
 432 
 433   // Constructor
 434   Thread();
 435   virtual ~Thread() = 0;        // Thread is abstract.
 436 
 437   // Manage Thread::current()
 438   void initialize_thread_current();
 439   static void clear_thread_current(); // TLS cleanup needed before threads terminate
 440 
 441  protected:
 442   // To be implemented by children.
 443   virtual void run() = 0;
 444   virtual void pre_run() = 0;
 445   virtual void post_run() = 0;  // Note: Thread must not be deleted prior to calling this!
 446 
 447 #ifdef ASSERT
 448   enum RunState {
 449     PRE_CALL_RUN,
 450     CALL_RUN,
 451     PRE_RUN,
 452     RUN,
 453     POST_RUN
 454     // POST_CALL_RUN - can't define this one as 'this' may be deleted when we want to set it
 455   };
 456   RunState _run_state;  // for lifecycle checks
 457 #endif
 458 
 459 
 460  public:
 461   // invokes <ChildThreadClass>::run(), with common preparations and cleanups.
 462   void call_run();
 463 
 464   // Testers
 465   virtual bool is_VM_thread()       const            { return false; }
 466   virtual bool is_Java_thread()     const            { return false; }
 467   virtual bool is_Compiler_thread() const            { return false; }
 468   virtual bool is_Code_cache_sweeper_thread() const  { return false; }
 469   virtual bool is_hidden_from_external_view() const  { return false; }
 470   virtual bool is_jvmti_agent_thread() const         { return false; }
 471   // True iff the thread can perform GC operations at a safepoint.
 472   // Generally will be true only of VM thread and parallel GC WorkGang
 473   // threads.
 474   virtual bool is_GC_task_thread() const             { return false; }
 475   virtual bool is_Watcher_thread() const             { return false; }
 476   virtual bool is_ConcurrentGC_thread() const        { return false; }
 477   virtual bool is_Named_thread() const               { return false; }
 478   virtual bool is_Worker_thread() const              { return false; }


 817   }
 818   return NULL;
 819 #endif
 820 }
 821 
 822 inline Thread* Thread::current_or_null_safe() {
 823   if (ThreadLocalStorage::is_initialized()) {
 824     return ThreadLocalStorage::thread();
 825   }
 826   return NULL;
 827 }
 828 
 829 class NonJavaThread: public Thread {
 830   friend class VMStructs;
 831 
 832   NonJavaThread* volatile _next;
 833 
 834   class List;
 835   static List _the_list;
 836 
 837   void add_to_the_list();
 838   void remove_from_the_list();
 839 
 840  protected:
 841   virtual void pre_run();
 842   virtual void post_run();
 843 
 844  public:
 845   NonJavaThread();
 846   ~NonJavaThread();
 847 
 848   class Iterator;
 849 };
 850 
 851 // Provides iteration over the list of NonJavaThreads.
 852 // List addition occurs in pre_run(), and removal occurs in post_run(),
 853 // so that only live fully-initialized threads can be found in the list.
 854 // Threads created after an iterator is constructed will not be visited
 855 // by the iterator. The scope of an iterator is a critical section; there
 856 // must be no safepoint checks in that scope.
 857 class NonJavaThread::Iterator : public StackObj {
 858   uint _protect_enter;
 859   NonJavaThread* _current;
 860 
 861   // Noncopyable.
 862   Iterator(const Iterator&);
 863   Iterator& operator=(const Iterator&);
 864 
 865 public:
 866   Iterator();
 867   ~Iterator();
 868 
 869   bool end() const { return _current == NULL; }
 870   NonJavaThread* current() const { return _current; }
 871   void step();
 872 };
 873 
 874 // Name support for threads.  non-JavaThread subclasses with multiple
 875 // uniquely named instances should derive from this.
 876 class NamedThread: public NonJavaThread {
 877   friend class VMStructs;
 878   enum {
 879     max_name_len = 64
 880   };
 881  private:
 882   char* _name;
 883   // log JavaThread being processed by oops_do
 884   JavaThread* _processed_thread;
 885   uint _gc_id; // The current GC id when a thread takes part in GC
 886 
 887  public:
 888   NamedThread();
 889   ~NamedThread();
 890   // May only be called once per thread.
 891   void set_name(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3);

 892   virtual bool is_Named_thread() const { return true; }
 893   virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; }
 894   JavaThread *processed_thread() { return _processed_thread; }
 895   void set_processed_thread(JavaThread *thread) { _processed_thread = thread; }
 896   virtual void print_on(outputStream* st) const;
 897 
 898   void set_gc_id(uint gc_id) { _gc_id = gc_id; }
 899   uint gc_id() { return _gc_id; }
 900 };
 901 
 902 // Worker threads are named and have an id of an assigned work.
 903 class WorkerThread: public NamedThread {
 904  private:
 905   uint _id;
 906  public:
 907   WorkerThread() : _id(0)               { }
 908   virtual bool is_Worker_thread() const { return true; }
 909 
 910   virtual WorkerThread* as_Worker_thread() const {
 911     assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
 912     return (WorkerThread*) this;
 913   }
 914 
 915   void set_id(uint work_id)             { _id = work_id; }
 916   uint id() const                       { return _id; }
 917 };
 918 
 919 // A single WatcherThread is used for simulating timer interrupts.
 920 class WatcherThread: public NonJavaThread {
 921   friend class VMStructs;
 922  protected:
 923   virtual void run();
 924 
 925  private:
 926   static WatcherThread* _watcher_thread;
 927 
 928   static bool _startable;
 929   // volatile due to at least one lock-free read
 930   volatile static bool _should_terminate;
 931  public:
 932   enum SomeConstants {
 933     delay_interval = 10                          // interrupt delay in milliseconds
 934   };
 935 
 936   // Constructor
 937   WatcherThread();
 938 
 939   // No destruction allowed
 940   ~WatcherThread() {
 941     guarantee(false, "WatcherThread deletion must fix the race with VM termination");
 942   }


1859   // Memory operations
1860   void oops_do(OopClosure* f, CodeBlobClosure* cf);
1861 
1862   // Sweeper operations
1863   virtual void nmethods_do(CodeBlobClosure* cf);
1864 
1865   // RedefineClasses Support
1866   void metadata_do(void f(Metadata*));
1867 
1868   // Misc. operations
1869   char* name() const { return (char*)get_thread_name(); }
1870   void print_on(outputStream* st, bool print_extended_info) const;
1871   void print_on(outputStream* st) const { print_on(st, false); }
1872   void print_value();
1873   void print_thread_state_on(outputStream*) const      PRODUCT_RETURN;
1874   void print_thread_state() const                      PRODUCT_RETURN;
1875   void print_on_error(outputStream* st, char* buf, int buflen) const;
1876   void print_name_on_error(outputStream* st, char* buf, int buflen) const;
1877   void verify();
1878   const char* get_thread_name() const;
1879  protected:
1880   // factor out low-level mechanics for use in both normal and error cases
1881   virtual const char* get_thread_name_string(char* buf = NULL, int buflen = 0) const;
1882  public:
1883   const char* get_threadgroup_name() const;
1884   const char* get_parent_name() const;
1885 
1886   // Accessing frames
1887   frame last_frame() {
1888     _anchor.make_walkable(this);
1889     return pd_last_frame();
1890   }
1891   javaVFrame* last_java_vframe(RegisterMap* reg_map);
1892 
1893   // Returns method at 'depth' java or native frames down the stack
1894   // Used for security checks
1895   Klass* security_get_caller_class(int depth);
1896 
1897   // Print stack trace in external format
1898   void print_stack_on(outputStream* st);
1899   void print_stack() { print_stack_on(tty); }
1900 
1901   // Print stack traces in various internal formats


1914   int depth() const;
1915 
1916   // Function for testing deoptimization
1917   void deoptimize();
1918   void make_zombies();
1919 
1920   void deoptimized_wrt_marked_nmethods();
1921 
1922  public:
1923   // Returns the running thread as a JavaThread
1924   static inline JavaThread* current();
1925 
1926   // Returns the active Java thread.  Do not use this if you know you are calling
1927   // from a JavaThread, as it's slower than JavaThread::current.  If called from
1928   // the VMThread, it also returns the JavaThread that instigated the VMThread's
1929   // operation.  You may not want that either.
1930   static JavaThread* active();
1931 
1932   inline CompilerThread* as_CompilerThread();
1933 
1934  protected:
1935   virtual void pre_run();
1936   virtual void run();
1937   void thread_main_inner();
1938   virtual void post_run();
1939 
1940 
1941  private:
1942   GrowableArray<oop>* _array_for_gc;
1943  public:
1944 
1945   void register_array_for_gc(GrowableArray<oop>* array) { _array_for_gc = array; }
1946 
1947  public:
1948   // Thread local information maintained by JVMTI.
1949   void set_jvmti_thread_state(JvmtiThreadState *value)                           { _jvmti_thread_state = value; }
1950   // A JvmtiThreadState is lazily allocated. This jvmti_thread_state()
1951   // getter is used to get this JavaThread's JvmtiThreadState if it has
1952   // one which means NULL can be returned. JvmtiThreadState::state_for()
1953   // is used to get the specified JavaThread's JvmtiThreadState if it has
1954   // one or it allocates a new JvmtiThreadState for the JavaThread and
1955   // returns it. JvmtiThreadState::state_for() will return NULL only if
1956   // the specified JavaThread is exiting.
1957   JvmtiThreadState *jvmti_thread_state() const                                   { return _jvmti_thread_state; }
1958   static ByteSize jvmti_thread_state_offset()                                    { return byte_offset_of(JavaThread, _jvmti_thread_state); }
1959 


< prev index next >