src/share/vm/runtime/thread.hpp

Print this page




 906  public:
 907   // State of the stack guard pages for this thread.
 908   enum StackGuardState {
 909     stack_guard_unused,         // not needed
 910     stack_guard_yellow_disabled,// disabled (temporarily) after stack overflow
 911     stack_guard_enabled         // enabled
 912   };
 913 
 914  private:
 915 
 916   StackGuardState        _stack_guard_state;
 917 
 918   // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
 919   // used to temp. parsing values into and out of the runtime system during exception handling for compiled
 920   // code)
 921   volatile oop     _exception_oop;               // Exception thrown in compiled code
 922   volatile address _exception_pc;                // PC where exception happened
 923   volatile address _exception_handler_pc;        // PC for handler of exception
 924   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 925 
 926   // support for compilation
 927   bool    _is_compiling;                         // is true if a compilation is active inthis thread (one compilation per thread possible)
 928 
 929   // support for JNI critical regions
 930   jint    _jni_active_critical;                  // count of entries into JNI critical region
 931 
 932   // For deadlock detection.
 933   int _depth_first_number;
 934 
 935   // JVMTI PopFrame support
 936   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 937   int _popframe_condition;
 938 
 939 #ifndef PRODUCT
 940   int _jmp_ring_index;
 941   struct {
 942       // We use intptr_t instead of address so debugger doesn't try and display strings
 943       intptr_t _target;
 944       intptr_t _instruction;
 945       const char*  _file;
 946       int _line;
 947   }   _jmp_ring[ jump_ring_buffer_size ];
 948 #endif /* PRODUCT */


 988 
 989   // This function is called at thread creation to allow
 990   // platform specific thread variables to be initialized.
 991   void cache_global_variables();
 992 
 993   // Executes Shutdown.shutdown()
 994   void invoke_shutdown_hooks();
 995 
 996   // Cleanup on thread exit
 997   enum ExitType {
 998     normal_exit,
 999     jni_detach
1000   };
1001   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
1002 
1003   void cleanup_failed_attach_current_thread();
1004 
1005   // Testers
1006   virtual bool is_Java_thread() const            { return true;  }
1007 
1008   // compilation
1009   void set_is_compiling(bool f)                  { _is_compiling = f; }
1010   bool is_compiling() const                      { return _is_compiling; }
1011 
1012   // Thread chain operations
1013   JavaThread* next() const                       { return _next; }
1014   void set_next(JavaThread* p)                   { _next = p; }
1015 
1016   // Thread oop. threadObj() can be NULL for initial JavaThread
1017   // (or for threads attached via JNI)
1018   oop threadObj() const                          { return _threadObj; }
1019   void set_threadObj(oop p)                      { _threadObj = p; }
1020 
1021   ThreadPriority java_priority() const;          // Read from threadObj()
1022 
1023   // Prepare thread and add to priority queue.  If a priority is
1024   // not specified, use the priority of the thread object. Threads_lock
1025   // must be held while this function is called.
1026   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1027 
1028   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
1029   address saved_exception_pc()                   { return _saved_exception_pc; }
1030 
1031 


1801     low_addr =  stack_base() - stack_size();
1802   } else {
1803     low_addr = stack_yellow_zone_base();
1804   }
1805   return cur_sp > low_addr ? cur_sp - low_addr : 0;
1806 }
1807 
1808 // A thread used for Compilation.
1809 class CompilerThread : public JavaThread {
1810   friend class VMStructs;
1811  private:
1812   CompilerCounters* _counters;
1813 
1814   ciEnv*        _env;
1815   CompileLog*   _log;
1816   CompileTask*  _task;
1817   CompileQueue* _queue;
1818   BufferBlob*   _buffer_blob;
1819 
1820   nmethod*      _scanned_nmethod;  // nmethod being scanned by the sweeper

1821 
1822  public:
1823 
1824   static CompilerThread* current();
1825 
1826   CompilerThread(CompileQueue* queue, CompilerCounters* counters);
1827 
1828   bool is_Compiler_thread() const                { return true; }
1829   // Hide this compiler thread from external view.
1830   bool is_hidden_from_external_view() const      { return true; }
1831 
1832   CompileQueue* queue()                          { return _queue; }
1833   CompilerCounters* counters()                   { return _counters; }



1834 
1835   // Get/set the thread's compilation environment.
1836   ciEnv*        env()                            { return _env; }
1837   void          set_env(ciEnv* env)              { _env = env; }
1838 
1839   BufferBlob*   get_buffer_blob()                { return _buffer_blob; }
1840   void          set_buffer_blob(BufferBlob* b)   { _buffer_blob = b; };
1841 
1842   // Get/set the thread's logging information
1843   CompileLog*   log()                            { return _log; }
1844   void          init_log(CompileLog* log) {
1845     // Set once, for good.
1846     assert(_log == NULL, "set only once");
1847     _log = log;
1848   }
1849 
1850   // GC support
1851   // Apply "f->do_oop" to all root oops in "this".
1852   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
1853   void oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf);
1854 
1855 #ifndef PRODUCT
1856 private:
1857   IdealGraphPrinter *_ideal_graph_printer;
1858 public:
1859   IdealGraphPrinter *ideal_graph_printer()                       { return _ideal_graph_printer; }




 906  public:
 907   // State of the stack guard pages for this thread.
 908   enum StackGuardState {
 909     stack_guard_unused,         // not needed
 910     stack_guard_yellow_disabled,// disabled (temporarily) after stack overflow
 911     stack_guard_enabled         // enabled
 912   };
 913 
 914  private:
 915 
 916   StackGuardState        _stack_guard_state;
 917 
 918   // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
 919   // used to temp. parsing values into and out of the runtime system during exception handling for compiled
 920   // code)
 921   volatile oop     _exception_oop;               // Exception thrown in compiled code
 922   volatile address _exception_pc;                // PC where exception happened
 923   volatile address _exception_handler_pc;        // PC for handler of exception
 924   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 925 



 926   // support for JNI critical regions
 927   jint    _jni_active_critical;                  // count of entries into JNI critical region
 928 
 929   // For deadlock detection.
 930   int _depth_first_number;
 931 
 932   // JVMTI PopFrame support
 933   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 934   int _popframe_condition;
 935 
 936 #ifndef PRODUCT
 937   int _jmp_ring_index;
 938   struct {
 939       // We use intptr_t instead of address so debugger doesn't try and display strings
 940       intptr_t _target;
 941       intptr_t _instruction;
 942       const char*  _file;
 943       int _line;
 944   }   _jmp_ring[ jump_ring_buffer_size ];
 945 #endif /* PRODUCT */


 985 
 986   // This function is called at thread creation to allow
 987   // platform specific thread variables to be initialized.
 988   void cache_global_variables();
 989 
 990   // Executes Shutdown.shutdown()
 991   void invoke_shutdown_hooks();
 992 
 993   // Cleanup on thread exit
 994   enum ExitType {
 995     normal_exit,
 996     jni_detach
 997   };
 998   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 999 
