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