< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

 463   // JVMTI PopFrame support
 464   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 465   int _popframe_condition;
 466 
 467   // If reallocation of scalar replaced objects fails, we throw OOM
 468   // and during exception propagation, pop the top
 469   // _frames_to_pop_failed_realloc frames, the ones that reference
 470   // failed reallocations.
 471   int _frames_to_pop_failed_realloc;
 472 
 473   ContinuationEntry* _cont_entry;
 474   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
 475                             // frame inside the continuation that we know about
 476   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 477 
 478   // It's signed for error detection.
 479   intx _held_monitor_count;  // used by continuations for fast lock detection
 480   intx _jni_monitor_count;
 481   ObjectMonitor* _unlocked_inflated_monitor;
 482 


 483   // This is the field we poke in the interpreter and native
 484   // wrapper (Object.wait) to check for preemption.
 485   address _preempt_alternate_return;
 486   // When preempting on monitorenter we could have acquired the
 487   // monitor after freezing all vthread frames. In that case we
 488   // set this field so that in the preempt stub we call thaw again
 489   // instead of unmounting.
 490   bool _preemption_cancelled;
 491   // For Object.wait() we set this field to know if we need to
 492   // throw IE at the end of thawing before returning to Java.
 493   bool _pending_interrupted_exception;
 494 
 495  public:
 496   bool preemption_cancelled()           { return _preemption_cancelled; }
 497   void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
 498 
 499   bool pending_interrupted_exception()           { return _pending_interrupted_exception; }
 500   void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
 501 
 502   bool preempting()           { return _preempt_alternate_return != nullptr; }

 537   struct JNINativeInterface_* get_jni_functions() {
 538     return (struct JNINativeInterface_ *)_jni_environment.functions;
 539   }
 540 
 541   // This function is called at thread creation to allow
 542   // platform specific thread variables to be initialized.
 543   void cache_global_variables();
 544 
 545   // Executes Shutdown.shutdown()
 546   void invoke_shutdown_hooks();
 547 
 548   // Cleanup on thread exit
 549   enum ExitType {
 550     normal_exit,
 551     jni_detach
 552   };
 553   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 554 
 555   void cleanup_failed_attach_current_thread(bool is_daemon);
 556 













 557   // Testers
 558   virtual bool is_Java_thread() const            { return true;  }
 559   virtual bool can_call_java() const             { return true; }
 560 
 561   virtual bool is_active_Java_thread() const;
 562 
 563   // Thread oop. threadObj() can be null for initial JavaThread
 564   // (or for threads attached via JNI)
 565   oop threadObj() const;
 566   void set_threadOopHandles(oop p);
 567   oop vthread() const;
 568   void set_vthread(oop p);
 569   oop scopedValueCache() const;
 570   void set_scopedValueCache(oop p);
 571   void clear_scopedValueBindings();
 572   oop jvmti_vthread() const;
 573   void set_jvmti_vthread(oop p);
 574   oop vthread_or_thread() const;
 575 
 576   // Prepare thread and add to priority queue.  If a priority is
 577   // not specified, use the priority of the thread object. Threads_lock
 578   // must be held while this function is called.
 579   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

1012 
1013   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
1014 
1015   // Returns method at 'depth' java or native frames down the stack
1016   // Used for security checks
1017   Klass* security_get_caller_class(int depth);
1018 
1019   // Print stack trace in external format
1020   // These variants print carrier/platform thread information only.
1021   void print_stack_on(outputStream* st);
1022   void print_stack() { print_stack_on(tty); }
1023   // This prints the currently mounted virtual thread.
1024   void print_vthread_stack_on(outputStream* st);
1025   // This prints the active stack: either carrier/platform or virtual.
1026   void print_active_stack_on(outputStream* st);
1027   // Print current stack trace for checked JNI warnings and JNI fatal errors.
1028   // This is the external format from above, but selecting the platform
1029   // or vthread as applicable.
1030   void print_jni_stack();
1031 


