< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

  76 
  77 class JavaThread: public Thread {
  78   friend class VMStructs;
  79   friend class JVMCIVMStructs;
  80   friend class WhiteBox;
  81   friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
  82   friend class HandshakeState;
  83   friend class Continuation;
  84   friend class Threads;
  85   friend class ServiceThread; // for deferred OopHandle release access
  86  private:
  87   bool           _in_asgct;                      // Is set when this JavaThread is handling ASGCT call
  88   bool           _on_thread_list;                // Is set when this JavaThread is added to the Threads list
  89 
  90   // All references to Java objects managed via OopHandles. These
  91   // have to be released by the ServiceThread after the JavaThread has
  92   // terminated - see add_oop_handles_for_release().
  93   OopHandle      _threadObj;                     // The Java level thread object
  94   OopHandle      _vthread; // the value returned by Thread.currentThread(): the virtual thread, if mounted, otherwise _threadObj
  95   OopHandle      _jvmti_vthread;
  96   OopHandle      _extentLocalCache;
  97 
  98   static OopStorage* _thread_oop_storage;
  99 
 100 #ifdef ASSERT
 101  private:
 102   int _java_call_counter;
 103 
 104  public:
 105   int  java_call_counter()                       { return _java_call_counter; }
 106   void inc_java_call_counter()                   { _java_call_counter++; }
 107   void dec_java_call_counter() {
 108     assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
 109     _java_call_counter--;
 110   }
 111  private:  // restore original namespace restriction
 112 #endif  // ifdef ASSERT
 113 
 114   JavaFrameAnchor _anchor;                       // Encapsulation of current java frame and it state
 115 
 116   ThreadFunction _entry_point;

 453   int64_t _held_monitor_count;  // used by continuations for fast lock detection
 454   int64_t _jni_monitor_count;
 455 #else
 456   int32_t _held_monitor_count;  // used by continuations for fast lock detection
 457   int32_t _jni_monitor_count;
 458 #endif
 459 
 460 private:
 461 
 462   friend class VMThread;
 463   friend class ThreadWaitTransition;
 464   friend class VM_Exit;
 465 
 466   // Stack watermark barriers.
 467   StackWatermarks _stack_watermarks;
 468 
 469  public:
 470   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 471 
 472  public:
 473   jlong _extentLocal_hash_table_shift;
 474 
 475   void allocate_extentLocal_hash_table(int count);
 476 
 477  public:
 478   // Constructor
 479   JavaThread();                            // delegating constructor
 480   JavaThread(bool is_attaching_via_jni);   // for main thread and JNI attached threads
 481   JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
 482   ~JavaThread();
 483 
 484 #ifdef ASSERT
 485   // verify this JavaThread hasn't be published in the Threads::list yet
 486   void verify_not_published();
 487 #endif // ASSERT
 488 
 489   StackOverflow* stack_overflow_state() { return &_stack_overflow_state; }
 490 
 491   //JNI functiontable getter/setter for JVMTI jni function table interception API.
 492   void set_jni_functions(struct JNINativeInterface_* functionTable) {
 493     _jni_environment.functions = functionTable;
 494   }
 495   struct JNINativeInterface_* get_jni_functions() {

 509     jni_detach
 510   };
 511   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 512 
 513   void cleanup_failed_attach_current_thread(bool is_daemon);
 514 
 515   // Testers
 516   virtual bool is_Java_thread() const            { return true;  }
 517   virtual bool can_call_java() const             { return true; }
 518 
 519   virtual bool is_active_Java_thread() const {
 520     return on_thread_list() && !is_terminated();
 521   }
 522 
 523   // Thread oop. threadObj() can be NULL for initial JavaThread
 524   // (or for threads attached via JNI)
 525   oop threadObj() const;
 526   void set_threadOopHandles(oop p);
 527   oop vthread() const;
 528   void set_vthread(oop p);
 529   oop extentLocalCache() const;
 530   void set_extentLocalCache(oop p);

 531   oop jvmti_vthread() const;
 532   void set_jvmti_vthread(oop p);
 533 
 534   // Prepare thread and add to priority queue.  If a priority is
 535   // not specified, use the priority of the thread object. Threads_lock
 536   // must be held while this function is called.
 537   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
 538 
 539   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
 540   address saved_exception_pc()                   { return _saved_exception_pc; }
 541 
 542   ThreadFunction entry_point() const             { return _entry_point; }
 543 
 544   // Allocates a new Java level thread object for this thread. thread_name may be NULL.
 545   void allocate_threadObj(Handle thread_group, const char* thread_name, bool daemon, TRAPS);
 546 
 547   // Last frame anchor routines
 548 
 549   JavaFrameAnchor* frame_anchor(void)            { return &_anchor; }
 550 

 741   void set_exception_handler_pc(address a)       { _exception_handler_pc = a; }
 742   void set_is_method_handle_return(bool value)   { _is_method_handle_return = value ? 1 : 0; }
 743 
 744   void clear_exception_oop_and_pc() {
 745     set_exception_oop(NULL);
 746     set_exception_pc(NULL);
 747   }
 748 
 749   // Check if address is in the usable part of the stack (excludes protected
 750   // guard pages). Can be applied to any thread and is an approximation for
 751   // using is_in_live_stack when the query has to happen from another thread.
 752   bool is_in_usable_stack(address adr) const {
 753     return is_in_stack_range_incl(adr, _stack_overflow_state.stack_reserved_zone_base());
 754   }
 755 
 756   // Misc. accessors/mutators
 757   void set_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = true; }
 758   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
 759   bool do_not_unlock(void)                       { return _do_not_unlock_if_synchronized; }
 760 
 761   static ByteSize extentLocalCache_offset()       { return byte_offset_of(JavaThread, _extentLocalCache); }
 762 
 763   // For assembly stub generation
 764   static ByteSize threadObj_offset()             { return byte_offset_of(JavaThread, _threadObj); }
 765   static ByteSize vthread_offset()               { return byte_offset_of(JavaThread, _vthread); }
 766   static ByteSize jni_environment_offset()       { return byte_offset_of(JavaThread, _jni_environment); }
 767   static ByteSize pending_jni_exception_check_fn_offset() {
 768     return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
 769   }
 770   static ByteSize last_Java_sp_offset() {
 771     return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
 772   }
 773   static ByteSize last_Java_pc_offset() {
 774     return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
 775   }
 776   static ByteSize frame_anchor_offset() {
 777     return byte_offset_of(JavaThread, _anchor);
 778   }
 779   static ByteSize callee_target_offset()         { return byte_offset_of(JavaThread, _callee_target); }
 780   static ByteSize vm_result_offset()             { return byte_offset_of(JavaThread, _vm_result); }
 781   static ByteSize vm_result_2_offset()           { return byte_offset_of(JavaThread, _vm_result_2); }

  76 
  77 class JavaThread: public Thread {
  78   friend class VMStructs;
  79   friend class JVMCIVMStructs;
  80   friend class WhiteBox;
  81   friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
  82   friend class HandshakeState;
  83   friend class Continuation;
  84   friend class Threads;
  85   friend class ServiceThread; // for deferred OopHandle release access
  86  private:
  87   bool           _in_asgct;                      // Is set when this JavaThread is handling ASGCT call
  88   bool           _on_thread_list;                // Is set when this JavaThread is added to the Threads list
  89 
  90   // All references to Java objects managed via OopHandles. These
  91   // have to be released by the ServiceThread after the JavaThread has
  92   // terminated - see add_oop_handles_for_release().
  93   OopHandle      _threadObj;                     // The Java level thread object
  94   OopHandle      _vthread; // the value returned by Thread.currentThread(): the virtual thread, if mounted, otherwise _threadObj
  95   OopHandle      _jvmti_vthread;
  96   OopHandle      _scopedValueCache;
  97 
  98   static OopStorage* _thread_oop_storage;
  99 
 100 #ifdef ASSERT
 101  private:
 102   int _java_call_counter;
 103 
 104  public:
 105   int  java_call_counter()                       { return _java_call_counter; }
 106   void inc_java_call_counter()                   { _java_call_counter++; }
 107   void dec_java_call_counter() {
 108     assert(_java_call_counter > 0, "Invalid nesting of JavaCallWrapper");
 109     _java_call_counter--;
 110   }
 111  private:  // restore original namespace restriction
 112 #endif  // ifdef ASSERT
 113 
 114   JavaFrameAnchor _anchor;                       // Encapsulation of current java frame and it state
 115 
 116   ThreadFunction _entry_point;

 453   int64_t _held_monitor_count;  // used by continuations for fast lock detection
 454   int64_t _jni_monitor_count;
 455 #else
 456   int32_t _held_monitor_count;  // used by continuations for fast lock detection
 457   int32_t _jni_monitor_count;
 458 #endif
 459 
 460 private:
 461 
 462   friend class VMThread;
 463   friend class ThreadWaitTransition;
 464   friend class VM_Exit;
 465 
 466   // Stack watermark barriers.
 467   StackWatermarks _stack_watermarks;
 468 
 469  public:
 470   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 471 
 472  public:
 473   jlong _scopedValue_hash_table_shift;
 474 
 475   void allocate_scopedValue_hash_table(int count);
 476 
 477  public:
 478   // Constructor
 479   JavaThread();                            // delegating constructor
 480   JavaThread(bool is_attaching_via_jni);   // for main thread and JNI attached threads
 481   JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
 482   ~JavaThread();
 483 
 484 #ifdef ASSERT
 485   // verify this JavaThread hasn't be published in the Threads::list yet
 486   void verify_not_published();
 487 #endif // ASSERT
 488 
 489   StackOverflow* stack_overflow_state() { return &_stack_overflow_state; }
 490 
 491   //JNI functiontable getter/setter for JVMTI jni function table interception API.
 492   void set_jni_functions(struct JNINativeInterface_* functionTable) {
 493     _jni_environment.functions = functionTable;
 494   }
 495   struct JNINativeInterface_* get_jni_functions() {

 509     jni_detach
 510   };
 511   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 512 
 513   void cleanup_failed_attach_current_thread(bool is_daemon);
 514 
 515   // Testers
 516   virtual bool is_Java_thread() const            { return true;  }
 517   virtual bool can_call_java() const             { return true; }
 518 
 519   virtual bool is_active_Java_thread() const {
 520     return on_thread_list() && !is_terminated();
 521   }
 522 
 523   // Thread oop. threadObj() can be NULL for initial JavaThread
 524   // (or for threads attached via JNI)
 525   oop threadObj() const;
 526   void set_threadOopHandles(oop p);
 527   oop vthread() const;
 528   void set_vthread(oop p);
 529   oop scopedValueCache() const;
 530   void set_scopedValueCache(oop p);
 531   void clear_scopedValueBindings();
 532   oop jvmti_vthread() const;
 533   void set_jvmti_vthread(oop p);
 534 
 535   // Prepare thread and add to priority queue.  If a priority is
 536   // not specified, use the priority of the thread object. Threads_lock
 537   // must be held while this function is called.
 538   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
 539 
 540   void set_saved_exception_pc(address pc)        { _saved_exception_pc = pc; }
 541   address saved_exception_pc()                   { return _saved_exception_pc; }
 542 
 543   ThreadFunction entry_point() const             { return _entry_point; }
 544 
 545   // Allocates a new Java level thread object for this thread. thread_name may be NULL.
 546   void allocate_threadObj(Handle thread_group, const char* thread_name, bool daemon, TRAPS);
 547 
 548   // Last frame anchor routines
 549 
 550   JavaFrameAnchor* frame_anchor(void)            { return &_anchor; }
 551 

 742   void set_exception_handler_pc(address a)       { _exception_handler_pc = a; }
 743   void set_is_method_handle_return(bool value)   { _is_method_handle_return = value ? 1 : 0; }
 744 
 745   void clear_exception_oop_and_pc() {
 746     set_exception_oop(NULL);
 747     set_exception_pc(NULL);
 748   }
 749 
 750   // Check if address is in the usable part of the stack (excludes protected
 751   // guard pages). Can be applied to any thread and is an approximation for
 752   // using is_in_live_stack when the query has to happen from another thread.
 753   bool is_in_usable_stack(address adr) const {
 754     return is_in_stack_range_incl(adr, _stack_overflow_state.stack_reserved_zone_base());
 755   }
 756 
 757   // Misc. accessors/mutators
 758   void set_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = true; }
 759   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
 760   bool do_not_unlock(void)                       { return _do_not_unlock_if_synchronized; }
 761 
 762   static ByteSize scopedValueCache_offset()       { return byte_offset_of(JavaThread, _scopedValueCache); }
 763 
 764   // For assembly stub generation
 765   static ByteSize threadObj_offset()             { return byte_offset_of(JavaThread, _threadObj); }
 766   static ByteSize vthread_offset()               { return byte_offset_of(JavaThread, _vthread); }
 767   static ByteSize jni_environment_offset()       { return byte_offset_of(JavaThread, _jni_environment); }
 768   static ByteSize pending_jni_exception_check_fn_offset() {
 769     return byte_offset_of(JavaThread, _pending_jni_exception_check_fn);
 770   }
 771   static ByteSize last_Java_sp_offset() {
 772     return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset();
 773   }
 774   static ByteSize last_Java_pc_offset() {
 775     return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset();
 776   }
 777   static ByteSize frame_anchor_offset() {
 778     return byte_offset_of(JavaThread, _anchor);
 779   }
 780   static ByteSize callee_target_offset()         { return byte_offset_of(JavaThread, _callee_target); }
 781   static ByteSize vm_result_offset()             { return byte_offset_of(JavaThread, _vm_result); }
 782   static ByteSize vm_result_2_offset()           { return byte_offset_of(JavaThread, _vm_result_2); }
< prev index next >