src/share/vm/runtime/thread.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/thread.hpp

Print this page




 288 
 289  public:
 290   enum {
 291     is_definitely_current_thread = true
 292   };
 293 
 294   // Constructor
 295   Thread();
 296   virtual ~Thread();
 297 
 298   // initializtion
 299   void initialize_thread_local_storage();
 300 
 301   // thread entry point
 302   virtual void run();
 303 
 304   // Testers
 305   virtual bool is_VM_thread()       const            { return false; }
 306   virtual bool is_Java_thread()     const            { return false; }
 307   virtual bool is_Compiler_thread() const            { return false; }

 308   virtual bool is_hidden_from_external_view() const  { return false; }
 309   virtual bool is_jvmti_agent_thread() const         { return false; }
 310   // True iff the thread can perform GC operations at a safepoint.
 311   // Generally will be true only of VM thread and parallel GC WorkGang
 312   // threads.
 313   virtual bool is_GC_task_thread() const             { return false; }
 314   virtual bool is_Watcher_thread() const             { return false; }
 315   virtual bool is_ConcurrentGC_thread() const        { return false; }
 316   virtual bool is_Named_thread() const               { return false; }
 317   virtual bool is_Worker_thread() const              { return false; }
 318 
 319   // Casts
 320   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
 321 
 322   virtual char* name() const { return (char*)"Unknown thread"; }
 323 
 324   // Returns the current thread
 325   static inline Thread* current();
 326 
 327   // Common thread operations


1729   // a par_id: it is UINT_MAX if the thread has not claimed a par_id;
1730   // otherwise its value is the par_id that has been claimed.
1731   uint _claimed_par_id;
1732  public:
1733   uint get_claimed_par_id() { return _claimed_par_id; }
1734   void set_claimed_par_id(uint id) { _claimed_par_id = id; }
1735 };
1736 
1737 // Inline implementation of JavaThread::current
1738 inline JavaThread* JavaThread::current() {
1739   Thread* thread = ThreadLocalStorage::thread();
1740   assert(thread != NULL && thread->is_Java_thread(), "just checking");
1741   return (JavaThread*)thread;
1742 }
1743 
1744 inline CompilerThread* JavaThread::as_CompilerThread() {
1745   assert(is_Compiler_thread(), "just checking");
1746   return (CompilerThread*)this;
1747 }
1748 


