1000   void cleanup_failed_attach_current_thread();
1001 
1002   // Testers
1003   virtual bool is_Java_thread() const            { return true;  }
1004 




1005   // Thread chain operations
1006   JavaThread* next() const                       { return _next; }
1007   void set_next(JavaThread* p)                   { _next = p; }
1008 
1009   // Thread oop. threadObj() can be NULL for initial JavaThread
1010   // (or for threads attached via JNI)
1011   oop threadObj() const                          { return _threadObj; }
1012   void set_threadObj(oop p)                      { _threadObj = p; }
1013 
1014   ThreadPriority java_priority() const;          // Read from threadObj()
1015 
1016   // Prepare thread and add to priority queue.  If a priority is
1017   // not specified, use the priority of the thread object. Threads_lock
1018   // must be held while this function is called.
1019   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1020 
1021   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
1022   address saved_exception_pc()                   { return _saved_exception_pc; }
1023 
1024 


1794     low_addr =  stack_base() - stack_size();
1795   } else {
1796     low_addr = stack_yellow_zone_base();
1797   }
1798   return cur_sp > low_addr ? cur_sp - low_addr : 0;
1799 }
1800 
1801 // A thread used for Compilation.
1802 class CompilerThread : public JavaThread {
1803   friend class VMStructs;
1804  private:
1805   CompilerCounters* _counters;
1806 
1807   ciEnv*            _env;
1808   CompileLog*       _log;
1809   CompileTask*      _task;
1810   CompileQueue*     _queue;
1811   BufferBlob*       _buffer_blob;
1812 
1813   nmethod*          _scanned_nmethod;  // nmethod being scanned by the sweeper
1814   AbstractCompiler* _compiler;
1815 
1816  public:
1817 
1818   static CompilerThread* current();
1819 
1820   CompilerThread(CompileQueue* queue, CompilerCounters* counters);
1821 
1822   bool is_Compiler_thread() const                { return true; }
1823   // Hide this compiler thread from external view.
1824   bool is_hidden_from_external_view() const      { return true; }
1825 
1826   void set_compiler(AbstractCompiler* c)         { _compiler = c; }
1827   AbstractCompiler* compiler() const             { return _compiler; }
1828 
1829   CompileQueue* queue()        const             { return _queue; }
1830   CompilerCounters* counters() const             { return _counters; }
1831 
1832   // Get/set the thread's compilation environment.
1833   ciEnv*        env()                            { return _env; }
1834   void          set_env(ciEnv* env)              { _env = env; }
1835 
1836   BufferBlob*   get_buffer_blob() const          { return _buffer_blob; }
1837   void          set_buffer_blob(BufferBlob* b)   { _buffer_blob = b; };
1838 
1839   // Get/set the thread's logging information
1840   CompileLog*   log()                            { return _log; }
1841   void          init_log(CompileLog* log) {
1842     // Set once, for good.
1843     assert(_log == NULL, "set only once");
1844     _log = log;
1845   }
1846 
1847   // GC support
1848   // Apply "f->do_oop" to all root oops in "this".
1849   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
1850   void oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf);
1851 
1852 #ifndef PRODUCT
1853 private:
1854   IdealGraphPrinter *_ideal_graph_printer;
1855 public:
1856   IdealGraphPrinter *ideal_graph_printer()                       { return _ideal_graph_printer; }