1032   // Print stack traces in various internal formats
1033   void trace_stack()                             PRODUCT_RETURN;
1034   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
1035   void trace_frames()                            PRODUCT_RETURN;
1036 
1037   // Print an annotated view of the stack frames
1038   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
1039   void validate_frame_layout() {
1040     print_frame_layout(0, true);
1041   }
1042 
1043   // Function for testing deoptimization
1044   void deoptimize();
1045   void make_zombies();
1046 
1047   void deoptimize_marked_methods();
1048 
1049  public:
1050   // Returns the running thread as a JavaThread
1051   static JavaThread* current() {

1194 #include OS_CPU_HEADER(javaThread)
1195 
1196   // JSR166 per-thread parker
1197  private:
1198   Parker _parker;
1199  public:
1200   Parker* parker() { return &_parker; }
1201 
1202  public:
1203   // clearing/querying jni attach status
1204   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1205   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1206   inline void set_done_attaching_via_jni();
1207 
1208   // Stack dump assistance:
1209   // Track the class we want to initialize but for which we have to wait
1210   // on its init_lock() because it is already being initialized.
1211   void set_class_to_be_initialized(InstanceKlass* k);
1212   InstanceKlass* class_to_be_initialized() const;
1213 
1214   // Track executing class initializer, see ThreadInClassInitializer
1215   void set_class_being_initialized(InstanceKlass* k);

1216   InstanceKlass* class_being_initialized() const;
1217 
1218 private:
1219   InstanceKlass* _class_to_be_initialized;
1220   InstanceKlass* _class_being_initialized;
1221 
1222   // java.lang.Thread.sleep support
1223   ParkEvent * _SleepEvent;
1224 
1225 #if INCLUDE_JFR
1226   // Support for jdk.VirtualThreadPinned event
1227   freeze_result _last_freeze_fail_result;
1228   Ticks _last_freeze_fail_time;
1229 #endif
1230 
1231 public:
1232   bool sleep(jlong millis);
1233   bool sleep_nanos(jlong nanos);
1234 
1235   // java.lang.Thread interruption support

 463   // JVMTI PopFrame support
 464   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 465   int _popframe_condition;
 466 
 467   // If reallocation of scalar replaced objects fails, we throw OOM
 468   // and during exception propagation, pop the top
 469   // _frames_to_pop_failed_realloc frames, the ones that reference
 470   // failed reallocations.
 471   int _frames_to_pop_failed_realloc;
 472 
 473   ContinuationEntry* _cont_entry;
 474   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
 475                             // frame inside the continuation that we know about
 476   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 477 
 478   // It's signed for error detection.
 479   intx _held_monitor_count;  // used by continuations for fast lock detection
 480   intx _jni_monitor_count;
 481   ObjectMonitor* _unlocked_inflated_monitor;
 482 
 483   bool _can_call_java;
 484 
 485   // This is the field we poke in the interpreter and native
 486   // wrapper (Object.wait) to check for preemption.
 487   address _preempt_alternate_return;
 488   // When preempting on monitorenter we could have acquired the
 489   // monitor after freezing all vthread frames. In that case we
 490   // set this field so that in the preempt stub we call thaw again
 491   // instead of unmounting.
 492   bool _preemption_cancelled;
 493   // For Object.wait() we set this field to know if we need to
 494   // throw IE at the end of thawing before returning to Java.
 495   bool _pending_interrupted_exception;
 496 
 497  public:
 498   bool preemption_cancelled()           { return _preemption_cancelled; }
 499   void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
 500 
 501   bool pending_interrupted_exception()           { return _pending_interrupted_exception; }
 502   void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
 503 
 504   bool preempting()           { return _preempt_alternate_return != nullptr; }

 539   struct JNINativeInterface_* get_jni_functions() {
 540     return (struct JNINativeInterface_ *)_jni_environment.functions;
 541   }
 542 
 543   // This function is called at thread creation to allow
 544   // platform specific thread variables to be initialized.
 545   void cache_global_variables();
 546 
 547   // Executes Shutdown.shutdown()
 548   void invoke_shutdown_hooks();
 549 
 550   // Cleanup on thread exit
 551   enum ExitType {
 552     normal_exit,
 553     jni_detach
 554   };
 555   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 556 
 557   void cleanup_failed_attach_current_thread(bool is_daemon);
 558 
 559   class NoJavaCodeMark : public StackObj {
 560     friend JavaThread;
 561     JavaThread* _target;
 562     bool _orig;
 563    public:
 564     NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
 565       _target->_can_call_java = false;
 566     }
 567     ~NoJavaCodeMark() {
 568       _target->_can_call_java = _orig;
 569     }
 570   };
 571 
 572   // Testers
 573   virtual bool is_Java_thread() const            { return true;  }
 574   virtual bool can_call_java() const             { return _can_call_java; }
 575 
 576   virtual bool is_active_Java_thread() const;
 577 
 578   // Thread oop. threadObj() can be null for initial JavaThread
 579   // (or for threads attached via JNI)
 580   oop threadObj() const;
 581   void set_threadOopHandles(oop p);
 582   oop vthread() const;
 583   void set_vthread(oop p);
 584   oop scopedValueCache() const;
 585   void set_scopedValueCache(oop p);
 586   void clear_scopedValueBindings();
 587   oop jvmti_vthread() const;
 588   void set_jvmti_vthread(oop p);
 589   oop vthread_or_thread() const;
 590 
 591   // Prepare thread and add to priority queue.  If a priority is
 592   // not specified, use the priority of the thread object. Threads_lock
 593   // must be held while this function is called.
 594   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

