< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

 440 
 441   // JVMTI PopFrame support
 442   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 443   int _popframe_condition;
 444 
 445   // If reallocation of scalar replaced objects fails, we throw OOM
 446   // and during exception propagation, pop the top
 447   // _frames_to_pop_failed_realloc frames, the ones that reference
 448   // failed reallocations.
 449   int _frames_to_pop_failed_realloc;
 450 
 451   ContinuationEntry* _cont_entry;
 452   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub frame inside the
 453                             // continuation that we know about
 454   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 455 
 456   // It's signed for error detection.
 457   intx _held_monitor_count;  // used by continuations for fast lock detection
 458   intx _jni_monitor_count;
 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   // Constructor
 474   JavaThread();                            // delegating constructor
 475   JavaThread(bool is_attaching_via_jni);   // for main thread and JNI attached threads
 476   JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
 477   ~JavaThread();
 478 
 479 #ifdef ASSERT

 490   struct JNINativeInterface_* get_jni_functions() {
 491     return (struct JNINativeInterface_ *)_jni_environment.functions;
 492   }
 493 
 494   // This function is called at thread creation to allow
 495   // platform specific thread variables to be initialized.
 496   void cache_global_variables();
 497 
 498   // Executes Shutdown.shutdown()
 499   void invoke_shutdown_hooks();
 500 
 501   // Cleanup on thread exit
 502   enum ExitType {
 503     normal_exit,
 504     jni_detach
 505   };
 506   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 507 
 508   void cleanup_failed_attach_current_thread(bool is_daemon);
 509 













 510   // Testers
 511   virtual bool is_Java_thread() const            { return true;  }
 512   virtual bool can_call_java() const             { return true; }
 513 
 514   virtual bool is_active_Java_thread() const;
 515 
 516   // Thread oop. threadObj() can be null for initial JavaThread
 517   // (or for threads attached via JNI)
 518   oop threadObj() const;
 519   void set_threadOopHandles(oop p);
 520   oop vthread() const;
 521   void set_vthread(oop p);
 522   oop scopedValueCache() const;
 523   void set_scopedValueCache(oop p);
 524   void clear_scopedValueBindings();
 525   oop jvmti_vthread() const;
 526   void set_jvmti_vthread(oop p);
 527 
 528   // Prepare thread and add to priority queue.  If a priority is
 529   // not specified, use the priority of the thread object. Threads_lock
 530   // must be held while this function is called.
 531   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
 532 

 938 
 939   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
 940 
 941   // Returns method at 'depth' java or native frames down the stack
 942   // Used for security checks
 943   Klass* security_get_caller_class(int depth);
 944 
 945   // Print stack trace in external format
 946   // These variants print carrier/platform thread information only.
 947   void print_stack_on(outputStream* st);
 948   void print_stack() { print_stack_on(tty); }
 949   // This prints the currently mounted virtual thread.
 950   void print_vthread_stack_on(outputStream* st);
 951   // This prints the active stack: either carrier/platform or virtual.
 952   void print_active_stack_on(outputStream* st);
 953   // Print current stack trace for checked JNI warnings and JNI fatal errors.
 954   // This is the external format from above, but selecting the platform
 955   // or vthread as applicable.
 956   void print_jni_stack();
 957 


 958   // Print stack traces in various internal formats
 959   void trace_stack()                             PRODUCT_RETURN;
 960   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
 961   void trace_frames()                            PRODUCT_RETURN;
 962 
 963   // Print an annotated view of the stack frames
 964   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
 965   void validate_frame_layout() {
 966     print_frame_layout(0, true);
 967   }
 968 
 969   // Function for testing deoptimization
 970   void deoptimize();
 971   void make_zombies();
 972 
 973   void deoptimize_marked_methods();
 974 
 975  public:
 976   // Returns the running thread as a JavaThread
 977   static JavaThread* current() {

1120 #include OS_CPU_HEADER(javaThread)
1121 
1122   // JSR166 per-thread parker
1123  private:
1124   Parker _parker;
1125  public:
1126   Parker* parker() { return &_parker; }
1127 
1128  public:
1129   // clearing/querying jni attach status
1130   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1131   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1132   inline void set_done_attaching_via_jni();
1133 
1134   // Stack dump assistance:
1135   // Track the class we want to initialize but for which we have to wait
1136   // on its init_lock() because it is already being initialized.
1137   void set_class_to_be_initialized(InstanceKlass* k);
1138   InstanceKlass* class_to_be_initialized() const;
1139 





1140 private:
1141   InstanceKlass* _class_to_be_initialized;

1142 
1143   // java.lang.Thread.sleep support
1144   ParkEvent * _SleepEvent;
1145 public:
1146   bool sleep(jlong millis);
1147   bool sleep_nanos(jlong nanos);
1148 
1149   // java.lang.Thread interruption support
1150   void interrupt();
1151   bool is_interrupted(bool clear_interrupted);
1152 
1153 private:
1154   LockStack _lock_stack;
1155 
1156 public:
1157   LockStack& lock_stack() { return _lock_stack; }
1158 
1159   static ByteSize lock_stack_offset()      { return byte_offset_of(JavaThread, _lock_stack); }
1160   // Those offsets are used in code generators to access the LockStack that is embedded in this
1161   // JavaThread structure. Those accesses are relative to the current thread, which

 440 
 441   // JVMTI PopFrame support
 442   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 443   int _popframe_condition;
 444 
 445   // If reallocation of scalar replaced objects fails, we throw OOM
 446   // and during exception propagation, pop the top
 447   // _frames_to_pop_failed_realloc frames, the ones that reference
 448   // failed reallocations.
 449   int _frames_to_pop_failed_realloc;
 450 
 451   ContinuationEntry* _cont_entry;
 452   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub frame inside the
 453                             // continuation that we know about
 454   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 455 
 456   // It's signed for error detection.
 457   intx _held_monitor_count;  // used by continuations for fast lock detection
 458   intx _jni_monitor_count;
 459 
 460   bool _can_call_java;
 461 
 462 private:
 463 
 464   friend class VMThread;
 465   friend class ThreadWaitTransition;
 466   friend class VM_Exit;
 467 
 468   // Stack watermark barriers.
 469   StackWatermarks _stack_watermarks;
 470 
 471  public:
 472   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 473 
 474  public:
 475   // Constructor
 476   JavaThread();                            // delegating constructor
 477   JavaThread(bool is_attaching_via_jni);   // for main thread and JNI attached threads
 478   JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
 479   ~JavaThread();
 480 
 481 #ifdef ASSERT

 492   struct JNINativeInterface_* get_jni_functions() {
 493     return (struct JNINativeInterface_ *)_jni_environment.functions;
 494   }
 495 
 496   // This function is called at thread creation to allow
 497   // platform specific thread variables to be initialized.
 498   void cache_global_variables();
 499 
 500   // Executes Shutdown.shutdown()
 501   void invoke_shutdown_hooks();
 502 
 503   // Cleanup on thread exit
 504   enum ExitType {
 505     normal_exit,
 506     jni_detach
 507   };
 508   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 509 
 510   void cleanup_failed_attach_current_thread(bool is_daemon);
 511 
 512   class NoJavaCodeMark : public StackObj {
 513     friend JavaThread;
 514     JavaThread* _target;
 515     bool _orig;
 516    public:
 517     NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
 518       _target->_can_call_java = false;
 519     }
 520     ~NoJavaCodeMark() {
 521       _target->_can_call_java = _orig;
 522     }
 523   };
 524 
 525   // Testers
 526   virtual bool is_Java_thread() const            { return true;  }
 527   virtual bool can_call_java() const             { return _can_call_java; }
 528 
 529   virtual bool is_active_Java_thread() const;
 530 
 531   // Thread oop. threadObj() can be null for initial JavaThread
 532   // (or for threads attached via JNI)
 533   oop threadObj() const;
 534   void set_threadOopHandles(oop p);
 535   oop vthread() const;
 536   void set_vthread(oop p);
 537   oop scopedValueCache() const;
 538   void set_scopedValueCache(oop p);
 539   void clear_scopedValueBindings();
 540   oop jvmti_vthread() const;
 541   void set_jvmti_vthread(oop p);
 542 
 543   // Prepare thread and add to priority queue.  If a priority is
 544   // not specified, use the priority of the thread object. Threads_lock
 545   // must be held while this function is called.
 546   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
 547 

 953 
 954   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
 955 
 956   // Returns method at 'depth' java or native frames down the stack
 957   // Used for security checks
 958   Klass* security_get_caller_class(int depth);
 959 
 960   // Print stack trace in external format
 961   // These variants print carrier/platform thread information only.
 962   void print_stack_on(outputStream* st);
 963   void print_stack() { print_stack_on(tty); }
 964   // This prints the currently mounted virtual thread.
 965   void print_vthread_stack_on(outputStream* st);
 966   // This prints the active stack: either carrier/platform or virtual.
 967   void print_active_stack_on(outputStream* st);
 968   // Print current stack trace for checked JNI warnings and JNI fatal errors.
 969   // This is the external format from above, but selecting the platform
 970   // or vthread as applicable.
 971   void print_jni_stack();
 972 
 973   void print_native_stack_on(outputStream* st);
 974 
 975   // Print stack traces in various internal formats
 976   void trace_stack()                             PRODUCT_RETURN;
 977   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
 978   void trace_frames()                            PRODUCT_RETURN;
 979 
 980   // Print an annotated view of the stack frames
 981   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
 982   void validate_frame_layout() {
 983     print_frame_layout(0, true);
 984   }
 985 
 986   // Function for testing deoptimization
 987   void deoptimize();
 988   void make_zombies();
 989 
 990   void deoptimize_marked_methods();
 991 
 992  public:
 993   // Returns the running thread as a JavaThread
 994   static JavaThread* current() {

1137 #include OS_CPU_HEADER(javaThread)
1138 
1139   // JSR166 per-thread parker
1140  private:
1141   Parker _parker;
1142  public:
1143   Parker* parker() { return &_parker; }
1144 
1145  public:
1146   // clearing/querying jni attach status
1147   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1148   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1149   inline void set_done_attaching_via_jni();
1150 
1151   // Stack dump assistance:
1152   // Track the class we want to initialize but for which we have to wait
1153   // on its init_lock() because it is already being initialized.
1154   void set_class_to_be_initialized(InstanceKlass* k);
1155   InstanceKlass* class_to_be_initialized() const;
1156 
1157   // The most recent active <clinit> invocation is tracked by this variable.
1158   // The setter returns the previous value, so it can be restored later if needed.
1159   InstanceKlass* set_class_being_initialized(InstanceKlass* k);
1160   InstanceKlass* class_being_initialized() const;
1161 
1162 private:
1163   InstanceKlass* _class_to_be_initialized;
1164   InstanceKlass* _class_being_initialized;
1165 
1166   // java.lang.Thread.sleep support
1167   ParkEvent * _SleepEvent;
1168 public:
1169   bool sleep(jlong millis);
1170   bool sleep_nanos(jlong nanos);
1171 
1172   // java.lang.Thread interruption support
1173   void interrupt();
1174   bool is_interrupted(bool clear_interrupted);
1175 
1176 private:
1177   LockStack _lock_stack;
1178 
1179 public:
1180   LockStack& lock_stack() { return _lock_stack; }
1181 
1182   static ByteSize lock_stack_offset()      { return byte_offset_of(JavaThread, _lock_stack); }
1183   // Those offsets are used in code generators to access the LockStack that is embedded in this
1184   // JavaThread structure. Those accesses are relative to the current thread, which
< prev index next >