< prev index next >

src/hotspot/share/oops/method.hpp

Print this page

  47 // Note that most applications load thousands of methods, so keeping the size of this
  48 // class small has a big impact on footprint.
  49 //
  50 // Note that native_function and signature_handler have to be at fixed offsets
  51 // (required by the interpreter)
  52 //
  53 //  Method embedded field layout (after declared fields):
  54 //   [EMBEDDED native_function       (present only if native) ]
  55 //   [EMBEDDED signature_handler     (present only if native) ]
  56 
  57 class CheckedExceptionElement;
  58 class LocalVariableTableElement;
  59 class AdapterHandlerEntry;
  60 class MethodData;
  61 class MethodCounters;
  62 class MethodTrainingData;
  63 class ConstMethod;
  64 class InlineTableSizes;
  65 class nmethod;
  66 class InterpreterOopMap;

  67 
  68 class Method : public Metadata {
  69  friend class VMStructs;
  70  friend class JVMCIVMStructs;
  71  friend class MethodTest;
  72  private:
  73   // If you add a new field that points to any metaspace object, you
  74   // must add this field to Method::metaspace_pointers_do().
  75   ConstMethod*      _constMethod;                // Method read-only data.
  76   MethodData*       _method_data;
  77   MethodCounters*   _method_counters;
  78   AdapterHandlerEntry* _adapter;
  79   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
  80   AccessFlags       _access_flags;               // Access flags
  81   MethodFlags       _flags;
  82 
  83   u2                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
  84 
  85   JFR_ONLY(DEFINE_TRACE_FLAG;)
  86 
  87 #ifndef PRODUCT
  88   int64_t _compiled_invocation_count;
  89 
  90   Symbol* _name;
  91 #endif
  92   // Entry point for calling both from and to the interpreter.
  93   address _i2i_entry;           // All-args-on-stack calling convention
  94   // Entry point for calling from compiled code, to compiled code if it exists
  95   // or else the interpreter.
  96   volatile address _from_compiled_entry;     // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
  97   // The entry point for calling both from and to compiled code is
  98   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
  99   // field can come and go.  It can transition from null to not-null at any
 100   // time (whenever a compile completes).  It can transition from not-null to
 101   // null only at safepoints (because of a de-opt).
 102   nmethod* volatile _code;                   // Points to the corresponding piece of native code
 103   volatile address  _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 104 



 105   // Constructor
 106   Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name);
 107  public:
 108 
 109   static Method* allocate(ClassLoaderData* loader_data,
 110                           int byte_code_size,
 111                           AccessFlags access_flags,
 112                           InlineTableSizes* sizes,
 113                           ConstMethod::MethodType method_type,
 114                           Symbol* name,
 115                           TRAPS);
 116 
 117   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 118   Method(){}
 119 
 120   virtual bool is_method() const { return true; }
 121 
 122 #if INCLUDE_CDS
 123   void remove_unshareable_info();
 124   void restore_unshareable_info(TRAPS);

 369   // Locks NMethodState_lock if not held.
 370   void unlink_code();
 371 
 372 private:
 373   // Either called with NMethodState_lock held or from constructor.
 374   void clear_code();
 375 
 376   void clear_method_data() {
 377     _method_data = nullptr;
 378   }
 379 
 380 public:
 381   static void set_code(const methodHandle& mh, nmethod* code);
 382   void set_adapter_entry(AdapterHandlerEntry* adapter) {
 383     _adapter = adapter;
 384   }
 385   void set_from_compiled_entry(address entry) {
 386     _from_compiled_entry =  entry;
 387   }
 388 













 389   address get_i2c_entry();
 390   address get_c2i_entry();
 391   address get_c2i_unverified_entry();
 392   address get_c2i_no_clinit_check_entry();
 393   AdapterHandlerEntry* adapter() const {
 394     return _adapter;
 395   }
 396   // setup entry points
 397   void link_method(const methodHandle& method, TRAPS);
 398   // clear entry points. Used by sharing code during dump time
 399   void unlink_method() NOT_CDS_RETURN;
 400   void remove_unshareable_flags() NOT_CDS_RETURN;
 401 
 402   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 403   virtual MetaspaceObj::Type type() const { return MethodType; }
 404 
 405   // vtable index
 406   enum VtableIndexFlag {
 407     // Valid vtable indexes are non-negative (>= 0).
 408     // These few negative values are used as sentinels.

  47 // Note that most applications load thousands of methods, so keeping the size of this
  48 // class small has a big impact on footprint.
  49 //
  50 // Note that native_function and signature_handler have to be at fixed offsets
  51 // (required by the interpreter)
  52 //
  53 //  Method embedded field layout (after declared fields):
  54 //   [EMBEDDED native_function       (present only if native) ]
  55 //   [EMBEDDED signature_handler     (present only if native) ]
  56 
  57 class CheckedExceptionElement;
  58 class LocalVariableTableElement;
  59 class AdapterHandlerEntry;
  60 class MethodData;
  61 class MethodCounters;
  62 class MethodTrainingData;
  63 class ConstMethod;
  64 class InlineTableSizes;
  65 class nmethod;
  66 class InterpreterOopMap;
  67 class AOTCodeEntry;
  68 
  69 class Method : public Metadata {
  70  friend class VMStructs;
  71  friend class JVMCIVMStructs;
  72  friend class MethodTest;
  73  private:
  74   // If you add a new field that points to any metaspace object, you
  75   // must add this field to Method::metaspace_pointers_do().
  76   ConstMethod*      _constMethod;                // Method read-only data.
  77   MethodData*       _method_data;
  78   MethodCounters*   _method_counters;
  79   AdapterHandlerEntry* _adapter;
  80   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
  81   AccessFlags       _access_flags;               // Access flags
  82   MethodFlags       _flags;
  83 
  84   u2                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
  85 
  86   JFR_ONLY(DEFINE_TRACE_FLAG;)
  87 
  88 #ifndef PRODUCT
  89   int64_t _compiled_invocation_count;
  90 
  91   Symbol* _name;
  92 #endif
  93   // Entry point for calling both from and to the interpreter.
  94   address _i2i_entry;           // All-args-on-stack calling convention
  95   // Entry point for calling from compiled code, to compiled code if it exists
  96   // or else the interpreter.
  97   volatile address _from_compiled_entry;     // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
  98   // The entry point for calling both from and to compiled code is
  99   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 100   // field can come and go.  It can transition from null to not-null at any
 101   // time (whenever a compile completes).  It can transition from not-null to
 102   // null only at safepoints (because of a de-opt).
 103   nmethod* volatile _code;                   // Points to the corresponding piece of native code
 104   volatile address  _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 105 
 106   nmethod*  _preload_code;       // preloaded AOT code
 107   AOTCodeEntry* _aot_code_entry; // AOT Code Cache entry for pre-loading code
 108 
 109   // Constructor
 110   Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name);
 111  public:
 112 
 113   static Method* allocate(ClassLoaderData* loader_data,
 114                           int byte_code_size,
 115                           AccessFlags access_flags,
 116                           InlineTableSizes* sizes,
 117                           ConstMethod::MethodType method_type,
 118                           Symbol* name,
 119                           TRAPS);
 120 
 121   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 122   Method(){}
 123 
 124   virtual bool is_method() const { return true; }
 125 
 126 #if INCLUDE_CDS
 127   void remove_unshareable_info();
 128   void restore_unshareable_info(TRAPS);

 373   // Locks NMethodState_lock if not held.
 374   void unlink_code();
 375 
 376 private:
 377   // Either called with NMethodState_lock held or from constructor.
 378   void clear_code();
 379 
 380   void clear_method_data() {
 381     _method_data = nullptr;
 382   }
 383 
 384 public:
 385   static void set_code(const methodHandle& mh, nmethod* code);
 386   void set_adapter_entry(AdapterHandlerEntry* adapter) {
 387     _adapter = adapter;
 388   }
 389   void set_from_compiled_entry(address entry) {
 390     _from_compiled_entry =  entry;
 391   }
 392 
 393   void set_preload_code(nmethod* code) {
 394     _preload_code = code;
 395   }
 396   nmethod* preload_code() const {
 397     return _preload_code;
 398   }
 399   void set_aot_code_entry(AOTCodeEntry* entry) {
 400     _aot_code_entry = entry;
 401   }
 402   AOTCodeEntry* aot_code_entry() const {
 403     return _aot_code_entry;
 404   }
 405 
 406   address get_i2c_entry();
 407   address get_c2i_entry();
 408   address get_c2i_unverified_entry();
 409   address get_c2i_no_clinit_check_entry();
 410   AdapterHandlerEntry* adapter() const {
 411     return _adapter;
 412   }
 413   // setup entry points
 414   void link_method(const methodHandle& method, TRAPS);
 415   // clear entry points. Used by sharing code during dump time
 416   void unlink_method() NOT_CDS_RETURN;
 417   void remove_unshareable_flags() NOT_CDS_RETURN;
 418 
 419   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 420   virtual MetaspaceObj::Type type() const { return MethodType; }
 421 
 422   // vtable index
 423   enum VtableIndexFlag {
 424     // Valid vtable indexes are non-negative (>= 0).
 425     // These few negative values are used as sentinels.
< prev index next >