449 static void dec_VTMS_transition_disable_count(oop java_thread);
450 static bool is_in_VTMS_transition(oop java_thread);
451 static void set_is_in_VTMS_transition(oop java_thread, bool val);
452 static int is_in_VTMS_transition_offset();
453
454 // Clear all scoped value bindings on error
455 static void clear_scopedValueBindings(oop java_thread);
456
457 // Blocker object responsible for thread parking
458 static oop park_blocker(oop java_thread);
459
460 // Write thread status info to threadStatus field of java.lang.Thread.
461 static void set_thread_status(oop java_thread_oop, JavaThreadStatus status);
462 // Read thread status info from threadStatus field of java.lang.Thread.
463 static JavaThreadStatus get_thread_status(oop java_thread_oop);
464
465 static const char* thread_status_name(oop java_thread_oop);
466
467 // Fill in current stack trace, can cause GC
468 static oop async_get_stack_trace(jobject jthread, TRAPS);
469
470 JFR_ONLY(static u2 jfr_epoch(oop java_thread);)
471 JFR_ONLY(static void set_jfr_epoch(oop java_thread, u2 epoch);)
472 JFR_ONLY(static int jfr_epoch_offset() { CHECK_INIT(_jfr_epoch_offset); })
473
474 // Debugging
475 friend class JavaClasses;
476 };
477
478 // Interface to java.lang.Thread$FieldHolder objects
479
480 class java_lang_Thread_FieldHolder : AllStatic {
481 private:
482 static int _group_offset;
483 static int _priority_offset;
484 static int _stackSize_offset;
485 static int _daemon_offset;
486 static int _thread_status_offset;
487
488 static void compute_offsets();
533
534 static void compute_offsets();
535 public:
536 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
537
538 // parent ThreadGroup
539 static oop parent(oop java_thread_group);
540 // name
541 static const char* name(oop java_thread_group);
542 // maxPriority in group
543 static ThreadPriority maxPriority(oop java_thread_group);
544 // Daemon
545 static bool is_daemon(oop java_thread_group);
546
547 // Debugging
548 friend class JavaClasses;
549 };
550
551
552 // Interface to java.lang.VirtualThread objects
553 #define VTHREAD_INJECTED_FIELDS(macro) \
554 macro(java_lang_VirtualThread, objectWaiter, intptr_signature, false)
555
556 class java_lang_VirtualThread : AllStatic {
557 private:
558 static int static_vthread_scope_offset;
559 static int _carrierThread_offset;
560 static int _continuation_offset;
561 static int _state_offset;
562 static int _next_offset;
563 static int _onWaitingList_offset;
564 static int _notified_offset;
565 static int _recheckInterval_offset;
566 static int _timeout_offset;
567 static int _objectWaiter_offset;
568 JFR_ONLY(static int _jfr_epoch_offset;)
569 public:
570 enum {
571 NEW = 0,
572 STARTED = 1,
573 RUNNING = 2,
574 PARKING = 3,
575 PARKED = 4,
576 PINNED = 5,
577 TIMED_PARKING = 6,
578 TIMED_PARKED = 7,
579 TIMED_PINNED = 8,
580 UNPARKED = 9,
581 YIELDING = 10,
582 YIELDED = 11,
583 BLOCKING = 12,
584 BLOCKED = 13,
597 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
598
599 // Testers
600 static bool is_subclass(Klass* klass) {
601 return klass->is_subclass_of(vmClasses::VirtualThread_klass());
602 }
603 static bool is_instance(oop obj);
604
605 static oop vthread_scope();
606 static oop carrier_thread(oop vthread);
607 static oop continuation(oop vthread);
608 static int state(oop vthread);
609 static void set_state(oop vthread, int state);
610 static int cmpxchg_state(oop vthread, int old_state, int new_state);
611 static oop next(oop vthread);
612 static void set_next(oop vthread, oop next_vthread);
613 static bool set_onWaitingList(oop vthread, OopHandle& list_head);
614 static jlong timeout(oop vthread);
615 static void set_timeout(oop vthread, jlong value);
616 static void set_notified(oop vthread, jboolean value);
617 static bool is_preempted(oop vthread);
618 static JavaThreadStatus map_state_to_thread_status(int state);
619
620 static inline ObjectWaiter* objectWaiter(oop vthread);
621 static inline void set_objectWaiter(oop vthread, ObjectWaiter* waiter);
622 static ObjectMonitor* current_pending_monitor(oop vthread);
623 static ObjectMonitor* current_waiting_monitor(oop vthread);
624 };
625
626
627 // Interface to java.lang.Throwable objects
628
629 class java_lang_Throwable: AllStatic {
630 friend class BacktraceBuilder;
631 friend class BacktraceIterator;
632
633 private:
634 // Trace constants
635 enum {
636 trace_methods_offset = 0,
|
449 static void dec_VTMS_transition_disable_count(oop java_thread);
450 static bool is_in_VTMS_transition(oop java_thread);
451 static void set_is_in_VTMS_transition(oop java_thread, bool val);
452 static int is_in_VTMS_transition_offset();
453
454 // Clear all scoped value bindings on error
455 static void clear_scopedValueBindings(oop java_thread);
456
457 // Blocker object responsible for thread parking
458 static oop park_blocker(oop java_thread);
459
460 // Write thread status info to threadStatus field of java.lang.Thread.
461 static void set_thread_status(oop java_thread_oop, JavaThreadStatus status);
462 // Read thread status info from threadStatus field of java.lang.Thread.
463 static JavaThreadStatus get_thread_status(oop java_thread_oop);
464
465 static const char* thread_status_name(oop java_thread_oop);
466
467 // Fill in current stack trace, can cause GC
468 static oop async_get_stack_trace(jobject jthread, TRAPS);
469 static oop get_thread_snapshot(jobject jthread, TRAPS);
470
471 JFR_ONLY(static u2 jfr_epoch(oop java_thread);)
472 JFR_ONLY(static void set_jfr_epoch(oop java_thread, u2 epoch);)
473 JFR_ONLY(static int jfr_epoch_offset() { CHECK_INIT(_jfr_epoch_offset); })
474
475 // Debugging
476 friend class JavaClasses;
477 };
478
479 // Interface to java.lang.Thread$FieldHolder objects
480
481 class java_lang_Thread_FieldHolder : AllStatic {
482 private:
483 static int _group_offset;
484 static int _priority_offset;
485 static int _stackSize_offset;
486 static int _daemon_offset;
487 static int _thread_status_offset;
488
489 static void compute_offsets();
534
535 static void compute_offsets();
536 public:
537 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
538
539 // parent ThreadGroup
540 static oop parent(oop java_thread_group);
541 // name
542 static const char* name(oop java_thread_group);
543 // maxPriority in group
544 static ThreadPriority maxPriority(oop java_thread_group);
545 // Daemon
546 static bool is_daemon(oop java_thread_group);
547
548 // Debugging
549 friend class JavaClasses;
550 };
551
552
553 // Interface to java.lang.VirtualThread objects
554 #define VTHREAD_INJECTED_FIELDS(macro) \
555 macro(java_lang_VirtualThread, objectWaiter, intptr_signature, false) \
556
557 class java_lang_VirtualThread : AllStatic {
558 private:
559 static int static_vthread_scope_offset;
560 static int _carrierThread_offset;
561 static int _continuation_offset;
562 static int _state_offset;
563 static int _next_offset;
564 static int _onWaitingList_offset;
565 static int _notified_offset;
566 static int _interruptible_wait_offset;
567 static int _recheckInterval_offset;
568 static int _timeout_offset;
569 static int _objectWaiter_offset;
570 JFR_ONLY(static int _jfr_epoch_offset;)
571 public:
572 enum {
573 NEW = 0,
574 STARTED = 1,
575 RUNNING = 2,
576 PARKING = 3,
577 PARKED = 4,
578 PINNED = 5,
579 TIMED_PARKING = 6,
580 TIMED_PARKED = 7,
581 TIMED_PINNED = 8,
582 UNPARKED = 9,
583 YIELDING = 10,
584 YIELDED = 11,
585 BLOCKING = 12,
586 BLOCKED = 13,
599 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
600
601 // Testers
602 static bool is_subclass(Klass* klass) {
603 return klass->is_subclass_of(vmClasses::VirtualThread_klass());
604 }
605 static bool is_instance(oop obj);
606
607 static oop vthread_scope();
608 static oop carrier_thread(oop vthread);
609 static oop continuation(oop vthread);
610 static int state(oop vthread);
611 static void set_state(oop vthread, int state);
612 static int cmpxchg_state(oop vthread, int old_state, int new_state);
613 static oop next(oop vthread);
614 static void set_next(oop vthread, oop next_vthread);
615 static bool set_onWaitingList(oop vthread, OopHandle& list_head);
616 static jlong timeout(oop vthread);
617 static void set_timeout(oop vthread, jlong value);
618 static void set_notified(oop vthread, jboolean value);
619 static void set_interruptible_wait(oop vthread, jboolean value);
620 static bool is_preempted(oop vthread);
621 static JavaThreadStatus map_state_to_thread_status(int state);
622
623 static inline ObjectWaiter* objectWaiter(oop vthread);
624 static inline void set_objectWaiter(oop vthread, ObjectWaiter* waiter);
625 static ObjectMonitor* current_pending_monitor(oop vthread);
626 static ObjectMonitor* current_waiting_monitor(oop vthread);
627 };
628
629
630 // Interface to java.lang.Throwable objects
631
632 class java_lang_Throwable: AllStatic {
633 friend class BacktraceBuilder;
634 friend class BacktraceIterator;
635
636 private:
637 // Trace constants
638 enum {
639 trace_methods_offset = 0,
|