< prev index next >

src/hotspot/share/oops/method.hpp

Print this page

   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_METHOD_HPP
  26 #define SHARE_OOPS_METHOD_HPP
  27 

  28 #include "code/compressedStream.hpp"
  29 #include "compiler/compilerDefinitions.hpp"
  30 #include "interpreter/invocationCounter.hpp"
  31 #include "oops/annotations.hpp"
  32 #include "oops/constantPool.hpp"
  33 #include "oops/methodCounters.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/oop.hpp"
  36 #include "oops/typeArrayOop.hpp"
  37 #include "utilities/accessFlags.hpp"
  38 #include "utilities/align.hpp"
  39 #include "utilities/growableArray.hpp"
  40 #include "utilities/macros.hpp"
  41 #include "utilities/vmEnums.hpp"
  42 #if INCLUDE_JFR
  43 #include "jfr/support/jfrTraceIdExtension.hpp"
  44 #endif
  45 
  46 
  47 // A Method represents a Java method.

  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   AccessFlags       _access_flags;               // Access flags
  80   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
  81                                                  // note: can have vtables with >2**16 elements (because of inheritance)
  82   u2                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
  83 
  84   // Flags
  85   enum Flags {
  86     _caller_sensitive      = 1 << 0,
  87     _force_inline          = 1 << 1,
  88     _dont_inline           = 1 << 2,
  89     _hidden                = 1 << 3,
  90     _has_injected_profile  = 1 << 4,
  91     _intrinsic_candidate   = 1 << 5,
  92     _reserved_stack_access = 1 << 6,
  93     _scoped                = 1 << 7


  94   };
  95   mutable u2 _flags;
  96 
  97   JFR_ONLY(DEFINE_TRACE_FLAG;)
  98 
  99 #ifndef PRODUCT
 100   int64_t _compiled_invocation_count;
 101 #endif
 102   // Entry point for calling both from and to the interpreter.
 103   address _i2i_entry;           // All-args-on-stack calling convention
 104   // Entry point for calling from compiled code, to compiled code if it exists
 105   // or else the interpreter.
 106   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 107   // The entry point for calling both from and to compiled code is
 108   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 109   // field can come and go.  It can transition from NULL to not-null at any
 110   // time (whenever a compile completes).  It can transition from not-null to
 111   // NULL only at safepoints (because of a de-opt).
 112   CompiledMethod* volatile _code;                       // Points to the corresponding piece of native code
 113   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 114 


 115   // Constructor
 116   Method(ConstMethod* xconst, AccessFlags access_flags);
 117  public:
 118 
 119   static Method* allocate(ClassLoaderData* loader_data,
 120                           int byte_code_size,
 121                           AccessFlags access_flags,
 122                           InlineTableSizes* sizes,
 123                           ConstMethod::MethodType method_type,
 124                           TRAPS);
 125 
 126   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 127   Method(){}
 128 
 129   virtual bool is_method() const { return true; }
 130 
 131   void restore_unshareable_info(TRAPS);
 132 
 133   // accessors for instance variables
 134 

 448   static void set_code(const methodHandle& mh, CompiledMethod* code);
 449   void set_adapter_entry(AdapterHandlerEntry* adapter) {
 450     _adapter = adapter;
 451   }
 452   void set_from_compiled_entry(address entry) {
 453     _from_compiled_entry =  entry;
 454   }
 455 
 456   address get_i2c_entry();
 457   address get_c2i_entry();
 458   address get_c2i_unverified_entry();
 459   address get_c2i_no_clinit_check_entry();
 460   AdapterHandlerEntry* adapter() const {
 461     return _adapter;
 462   }
 463   // setup entry points
 464   void link_method(const methodHandle& method, TRAPS);
 465   // clear entry points. Used by sharing code during dump time
 466   void unlink_method() NOT_CDS_RETURN;
 467 



 468   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 469   virtual MetaspaceObj::Type type() const { return MethodType; }
 470 
 471   // vtable index
 472   enum VtableIndexFlag {
 473     // Valid vtable indexes are non-negative (>= 0).
 474     // These few negative values are used as sentinels.
 475     itable_index_max        = -10, // first itable index, growing downward
 476     pending_itable_index    = -9,  // itable index will be assigned
 477     invalid_vtable_index    = -4,  // distinct from any valid vtable index
 478     garbage_vtable_index    = -3,  // not yet linked; no vtable layout yet
 479     nonvirtual_vtable_index = -2   // there is no need for vtable dispatch
 480     // 6330203 Note:  Do not use -1, which was overloaded with many meanings.
 481   };
 482   DEBUG_ONLY(bool valid_vtable_index() const     { return _vtable_index >= nonvirtual_vtable_index; })
 483   bool has_vtable_index() const                  { return _vtable_index >= 0; }
 484   int  vtable_index() const                      { return _vtable_index; }
 485   void set_vtable_index(int index);
 486   DEBUG_ONLY(bool valid_itable_index() const     { return _vtable_index <= pending_itable_index; })
 487   bool has_itable_index() const                  { return _vtable_index <= itable_index_max; }

 703   int validate_bci_from_bcp(address bcp) const;
 704   int validate_bci(int bci) const;
 705 
 706   // Returns the line number for a bci if debugging information for the method is prowided,
 707   // -1 is returned otherwise.
 708   int line_number_from_bci(int bci) const;
 709 
 710   // Reflection support
 711   bool is_overridden_in(Klass* k) const;
 712 
 713   // Stack walking support
 714   bool is_ignored_by_security_stack_walk() const;
 715 
 716   // JSR 292 support
 717   bool is_method_handle_intrinsic() const;          // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
 718   bool is_compiled_lambda_form() const;             // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
 719   bool has_member_arg() const;                      // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
 720   static methodHandle make_method_handle_intrinsic(vmIntrinsicID iid, // _invokeBasic, _linkToVirtual
 721                                                    Symbol* signature, //anything at all
 722                                                    TRAPS);







 723   static Klass* check_non_bcp_klass(Klass* klass);
 724 
 725   enum {
 726     // How many extra stack entries for invokedynamic
 727     extra_stack_entries_for_jsr292 = 1
 728   };
 729 
 730   // this operates only on invoke methods:
 731   // presize interpreter frames for extra interpreter stack entries, if needed
 732   // Account for the extra appendix argument for invokehandle/invokedynamic
 733   static int extra_stack_entries() { return extra_stack_entries_for_jsr292; }
 734   static int extra_stack_words();  // = extra_stack_entries() * Interpreter::stackElementSize
 735 
 736   // RedefineClasses() support:
 737   bool is_old() const                               { return access_flags().is_old(); }
 738   void set_is_old()                                 { _access_flags.set_is_old(); }
 739   bool is_obsolete() const                          { return access_flags().is_obsolete(); }
 740   void set_is_obsolete()                            { _access_flags.set_is_obsolete(); }
 741   bool is_deleted() const                           { return access_flags().is_deleted(); }
 742   void set_is_deleted()                             { _access_flags.set_is_deleted(); }
 743 
 744   bool on_stack() const                             { return access_flags().on_stack(); }
 745   void set_on_stack(const bool value);
 746 


 747   // see the definition in Method*.cpp for the gory details
 748   bool should_not_be_cached() const;
 749 
 750   // JVMTI Native method prefixing support:
 751   bool is_prefixed_native() const                   { return access_flags().is_prefixed_native(); }
 752   void set_is_prefixed_native()                     { _access_flags.set_is_prefixed_native(); }
 753 
 754   // Rewriting support
 755   static methodHandle clone_with_new_data(const methodHandle& m, u_char* new_code, int new_code_length,
 756                                           u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS);
 757 
 758   // jmethodID handling
 759   // Because the useful life-span of a jmethodID cannot be determined,
 760   // once created they are never reclaimed.  The methods to which they refer,
 761   // however, can be GC'ed away if the class is unloaded or if the method is
 762   // made obsolete or deleted -- in these cases, the jmethodID
 763   // refers to NULL (as is the case for any weak reference).
 764   static jmethodID make_jmethod_id(ClassLoaderData* loader_data, Method* mh);
 765   static void destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID mid);
 766 

 811     return (_flags & _caller_sensitive) != 0;
 812   }
 813   void set_caller_sensitive(bool x) {
 814     _flags = x ? (_flags | _caller_sensitive) : (_flags & ~_caller_sensitive);
 815   }
 816 
 817   bool force_inline() {
 818     return (_flags & _force_inline) != 0;
 819   }
 820   void set_force_inline(bool x) {
 821     _flags = x ? (_flags | _force_inline) : (_flags & ~_force_inline);
 822   }
 823 
 824   bool dont_inline() {
 825     return (_flags & _dont_inline) != 0;
 826   }
 827   void set_dont_inline(bool x) {
 828     _flags = x ? (_flags | _dont_inline) : (_flags & ~_dont_inline);
 829   }
 830 














 831   bool is_hidden() const {
 832     return (_flags & _hidden) != 0;
 833   }
 834 
 835   void set_hidden(bool x) {
 836     _flags = x ? (_flags | _hidden) : (_flags & ~_hidden);
 837   }
 838 
 839   bool is_scoped() const {
 840     return (_flags & _scoped) != 0;
 841   }
 842 
 843   void set_scoped(bool x) {
 844     _flags = x ? (_flags | _scoped) : (_flags & ~_scoped);
 845   }
 846 
 847   bool intrinsic_candidate() {
 848     return (_flags & _intrinsic_candidate) != 0;
 849   }
 850   void set_intrinsic_candidate(bool x) {

 925 
 926   bool    is_not_c1_osr_compilable() const    { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
 927   void   set_not_c1_osr_compilable()          {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
 928   void clear_not_c1_osr_compilable()          {     clear_not_c1_compilable(); }  // don't waste an accessFlags bit
 929   bool   is_not_c2_osr_compilable() const     { return access_flags().is_not_c2_osr_compilable();  }
 930   void  set_not_c2_osr_compilable()           {       _access_flags.set_not_c2_osr_compilable();   }
 931   void clear_not_c2_osr_compilable()          {       _access_flags.clear_not_c2_osr_compilable(); }
 932 
 933   // Background compilation support
 934   bool queued_for_compilation() const  { return access_flags().queued_for_compilation(); }
 935   void set_queued_for_compilation()    { _access_flags.set_queued_for_compilation();     }
 936   void clear_queued_for_compilation()  { _access_flags.clear_queued_for_compilation();   }
 937 
 938   // Resolve all classes in signature, return 'true' if successful
 939   static bool load_signature_classes(const methodHandle& m, TRAPS);
 940 
 941   // Return if true if not all classes references in signature, including return type, has been loaded
 942   static bool has_unloaded_classes_in_signature(const methodHandle& m, TRAPS);
 943 
 944   // Printing
 945   void print_short_name(outputStream* st = tty); // prints as klassname::methodname; Exposed so field engineers can debug VM
 946 #if INCLUDE_JVMTI
 947   void print_name(outputStream* st = tty); // prints as "virtual void foo(int)"; exposed for -Xlog:redefine+class
 948 #else
 949   void print_name(outputStream* st = tty)        PRODUCT_RETURN; // prints as "virtual void foo(int)"
 950 #endif
 951 
 952   typedef int (*method_comparator_func)(Method* a, Method* b);
 953 
 954   // Helper routine used for method sorting
 955   static void sort_methods(Array<Method*>* methods, bool set_idnums = true, method_comparator_func func = NULL);
 956 
 957   // Deallocation function for redefine classes or if an error occurs
 958   void deallocate_contents(ClassLoaderData* loader_data);
 959 
 960   void release_C_heap_structures();
 961 
 962   Method* get_new_method() const {
 963     InstanceKlass* holder = method_holder();
 964     Method* new_method = holder->method_with_idnum(orig_method_idnum());
 965 
 966     assert(new_method != NULL, "method_with_idnum() should not be NULL");
 967     assert(this != new_method, "sanity check");
 968     return new_method;
 969   }

 973   void print_on(outputStream* st) const;
 974 #endif
 975   void print_value_on(outputStream* st) const;
 976   void print_linkage_flags(outputStream* st) PRODUCT_RETURN;
 977 
 978   const char* internal_name() const { return "{method}"; }
 979 
 980   // Check for valid method pointer
 981   static bool has_method_vptr(const void* ptr);
 982   static bool is_valid_method(const Method* m);
 983 
 984   // Verify
 985   void verify() { verify_on(tty); }
 986   void verify_on(outputStream* st);
 987 
 988  private:
 989 
 990   // Inlined elements
 991   address* native_function_addr() const          { assert(is_native(), "must be native"); return (address*) (this+1); }
 992   address* signature_handler_addr() const        { return native_function_addr() + 1; }


 993 };
 994 
 995 
 996 // Utility class for compressing line number tables
 997 
 998 class CompressedLineNumberWriteStream: public CompressedWriteStream {
 999  private:
1000   int _bci;
1001   int _line;
1002  public:
1003   // Constructor
1004   CompressedLineNumberWriteStream(int initial_size) : CompressedWriteStream(initial_size), _bci(0), _line(0) {}
1005   CompressedLineNumberWriteStream(u_char* buffer, int initial_size) : CompressedWriteStream(buffer, initial_size), _bci(0), _line(0) {}
1006 
1007   // Write (bci, line number) pair to stream
1008   void write_pair_regular(int bci_delta, int line_delta);
1009 
1010   // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1011   // we save it as one byte, otherwise we write a 0xFF escape character
1012   // and use regular compression. 0x0 is used as end-of-stream terminator.

   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_METHOD_HPP
  26 #define SHARE_OOPS_METHOD_HPP
  27 
  28 #include "classfile/vmSymbols.hpp"
  29 #include "code/compressedStream.hpp"
  30 #include "compiler/compilerDefinitions.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/align.hpp"
  40 #include "utilities/growableArray.hpp"
  41 #include "utilities/macros.hpp"
  42 #include "utilities/vmEnums.hpp"
  43 #if INCLUDE_JFR
  44 #include "jfr/support/jfrTraceIdExtension.hpp"
  45 #endif
  46 
  47 
  48 // A Method represents a Java method.

  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   AccessFlags       _access_flags;               // Access flags
  81   int               _vtable_index;               // vtable index of this method (see VtableIndexFlag)
  82                                                  // note: can have vtables with >2**16 elements (because of inheritance)
  83   u2                _intrinsic_id;               // vmSymbols::intrinsic_id (0 == _none)
  84 
  85   // Flags
  86   enum Flags {
  87     _caller_sensitive      = 1 << 0,
  88     _force_inline          = 1 << 1,
  89     _dont_inline           = 1 << 2,
  90     _hidden                = 1 << 3,
  91     _has_injected_profile  = 1 << 4,
  92     _intrinsic_candidate   = 1 << 5,
  93     _reserved_stack_access = 1 << 6,
  94     _scoped                = 1 << 7,
  95     _changes_current_thread = 1 << 8,
  96     _jvmti_mount_transition = 1 << 9,
  97   };
  98   mutable u2 _flags;
  99 
 100   JFR_ONLY(DEFINE_TRACE_FLAG;)
 101 
 102 #ifndef PRODUCT
 103   int64_t _compiled_invocation_count;
 104 #endif
 105   // Entry point for calling both from and to the interpreter.
 106   address _i2i_entry;           // All-args-on-stack calling convention
 107   // Entry point for calling from compiled code, to compiled code if it exists
 108   // or else the interpreter.
 109   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 110   // The entry point for calling both from and to compiled code is
 111   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 112   // field can come and go.  It can transition from NULL to not-null at any
 113   // time (whenever a compile completes).  It can transition from not-null to
 114   // NULL only at safepoints (because of a de-opt).
 115   CompiledMethod* volatile _code;                       // Points to the corresponding piece of native code
 116   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 117 
 118   int _num_stack_arg_slots;
 119 
 120   // Constructor
 121   Method(ConstMethod* xconst, AccessFlags access_flags);
 122  public:
 123 
 124   static Method* allocate(ClassLoaderData* loader_data,
 125                           int byte_code_size,
 126                           AccessFlags access_flags,
 127                           InlineTableSizes* sizes,
 128                           ConstMethod::MethodType method_type,
 129                           TRAPS);
 130 
 131   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 132   Method(){}
 133 
 134   virtual bool is_method() const { return true; }
 135 
 136   void restore_unshareable_info(TRAPS);
 137 
 138   // accessors for instance variables
 139 

 453   static void set_code(const methodHandle& mh, CompiledMethod* code);
 454   void set_adapter_entry(AdapterHandlerEntry* adapter) {
 455     _adapter = adapter;
 456   }
 457   void set_from_compiled_entry(address entry) {
 458     _from_compiled_entry =  entry;
 459   }
 460 
 461   address get_i2c_entry();
 462   address get_c2i_entry();
 463   address get_c2i_unverified_entry();
 464   address get_c2i_no_clinit_check_entry();
 465   AdapterHandlerEntry* adapter() const {
 466     return _adapter;
 467   }
 468   // setup entry points
 469   void link_method(const methodHandle& method, TRAPS);
 470   // clear entry points. Used by sharing code during dump time
 471   void unlink_method() NOT_CDS_RETURN;
 472 
 473   // the number of argument reg slots that the compiled method uses on the stack.
 474   int num_stack_arg_slots() const { return _num_stack_arg_slots;  };
 475 
 476   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 477   virtual MetaspaceObj::Type type() const { return MethodType; }
 478 
 479   // vtable index
 480   enum VtableIndexFlag {
 481     // Valid vtable indexes are non-negative (>= 0).
 482     // These few negative values are used as sentinels.
 483     itable_index_max        = -10, // first itable index, growing downward
 484     pending_itable_index    = -9,  // itable index will be assigned
 485     invalid_vtable_index    = -4,  // distinct from any valid vtable index
 486     garbage_vtable_index    = -3,  // not yet linked; no vtable layout yet
 487     nonvirtual_vtable_index = -2   // there is no need for vtable dispatch
 488     // 6330203 Note:  Do not use -1, which was overloaded with many meanings.
 489   };
 490   DEBUG_ONLY(bool valid_vtable_index() const     { return _vtable_index >= nonvirtual_vtable_index; })
 491   bool has_vtable_index() const                  { return _vtable_index >= 0; }
 492   int  vtable_index() const                      { return _vtable_index; }
 493   void set_vtable_index(int index);
 494   DEBUG_ONLY(bool valid_itable_index() const     { return _vtable_index <= pending_itable_index; })
 495   bool has_itable_index() const                  { return _vtable_index <= itable_index_max; }

 711   int validate_bci_from_bcp(address bcp) const;
 712   int validate_bci(int bci) const;
 713 
 714   // Returns the line number for a bci if debugging information for the method is prowided,
 715   // -1 is returned otherwise.
 716   int line_number_from_bci(int bci) const;
 717 
 718   // Reflection support
 719   bool is_overridden_in(Klass* k) const;
 720 
 721   // Stack walking support
 722   bool is_ignored_by_security_stack_walk() const;
 723 
 724   // JSR 292 support
 725   bool is_method_handle_intrinsic() const;          // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
 726   bool is_compiled_lambda_form() const;             // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
 727   bool has_member_arg() const;                      // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
 728   static methodHandle make_method_handle_intrinsic(vmIntrinsicID iid, // _invokeBasic, _linkToVirtual
 729                                                    Symbol* signature, //anything at all
 730                                                    TRAPS);
 731 
 732 
 733   // Continuation
 734   bool is_continuation_enter_intrinsic() const { return intrinsic_id() == vmIntrinsics::_Continuation_enterSpecial; }
 735 
 736   bool is_special_native_intrinsic() const { return is_method_handle_intrinsic() || is_continuation_enter_intrinsic(); }
 737 
 738   static Klass* check_non_bcp_klass(Klass* klass);
 739 
 740   enum {
 741     // How many extra stack entries for invokedynamic
 742     extra_stack_entries_for_jsr292 = 1
 743   };
 744 
 745   // this operates only on invoke methods:
 746   // presize interpreter frames for extra interpreter stack entries, if needed
 747   // Account for the extra appendix argument for invokehandle/invokedynamic
 748   static int extra_stack_entries() { return extra_stack_entries_for_jsr292; }
 749   static int extra_stack_words();  // = extra_stack_entries() * Interpreter::stackElementSize
 750 
 751   // RedefineClasses() support:
 752   bool is_old() const                               { return access_flags().is_old(); }
 753   void set_is_old()                                 { _access_flags.set_is_old(); }
 754   bool is_obsolete() const                          { return access_flags().is_obsolete(); }
 755   void set_is_obsolete()                            { _access_flags.set_is_obsolete(); }
 756   bool is_deleted() const                           { return access_flags().is_deleted(); }
 757   void set_is_deleted()                             { _access_flags.set_is_deleted(); }
 758 
 759   bool on_stack() const                             { return access_flags().on_stack(); }
 760   void set_on_stack(const bool value);
 761 
 762   void record_marking_cycle();
 763 
 764   // see the definition in Method*.cpp for the gory details
 765   bool should_not_be_cached() const;
 766 
 767   // JVMTI Native method prefixing support:
 768   bool is_prefixed_native() const                   { return access_flags().is_prefixed_native(); }
 769   void set_is_prefixed_native()                     { _access_flags.set_is_prefixed_native(); }
 770 
 771   // Rewriting support
 772   static methodHandle clone_with_new_data(const methodHandle& m, u_char* new_code, int new_code_length,
 773                                           u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS);
 774 
 775   // jmethodID handling
 776   // Because the useful life-span of a jmethodID cannot be determined,
 777   // once created they are never reclaimed.  The methods to which they refer,
 778   // however, can be GC'ed away if the class is unloaded or if the method is
 779   // made obsolete or deleted -- in these cases, the jmethodID
 780   // refers to NULL (as is the case for any weak reference).
 781   static jmethodID make_jmethod_id(ClassLoaderData* loader_data, Method* mh);
 782   static void destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID mid);
 783 

 828     return (_flags & _caller_sensitive) != 0;
 829   }
 830   void set_caller_sensitive(bool x) {
 831     _flags = x ? (_flags | _caller_sensitive) : (_flags & ~_caller_sensitive);
 832   }
 833 
 834   bool force_inline() {
 835     return (_flags & _force_inline) != 0;
 836   }
 837   void set_force_inline(bool x) {
 838     _flags = x ? (_flags | _force_inline) : (_flags & ~_force_inline);
 839   }
 840 
 841   bool dont_inline() {
 842     return (_flags & _dont_inline) != 0;
 843   }
 844   void set_dont_inline(bool x) {
 845     _flags = x ? (_flags | _dont_inline) : (_flags & ~_dont_inline);
 846   }
 847 
 848   bool changes_current_thread() {
 849     return (_flags & _changes_current_thread) != 0;
 850   }
 851   void set_changes_current_thread(bool x) {
 852     _flags = x ? (_flags | _changes_current_thread) : (_flags & ~_changes_current_thread);
 853   }
 854 
 855   bool jvmti_mount_transition() {
 856     return (_flags & _jvmti_mount_transition) != 0;
 857   }
 858   void set_jvmti_mount_transition(bool x) {
 859     _flags = x ? (_flags | _jvmti_mount_transition) : (_flags & ~_jvmti_mount_transition);
 860   }
 861 
 862   bool is_hidden() const {
 863     return (_flags & _hidden) != 0;
 864   }
 865 
 866   void set_hidden(bool x) {
 867     _flags = x ? (_flags | _hidden) : (_flags & ~_hidden);
 868   }
 869 
 870   bool is_scoped() const {
 871     return (_flags & _scoped) != 0;
 872   }
 873 
 874   void set_scoped(bool x) {
 875     _flags = x ? (_flags | _scoped) : (_flags & ~_scoped);
 876   }
 877 
 878   bool intrinsic_candidate() {
 879     return (_flags & _intrinsic_candidate) != 0;
 880   }
 881   void set_intrinsic_candidate(bool x) {

 956 
 957   bool    is_not_c1_osr_compilable() const    { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
 958   void   set_not_c1_osr_compilable()          {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
 959   void clear_not_c1_osr_compilable()          {     clear_not_c1_compilable(); }  // don't waste an accessFlags bit
 960   bool   is_not_c2_osr_compilable() const     { return access_flags().is_not_c2_osr_compilable();  }
 961   void  set_not_c2_osr_compilable()           {       _access_flags.set_not_c2_osr_compilable();   }
 962   void clear_not_c2_osr_compilable()          {       _access_flags.clear_not_c2_osr_compilable(); }
 963 
 964   // Background compilation support
 965   bool queued_for_compilation() const  { return access_flags().queued_for_compilation(); }
 966   void set_queued_for_compilation()    { _access_flags.set_queued_for_compilation();     }
 967   void clear_queued_for_compilation()  { _access_flags.clear_queued_for_compilation();   }
 968 
 969   // Resolve all classes in signature, return 'true' if successful
 970   static bool load_signature_classes(const methodHandle& m, TRAPS);
 971 
 972   // Return if true if not all classes references in signature, including return type, has been loaded
 973   static bool has_unloaded_classes_in_signature(const methodHandle& m, TRAPS);
 974 
 975   // Printing
 976   void print_short_name(outputStream* st = tty) const; // prints as klassname::methodname; Exposed so field engineers can debug VM
 977 #if INCLUDE_JVMTI
 978   void print_name(outputStream* st = tty) const; // prints as "virtual void foo(int)"; exposed for -Xlog:redefine+class
 979 #else
 980   void print_name(outputStream* st = tty) const  PRODUCT_RETURN; // prints as "virtual void foo(int)"
 981 #endif
 982 
 983   typedef int (*method_comparator_func)(Method* a, Method* b);
 984 
 985   // Helper routine used for method sorting
 986   static void sort_methods(Array<Method*>* methods, bool set_idnums = true, method_comparator_func func = NULL);
 987 
 988   // Deallocation function for redefine classes or if an error occurs
 989   void deallocate_contents(ClassLoaderData* loader_data);
 990 
 991   void release_C_heap_structures();
 992 
 993   Method* get_new_method() const {
 994     InstanceKlass* holder = method_holder();
 995     Method* new_method = holder->method_with_idnum(orig_method_idnum());
 996 
 997     assert(new_method != NULL, "method_with_idnum() should not be NULL");
 998     assert(this != new_method, "sanity check");
 999     return new_method;
1000   }

1004   void print_on(outputStream* st) const;
1005 #endif
1006   void print_value_on(outputStream* st) const;
1007   void print_linkage_flags(outputStream* st) PRODUCT_RETURN;
1008 
1009   const char* internal_name() const { return "{method}"; }
1010 
1011   // Check for valid method pointer
1012   static bool has_method_vptr(const void* ptr);
1013   static bool is_valid_method(const Method* m);
1014 
1015   // Verify
1016   void verify() { verify_on(tty); }
1017   void verify_on(outputStream* st);
1018 
1019  private:
1020 
1021   // Inlined elements
1022   address* native_function_addr() const          { assert(is_native(), "must be native"); return (address*) (this+1); }
1023   address* signature_handler_addr() const        { return native_function_addr() + 1; }
1024 
1025   void set_num_stack_arg_slots();
1026 };
1027 
1028 
1029 // Utility class for compressing line number tables
1030 
1031 class CompressedLineNumberWriteStream: public CompressedWriteStream {
1032  private:
1033   int _bci;
1034   int _line;
1035  public:
1036   // Constructor
1037   CompressedLineNumberWriteStream(int initial_size) : CompressedWriteStream(initial_size), _bci(0), _line(0) {}
1038   CompressedLineNumberWriteStream(u_char* buffer, int initial_size) : CompressedWriteStream(buffer, initial_size), _bci(0), _line(0) {}
1039 
1040   // Write (bci, line number) pair to stream
1041   void write_pair_regular(int bci_delta, int line_delta);
1042 
1043   // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1044   // we save it as one byte, otherwise we write a 0xFF escape character
1045   // and use regular compression. 0x0 is used as end-of-stream terminator.
< prev index next >