hotspot/src/share/vm/runtime/thread.hpp
changeset 22823 40b2c6c30123
parent 22810 3a4dae5224c7
parent 18943 7d0ef675e808
child 22827 07d991d45a51
equal deleted inserted replaced
22822:696e77cc8e7b 22823:40b2c6c30123
    83 class jvmtiDeferredLocalVariableSet;
    83 class jvmtiDeferredLocalVariableSet;
    84 
    84 
    85 class GCTaskQueue;
    85 class GCTaskQueue;
    86 class ThreadClosure;
    86 class ThreadClosure;
    87 class IdealGraphPrinter;
    87 class IdealGraphPrinter;
       
    88 
       
    89 DEBUG_ONLY(class ResourceMark;)
    88 
    90 
    89 class WorkerThread;
    91 class WorkerThread;
    90 
    92 
    91 // Class hierarchy
    93 // Class hierarchy
    92 // - Thread
    94 // - Thread
   517   virtual bool is_lock_owned(address adr) const;
   519   virtual bool is_lock_owned(address adr) const;
   518 
   520 
   519   // Check if address is in the stack of the thread (not just for locks).
   521   // Check if address is in the stack of the thread (not just for locks).
   520   // Warning: the method can only be used on the running thread
   522   // Warning: the method can only be used on the running thread
   521   bool is_in_stack(address adr) const;
   523   bool is_in_stack(address adr) const;
       
   524   // Check if address is in the usable part of the stack (excludes protected
       
   525   // guard pages)
       
   526   bool is_in_usable_stack(address adr) const;
   522 
   527 
   523   // Sets this thread as starting thread. Returns failure if thread
   528   // Sets this thread as starting thread. Returns failure if thread
   524   // creation fails due to lack of memory, too many threads etc.
   529   // creation fails due to lack of memory, too many threads etc.
   525   bool set_as_starting_thread();
   530   bool set_as_starting_thread();
   526 
   531 
   528   // OS data associated with the thread
   533   // OS data associated with the thread
   529   OSThread* _osthread;  // Platform-specific thread information
   534   OSThread* _osthread;  // Platform-specific thread information
   530 
   535 
   531   // Thread local resource area for temporary allocation within the VM
   536   // Thread local resource area for temporary allocation within the VM
   532   ResourceArea* _resource_area;
   537   ResourceArea* _resource_area;
       
   538 
       
   539   DEBUG_ONLY(ResourceMark* _current_resource_mark;)
   533 
   540 
   534   // Thread local handle area for allocation of handles within the VM
   541   // Thread local handle area for allocation of handles within the VM
   535   HandleArea* _handle_area;
   542   HandleArea* _handle_area;
   536   GrowableArray<Metadata*>* _metadata_handles;
   543   GrowableArray<Metadata*>* _metadata_handles;
   537 
   544 
   583   bool owns_locks() const                        { return owned_locks() != NULL; }
   590   bool owns_locks() const                        { return owned_locks() != NULL; }
   584   bool owns_locks_but_compiled_lock() const;
   591   bool owns_locks_but_compiled_lock() const;
   585 
   592 
   586   // Deadlock detection
   593   // Deadlock detection
   587   bool allow_allocation()                        { return _allow_allocation_count == 0; }
   594   bool allow_allocation()                        { return _allow_allocation_count == 0; }
       
   595   ResourceMark* current_resource_mark()          { return _current_resource_mark; }
       
   596   void set_current_resource_mark(ResourceMark* rm) { _current_resource_mark = rm; }
   588 #endif
   597 #endif
   589 
   598 
   590   void check_for_valid_safepoint_state(bool potential_vm_operation) PRODUCT_RETURN;
   599   void check_for_valid_safepoint_state(bool potential_vm_operation) PRODUCT_RETURN;
   591 
   600 
   592  private:
   601  private:
   722  private:
   731  private:
   723   static WatcherThread* _watcher_thread;
   732   static WatcherThread* _watcher_thread;
   724 
   733 
   725   static bool _startable;
   734   static bool _startable;
   726   volatile static bool _should_terminate; // updated without holding lock
   735   volatile static bool _should_terminate; // updated without holding lock
       
   736 
       
   737   os::WatcherThreadCrashProtection* _crash_protection;
   727  public:
   738  public:
   728   enum SomeConstants {
   739   enum SomeConstants {
   729     delay_interval = 10                          // interrupt delay in milliseconds
   740     delay_interval = 10                          // interrupt delay in milliseconds
   730   };
   741   };
   731 
   742 
   748   static void start();
   759   static void start();
   749   static void stop();
   760   static void stop();
   750   // Only allow start once the VM is sufficiently initialized
   761   // Only allow start once the VM is sufficiently initialized
   751   // Otherwise the first task to enroll will trigger the start
   762   // Otherwise the first task to enroll will trigger the start
   752   static void make_startable();
   763   static void make_startable();
       
   764 
       
   765   void set_crash_protection(os::WatcherThreadCrashProtection* crash_protection) {
       
   766     assert(Thread::current()->is_Watcher_thread(), "Can only be set by WatcherThread");
       
   767     _crash_protection = crash_protection;
       
   768   }
       
   769 
       
   770   bool has_crash_protection() const { return _crash_protection != NULL; }
       
   771   os::WatcherThreadCrashProtection* crash_protection() const { return _crash_protection; }
   753 
   772 
   754  private:
   773  private:
   755   int sleep() const;
   774   int sleep() const;
   756 };
   775 };
   757 
   776