< prev index next >

src/hotspot/share/classfile/javaClasses.hpp

Print this page
*** 26,14 ***
--- 26,16 ---
  #define SHARE_CLASSFILE_JAVACLASSES_HPP
  
  #include "classfile/vmClasses.hpp"
  #include "oops/oop.hpp"
  #include "oops/instanceKlass.hpp"
+ #include "oops/stackChunkOop.hpp"
  #include "oops/symbol.hpp"
  #include "runtime/os.hpp"
  #include "utilities/vmEnums.hpp"
  
+ class JvmtiThreadState;
  class RecordComponent;
  
  // Interface for manipulating the basic Java classes.
  
  #define BASIC_JAVA_CLASSES_DO_PART1(f) \

*** 45,11 ***
--- 47,15 ---
  #define BASIC_JAVA_CLASSES_DO_PART2(f) \
    f(java_lang_System) \
    f(java_lang_ClassLoader) \
    f(java_lang_Throwable) \
    f(java_lang_Thread) \
+   f(java_lang_Thread_FieldHolder) \
+   f(java_lang_Thread_VirtualThreads) \
+   f(java_lang_Thread_ClassLoaders) \
    f(java_lang_ThreadGroup) \
+   f(java_lang_VirtualThread) \
    f(java_lang_InternalError) \
    f(java_lang_AssertionStatusDirectives) \
    f(java_lang_ref_SoftReference) \
    f(java_lang_invoke_MethodHandle) \
    f(java_lang_invoke_DirectMethodHandle) \

*** 71,10 ***
--- 77,13 ---
    f(java_lang_reflect_Parameter) \
    f(java_lang_Module) \
    f(java_lang_StackTraceElement) \
    f(java_lang_StackFrameInfo) \
    f(java_lang_LiveStackFrameInfo) \
+   f(jdk_internal_vm_ContinuationScope) \
+   f(jdk_internal_vm_Continuation) \
+   f(jdk_internal_vm_StackChunk) \
    f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
    f(jdk_internal_invoke_NativeEntryPoint) \
    f(jdk_internal_misc_UnsafeConstants) \
    f(java_lang_boxing_object) \
    f(vector_VectorPayload) \

*** 388,37 ***
    friend class JavaClasses;
  };
  
  // Interface to java.lang.Thread objects
  
  class java_lang_Thread : AllStatic {
   private:
    // Note that for this class the layout changed between JDK1.2 and JDK1.3,
    // so we compute the offsets at startup rather than hard-wiring them.
    static int _name_offset;
-   static int _group_offset;
    static int _contextClassLoader_offset;
    static int _inheritedAccessControlContext_offset;
-   static int _priority_offset;
    static int _eetop_offset;
    static int _interrupted_offset;
-   static int _daemon_offset;
-   static int _stillborn_offset;
-   static int _stackSize_offset;
    static int _tid_offset;
!   static int _thread_status_offset;
    static int _park_blocker_offset;
  
    static void compute_offsets();
  
   public:
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    // Returns the JavaThread associated with the thread obj
    static JavaThread* thread(oop java_thread);
    // Set JavaThread for instance
    static void set_thread(oop java_thread, JavaThread* thread);
    // Interrupted status
    static bool interrupted(oop java_thread);
    static void set_interrupted(oop java_thread, bool val);
    // Name
    static oop name(oop java_thread);
--- 397,41 ---
    friend class JavaClasses;
  };
  
  // Interface to java.lang.Thread objects
  
