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