< 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.

 583 
 584   // returns true if the method is static OR if the classfile version < 51
 585   bool has_valid_initializer_flags() const;
 586 
 587   // returns true if the method name is <clinit> and the method has
 588   // valid static initializer flags.
 589   bool is_static_initializer() const;
 590 
 591   // returns true if the method name is <init>
 592   bool is_object_initializer() const;
 593 
 594   // returns true if the method name is wait0
 595   bool is_object_wait0() const;
 596 
 597   // compiled code support
 598   // NOTE: code() is inherently racy as deopt can be clearing code
 599   // simultaneously. Use with caution.
 600   bool has_compiled_code() const;
 601 
 602   bool needs_clinit_barrier() const;

 603 
 604   // sizing
 605   static int header_size()                       {
 606     return align_up((int)sizeof(Method), wordSize) / wordSize;
 607   }
 608   static int size(bool is_native);
 609   int size() const                               { return method_size(); }
 610   void log_touched(Thread* current);
 611   static void print_touched_methods(outputStream* out);
 612 
 613   // interpreter support
 614   static ByteSize const_offset()                 { return byte_offset_of(Method, _constMethod       ); }
 615   static ByteSize access_flags_offset()          { return byte_offset_of(Method, _access_flags      ); }
 616   static ByteSize from_compiled_offset()         { return byte_offset_of(Method, _from_compiled_entry); }
 617   static ByteSize code_offset()                  { return byte_offset_of(Method, _code); }
 618 
 619   static ByteSize method_counters_offset()       {
 620     return byte_offset_of(Method, _method_counters);
 621   }
 622 #ifndef PRODUCT

  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   void set_aot_code_entry(AOTCodeEntry* entry) {
 397     _aot_code_entry = entry;
 398   }
 399   AOTCodeEntry* aot_code_entry() const {
 400     return _aot_code_entry;
 401   }
 402 
 403   address get_i2c_entry();
 404   address get_c2i_entry();
 405   address get_c2i_unverified_entry();
 406   address get_c2i_no_clinit_check_entry();
 407   AdapterHandlerEntry* adapter() const {
 408     return _adapter;
 409   }
 410   // setup entry points
 411   void link_method(const methodHandle& method, TRAPS);
 412   // clear entry points. Used by sharing code during dump time
 413   void unlink_method() NOT_CDS_RETURN;
 414   void remove_unshareable_flags() NOT_CDS_RETURN;
 415 
 416   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 417   virtual MetaspaceObj::Type type() const { return MethodType; }
 418 
 419   // vtable index
 420   enum VtableIndexFlag {
 421     // Valid vtable indexes are non-negative (>= 0).
 422     // These few negative values are used as sentinels.

 597 
 598   // returns true if the method is static OR if the classfile version < 51
 599   bool has_valid_initializer_flags() const;
 600 
 601   // returns true if the method name is <clinit> and the method has
 602   // valid static initializer flags.
 603   bool is_static_initializer() const;
 604 
 605   // returns true if the method name is <init>
 606   bool is_object_initializer() const;
 607 
 608   // returns true if the method name is wait0
 609   bool is_object_wait0() const;
 610 
 611   // compiled code support
 612   // NOTE: code() is inherently racy as deopt can be clearing code
 613   // simultaneously. Use with caution.
 614   bool has_compiled_code() const;
 615 
 616   bool needs_clinit_barrier() const;
 617   bool code_has_clinit_barriers() const;
 618 
 619   // sizing
 620   static int header_size()                       {
 621     return align_up((int)sizeof(Method), wordSize) / wordSize;
 622   }
 623   static int size(bool is_native);
 624   int size() const                               { return method_size(); }
 625   void log_touched(Thread* current);
 626   static void print_touched_methods(outputStream* out);
 627 
 628   // interpreter support
 629   static ByteSize const_offset()                 { return byte_offset_of(Method, _constMethod       ); }
 630   static ByteSize access_flags_offset()          { return byte_offset_of(Method, _access_flags      ); }
 631   static ByteSize from_compiled_offset()         { return byte_offset_of(Method, _from_compiled_entry); }
 632   static ByteSize code_offset()                  { return byte_offset_of(Method, _code); }
 633 
 634   static ByteSize method_counters_offset()       {
 635     return byte_offset_of(Method, _method_counters);
 636   }
 637 #ifndef PRODUCT
< prev index next >