1027 
1028   javaVFrame* last_java_vframe(const frame f, RegisterMap* reg_map);
1029 
1030   // Returns method at 'depth' java or native frames down the stack
1031   // Used for security checks
1032   Klass* security_get_caller_class(int depth);
1033 
1034   // Print stack trace in external format
1035   // These variants print carrier/platform thread information only.
1036   void print_stack_on(outputStream* st);
1037   void print_stack() { print_stack_on(tty); }
1038   // This prints the currently mounted virtual thread.
1039   void print_vthread_stack_on(outputStream* st);
1040   // This prints the active stack: either carrier/platform or virtual.
1041   void print_active_stack_on(outputStream* st);
1042   // Print current stack trace for checked JNI warnings and JNI fatal errors.
1043   // This is the external format from above, but selecting the platform
1044   // or vthread as applicable.
1045   void print_jni_stack();
1046 
1047   void print_native_stack_on(outputStream* st);
1048 
1049   // Print stack traces in various internal formats
1050   void trace_stack()                             PRODUCT_RETURN;
1051   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
1052   void trace_frames()                            PRODUCT_RETURN;
1053 
1054   // Print an annotated view of the stack frames
1055   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
1056   void validate_frame_layout() {
1057     print_frame_layout(0, true);
1058   }
1059 
1060   // Function for testing deoptimization
1061   void deoptimize();
1062   void make_zombies();
1063 
1064   void deoptimize_marked_methods();
1065 
1066  public:
1067   // Returns the running thread as a JavaThread
1068   static JavaThread* current() {

1211 #include OS_CPU_HEADER(javaThread)
1212 
1213   // JSR166 per-thread parker
1214  private:
1215   Parker _parker;
1216  public:
1217   Parker* parker() { return &_parker; }
1218 
1219  public:
1220   // clearing/querying jni attach status
1221   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1222   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1223   inline void set_done_attaching_via_jni();
1224 
1225   // Stack dump assistance:
1226   // Track the class we want to initialize but for which we have to wait
1227   // on its init_lock() because it is already being initialized.
1228   void set_class_to_be_initialized(InstanceKlass* k);
1229   InstanceKlass* class_to_be_initialized() const;
1230 
1231   // The most recent active <clinit> invocation is tracked by this variable.
1232   // The setter returns the previous value, so it can be restored later if needed.
1233   InstanceKlass* set_class_being_initialized(InstanceKlass* k);
1234   InstanceKlass* class_being_initialized() const;
1235 
1236 private:
1237   InstanceKlass* _class_to_be_initialized;
1238   InstanceKlass* _class_being_initialized;
1239 
1240   // java.lang.Thread.sleep support
1241   ParkEvent * _SleepEvent;
1242 
1243 #if INCLUDE_JFR
1244   // Support for jdk.VirtualThreadPinned event
1245   freeze_result _last_freeze_fail_result;
1246   Ticks _last_freeze_fail_time;
1247 #endif
1248 
1249 public:
1250   bool sleep(jlong millis);
1251   bool sleep_nanos(jlong nanos);
1252 
1253   // java.lang.Thread interruption support
< prev index next >