1749 // A thread used for Compilation.
1750 class CompilerThread : public JavaThread {
1751   friend class VMStructs;
1752  private:
1753   CompilerCounters* _counters;
1754 
1755   ciEnv*            _env;
1756   CompileLog*       _log;
1757   CompileTask*      _task;
1758   CompileQueue*     _queue;
1759   BufferBlob*       _buffer_blob;
1760 
1761   nmethod*          _scanned_nmethod;  // nmethod being scanned by the sweeper
1762   AbstractCompiler* _compiler;
1763 
1764  public:
1765 
1766   static CompilerThread* current();
1767 
1768   CompilerThread(CompileQueue* queue, CompilerCounters* counters);
1769 
1770   bool is_Compiler_thread() const                { return true; }
1771   // Hide this compiler thread from external view.
1772   bool is_hidden_from_external_view() const      { return true; }
1773 
1774   void set_compiler(AbstractCompiler* c)         { _compiler = c; }
1775   AbstractCompiler* compiler() const             { return _compiler; }
1776 
1777   CompileQueue* queue()        const             { return _queue; }
1778   CompilerCounters* counters() const             { return _counters; }
1779 
1780   // Get/set the thread's compilation environment.
1781   ciEnv*        env()                            { return _env; }
1782   void          set_env(ciEnv* env)              { _env = env; }
1783 
1784   BufferBlob*   get_buffer_blob() const          { return _buffer_blob; }
1785   void          set_buffer_blob(BufferBlob* b)   { _buffer_blob = b; }
1786 
1787   // Get/set the thread's logging information
1788   CompileLog*   log()                            { return _log; }
1789   void          init_log(CompileLog* log) {
1790     // Set once, for good.
1791     assert(_log == NULL, "set only once");
1792     _log = log;
1793   }
1794 
1795   // GC support
1796   // Apply "f->do_oop" to all root oops in "this".
1797   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
1798   void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
1799 
1800 #ifndef PRODUCT
1801  private:
1802   IdealGraphPrinter *_ideal_graph_printer;
1803  public:
1804   IdealGraphPrinter *ideal_graph_printer()                       { return _ideal_graph_printer; }
1805   void set_ideal_graph_printer(IdealGraphPrinter *n)             { _ideal_graph_printer = n; }
1806 #endif
1807 
1808   // Get/set the thread's current task
1809   CompileTask*  task()                           { return _task; }
1810   void          set_task(CompileTask* task)      { _task = task; }
1811 
1812   // Track the nmethod currently being scanned by the sweeper
1813   void          set_scanned_nmethod(nmethod* nm) {
1814     assert(_scanned_nmethod == NULL || nm == NULL, "should reset to NULL before writing a new value");
1815     _scanned_nmethod = nm;
1816   }
1817 };
1818 
1819 inline CompilerThread* CompilerThread::current() {
1820   return JavaThread::current()->as_CompilerThread();
1821 }
1822 
1823 // The active thread queue. It also keeps track of the current used
1824 // thread priorities.
1825 class Threads: AllStatic {
1826   friend class VMStructs;
1827  private:
1828   static JavaThread* _thread_list;
1829   static int         _number_of_threads;
1830   static int         _number_of_non_daemon_threads;
1831   static int         _return_code;
1832 #ifdef ASSERT
1833   static bool        _vm_complete;
1834 #endif
1835 
1836   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);




 288 
 289  public:
 290   enum {
 291     is_definitely_current_thread = true
 292   };
 293 
 294   // Constructor
 295   Thread();
 296   virtual ~Thread();
 297 
 298   // initializtion
 299   void initialize_thread_local_storage();
 300 
 301   // thread entry point
 302   virtual void run();
 303 
 304   // Testers
 305   virtual bool is_VM_thread()       const            { return false; }
 306   virtual bool is_Java_thread()     const            { return false; }
 307   virtual bool is_Compiler_thread() const            { return false; }
 308   virtual bool is_Code_cache_sweeper_thread() const  { return false; }
 309   virtual bool is_hidden_from_external_view() const  { return false; }
 310   virtual bool is_jvmti_agent_thread() const         { return false; }
 311   // True iff the thread can perform GC operations at a safepoint.
 312   // Generally will be true only of VM thread and parallel GC WorkGang
 313   // threads.
 314   virtual bool is_GC_task_thread() const             { return false; }
 315   virtual bool is_Watcher_thread() const             { return false; }
 316   virtual bool is_ConcurrentGC_thread() const        { return false; }
 317   virtual bool is_Named_thread() const               { return false; }
 318   virtual bool is_Worker_thread() const              { return false; }
 319 
 320   // Casts
 321   virtual WorkerThread* as_Worker_thread() const     { return NULL; }
 322 
 323   virtual char* name() const { return (char*)"Unknown thread"; }
 324 
 325   // Returns the current thread
 326   static inline Thread* current();
 327 
 328   // Common thread operations


