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