< prev index next >

src/hotspot/share/runtime/javaThread.hpp

Print this page

 457   // For deadlock detection.
 458   int _depth_first_number;
 459 
 460   // JVMTI PopFrame support
 461   // This is set to popframe_pending to signal that top Java frame should be popped immediately
 462   int _popframe_condition;
 463 
 464   // If reallocation of scalar replaced objects fails, we throw OOM
 465   // and during exception propagation, pop the top
 466   // _frames_to_pop_failed_realloc frames, the ones that reference
 467   // failed reallocations.
 468   int _frames_to_pop_failed_realloc;
 469 
 470   ContinuationEntry* _cont_entry;
 471   intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
 472                             // frame inside the continuation that we know about
 473   int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
 474 
 475   ObjectMonitor* _unlocked_inflated_monitor;
 476 


 477   // This is the field we poke in the interpreter and native
 478   // wrapper (Object.wait) to check for preemption.
 479   address _preempt_alternate_return;
 480   // When preempting on monitorenter we could have acquired the
 481   // monitor after freezing all vthread frames. In that case we
 482   // set this field so that in the preempt stub we call thaw again
 483   // instead of unmounting.
 484   bool _preemption_cancelled;
 485   // For Object.wait() we set this field to know if we need to
 486   // throw IE at the end of thawing before returning to Java.
 487   bool _pending_interrupted_exception;
 488   // We allow preemption on some klass initialization calls.
 489   // We use this boolean to mark such calls.
 490   bool _at_preemptable_init;
 491 
 492  public:
 493   bool preemption_cancelled()           { return _preemption_cancelled; }
 494   void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
 495 
 496   bool pending_interrupted_exception()           { return _pending_interrupted_exception; }

 569   struct JNINativeInterface_* get_jni_functions() {
 570     return (struct JNINativeInterface_ *)_jni_environment.functions;
 571   }
 572 
 573   // This function is called at thread creation to allow
 574   // platform specific thread variables to be initialized.
 575   void cache_global_variables();
 576 
 577   // Executes Shutdown.shutdown()
 578   void invoke_shutdown_hooks();
 579 
 580   // Cleanup on thread exit
 581   enum ExitType {
 582     normal_exit,
 583     jni_detach
 584   };
 585   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 586 
 587   void cleanup_failed_attach_current_thread(bool is_daemon);
 588 













 589   // Testers
 590   virtual bool is_Java_thread() const            { return true;  }
 591   virtual bool can_call_java() const             { return true; }
 592 
 593   virtual bool is_active_Java_thread() const;
 594 
 595   // Thread oop. threadObj() can be null for initial JavaThread
 596   // (or for threads attached via JNI)
 597   oop threadObj() const;
 598   void set_threadOopHandles(oop p);
 599   oop vthread() const;
 600   void set_vthread(oop p);
 601   oop scopedValueCache() const;
 602   void set_scopedValueCache(oop p);
 603   void clear_scopedValueBindings();
 604   oop jvmti_vthread() const;
 605   void set_jvmti_vthread(oop p);
 606   oop vthread_or_thread() const;
 607 
 608   // Prepare thread and add to priority queue.  If a priority is
 609   // not specified, use the priority of the thread object. Threads_lock
 610   // must be held while this function is called.
 611   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

1227 #include OS_CPU_HEADER(javaThread)
1228 
1229   // JSR166 per-thread parker
1230  private:
1231   Parker _parker;
1232  public:
1233   Parker* parker() { return &_parker; }
1234 
1235  public:
1236   // clearing/querying jni attach status
1237   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1238   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1239   inline void set_done_attaching_via_jni();
1240 
1241   // Stack dump assistance:
1242   // Track the class we want to initialize but for which we have to wait
1243   // on its init_lock() because it is already being initialized.
1244   void set_class_to_be_initialized(InstanceKlass* k);
1245   InstanceKlass* class_to_be_initialized() const;
1246 
1247   // Track executing class initializer, see ThreadInClassInitializer
1248   void set_class_being_initialized(InstanceKlass* k);