+ #define THREAD_INJECTED_FIELDS(macro)                            \
+   macro(java_lang_Thread, jvmti_thread_state, intptr_signature, false)
+ 
  class java_lang_Thread : AllStatic {
+   friend class java_lang_VirtualThread;
   private:
    // Note that for this class the layout changed between JDK1.2 and JDK1.3,
    // so we compute the offsets at startup rather than hard-wiring them.
+   static int _holder_offset;
    static int _name_offset;
    static int _contextClassLoader_offset;
    static int _inheritedAccessControlContext_offset;
    static int _eetop_offset;
+   static int _jvmti_thread_state_offset;
    static int _interrupted_offset;
    static int _tid_offset;
!   static int _continuation_offset;
    static int _park_blocker_offset;
+   static int _scopeLocalBindings_offset;
  
    static void compute_offsets();
  
   public:
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    // Returns the JavaThread associated with the thread obj
    static JavaThread* thread(oop java_thread);
    // Set JavaThread for instance
    static void set_thread(oop java_thread, JavaThread* thread);
+   // FieldHolder
+   static oop holder(oop java_thread);
    // Interrupted status
    static bool interrupted(oop java_thread);
    static void set_interrupted(oop java_thread, bool val);
    // Name
    static oop name(oop java_thread);

*** 443,10 ***
--- 456,19 ---
    static oop inherited_access_control_context(oop java_thread);
    // Stack size hint
    static jlong stackSize(oop java_thread);
    // Thread ID
    static jlong thread_id(oop java_thread);
+   static ByteSize thread_id_offset();
+   // Continuation
+   static inline oop continuation(oop java_thread);
+ 
+   static JvmtiThreadState* jvmti_thread_state(oop java_thread);
+   static void set_jvmti_thread_state(oop java_thread, JvmtiThreadState* state);
+ 
+   // Clear all scope local bindings on error
+   static void clear_scopeLocalBindings(oop java_thread);
  
    // Blocker object responsible for thread parking
    static oop park_blocker(oop java_thread);
  
    // Write thread status info to threadStatus field of java.lang.Thread.

*** 454,57 ***
    // Read thread status info from threadStatus field of java.lang.Thread.
    static JavaThreadStatus get_thread_status(oop java_thread_oop);
  
    static const char*  thread_status_name(oop java_thread_oop);
  
    // Debugging
    friend class JavaClasses;
  };
  
  // Interface to java.lang.ThreadGroup objects
  
  class java_lang_ThreadGroup : AllStatic {
   private:
    static int _parent_offset;
    static int _name_offset;
-   static int _threads_offset;
-   static int _groups_offset;
    static int _maxPriority_offset;
!   static int _destroyed_offset;
-   static int _daemon_offset;
-   static int _nthreads_offset;
    static int _ngroups_offset;
  
    static void compute_offsets();
  
   public:
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    // parent ThreadGroup
!   static oop  parent(oop java_thread_group);
    // name
    static const char* name(oop java_thread_group);
-   // ("name as oop" accessor is not necessary)
-   // Number of threads in group
-   static int nthreads(oop java_thread_group);
-   // threads
-   static objArrayOop threads(oop java_thread_group);
-   // Number of threads in group
-   static int ngroups(oop java_thread_group);
-   // groups
-   static objArrayOop groups(oop java_thread_group);
    // maxPriority in group
    static ThreadPriority maxPriority(oop java_thread_group);
!   // Destroyed
!   static bool is_destroyed(oop java_thread_group);
!   // Daemon
!   static bool is_daemon(oop java_thread_group);
    // Debugging
    friend class JavaClasses;
  };
  
  
  
  // Interface to java.lang.Throwable objects
  
  class java_lang_Throwable: AllStatic {
    friend class BacktraceBuilder;
--- 476,167 ---
    // Read thread status info from threadStatus field of java.lang.Thread.
    static JavaThreadStatus get_thread_status(oop java_thread_oop);
  
    static const char*  thread_status_name(oop java_thread_oop);
  
+   // Fill in current stack trace, can cause GC
+   static oop async_get_stack_trace(oop java_thread, TRAPS);
+ 
    // Debugging
    friend class JavaClasses;
  };
  
+ // Interface to java.lang.Thread$FieldHolder objects
+ 
+ class java_lang_Thread_FieldHolder : AllStatic {
+  private:
+   static int _group_offset;
+   static int _priority_offset;
+   static int _stackSize_offset;
+   static int _stillborn_offset;
+   static int _daemon_offset;
+   static int _thread_status_offset;
+ 
+   static void compute_offsets();
+  public:
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+ 
+   static oop threadGroup(oop holder);
+ 
+   static ThreadPriority priority(oop holder);
+   static void set_priority(oop holder, ThreadPriority priority);
+ 
+   static jlong stackSize(oop holder);
+ 
+   static bool is_stillborn(oop holder);
+   static void set_stillborn(oop holder);
+ 
+   static bool is_daemon(oop holder);
+   static void set_daemon(oop holder);
+ 
+   static void set_thread_status(oop holder, JavaThreadStatus);
+   static JavaThreadStatus get_thread_status(oop holder);
+ 
+   friend class JavaClasses;
+ };
+ 
+ // Interface to java.lang.Thread$VirtualThreads objects
+ 
+ class java_lang_Thread_VirtualThreads : AllStatic {
+  private:
+   static int _static_THREAD_GROUP_offset;
+ 
+   static void compute_offsets();
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+  public:
+   static oop get_THREAD_GROUP();
+ 
+   friend class JavaClasses;
+ };
+ 
+ 
+ // Interface to java.lang.Thread$ClassLoaders objects
+ 
+ class java_lang_Thread_ClassLoaders : AllStatic {
+  private:
+   static int _static_NOT_SUPPORTED_offset;
+ 
+   static void compute_offsets();
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+  public:
+   static oop get_NOT_SUPPORTED();
+ 
+   friend class JavaClasses;
+ };
+ 
+ 
  // Interface to java.lang.ThreadGroup objects
  
  class java_lang_ThreadGroup : AllStatic {
   private:
    static int _parent_offset;
    static int _name_offset;
    static int _maxPriority_offset;
! 
    static int _ngroups_offset;
+   static int _groups_offset;
+   static int _nweaks_offset;
+   static int _weaks_offset;
  
    static void compute_offsets();
  
   public:
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    // parent ThreadGroup
!   static oop parent(oop java_thread_group);
    // name
    static const char* name(oop java_thread_group);
    // maxPriority in group
    static ThreadPriority maxPriority(oop java_thread_group);
! 
!   // Number of strongly reachable thread groups
!   static int ngroups(oop java_thread_group);
!   // Strongly reachable thread groups
+   static objArrayOop groups(oop java_thread_group);
+   // Number of weakly reachable thread groups
+   static int nweaks(oop java_thread_group);
+   // Weakly reachable thread groups
+   static objArrayOop weaks(oop java_thread_group);
+ 
    // Debugging
    friend class JavaClasses;
  };
  
  