1730   // a par_id: it is UINT_MAX if the thread has not claimed a par_id;
1731   // otherwise its value is the par_id that has been claimed.
1732   uint _claimed_par_id;
1733  public:
1734   uint get_claimed_par_id() { return _claimed_par_id; }
1735   void set_claimed_par_id(uint id) { _claimed_par_id = id; }
1736 };
1737 
1738 // Inline implementation of JavaThread::current
1739 inline JavaThread* JavaThread::current() {
1740   Thread* thread = ThreadLocalStorage::thread();
1741   assert(thread != NULL && thread->is_Java_thread(), "just checking");
1742   return (JavaThread*)thread;
1743 }
1744 
1745 inline CompilerThread* JavaThread::as_CompilerThread() {
1746   assert(is_Compiler_thread(), "just checking");
1747   return (CompilerThread*)this;
1748 }
1749 
1750 // Dedicated thread to sweep the code cache
1751 class CodeCacheSweeperThread : public JavaThread {
1752   nmethod*       _scanned_nmethod; // nmethod being scanned by the sweeper
1753  public:
1754   CodeCacheSweeperThread();
1755   // Track the nmethod currently being scanned by the sweeper
1756   void set_scanned_nmethod(nmethod* nm) {
1757     assert(_scanned_nmethod == NULL || nm == NULL, "should reset to NULL before writing a new value");
1758     _scanned_nmethod = nm;
1759   }
1760 
1761   bool is_Code_cache_sweeper_thread() const { return true; }
1762   // GC support
1763   // Apply "f->do_oop" to all root oops in "this".
1764   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
1765   void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
1766 };
1767 
1768 // A thread used for Compilation.
1769 class CompilerThread : public JavaThread {
1770   friend class VMStructs;
1771  private:
1772   CompilerCounters* _counters;
1773 
1774   ciEnv*            _env;
1775   CompileLog*       _log;
1776   CompileTask*      _task;
1777   CompileQueue*     _queue;
1778   BufferBlob*       _buffer_blob;
1779 

1780   AbstractCompiler* _compiler;
1781 
1782  public:
1783 
1784   static CompilerThread* current();
1785 
1786   CompilerThread(CompileQueue* queue, CompilerCounters* counters);
1787 
1788   bool is_Compiler_thread() const                { return true; }
1789   // Hide this compiler thread from external view.
1790   bool is_hidden_from_external_view() const      { return true; }
1791 
1792   void set_compiler(AbstractCompiler* c)         { _compiler = c; }
1793   AbstractCompiler* compiler() const             { return _compiler; }
1794 
1795   CompileQueue* queue()        const             { return _queue; }
1796   CompilerCounters* counters() const             { return _counters; }
1797 
1798   // Get/set the thread's compilation environment.
1799   ciEnv*        env()                            { return _env; }
1800   void          set_env(ciEnv* env)              { _env = env; }
1801 
1802   BufferBlob*   get_buffer_blob() const          { return _buffer_blob; }
1803   void          set_buffer_blob(BufferBlob* b)   { _buffer_blob = b; }
1804 
1805   // Get/set the thread's logging information
1806   CompileLog*   log()                            { return _log; }
1807   void          init_log(CompileLog* log) {
1808     // Set once, for good.
1809     assert(_log == NULL, "set only once");
1810     _log = log;
1811   }
1812 





1813 #ifndef PRODUCT
1814  private:
1815   IdealGraphPrinter *_ideal_graph_printer;
1816  public:
1817   IdealGraphPrinter *ideal_graph_printer()           { return _ideal_graph_printer; }
1818   void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
1819 #endif
1820 
1821   // Get/set the thread's current task
1822   CompileTask* task()                      { return _task; }
1823   void         set_task(CompileTask* task) { _task = task; }






1824 };
1825 
1826 inline CompilerThread* CompilerThread::current() {
1827   return JavaThread::current()->as_CompilerThread();
1828 }
1829 
1830 // The active thread queue. It also keeps track of the current used
1831 // thread priorities.
1832 class Threads: AllStatic {
1833   friend class VMStructs;
1834  private:
1835   static JavaThread* _thread_list;
1836   static int         _number_of_threads;
1837   static int         _number_of_non_daemon_threads;
1838   static int         _return_code;
1839 #ifdef ASSERT
1840   static bool        _vm_complete;
1841 #endif
1842 
1843   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);


src/share/vm/runtime/thread.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File