< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

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


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

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













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

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


 967   // Print stack traces in various internal formats
 968   void trace_stack()                             PRODUCT_RETURN;
 969   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
 970   void trace_frames()                            PRODUCT_RETURN;
 971 
 972   // Print an annotated view of the stack frames
 973   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
 974   void validate_frame_layout() {
 975     print_frame_layout(0, true);
 976   }
 977 
 978   // Function for testing deoptimization
 979   void deoptimize();
 980   void make_zombies();
 981 
 982   void deoptimize_marked_methods();
 983 
 984  public:
 985   // Returns the running thread as a JavaThread
 986   static JavaThread* current() {

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





1149 private:
1150   InstanceKlass* _class_to_be_initialized;

1151 
1152   // java.lang.Thread.sleep support
1153   ParkEvent * _SleepEvent;
1154 public:
1155   bool sleep(jlong millis);
1156   bool sleep_nanos(jlong nanos);
1157 
1158   // java.lang.Thread interruption support
1159   void interrupt();
1160   bool is_interrupted(bool clear_interrupted);
1161 
1162   // This is only for use by JVMTI RawMonitorWait. It emulates the actions of
1163   // the Java code in Object::wait which are not present in RawMonitorWait.
1164   bool get_and_clear_interrupted();
1165 
1166 private:
1167   LockStack _lock_stack;
1168 
1169 public:
1170   LockStack& lock_stack() { return _lock_stack; }

 447 
 448   // JVMTI PopFrame support
 449   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 450   int _popframe_condition;
 451 
 452   // If reallocation of scalar replaced objects fails, we throw OOM
 453   // and during exception propagation, pop the top
 454   // _frames_to_pop_failed_realloc frames, the ones that reference
 455   // failed reallocations.
 456   int _frames_to_pop_failed_realloc;
 457 
 458   ContinuationEntry* _cont_entry;
 459   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub frame inside the
 460                             // continuation that we know about
 461   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 462 
 463   // It's signed for error detection.
 464   intx _held_monitor_count;  // used by continuations for fast lock detection
 465   intx _jni_monitor_count;
 466 
 467   bool _can_call_java;
 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(MEMFLAGS flags = mtThread);   // delegating constructor
 484   JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MEMFLAGS flags = 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   class NoJavaCodeMark : public StackObj {
 522     friend JavaThread;
 523     JavaThread* _target;
 524     bool _orig;
 525    public:
 526     NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
 527       _target->_can_call_java = false;
 528     }
 529     ~NoJavaCodeMark() {
 530       _target->_can_call_java = _orig;
 531     }
 532   };
 533 
 534   // Testers
 535   virtual bool is_Java_thread() const            { return true;  }
 536   virtual bool can_call_java() const             { return _can_call_java; }
 537 
 538   virtual bool is_active_Java_thread() const;
 539 
 540   // Thread oop. threadObj() can be null for initial JavaThread
 541   // (or for threads attached via JNI)
 542   oop threadObj() const;
 543   void set_threadOopHandles(oop p);
 544   oop vthread() const;
 545   void set_vthread(oop p);
 546   oop scopedValueCache() const;
 547   void set_scopedValueCache(oop p);
 548   void clear_scopedValueBindings();
 549   oop jvmti_vthread() const;
 550   void set_jvmti_vthread(oop p);
 551   oop vthread_or_thread() const;
 552 
 553   // Prepare thread and add to priority queue.  If a priority is
 554   // not specified, use the priority of the thread object. Threads_lock
 555   // must be held while this function is called.
 556   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

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

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