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