+ // Interface to java.lang.VirtualThread objects
+ 
+ class java_lang_VirtualThread : AllStatic {
+  private:
+   static int static_notify_jvmti_events_offset;
+   static int static_vthread_scope_offset;
+   static int _carrierThread_offset;
+   static int _continuation_offset;
+   static int _state_offset;
+ 
+  public:
+   enum {
+     NEW          = 0,
+     STARTED      = 1,
+     RUNNABLE     = 2,
+     RUNNING      = 3,
+     PARKING      = 4,
+     PARKED       = 5,
+     PINNED       = 6,
+     YIELDING     = 7,
+     TERMINATED   = 99,
+ 
+     // can be suspended from scheduling when parked
+     SUSPENDED    = 1 << 8,
+     PARKED_SUSPENDED = (PARKED | SUSPENDED)
+   };
+ 
+   static void compute_offsets();
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+ 
+   // Testers
+   static bool is_subclass(Klass* klass) {
+     return klass->is_subclass_of(vmClasses::VirtualThread_klass());
+   }
+   static bool is_instance(oop obj);
+ 
+   static oop vthread_scope();
+   static oop carrier_thread(oop vthread);
+   static oop continuation(oop vthread);
+   static jshort state(oop vthread);
+   static JavaThreadStatus map_state_to_thread_status(jint state);
+   static bool notify_jvmti_events();
+   static void set_notify_jvmti_events(jboolean enable);
+   static void init_static_notify_jvmti_events();
+   static jlong set_jfrTraceId(oop vthread, jlong id);
+ };
+ 
  
  // Interface to java.lang.Throwable objects
  
  class java_lang_Throwable: AllStatic {
    friend class BacktraceBuilder;

*** 515,13 ***
    enum {
      trace_methods_offset = 0,
      trace_bcis_offset    = 1,
      trace_mirrors_offset = 2,
      trace_names_offset   = 3,
!     trace_next_offset    = 4,
!     trace_hidden_offset  = 5,
!     trace_size           = 6,
      trace_chunk_size     = 32
    };
  
    static int _backtrace_offset;
    static int _detailMessage_offset;
--- 647,14 ---
    enum {
      trace_methods_offset = 0,
      trace_bcis_offset    = 1,
      trace_mirrors_offset = 2,
      trace_names_offset   = 3,
!     trace_conts_offset   = 4,
!     trace_next_offset    = 5,
!     trace_hidden_offset  = 6,
+     trace_size           = 7,
      trace_chunk_size     = 32
    };
  
    static int _backtrace_offset;
    static int _detailMessage_offset;

*** 558,12 ***
    // Fill in current stack trace for throwable with preallocated backtrace (no GC)
    static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
    // Fill in current stack trace, can cause GC
    static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
    static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
    // Programmatic access to stack trace
!   static void get_stack_trace_elements(Handle throwable, objArrayHandle stack_trace, TRAPS);
  
    // For recreating class initialization error exceptions.
    static Handle get_cause_with_stack_trace(Handle throwable, TRAPS);
  
    // Printing
--- 691,13 ---
    // Fill in current stack trace for throwable with preallocated backtrace (no GC)
    static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
    // Fill in current stack trace, can cause GC
    static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
    static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
+ 
    // Programmatic access to stack trace
!   static void get_stack_trace_elements(int depth, Handle backtrace, objArrayHandle stack_trace, TRAPS);
  
    // For recreating class initialization error exceptions.
    static Handle get_cause_with_stack_trace(Handle throwable, TRAPS);
  
    // Printing

*** 905,10 ***
--- 1039,11 ---
   public:
    // Accessors
    static inline oop weak_referent_no_keepalive(oop ref);
    static inline oop phantom_referent_no_keepalive(oop ref);
    static inline oop unknown_referent_no_keepalive(oop ref);
+   static inline oop unknown_referent(oop ref);
    static inline void clear_referent(oop ref);
    static inline HeapWord* referent_addr_raw(oop ref);
    static inline oop next(oop ref);
    static inline void set_next(oop ref, oop value);
    static inline void set_next_raw(oop ref, oop value);

*** 947,10 ***
--- 1082,118 ---
  
    static void compute_offsets();
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  };
  
