< prev index next >

src/share/vm/oops/method.hpp

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODOOP_HPP
  26 #define SHARE_VM_OOPS_METHODOOP_HPP
  27 
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/compressedStream.hpp"
  30 #include "compiler/oopMap.hpp"
  31 #include "interpreter/invocationCounter.hpp"
  32 #include "oops/annotations.hpp"
  33 #include "oops/constantPool.hpp"
  34 #include "oops/methodCounters.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/oop.hpp"
  37 #include "oops/typeArrayOop.hpp"
  38 #include "utilities/accessFlags.hpp"
  39 #include "utilities/growableArray.hpp"




  40 
  41 // A Method* represents a Java method.
  42 //
  43 // Memory layout (each line represents a word). Note that most applications load thousands of methods,
  44 // so keeping the size of this structure small has a big impact on footprint.
  45 //
  46 // We put all oops and method_size first for better gc cache locality.
  47 //
  48 // The actual bytecodes are inlined after the end of the Method struct.
  49 //
  50 // There are bits in the access_flags telling whether inlined tables are present.
  51 // Note that accessing the line number and local variable tables is not performance critical at all.
  52 // Accessing the checked exceptions table is used by reflection, so we put that last to make access
  53 // to it fast.
  54 //
  55 // The line number table is compressed and inlined following the byte codes. It is found as the first
  56 // byte following the byte codes. The checked exceptions table and the local variable table are inlined
  57 // after the line number table, and indexed from the end of the method. We do not compress the checked
  58 // exceptions table since the average length is less than 2, and do not bother to compress the local
  59 // variable table either since it is mostly absent.


  99 class Method : public Metadata {
 100  friend class VMStructs;
 101  private:
 102   ConstMethod*      _constMethod;                // Method read-only data.
 103   MethodData*       _method_data;
 104   MethodCounters*   _method_counters;
 105   AccessFlags       _access_flags;               // Access flags
 106   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
 107                                                  // note: can have vtables with >2**16 elements (because of inheritance)
 108   u2                _method_size;                // size of this object
 109   u1                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
 110   u1                _jfr_towrite          : 1,   // Flags
 111                     _caller_sensitive     : 1,
 112                     _force_inline         : 1,
 113                     _hidden               : 1,
 114                     _running_emcp         : 1,
 115                     _dont_inline          : 1,
 116                     _has_injected_profile : 1,
 117                                           : 2;
 118 


 119 #ifndef PRODUCT
 120   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 121 #endif
 122   // Entry point for calling both from and to the interpreter.
 123   address _i2i_entry;           // All-args-on-stack calling convention
 124   // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
 125   AdapterHandlerEntry* _adapter;
 126   // Entry point for calling from compiled code, to compiled code if it exists
 127   // or else the interpreter.
 128   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 129   // The entry point for calling both from and to compiled code is
 130   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 131   // field can come and go.  It can transition from NULL to not-null at any
 132   // time (whenever a compile completes).  It can transition from not-null to
 133   // NULL only at safepoints (because of a de-opt).
 134   nmethod* volatile _code;                       // Points to the corresponding piece of native code
 135   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 136 
 137   // Constructor
 138   Method(ConstMethod* xconst, AccessFlags access_flags, int size);


 787   void     set_intrinsic_id(vmIntrinsics::ID id) {                           _intrinsic_id = (u1) id; }
 788 
 789   // Helper routines for intrinsic_id() and vmIntrinsics::method().
 790   void init_intrinsic_id();     // updates from _none if a match
 791   void clear_jmethod_id(ClassLoaderData* loader_data);
 792 
 793   static vmSymbols::SID klass_id_for_intrinsics(Klass* holder);
 794 
 795   bool     jfr_towrite()                { return _jfr_towrite;              }
 796   void set_jfr_towrite(bool x)          {        _jfr_towrite = x;          }
 797   bool     caller_sensitive()           { return _caller_sensitive;         }
 798   void set_caller_sensitive(bool x)     {        _caller_sensitive = x;     }
 799   bool     force_inline()               { return _force_inline;             }
 800   void set_force_inline(bool x)         {        _force_inline = x;         }
 801   bool     dont_inline()                { return _dont_inline;              }
 802   void set_dont_inline(bool x)          {        _dont_inline = x;          }
 803   bool  is_hidden()                     { return _hidden;                   }
 804   void set_hidden(bool x)               {        _hidden = x;               }
 805   bool     has_injected_profile()       { return _has_injected_profile;     }
 806   void set_has_injected_profile(bool x) {        _has_injected_profile = x; }


 807 
 808   ConstMethod::MethodType method_type() const {
 809       return _constMethod->method_type();
 810   }
 811   bool is_overpass() const { return method_type() == ConstMethod::OVERPASS; }
 812 
 813   // On-stack replacement support
 814   bool has_osr_nmethod(int level, bool match_level) {
 815    return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
 816   }
 817 
 818   int mark_osr_nmethods() {
 819     return method_holder()->mark_osr_nmethods(this);
 820   }
 821 
 822   nmethod* lookup_osr_nmethod_for(int bci, int level, bool match_level) {
 823     return method_holder()->lookup_osr_nmethod(this, bci, level, match_level);
 824   }
 825 
 826   // Inline cache support




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODOOP_HPP
  26 #define SHARE_VM_OOPS_METHODOOP_HPP
  27 
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/compressedStream.hpp"
  30 #include "compiler/oopMap.hpp"
  31 #include "interpreter/invocationCounter.hpp"
  32 #include "oops/annotations.hpp"
  33 #include "oops/constantPool.hpp"
  34 #include "oops/methodCounters.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/oop.hpp"
  37 #include "oops/typeArrayOop.hpp"
  38 #include "utilities/accessFlags.hpp"
  39 #include "utilities/growableArray.hpp"
  40 #include "utilities/macros.hpp"
  41 #if INCLUDE_JFR
  42 #include "jfr/support/jfrTraceIdExtension.hpp"
  43 #endif
  44 
  45 // A Method* represents a Java method.
  46 //
  47 // Memory layout (each line represents a word). Note that most applications load thousands of methods,
  48 // so keeping the size of this structure small has a big impact on footprint.
  49 //
  50 // We put all oops and method_size first for better gc cache locality.
  51 //
  52 // The actual bytecodes are inlined after the end of the Method struct.
  53 //
  54 // There are bits in the access_flags telling whether inlined tables are present.
  55 // Note that accessing the line number and local variable tables is not performance critical at all.
  56 // Accessing the checked exceptions table is used by reflection, so we put that last to make access
  57 // to it fast.
  58 //
  59 // The line number table is compressed and inlined following the byte codes. It is found as the first
  60 // byte following the byte codes. The checked exceptions table and the local variable table are inlined
  61 // after the line number table, and indexed from the end of the method. We do not compress the checked
  62 // exceptions table since the average length is less than 2, and do not bother to compress the local
  63 // variable table either since it is mostly absent.


 103 class Method : public Metadata {
 104  friend class VMStructs;
 105  private:
 106   ConstMethod*      _constMethod;                // Method read-only data.
 107   MethodData*       _method_data;
 108   MethodCounters*   _method_counters;
 109   AccessFlags       _access_flags;               // Access flags
 110   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
 111                                                  // note: can have vtables with >2**16 elements (because of inheritance)
 112   u2                _method_size;                // size of this object
 113   u1                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
 114   u1                _jfr_towrite          : 1,   // Flags
 115                     _caller_sensitive     : 1,
 116                     _force_inline         : 1,
 117                     _hidden               : 1,
 118                     _running_emcp         : 1,
 119                     _dont_inline          : 1,
 120                     _has_injected_profile : 1,
 121                                           : 2;
 122 
 123   JFR_ONLY(DEFINE_TRACE_FLAG;)
 124 
 125 #ifndef PRODUCT
 126   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 127 #endif
 128   // Entry point for calling both from and to the interpreter.
 129   address _i2i_entry;           // All-args-on-stack calling convention
 130   // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
 131   AdapterHandlerEntry* _adapter;
 132   // Entry point for calling from compiled code, to compiled code if it exists
 133   // or else the interpreter.
 134   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 135   // The entry point for calling both from and to compiled code is
 136   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 137   // field can come and go.  It can transition from NULL to not-null at any
 138   // time (whenever a compile completes).  It can transition from not-null to
 139   // NULL only at safepoints (because of a de-opt).
 140   nmethod* volatile _code;                       // Points to the corresponding piece of native code
 141   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 142 
 143   // Constructor
 144   Method(ConstMethod* xconst, AccessFlags access_flags, int size);


 793   void     set_intrinsic_id(vmIntrinsics::ID id) {                           _intrinsic_id = (u1) id; }
 794 
 795   // Helper routines for intrinsic_id() and vmIntrinsics::method().
 796   void init_intrinsic_id();     // updates from _none if a match
 797   void clear_jmethod_id(ClassLoaderData* loader_data);
 798 
 799   static vmSymbols::SID klass_id_for_intrinsics(Klass* holder);
 800 
 801   bool     jfr_towrite()                { return _jfr_towrite;              }
 802   void set_jfr_towrite(bool x)          {        _jfr_towrite = x;          }
 803   bool     caller_sensitive()           { return _caller_sensitive;         }
 804   void set_caller_sensitive(bool x)     {        _caller_sensitive = x;     }
 805   bool     force_inline()               { return _force_inline;             }
 806   void set_force_inline(bool x)         {        _force_inline = x;         }
 807   bool     dont_inline()                { return _dont_inline;              }
 808   void set_dont_inline(bool x)          {        _dont_inline = x;          }
 809   bool  is_hidden()                     { return _hidden;                   }
 810   void set_hidden(bool x)               {        _hidden = x;               }
 811   bool     has_injected_profile()       { return _has_injected_profile;     }
 812   void set_has_injected_profile(bool x) {        _has_injected_profile = x; }
 813 
 814   JFR_ONLY(DEFINE_TRACE_FLAG_ACCESSOR;)
 815 
 816   ConstMethod::MethodType method_type() const {
 817       return _constMethod->method_type();
 818   }
 819   bool is_overpass() const { return method_type() == ConstMethod::OVERPASS; }
 820 
 821   // On-stack replacement support
 822   bool has_osr_nmethod(int level, bool match_level) {
 823    return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
 824   }
 825 
 826   int mark_osr_nmethods() {
 827     return method_holder()->mark_osr_nmethods(this);
 828   }
 829 
 830   nmethod* lookup_osr_nmethod_for(int bci, int level, bool match_level) {
 831     return method_holder()->lookup_osr_nmethod(this, bci, level, match_level);
 832   }
 833 
 834   // Inline cache support


< prev index next >