< prev index next >

src/hotspot/share/runtime/thread.hpp

Print this page
rev 54717 : imported patch 8223306


 966   // Create and start the single instance of WatcherThread, or stop it on shutdown
 967   static void start();
 968   static void stop();
 969   // Only allow start once the VM is sufficiently initialized
 970   // Otherwise the first task to enroll will trigger the start
 971   static void make_startable();
 972  private:
 973   int sleep() const;
 974 };
 975 
 976 
 977 class CompilerThread;
 978 
 979 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
 980 
 981 class JavaThread: public Thread {
 982   friend class VMStructs;
 983   friend class JVMCIVMStructs;
 984   friend class WhiteBox;
 985  private:
 986   JavaThread*    _next;                          // The next thread in the Threads list
 987   bool           _on_thread_list;                // Is set when this JavaThread is added to the Threads list
 988   oop            _threadObj;                     // The Java level thread object
 989 
 990 #ifdef ASSERT
 991  private:
 992   int _java_call_counter;
 993 
 994  public:
 995   int  java_call_counter()                       { return _java_call_counter; }
 996   void inc_java_call_counter()                   { _java_call_counter++; }
 997   void dec_java_call_counter() {
 998     assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
 999     _java_call_counter--;
1000   }
1001  private:  // restore original namespace restriction
1002 #endif  // ifdef ASSERT
1003 
1004 #ifndef PRODUCT
1005  public:
1006   enum {


1230   // This function is called at thread creation to allow
1231   // platform specific thread variables to be initialized.
1232   void cache_global_variables();
1233 
1234   // Executes Shutdown.shutdown()
1235   void invoke_shutdown_hooks();
1236 
1237   // Cleanup on thread exit
1238   enum ExitType {
1239     normal_exit,
1240     jni_detach
1241   };
1242   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
1243 
1244   void cleanup_failed_attach_current_thread(bool is_daemon);
1245 
1246   // Testers
1247   virtual bool is_Java_thread() const            { return true;  }
1248   virtual bool can_call_java() const             { return true; }
1249 
1250   // Thread chain operations
1251   JavaThread* next() const                       { return _next; }
1252   void set_next(JavaThread* p)                   { _next = p; }
1253 
1254   // Thread oop. threadObj() can be NULL for initial JavaThread
1255   // (or for threads attached via JNI)
1256   oop threadObj() const                          { return _threadObj; }
1257   void set_threadObj(oop p)                      { _threadObj = p; }
1258 
1259   ThreadPriority java_priority() const;          // Read from threadObj()
1260 
1261   // Prepare thread and add to priority queue.  If a priority is
1262   // not specified, use the priority of the thread object. Threads_lock
1263   // must be held while this function is called.
1264   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1265 
1266   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
1267   address saved_exception_pc()                   { return _saved_exception_pc; }
1268 
1269 
1270   ThreadFunction entry_point() const             { return _entry_point; }
1271 
1272   // Allocates a new Java level thread object for this thread. thread_name may be NULL.
1273   void allocate_threadObj(Handle thread_group, const char* thread_name, bool daemon, TRAPS);


2195   IdealGraphPrinter *_ideal_graph_printer;
2196  public:
2197   IdealGraphPrinter *ideal_graph_printer()           { return _ideal_graph_printer; }
2198   void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
2199 #endif
2200 
2201   // Get/set the thread's current task
2202   CompileTask* task()                      { return _task; }
2203   void         set_task(CompileTask* task) { _task = task; }
2204 };
2205 
2206 inline CompilerThread* CompilerThread::current() {
2207   return JavaThread::current()->as_CompilerThread();
2208 }
2209 
2210 // The active thread queue. It also keeps track of the current used
2211 // thread priorities.
2212 class Threads: AllStatic {
2213   friend class VMStructs;
2214  private:
2215   static JavaThread* _thread_list;
2216   static int         _number_of_threads;
2217   static int         _number_of_non_daemon_threads;
2218   static int         _return_code;
2219   static uintx       _thread_claim_token;
2220 #ifdef ASSERT
2221   static bool        _vm_complete;
2222 #endif
2223 
2224   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
2225   static void initialize_jsr292_core_classes(TRAPS);
2226 
2227  public:
2228   // Thread management
2229   // force_daemon is a concession to JNI, where we may need to add a
2230   // thread to the thread list before allocating its thread object
2231   static void add(JavaThread* p, bool force_daemon = false);
2232   static void remove(JavaThread* p, bool is_daemon);
2233   static void non_java_threads_do(ThreadClosure* tc);
2234   static void java_threads_do(ThreadClosure* tc);
2235   static void java_threads_and_vm_thread_do(ThreadClosure* tc);




 966   // Create and start the single instance of WatcherThread, or stop it on shutdown
 967   static void start();
 968   static void stop();
 969   // Only allow start once the VM is sufficiently initialized
 970   // Otherwise the first task to enroll will trigger the start
 971   static void make_startable();
 972  private:
 973   int sleep() const;
 974 };
 975 
 976 
 977 class CompilerThread;
 978 
 979 typedef void (*ThreadFunction)(JavaThread*, TRAPS);
 980 
 981 class JavaThread: public Thread {
 982   friend class VMStructs;
 983   friend class JVMCIVMStructs;
 984   friend class WhiteBox;
 985  private:

 986   bool           _on_thread_list;                // Is set when this JavaThread is added to the Threads list
 987   oop            _threadObj;                     // The Java level thread object
 988 
 989 #ifdef ASSERT
 990  private:
 991   int _java_call_counter;
 992 
 993  public:
 994   int  java_call_counter()                       { return _java_call_counter; }
 995   void inc_java_call_counter()                   { _java_call_counter++; }
 996   void dec_java_call_counter() {
 997     assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
 998     _java_call_counter--;
 999   }
1000  private:  // restore original namespace restriction
1001 #endif  // ifdef ASSERT
1002 
1003 #ifndef PRODUCT
1004  public:
1005   enum {


1229   // This function is called at thread creation to allow
1230   // platform specific thread variables to be initialized.
1231   void cache_global_variables();
1232 
1233   // Executes Shutdown.shutdown()
1234   void invoke_shutdown_hooks();
1235 
1236   // Cleanup on thread exit
1237   enum ExitType {
1238     normal_exit,
1239     jni_detach
1240   };
1241   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
1242 
1243   void cleanup_failed_attach_current_thread(bool is_daemon);
1244 
1245   // Testers
1246   virtual bool is_Java_thread() const            { return true;  }
1247   virtual bool can_call_java() const             { return true; }
1248 




1249   // Thread oop. threadObj() can be NULL for initial JavaThread
1250   // (or for threads attached via JNI)
1251   oop threadObj() const                          { return _threadObj; }
1252   void set_threadObj(oop p)                      { _threadObj = p; }
1253 
1254   ThreadPriority java_priority() const;          // Read from threadObj()
1255 
1256   // Prepare thread and add to priority queue.  If a priority is
1257   // not specified, use the priority of the thread object. Threads_lock
1258   // must be held while this function is called.
1259   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1260 
1261   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
1262   address saved_exception_pc()                   { return _saved_exception_pc; }
1263 
1264 
1265   ThreadFunction entry_point() const             { return _entry_point; }
1266 
1267   // Allocates a new Java level thread object for this thread. thread_name may be NULL.
1268   void allocate_threadObj(Handle thread_group, const char* thread_name, bool daemon, TRAPS);


2190   IdealGraphPrinter *_ideal_graph_printer;
2191  public:
2192   IdealGraphPrinter *ideal_graph_printer()           { return _ideal_graph_printer; }
2193   void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
2194 #endif
2195 
2196   // Get/set the thread's current task
2197   CompileTask* task()                      { return _task; }
2198   void         set_task(CompileTask* task) { _task = task; }
2199 };
2200 
2201 inline CompilerThread* CompilerThread::current() {
2202   return JavaThread::current()->as_CompilerThread();
2203 }
2204 
2205 // The active thread queue. It also keeps track of the current used
2206 // thread priorities.
2207 class Threads: AllStatic {
2208   friend class VMStructs;
2209  private:

2210   static int         _number_of_threads;
2211   static int         _number_of_non_daemon_threads;
2212   static int         _return_code;
2213   static uintx       _thread_claim_token;
2214 #ifdef ASSERT
2215   static bool        _vm_complete;
2216 #endif
2217 
2218   static void initialize_java_lang_classes(JavaThread* main_thread, TRAPS);
2219   static void initialize_jsr292_core_classes(TRAPS);
2220 
2221  public:
2222   // Thread management
2223   // force_daemon is a concession to JNI, where we may need to add a
2224   // thread to the thread list before allocating its thread object
2225   static void add(JavaThread* p, bool force_daemon = false);
2226   static void remove(JavaThread* p, bool is_daemon);
2227   static void non_java_threads_do(ThreadClosure* tc);
2228   static void java_threads_do(ThreadClosure* tc);
2229   static void java_threads_and_vm_thread_do(ThreadClosure* tc);


< prev index next >