+ // Interface to jdk.internal.vm.ContinuationScope objects
+ class jdk_internal_vm_ContinuationScope: AllStatic {
+   friend class JavaClasses;
+  private:
+   static int _name_offset;
+ 
+   static void compute_offsets();
+  public:
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+ 
+   static inline oop name(oop ref);
+ };
+ 
+ // Interface to jdk.internal.vm.Continuation objects
+ class jdk_internal_vm_Continuation: AllStatic {
+   friend class JavaClasses;
+  private:
+   static int _scope_offset;
+   static int _target_offset;
+   static int _parent_offset;
+   static int _yieldInfo_offset;
+   static int _tail_offset;
+   static int _cs_offset;
+   static int _reset_offset;
+   static int _mounted_offset;
+   static int _done_offset;
+   static int _preempted_offset;
+ 
+   static void compute_offsets();
+  public:
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+   // Accessors
+   static inline oop scope(oop ref);
+   static inline oop target(oop ref);
+   static inline oop parent(oop ref);
+   static inline oop yieldInfo(oop ref);
+   static inline void set_yieldInfo(oop ref, oop value);
+   static inline stackChunkOop tail(oop ref);
+   static inline void set_tail(oop ref, stackChunkOop value);
+   static inline jshort critical_section(oop ref);
+   static inline void set_critical_section(oop ref, jshort value);
+   static inline bool on_local_stack(oop ref, address adr);
+   static inline bool is_reset(oop ref);
+   static inline bool is_mounted(oop ref);
+   static inline bool done(oop ref);
+   static inline bool is_preempted(oop ref);
+   static inline void set_preempted(oop ref, bool value);
+ };
+ 
+ // Interface to jdk.internal.vm.StackChunk objects
+ class jdk_internal_vm_StackChunk: AllStatic {
+   friend class JavaClasses;
+  private:
+   static int _parent_offset;
+   static int _size_offset;
+   static int _sp_offset;
+   static int _pc_offset;
+   static int _argsize_offset;
+   static int _flags_offset;
+   static int _gcSP_offset;
+   static int _markCycle_offset;
+   static int _maxSize_offset;
+   static int _numFrames_offset;
+   static int _numOops_offset;
+   static int _cont_offset;
+ 
+   static void compute_offsets();
+  public:
+   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
+ 
+   static inline int parent_offset() { return _parent_offset; }
+   static inline int cont_offset()   { return _cont_offset; }
+ 
+   // Accessors
+   static inline oop parent(oop ref);
+   static inline void set_parent(oop ref, oop value);
+   template<typename P>
+   static inline bool is_parent_null(oop ref); // bypasses barriers for a faster test
+   template<typename P>
+   static inline void set_parent_raw(oop ref, oop value);
+   static inline jint size(oop ref);
+   static inline void set_size(HeapWord* ref, jint value);
+   static inline jint sp(oop ref);
+   static inline void set_sp(oop ref, jint value);
+   static inline jlong pc(oop ref);
+   static inline void set_pc(oop ref, jlong value);
+   static inline jint argsize(oop ref);
+   static inline void set_argsize(oop ref, jint value);
+   static inline jbyte flags(oop ref);
+   static inline void set_flags(oop ref, jbyte value);
+   static inline jint gc_sp(oop ref);
+   static inline void set_gc_sp(oop ref, jint value);
+   static inline jlong mark_cycle(oop ref);
+   static inline void set_mark_cycle(oop ref, jlong value);
+   static inline jint maxSize(oop ref);
+   static inline void set_maxSize(oop ref, jint value);
+   static inline jint numFrames(oop ref);
+   static inline void set_numFrames(oop ref, jint value);
+   static inline jint numOops(oop ref);
+   static inline void set_numOops(oop ref, jint value);
+   static inline oop cont(oop ref);
+   static inline void set_cont(oop ref, oop value);
+   template<typename P>
+   static inline oop cont_raw(oop ref);
+   template<typename P>
+   static inline void set_cont_raw(oop ref, oop value);
+ };
+ 
  // Interface to java.lang.invoke.MethodHandle objects
  
  class java_lang_invoke_MethodHandle: AllStatic {
    friend class JavaClasses;
  

*** 1423,31 ***
    static int _moduleVersion_offset;
    static int _declaringClass_offset;
    static int _methodName_offset;
    static int _fileName_offset;
    static int _lineNumber_offset;
  
    // Setters
    static void set_classLoaderName(oop element, oop value);
    static void set_moduleName(oop element, oop value);
    static void set_moduleVersion(oop element, oop value);
    static void set_declaringClass(oop element, oop value);
    static void set_methodName(oop element, oop value);
    static void set_fileName(oop element, oop value);
    static void set_lineNumber(oop element, int value);
    static void set_declaringClassObject(oop element, oop value);
  
    static void decode_file_and_line(Handle java_mirror, InstanceKlass* holder, int version,
                                     const methodHandle& method, int bci,
                                     Symbol*& source, oop& source_file, int& line_number, TRAPS);
  
   public:
    // Create an instance of StackTraceElement
!   static oop create(const methodHandle& method, int bci, TRAPS);
  
    static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
!                       int version, int bci, Symbol* name, TRAPS);
  
    static void compute_offsets();
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
  #if INCLUDE_JVMCI
