454 // For deadlock detection.
455 int _depth_first_number;
456
457 // JVMTI PopFrame support
458 // This is set to popframe_pending to signal that top Java frame should be popped immediately
459 int _popframe_condition;
460
461 // If reallocation of scalar replaced objects fails, we throw OOM
462 // and during exception propagation, pop the top
463 // _frames_to_pop_failed_realloc frames, the ones that reference
464 // failed reallocations.
465 int _frames_to_pop_failed_realloc;
466
467 ContinuationEntry* _cont_entry;
468 intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
469 // frame inside the continuation that we know about
470 int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
471
472 ObjectMonitor* _unlocked_inflated_monitor;
473
474 // This is the field we poke in the interpreter and native
475 // wrapper (Object.wait) to check for preemption.
476 address _preempt_alternate_return;
477 // When preempting on monitorenter we could have acquired the
478 // monitor after freezing all vthread frames. In that case we
479 // set this field so that in the preempt stub we call thaw again
480 // instead of unmounting.
481 bool _preemption_cancelled;
482 // For Object.wait() we set this field to know if we need to
483 // throw IE at the end of thawing before returning to Java.
484 bool _pending_interrupted_exception;
485 // We allow preemption on some klass initialization calls.
486 // We use this boolean to mark such calls.
487 bool _at_preemptable_init;
488
489 public:
490 bool preemption_cancelled() { return _preemption_cancelled; }
491 void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
492
493 bool pending_interrupted_exception() { return _pending_interrupted_exception; }
566 struct JNINativeInterface_* get_jni_functions() {
567 return (struct JNINativeInterface_ *)_jni_environment.functions;
568 }
569
570 // This function is called at thread creation to allow
571 // platform specific thread variables to be initialized.
572 void cache_global_variables();
573
574 // Executes Shutdown.shutdown()
575 void invoke_shutdown_hooks();
576
577 // Cleanup on thread exit
578 enum ExitType {
579 normal_exit,
580 jni_detach
581 };
582 void exit(bool destroy_vm, ExitType exit_type = normal_exit);
583
584 void cleanup_failed_attach_current_thread(bool is_daemon);
585
586 // Testers
587 virtual bool is_Java_thread() const { return true; }
588 virtual bool can_call_java() const { return true; }
589
590 virtual bool is_active_Java_thread() const;
591
592 // Thread oop. threadObj() can be null for initial JavaThread
593 // (or for threads attached via JNI)
594 oop threadObj() const;
595 void set_threadOopHandles(oop p);
596 oop vthread() const;
597 void set_vthread(oop p);
598 oop scopedValueCache() const;
599 void set_scopedValueCache(oop p);
600 void clear_scopedValueBindings();
601 oop jvmti_vthread() const;
602 void set_jvmti_vthread(oop p);
603 oop vthread_or_thread() const;
604
605 // Prepare thread and add to priority queue. If a priority is
606 // not specified, use the priority of the thread object. Threads_lock
607 // must be held while this function is called.
608 void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1233 #include OS_CPU_HEADER(javaThread)
1234
1235 // JSR166 per-thread parker
1236 private:
1237 Parker _parker;
1238 public:
1239 Parker* parker() { return &_parker; }
1240
1241 public:
1242 // clearing/querying jni attach status
1243 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1244 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1245 inline void set_done_attaching_via_jni();
1246
1247 // Stack dump assistance:
1248 // Track the class we want to initialize but for which we have to wait
1249 // on its init_lock() because it is already being initialized.
1250 void set_class_to_be_initialized(InstanceKlass* k);
1251 InstanceKlass* class_to_be_initialized() const;
1252
1253 // Track executing class initializer, see ThreadInClassInitializer
1254 void set_class_being_initialized(InstanceKlass* k);
1255 InstanceKlass* class_being_initialized() const;
1256
1257 private:
1258 InstanceKlass* _class_to_be_initialized;
1259 InstanceKlass* _class_being_initialized;
1260
1261 // java.lang.Thread.sleep support
1262 ParkEvent * _SleepEvent;
1263
1264 #if INCLUDE_JFR
1265 // Support for jdk.VirtualThreadPinned event
1266 freeze_result _last_freeze_fail_result;
1267 Ticks _last_freeze_fail_time;
1268 #endif
1269
1270 public:
1271 bool sleep(jlong millis);
1272 bool sleep_nanos(jlong nanos);
1273
1274 // java.lang.Thread interruption support
|
454 // For deadlock detection.
455 int _depth_first_number;
456
457 // JVMTI PopFrame support
458 // This is set to popframe_pending to signal that top Java frame should be popped immediately
459 int _popframe_condition;
460
461 // If reallocation of scalar replaced objects fails, we throw OOM
462 // and during exception propagation, pop the top
463 // _frames_to_pop_failed_realloc frames, the ones that reference
464 // failed reallocations.
465 int _frames_to_pop_failed_realloc;
466
467 ContinuationEntry* _cont_entry;
468 intptr_t* _cont_fastpath; // the sp of the oldest known interpreted/call_stub/upcall_stub/native_wrapper
469 // frame inside the continuation that we know about
470 int _cont_fastpath_thread_state; // whether global thread state allows continuation fastpath (JVMTI)
471
472 ObjectMonitor* _unlocked_inflated_monitor;
473
474 bool _can_call_java;
475
476 // This is the field we poke in the interpreter and native
477 // wrapper (Object.wait) to check for preemption.
478 address _preempt_alternate_return;
479 // When preempting on monitorenter we could have acquired the
480 // monitor after freezing all vthread frames. In that case we
481 // set this field so that in the preempt stub we call thaw again
482 // instead of unmounting.
483 bool _preemption_cancelled;
484 // For Object.wait() we set this field to know if we need to
485 // throw IE at the end of thawing before returning to Java.
486 bool _pending_interrupted_exception;
487 // We allow preemption on some klass initialization calls.
488 // We use this boolean to mark such calls.
489 bool _at_preemptable_init;
490
491 public:
492 bool preemption_cancelled() { return _preemption_cancelled; }
493 void set_preemption_cancelled(bool b) { _preemption_cancelled = b; }
494
495 bool pending_interrupted_exception() { return _pending_interrupted_exception; }
568 struct JNINativeInterface_* get_jni_functions() {
569 return (struct JNINativeInterface_ *)_jni_environment.functions;
570 }
571
572 // This function is called at thread creation to allow
573 // platform specific thread variables to be initialized.
574 void cache_global_variables();
575
576 // Executes Shutdown.shutdown()
577 void invoke_shutdown_hooks();
578
579 // Cleanup on thread exit
580 enum ExitType {
581 normal_exit,
582 jni_detach
583 };
584 void exit(bool destroy_vm, ExitType exit_type = normal_exit);
585
586 void cleanup_failed_attach_current_thread(bool is_daemon);
587
588 class NoJavaCodeMark : public StackObj {
589 friend JavaThread;
590 JavaThread* _target;
591 bool _orig;
592 public:
593 NoJavaCodeMark(JavaThread* t) : _target(t), _orig(t->_can_call_java) {
594 _target->_can_call_java = false;
595 }
596 ~NoJavaCodeMark() {
597 _target->_can_call_java = _orig;
598 }
599 };
600
601 // Testers
602 virtual bool is_Java_thread() const { return true; }
603 virtual bool can_call_java() const { return _can_call_java; }
604
605 virtual bool is_active_Java_thread() const;
606
607 // Thread oop. threadObj() can be null for initial JavaThread
608 // (or for threads attached via JNI)
609 oop threadObj() const;
610 void set_threadOopHandles(oop p);
611 oop vthread() const;
612 void set_vthread(oop p);
613 oop scopedValueCache() const;
614 void set_scopedValueCache(oop p);
615 void clear_scopedValueBindings();
616 oop jvmti_vthread() const;
617 void set_jvmti_vthread(oop p);
618 oop vthread_or_thread() const;
619
620 // Prepare thread and add to priority queue. If a priority is
621 // not specified, use the priority of the thread object. Threads_lock
622 // must be held while this function is called.
623 void prepare(jobject jni_thread, ThreadPriority prio=NoPriority);
1248 #include OS_CPU_HEADER(javaThread)
1249
1250 // JSR166 per-thread parker
1251 private:
1252 Parker _parker;
1253 public:
1254 Parker* parker() { return &_parker; }
1255
1256 public:
1257 // clearing/querying jni attach status
1258 bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
1259 bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
1260 inline void set_done_attaching_via_jni();
1261
1262 // Stack dump assistance:
1263 // Track the class we want to initialize but for which we have to wait
1264 // on its init_lock() because it is already being initialized.
1265 void set_class_to_be_initialized(InstanceKlass* k);
1266 InstanceKlass* class_to_be_initialized() const;
1267
1268 // The most recent active <clinit> invocation is tracked by this variable.
1269 // The setter returns the previous value, so it can be restored later if needed.
1270 InstanceKlass* set_class_being_initialized(InstanceKlass* k);
1271 InstanceKlass* class_being_initialized() const;
1272
1273 private:
1274 InstanceKlass* _class_to_be_initialized;
1275 InstanceKlass* _class_being_initialized;
1276
1277 // java.lang.Thread.sleep support
1278 ParkEvent * _SleepEvent;
1279
1280 #if INCLUDE_JFR
1281 // Support for jdk.VirtualThreadPinned event
1282 freeze_result _last_freeze_fail_result;
1283 Ticks _last_freeze_fail_time;
1284 #endif
1285
1286 public:
1287 bool sleep(jlong millis);
1288 bool sleep_nanos(jlong nanos);
1289
1290 // java.lang.Thread interruption support
|