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