468 // JVMTI PopFrame support
469 // This is set to popframe_pending to signal that top Java frame should be popped immediately
470 int _popframe_condition;
471
472 // If reallocation of scalar replaced objects fails, we throw OOM
473 // and during exception propagation, pop the top
474 // _frames_to_pop_failed_realloc frames, the ones that reference
475 // failed reallocations.
476 int _frames_to_pop_failed_realloc;
477
478 ContinuationEntry* _cont_entry;
479 intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
480 // frame inside the continuation that we know about
481 int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
482
483 // It's signed for error detection.
484 intx _held_monitor_count; // used by continuations for fast lock detection
485 intx _jni_monitor_count;
486 ObjectMonitor* _unlocked_inflated_monitor;
487
488 // This is the field we poke in the interpreter and native
489 // wrapper (Object.wait) to check for preemption.
490 address _preempt_alternate_return;
491 // When preempting on monitorenter we could have acquired the
492 // monitor after freezing all vthread frames. In that case we
493 // set this field so that in the preempt stub we call thaw again
494 // instead of unmounting.
495 bool _preemption_cancelled;
496 // For Object.wait() we set this field to know if we need to
497 // throw IE at the end of thawing before returning to Java.
498 bool _pending_interrupted_exception;
499
500 public:
501 bool preemption_cancelled() { return _preemption_cancelled; }
502 void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
503
504 bool pending_interrupted_exception() { return _pending_interrupted_exception; }
505 void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
506
507 bool preempting() { return _preempt_alternate_return != nullptr; }
542 struct JNINativeInterface_* get_jni_functions() {
543 return (struct JNINativeInterface_ *)_jni_environment.functions;
544 }
545
546 // This function is called at thread creation to allow
547 // platform specific thread variables to be initialized.
548 void cache_global_variables();
549
550 // Executes Shutdown.shutdown()
551 void invoke_shutdown_hooks();
552
553 // Cleanup on thread exit
554 enum ExitType {
555 normal_exit,
556 jni_detach
557 };
558 void exit(bool destroy_vm, ExitType exit_type = normal_exit);
559
560 void cleanup_failed_attach_current_thread(bool is_daemon);
561
562 // Testers
563 virtual bool is_Java_thread() const { return true; }
564 virtual bool can_call_java() const { return true; }
565
566 virtual bool is_active_Java_thread() const;
567
568 // Thread oop. threadObj() can be null for initial JavaThread
569 // (or for threads attached via JNI)
570 oop threadObj() const;
571 void set_threadOopHandles(oop p);
572 oop vthread() const;
573 void set_vthread(oop p);
574 oop scopedValueCache() const;
575 void set_scopedValueCache(oop p);
576 void clear_scopedValueBindings();
577 oop jvmti_vthread() const;
578 void set_jvmti_vthread(oop p);
579 oop vthread_or_thread() const;
580
581 // Prepare thread and add to priority queue. If a priority is
582 // not specified, use the priority of the thread object. Threads_lock
583 // must be held while this function is called.
584 void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
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 // Track executing class initializer, see ThreadInClassInitializer
1232 void set_class_being_initialized(InstanceKlass* k);
1233 InstanceKlass* class_being_initialized() const;
1234
1235 private:
1236 InstanceKlass* _class_to_be_initialized;
1237 InstanceKlass* _class_being_initialized;
1238
1239 // java.lang.Thread.sleep support
1240 ParkEvent * _SleepEvent;
1241
1242 #if INCLUDE_JFR
1243 // Support for jdk.VirtualThreadPinned event
1244 freeze_result _last_freeze_fail_result;
1245 Ticks _last_freeze_fail_time;
1246 #endif
1247
1248 public:
1249 bool sleep(jlong millis);
1250 bool sleep_nanos(jlong nanos);
1251
1252 // java.lang.Thread interruption support
|
468 // JVMTI PopFrame support
469 // This is set to popframe_pending to signal that top Java frame should be popped immediately
470 int _popframe_condition;
471
472 // If reallocation of scalar replaced objects fails, we throw OOM
473 // and during exception propagation, pop the top
474 // _frames_to_pop_failed_realloc frames, the ones that reference
475 // failed reallocations.
476 int _frames_to_pop_failed_realloc;
477
478 ContinuationEntry* _cont_entry;
479 intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
480 // frame inside the continuation that we know about
481 int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
482
483 // It's signed for error detection.
484 intx _held_monitor_count; // used by continuations for fast lock detection
485 intx _jni_monitor_count;
486 ObjectMonitor* _unlocked_inflated_monitor;
487
488 bool _can_call_java;
489
490 // This is the field we poke in the interpreter and native
491 // wrapper (Object.wait) to check for preemption.
492 address _preempt_alternate_return;
493 // When preempting on monitorenter we could have acquired the
494 // monitor after freezing all vthread frames. In that case we
495 // set this field so that in the preempt stub we call thaw again
496 // instead of unmounting.
497 bool _preemption_cancelled;
498 // For Object.wait() we set this field to know if we need to
499 // throw IE at the end of thawing before returning to Java.
500 bool _pending_interrupted_exception;
501
502 public:
503 bool preemption_cancelled() { return _preemption_cancelled; }
504 void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
505
506 bool pending_interrupted_exception() { return _pending_interrupted_exception; }
507 void set_pending_interrupted_exception(bool b) { _pending_interrupted_exception = b; }
508
509 bool preempting() { return _preempt_alternate_return != nullptr; }
544 struct JNINativeInterface_* get_jni_functions() {
545 return (struct JNINativeInterface_ *)_jni_environment.functions;
546 }
547
548 // This function is called at thread creation to allow
549 // platform specific thread variables to be initialized.
550 void cache_global_variables();
551
552 // Executes Shutdown.shutdown()
553 void invoke_shutdown_hooks();
554
555 // Cleanup on thread exit
556 enum ExitType {
557 normal_exit,
558 jni_detach
559 };
560 void exit(bool destroy_vm, ExitType exit_type = normal_exit);
561
562 void cleanup_failed_attach_current_thread(bool is_daemon);
563
564 class NoJavaCodeMark : public StackObj {
565 friend JavaThread;
566 JavaThread* _target;
567 bool _orig;
568 public:
569 NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
570 _target->_can_call_java = false;
571 }
572 ~NoJavaCodeMark() {
573 _target->_can_call_java = _orig;
574 }
575 };
576
577 // Testers
578 virtual bool is_Java_thread() const { return true; }
579 virtual bool can_call_java() const { return _can_call_java; }
580
581 virtual bool is_active_Java_thread() const;
582
583 // Thread oop. threadObj() can be null for initial JavaThread
584 // (or for threads attached via JNI)
585 oop threadObj() const;
586 void set_threadOopHandles(oop p);
587 oop vthread() const;
588 void set_vthread(oop p);
589 oop scopedValueCache() const;
590 void set_scopedValueCache(oop p);
591 void clear_scopedValueBindings();
592 oop jvmti_vthread() const;
593 void set_jvmti_vthread(oop p);
594 oop vthread_or_thread() const;
595
596 // Prepare thread and add to priority queue. If a priority is
597 // not specified, use the priority of the thread object. Threads_lock
598 // must be held while this function is called.
599 void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1226 #include OS_CPU_HEADER(javaThread)
1227
1228 // JSR166 per-thread parker
1229 private:
1230 Parker _parker;
1231 public:
1232 Parker* parker() { return &_parker; }
1233
1234 public:
1235 // clearing/querying jni attach status
1236 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1237 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1238 inline void set_done_attaching_via_jni();
1239
1240 // Stack dump assistance:
1241 // Track the class we want to initialize but for which we have to wait
1242 // on its init_lock() because it is already being initialized.
1243 void set_class_to_be_initialized(InstanceKlass* k);
1244 InstanceKlass* class_to_be_initialized() const;
1245
1246 // The most recent active <clinit> invocation is tracked by this variable.
1247 // The setter returns the previous value, so it can be restored later if needed.
1248 InstanceKlass* 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
|