1249   InstanceKlass* class_being_initialized() const;
1250 
1251 private:
1252   InstanceKlass* _class_to_be_initialized;
1253   InstanceKlass* _class_being_initialized;
1254 
1255   // java.lang.Thread.sleep support
1256   ParkEvent * _SleepEvent;
1257 
1258 #if INCLUDE_JFR
1259   // Support for jdk.VirtualThreadPinned event
1260   freeze_result _last_freeze_fail_result;
1261   Ticks _last_freeze_fail_time;
1262 #endif
1263 
1264 public:
1265   bool sleep(jlong millis);
1266   bool sleep_nanos(jlong nanos);
1267 
1268   // java.lang.Thread interruption support

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

 571   struct JNINativeInterface_* get_jni_functions() {
 572     return (struct JNINativeInterface_ *)_jni_environment.functions;
 573   }
 574 
 575   // This function is called at thread creation to allow
 576   // platform specific thread variables to be initialized.
 577   void cache_global_variables();
 578 
 579   // Executes Shutdown.shutdown()
 580   void invoke_shutdown_hooks();
 581 
 582   // Cleanup on thread exit
 583   enum ExitType {
 584     normal_exit,
 585     jni_detach
 586   };
 587   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 588 
 589   void cleanup_failed_attach_current_thread(bool is_daemon);
 590 
 591   class NoJavaCodeMark : public StackObj {
 592     friend JavaThread;
 593     JavaThread* _target;
 594     bool _orig;
 595    public:
 596     NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
 597       _target->_can_call_java = false;
 598     }
 599     ~NoJavaCodeMark() {
 600       _target->_can_call_java = _orig;
 601     }
 602   };
 603 
 604   // Testers
 605   virtual bool is_Java_thread() const            { return true;  }
 606   virtual bool can_call_java() const             { return _can_call_java; }
 607 
 608   virtual bool is_active_Java_thread() const;
 609 
 610   // Thread oop. threadObj() can be null for initial JavaThread
 611   // (or for threads attached via JNI)
 612   oop threadObj() const;
 613   void set_threadOopHandles(oop p);
 614   oop vthread() const;
 615   void set_vthread(oop p);
 616   oop scopedValueCache() const;
 617   void set_scopedValueCache(oop p);
 618   void clear_scopedValueBindings();
 619   oop jvmti_vthread() const;
 620   void set_jvmti_vthread(oop p);
 621   oop vthread_or_thread() const;
 622 
 623   // Prepare thread and add to priority queue.  If a priority is
 624   // not specified, use the priority of the thread object. Threads_lock
 625   // must be held while this function is called.
 626   void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);

1242 #include OS_CPU_HEADER(javaThread)
1243 
1244   // JSR166 per-thread parker
1245  private:
1246   Parker _parker;
1247  public:
1248   Parker* parker() { return &_parker; }
1249 
1250  public:
1251   // clearing/querying jni attach status
1252   bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1253   bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1254   inline void set_done_attaching_via_jni();
1255 
1256   // Stack dump assistance:
1257   // Track the class we want to initialize but for which we have to wait
1258   // on its init_lock() because it is already being initialized.
1259   void set_class_to_be_initialized(InstanceKlass* k);
1260   InstanceKlass* class_to_be_initialized() const;
1261 
1262   // The most recent active <clinit> invocation is tracked by this variable.
1263   // The setter returns the previous value, so it can be restored later if needed.
1264   InstanceKlass* set_class_being_initialized(InstanceKlass* k);
1265   InstanceKlass* class_being_initialized() const;
1266 
1267 private:
1268   InstanceKlass* _class_to_be_initialized;
1269   InstanceKlass* _class_being_initialized;
1270 
1271   // java.lang.Thread.sleep support
1272   ParkEvent * _SleepEvent;
1273 
1274 #if INCLUDE_JFR
1275   // Support for jdk.VirtualThreadPinned event
1276   freeze_result _last_freeze_fail_result;
1277   Ticks _last_freeze_fail_time;
1278 #endif
1279 
1280 public:
1281   bool sleep(jlong millis);
1282   bool sleep_nanos(jlong nanos);
1283 
1284   // java.lang.Thread interruption support
< prev index next >