< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

 449   // JVMTI PopFrame support
 450   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 451   int _popframe_condition;
 452 
 453   // If reallocation of scalar replaced objects fails, we throw OOM
 454   // and during exception propagation, pop the top
 455   // _frames_to_pop_failed_realloc frames, the ones that reference
 456   // failed reallocations.
 457   int _frames_to_pop_failed_realloc;
 458 
 459   ContinuationEntry* _cont_entry;
 460   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub frame inside the
 461                             // continuation that we know about
 462   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 463 
 464   // It's signed for error detection.
 465   intx _held_monitor_count;  // used by continuations for fast lock detection
 466   intx _jni_monitor_count;
 467   ObjectMonitor* _unlocked_inflated_monitor;
 468 


 469 private:
 470 
 471   friend class VMThread;
 472   friend class ThreadWaitTransition;
 473   friend class VM_Exit;
 474 
 475   // Stack watermark barriers.
 476   StackWatermarks _stack_watermarks;
 477 
 478  public:
 479   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 480 
 481  public:
 482   // Constructor
 483   JavaThread(MemTag mem_tag = mtThread);   // delegating constructor
 484   JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MemTag mem_tag = mtThread);
 485   ~JavaThread();
 486 
 487   // Factory method to create a new JavaThread whose attach state is "is attaching"
 488   static JavaThread* create_attaching_thread();

 501   struct JNINativeInterface_* get_jni_functions() {
 502     return (struct JNINativeInterface_ *)_jni_environment.functions;
 503   }
 504 
 505   // This function is called at thread creation to allow
 506   // platform specific thread variables to be initialized.
 507   void cache_global_variables();
 508 
 509   // Executes Shutdown.shutdown()
 510   void invoke_shutdown_hooks();
 511 
 512   // Cleanup on thread exit
 513   enum ExitType {
 514     normal_exit,
 515     jni_detach
 516   };
 517   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 518 
 519   void cleanup_failed_attach_current_thread(bool is_daemon);
 520 













 521   // Testers
 522   virtual bool is_Java_thread() const            { return true;  }
 523   virtual bool can_call_java() const             { return true; }
 524 
 525   virtual bool is_active_Java_thread() const;
 526 
 527   // Thread oop. threadObj() can be null for initial JavaThread
 528   // (or for threads attached via JNI)
 529   oop threadObj() const;
 530   void set_threadOopHandles(oop p);
 531   oop vthread() const;
 532   void set_vthread(oop p);
 533   oop scopedValueCache() const;
 534   void set_scopedValueCache(oop p);
 535   void clear_scopedValueBindings();
 536   oop jvmti_vthread() const;
 537   void set_jvmti_vthread(oop p);
 538   oop vthread_or_thread() const;
 539 
 540   // Prepare thread and add to priority queue.  If a priority is
 541   // not specified, use the priority of the thread object. Threads_lock
 542   // must be held while this function is called.
 543   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

 956 
 957   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
 958 
 959   // Returns method at 'depth' java or native frames down the stack
 960   // Used for security checks
 961   Klass* security_get_caller_class(int depth);
 962 
 963   // Print stack trace in external format
 964   // These variants print carrier/platform thread information only.
 965   void print_stack_on(outputStream* st);
 966   void print_stack() { print_stack_on(tty); }
 967   // This prints the currently mounted virtual thread.
 968   void print_vthread_stack_on(outputStream* st);
 969   // This prints the active stack: either carrier/platform or virtual.
 970   void print_active_stack_on(outputStream* st);
 971   // Print current stack trace for checked JNI warnings and JNI fatal errors.
 972   // This is the external format from above, but selecting the platform
 973   // or vthread as applicable.
 974   void print_jni_stack();
 975 


 976   // Print stack traces in various internal formats
 977   void trace_stack()                             PRODUCT_RETURN;
 978   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
 979   void trace_frames()                            PRODUCT_RETURN;
 980 
 981   // Print an annotated view of the stack frames
 982   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
 983   void validate_frame_layout() {
 984     print_frame_layout(0, true);
 985   }
 986 
 987   // Function for testing deoptimization
 988   void deoptimize();
 989   void make_zombies();
 990 
 991   void deoptimize_marked_methods();
 992 
 993  public:
 994   // Returns the running thread as a JavaThread
 995   static JavaThread* current() {

1138 #include OS_CPU_HEADER(javaThread)
1139 
1140   // JSR166 per-thread parker
1141  private:
1142   Parker _parker;
1143  public:
1144   Parker* parker() { return &_parker; }
1145 
1146  public:
1147   // clearing/querying jni attach status
1148   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1149   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1150   inline void set_done_attaching_via_jni();
1151 
1152   // Stack dump assistance:
1153   // Track the class we want to initialize but for which we have to wait
1154   // on its init_lock() because it is already being initialized.
1155   void set_class_to_be_initialized(InstanceKlass* k);
1156   InstanceKlass* class_to_be_initialized() const;
1157 





1158 private:
1159   InstanceKlass* _class_to_be_initialized;

1160 
1161   // java.lang.Thread.sleep support
1162   ParkEvent * _SleepEvent;
1163 public:
1164   bool sleep(jlong millis);
1165   bool sleep_nanos(jlong nanos);
1166 
1167   // java.lang.Thread interruption support
1168   void interrupt();
1169   bool is_interrupted(bool clear_interrupted);
1170 
1171   // This is only for use by JVMTI RawMonitorWait. It emulates the actions of
1172   // the Java code in Object::wait which are not present in RawMonitorWait.
1173   bool get_and_clear_interrupted();
1174 
1175 private:
1176   LockStack _lock_stack;
1177   OMCache _om_cache;
1178 
1179 public:

 449   // JVMTI PopFrame support
 450   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 451   int _popframe_condition;
 452 
 453   // If reallocation of scalar replaced objects fails, we throw OOM
 454   // and during exception propagation, pop the top
 455   // _frames_to_pop_failed_realloc frames, the ones that reference
 456   // failed reallocations.
 457   int _frames_to_pop_failed_realloc;
 458 
 459   ContinuationEntry* _cont_entry;
 460   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub frame inside the
 461                             // continuation that we know about
 462   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 463 
 464   // It's signed for error detection.
 465   intx _held_monitor_count;  // used by continuations for fast lock detection
 466   intx _jni_monitor_count;
 467   ObjectMonitor* _unlocked_inflated_monitor;
 468 
 469   bool _can_call_java;
 470 
 471 private:
 472 
 473   friend class VMThread;
 474   friend class ThreadWaitTransition;
 475   friend class VM_Exit;
 476 
 477   // Stack watermark barriers.
 478   StackWatermarks _stack_watermarks;
 479 
 480  public:
 481   inline StackWatermarks* stack_watermarks() { return &_stack_watermarks; }
 482 
 483  public:
 484   // Constructor
 485   JavaThread(MemTag mem_tag = mtThread);   // delegating constructor
 486   JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MemTag mem_tag = mtThread);
 487   ~JavaThread();
 488 
 489   // Factory method to create a new JavaThread whose attach state is "is attaching"
 490   static JavaThread* create_attaching_thread();

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

 971 
 972   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
 973 
 974   // Returns method at 'depth' java or native frames down the stack
 975   // Used for security checks
 976   Klass* security_get_caller_class(int depth);
 977 
 978   // Print stack trace in external format
 979   // These variants print carrier/platform thread information only.
 980   void print_stack_on(outputStream* st);
 981   void print_stack() { print_stack_on(tty); }
 982   // This prints the currently mounted virtual thread.
 983   void print_vthread_stack_on(outputStream* st);
 984   // This prints the active stack: either carrier/platform or virtual.
 985   void print_active_stack_on(outputStream* st);
 986   // Print current stack trace for checked JNI warnings and JNI fatal errors.
 987   // This is the external format from above, but selecting the platform
 988   // or vthread as applicable.
 989   void print_jni_stack();
 990 
 991   void print_native_stack_on(outputStream* st);
 992 
 993   // Print stack traces in various internal formats
 994   void trace_stack()                             PRODUCT_RETURN;
 995   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
 996   void trace_frames()                            PRODUCT_RETURN;
 997 
 998   // Print an annotated view of the stack frames
 999   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
