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