--- 1666,33 ---
    static int _moduleVersion_offset;
    static int _declaringClass_offset;
    static int _methodName_offset;
    static int _fileName_offset;
    static int _lineNumber_offset;
+   static int _contScopeName_offset;
  
    // Setters
    static void set_classLoaderName(oop element, oop value);
    static void set_moduleName(oop element, oop value);
    static void set_moduleVersion(oop element, oop value);
    static void set_declaringClass(oop element, oop value);
    static void set_methodName(oop element, oop value);
    static void set_fileName(oop element, oop value);
    static void set_lineNumber(oop element, int value);
    static void set_declaringClassObject(oop element, oop value);
+   static void set_contScopeName(oop element, oop value);
  
    static void decode_file_and_line(Handle java_mirror, InstanceKlass* holder, int version,
                                     const methodHandle& method, int bci,
                                     Symbol*& source, oop& source_file, int& line_number, TRAPS);
  
   public:
    // Create an instance of StackTraceElement
!   static oop create(const methodHandle& method, int bci, Handle contScopeName, TRAPS);
  
    static void fill_in(Handle element, InstanceKlass* holder, const methodHandle& method,
!                       int version, int bci, Symbol* name, Handle contScopeName, TRAPS);
  
    static void compute_offsets();
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
  #if INCLUDE_JVMCI

*** 1483,19 ***
  class java_lang_StackFrameInfo: AllStatic {
  private:
    static int _memberName_offset;
    static int _bci_offset;
    static int _version_offset;
  
    static Method* get_method(Handle stackFrame, InstanceKlass* holder, TRAPS);
  
  public:
    // Setters
!   static void set_method_and_bci(Handle stackFrame, const methodHandle& method, int bci, TRAPS);
    static void set_bci(oop info, int value);
  
    static void set_version(oop info, short value);
  
    static void compute_offsets();
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    static void to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS);
--- 1728,21 ---
  class java_lang_StackFrameInfo: AllStatic {
  private:
    static int _memberName_offset;
    static int _bci_offset;
    static int _version_offset;
+   static int _contScope_offset;
  
    static Method* get_method(Handle stackFrame, InstanceKlass* holder, TRAPS);
  
  public:
    // Setters
!   static void set_method_and_bci(Handle stackFrame, const methodHandle& method, int bci, oop cont, TRAPS);
    static void set_bci(oop info, int value);
  
    static void set_version(oop info, short value);
+   static void set_contScope(oop info, oop value);
  
    static void compute_offsets();
    static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
  
    static void to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS);

*** 1762,10 ***
--- 2009,11 ---
    RESOLVEDMETHOD_INJECTED_FIELDS(macro)     \
    MEMBERNAME_INJECTED_FIELDS(macro)         \
    CALLSITECONTEXT_INJECTED_FIELDS(macro)    \
    STACKFRAMEINFO_INJECTED_FIELDS(macro)     \
    MODULE_INJECTED_FIELDS(macro)             \
+   THREAD_INJECTED_FIELDS(macro)             \
    INTERNALERROR_INJECTED_FIELDS(macro)
  
  
  // Interface to hard-coded offset checking
  
< prev index next >