1000   void validate_frame_layout() {
1001     print_frame_layout(0, true);
1002   }
1003 
1004   // Function for testing deoptimization
1005   void deoptimize();
1006   void make_zombies();
1007 
1008   void deoptimize_marked_methods();
1009 
1010  public:
1011   // Returns the running thread as a JavaThread
1012   static JavaThread* current() {

1155 #include OS_CPU_HEADER(javaThread)
1156 
1157   // JSR166 per-thread parker
1158  private:
1159   Parker _parker;
1160  public:
1161   Parker* parker() { return &_parker; }
1162 
1163  public:
1164   // clearing/querying jni attach status
1165   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1166   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1167   inline void set_done_attaching_via_jni();
1168 
1169   // Stack dump assistance:
1170   // Track the class we want to initialize but for which we have to wait
1171   // on its init_lock() because it is already being initialized.
1172   void set_class_to_be_initialized(InstanceKlass* k);
1173   InstanceKlass* class_to_be_initialized() const;
1174 
1175   // The most recent active <clinit> invocation is tracked by this variable.
1176   // The setter returns the previous value, so it can be restored later if needed.
1177   InstanceKlass* set_class_being_initialized(InstanceKlass* k);
1178   InstanceKlass* class_being_initialized() const;
1179 
1180 private:
1181   InstanceKlass* _class_to_be_initialized;
1182   InstanceKlass* _class_being_initialized;
1183 
1184   // java.lang.Thread.sleep support
1185   ParkEvent * _SleepEvent;
1186 public:
1187   bool sleep(jlong millis);
1188   bool sleep_nanos(jlong nanos);
1189 
1190   // java.lang.Thread interruption support
1191   void interrupt();
1192   bool is_interrupted(bool clear_interrupted);
1193 
1194   // This is only for use by JVMTI RawMonitorWait. It emulates the actions of
1195   // the Java code in Object::wait which are not present in RawMonitorWait.
1196   bool get_and_clear_interrupted();
1197 
1198 private:
1199   LockStack _lock_stack;
1200   OMCache _om_cache;
1201 
1202 public:
< prev index next >