< prev index next >

src/hotspot/share/oops/method.hpp

Print this page




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


 116 #if INCLUDE_AOT && defined(TIERED)
 117   CompiledMethod* _aot_code;
 118 #endif
 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   bool is_method() const volatile { return true; }
 135 


 473   }
 474   void update_adapter_trampoline(AdapterHandlerEntry* adapter) {
 475     constMethod()->update_adapter_trampoline(adapter);
 476   }
 477   void set_from_compiled_entry(address entry) {
 478     _from_compiled_entry =  entry;
 479   }
 480 
 481   address get_i2c_entry();
 482   address get_c2i_entry();
 483   address get_c2i_unverified_entry();
 484   address get_c2i_no_clinit_check_entry();
 485   AdapterHandlerEntry* adapter() const {
 486     return constMethod()->adapter();
 487   }
 488   // setup entry points
 489   void link_method(const methodHandle& method, TRAPS);
 490   // clear entry points. Used by sharing code during dump time
 491   void unlink_method() NOT_CDS_RETURN;
 492 



 493   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 494   virtual MetaspaceObj::Type type() const { return MethodType; }
 495 
 496   // vtable index
 497   enum VtableIndexFlag {
 498     // Valid vtable indexes are non-negative (>= 0).
 499     // These few negative values are used as sentinels.
 500     itable_index_max        = -10, // first itable index, growing downward
 501     pending_itable_index    = -9,  // itable index will be assigned
 502     invalid_vtable_index    = -4,  // distinct from any valid vtable index
 503     garbage_vtable_index    = -3,  // not yet linked; no vtable layout yet
 504     nonvirtual_vtable_index = -2   // there is no need for vtable dispatch
 505     // 6330203 Note:  Do not use -1, which was overloaded with many meanings.
 506   };
 507   DEBUG_ONLY(bool valid_vtable_index() const     { return _vtable_index >= nonvirtual_vtable_index; })
 508   bool has_vtable_index() const                  { return _vtable_index >= 0; }
 509   int  vtable_index() const                      { return _vtable_index; }
 510   void set_vtable_index(int index);
 511   DEBUG_ONLY(bool valid_itable_index() const     { return _vtable_index <= pending_itable_index; })
 512   bool has_itable_index() const                  { return _vtable_index <= itable_index_max; }


 966 
 967   bool    is_not_c1_osr_compilable() const    { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
 968   void   set_not_c1_osr_compilable()          {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
 969   void clear_not_c1_osr_compilable()          {     clear_not_c1_compilable(); }  // don't waste an accessFlags bit
 970   bool   is_not_c2_osr_compilable() const     { return access_flags().is_not_c2_osr_compilable();  }
 971   void  set_not_c2_osr_compilable()           {       _access_flags.set_not_c2_osr_compilable();   }
 972   void clear_not_c2_osr_compilable()          {       _access_flags.clear_not_c2_osr_compilable(); }
 973 
 974   // Background compilation support
 975   bool queued_for_compilation() const  { return access_flags().queued_for_compilation(); }
 976   void set_queued_for_compilation()    { _access_flags.set_queued_for_compilation();     }
 977   void clear_queued_for_compilation()  { _access_flags.clear_queued_for_compilation();   }
 978 
 979   // Resolve all classes in signature, return 'true' if successful
 980   static bool load_signature_classes(const methodHandle& m, TRAPS);
 981 
 982   // Return if true if not all classes references in signature, including return type, has been loaded
 983   static bool has_unloaded_classes_in_signature(const methodHandle& m, TRAPS);
 984 
 985   // Printing
 986   void print_short_name(outputStream* st = tty); // prints as klassname::methodname; Exposed so field engineers can debug VM
 987 #if INCLUDE_JVMTI
 988   void print_name(outputStream* st = tty); // prints as "virtual void foo(int)"; exposed for TraceRedefineClasses
 989 #else
 990   void print_name(outputStream* st = tty)        PRODUCT_RETURN; // prints as "virtual void foo(int)"
 991 #endif
 992 
 993   // Helper routine used for method sorting
 994   static void sort_methods(Array<Method*>* methods, bool set_idnums = true);
 995 
 996   // Deallocation function for redefine classes or if an error occurs
 997   void deallocate_contents(ClassLoaderData* loader_data);
 998 
 999   Method* get_new_method() const {
1000     InstanceKlass* holder = method_holder();
1001     Method* new_method = holder->method_with_idnum(orig_method_idnum());
1002 
1003     assert(new_method != NULL, "method_with_idnum() should not be NULL");
1004     assert(this != new_method, "sanity check");
1005     return new_method;
1006   }
1007 
1008   // Printing
1009 #ifndef PRODUCT
1010   void print_on(outputStream* st) const;
1011 #endif
1012   void print_value_on(outputStream* st) const;
1013   void print_linkage_flags(outputStream* st) PRODUCT_RETURN;
1014 
1015   const char* internal_name() const { return "{method}"; }
1016 
1017   // Check for valid method pointer
1018   static bool has_method_vptr(const void* ptr);
1019   static bool is_valid_method(const Method* m);
1020 
1021   // Verify
1022   void verify() { verify_on(tty); }
1023   void verify_on(outputStream* st);
1024 
1025  private:
1026 
1027   // Inlined elements
1028   address* native_function_addr() const          { assert(is_native(), "must be native"); return (address*) (this+1); }
1029   address* signature_handler_addr() const        { return native_function_addr() + 1; }


1030 };
1031 
1032 
1033 // Utility class for compressing line number tables
1034 
1035 class CompressedLineNumberWriteStream: public CompressedWriteStream {
1036  private:
1037   int _bci;
1038   int _line;
1039  public:
1040   // Constructor
1041   CompressedLineNumberWriteStream(int initial_size) : CompressedWriteStream(initial_size), _bci(0), _line(0) {}
1042   CompressedLineNumberWriteStream(u_char* buffer, int initial_size) : CompressedWriteStream(buffer, initial_size), _bci(0), _line(0) {}
1043 
1044   // Write (bci, line number) pair to stream
1045   void write_pair_regular(int bci_delta, int line_delta);
1046 
1047   // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1048   // we save it as one byte, otherwise we write a 0xFF escape character
1049   // and use regular compression. 0x0 is used as end-of-stream terminator.




  96   mutable u2 _flags;
  97 
  98   JFR_ONLY(DEFINE_TRACE_FLAG;)
  99 
 100 #ifndef PRODUCT
 101   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 102 #endif
 103   // Entry point for calling both from and to the interpreter.
 104   address _i2i_entry;           // All-args-on-stack calling convention
 105   // Entry point for calling from compiled code, to compiled code if it exists
 106   // or else the interpreter.
 107   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 108   // The entry point for calling both from and to compiled code is
 109   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 110   // field can come and go.  It can transition from NULL to not-null at any
 111   // time (whenever a compile completes).  It can transition from not-null to
 112   // NULL only at safepoints (because of a de-opt).
 113   CompiledMethod* volatile _code;                       // Points to the corresponding piece of native code
 114   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 115 
 116   int _num_stack_arg_slots;
 117   
 118 #if INCLUDE_AOT && defined(TIERED)
 119   CompiledMethod* _aot_code;
 120 #endif
 121 
 122   // Constructor
 123   Method(ConstMethod* xconst, AccessFlags access_flags);
 124  public:
 125 
 126   static Method* allocate(ClassLoaderData* loader_data,
 127                           int byte_code_size,
 128                           AccessFlags access_flags,
 129                           InlineTableSizes* sizes,
 130                           ConstMethod::MethodType method_type,
 131                           TRAPS);
 132 
 133   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 134   Method(){}
 135 
 136   bool is_method() const volatile { return true; }
 137 


 475   }
 476   void update_adapter_trampoline(AdapterHandlerEntry* adapter) {
 477     constMethod()->update_adapter_trampoline(adapter);
 478   }
 479   void set_from_compiled_entry(address entry) {
 480     _from_compiled_entry =  entry;
 481   }
 482 
 483   address get_i2c_entry();
 484   address get_c2i_entry();
 485   address get_c2i_unverified_entry();
 486   address get_c2i_no_clinit_check_entry();
 487   AdapterHandlerEntry* adapter() const {
 488     return constMethod()->adapter();
 489   }
 490   // setup entry points
 491   void link_method(const methodHandle& method, TRAPS);
 492   // clear entry points. Used by sharing code during dump time
 493   void unlink_method() NOT_CDS_RETURN;
 494 
 495   // the number of argument reg slots that the compiled method uses on the stack.
 496   int num_stack_arg_slots() const { return _num_stack_arg_slots;  };
 497 
 498   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 499   virtual MetaspaceObj::Type type() const { return MethodType; }
 500 
 501   // vtable index
 502   enum VtableIndexFlag {
 503     // Valid vtable indexes are non-negative (>= 0).
 504     // These few negative values are used as sentinels.
 505     itable_index_max        = -10, // first itable index, growing downward
 506     pending_itable_index    = -9,  // itable index will be assigned
 507     invalid_vtable_index    = -4,  // distinct from any valid vtable index
 508     garbage_vtable_index    = -3,  // not yet linked; no vtable layout yet
 509     nonvirtual_vtable_index = -2   // there is no need for vtable dispatch
 510     // 6330203 Note:  Do not use -1, which was overloaded with many meanings.
 511   };
 512   DEBUG_ONLY(bool valid_vtable_index() const     { return _vtable_index >= nonvirtual_vtable_index; })
 513   bool has_vtable_index() const                  { return _vtable_index >= 0; }
 514   int  vtable_index() const                      { return _vtable_index; }
 515   void set_vtable_index(int index);
 516   DEBUG_ONLY(bool valid_itable_index() const     { return _vtable_index <= pending_itable_index; })
 517   bool has_itable_index() const                  { return _vtable_index <= itable_index_max; }


 971 
 972   bool    is_not_c1_osr_compilable() const    { return is_not_c1_compilable(); }  // don't waste an accessFlags bit
 973   void   set_not_c1_osr_compilable()          {       set_not_c1_compilable(); }  // don't waste an accessFlags bit
 974   void clear_not_c1_osr_compilable()          {     clear_not_c1_compilable(); }  // don't waste an accessFlags bit
 975   bool   is_not_c2_osr_compilable() const     { return access_flags().is_not_c2_osr_compilable();  }
 976   void  set_not_c2_osr_compilable()           {       _access_flags.set_not_c2_osr_compilable();   }
 977   void clear_not_c2_osr_compilable()          {       _access_flags.clear_not_c2_osr_compilable(); }
 978 
 979   // Background compilation support
 980   bool queued_for_compilation() const  { return access_flags().queued_for_compilation(); }
 981   void set_queued_for_compilation()    { _access_flags.set_queued_for_compilation();     }
 982   void clear_queued_for_compilation()  { _access_flags.clear_queued_for_compilation();   }
 983 
 984   // Resolve all classes in signature, return 'true' if successful
 985   static bool load_signature_classes(const methodHandle& m, TRAPS);
 986 
 987   // Return if true if not all classes references in signature, including return type, has been loaded
 988   static bool has_unloaded_classes_in_signature(const methodHandle& m, TRAPS);
 989 
 990   // Printing
 991   void print_short_name(outputStream* st = tty) const; // prints as klassname::methodname; Exposed so field engineers can debug VM
 992 #if INCLUDE_JVMTI
 993   void print_name(outputStream* st = tty) const; // prints as "virtual void foo(int)"; exposed for TraceRedefineClasses
 994 #else
 995   void print_name(outputStream* st = tty) const  PRODUCT_RETURN; // prints as "virtual void foo(int)"
 996 #endif
 997 
 998   // Helper routine used for method sorting
 999   static void sort_methods(Array<Method*>* methods, bool set_idnums = true);
1000 
1001   // Deallocation function for redefine classes or if an error occurs
1002   void deallocate_contents(ClassLoaderData* loader_data);
1003 
1004   Method* get_new_method() const {
1005     InstanceKlass* holder = method_holder();
1006     Method* new_method = holder->method_with_idnum(orig_method_idnum());
1007 
1008     assert(new_method != NULL, "method_with_idnum() should not be NULL");
1009     assert(this != new_method, "sanity check");
1010     return new_method;
1011   }
1012 
1013   // Printing
1014 #ifndef PRODUCT
1015   void print_on(outputStream* st) const;
1016 #endif
1017   void print_value_on(outputStream* st) const;
1018   void print_linkage_flags(outputStream* st) PRODUCT_RETURN;
1019 
1020   const char* internal_name() const { return "{method}"; }
1021 
1022   // Check for valid method pointer
1023   static bool has_method_vptr(const void* ptr);
1024   static bool is_valid_method(const Method* m);
1025 
1026   // Verify
1027   void verify() { verify_on(tty); }
1028   void verify_on(outputStream* st);
1029 
1030  private:
1031 
1032   // Inlined elements
1033   address* native_function_addr() const          { assert(is_native(), "must be native"); return (address*) (this+1); }
1034   address* signature_handler_addr() const        { return native_function_addr() + 1; }
1035 
1036   void set_num_stack_arg_slots();
1037 };
1038 
1039 
1040 // Utility class for compressing line number tables
1041 
1042 class CompressedLineNumberWriteStream: public CompressedWriteStream {
1043  private:
1044   int _bci;
1045   int _line;
1046  public:
1047   // Constructor
1048   CompressedLineNumberWriteStream(int initial_size) : CompressedWriteStream(initial_size), _bci(0), _line(0) {}
1049   CompressedLineNumberWriteStream(u_char* buffer, int initial_size) : CompressedWriteStream(buffer, initial_size), _bci(0), _line(0) {}
1050 
1051   // Write (bci, line number) pair to stream
1052   void write_pair_regular(int bci_delta, int line_delta);
1053 
1054   // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1055   // we save it as one byte, otherwise we write a 0xFF escape character
1056   // and use regular compression. 0x0 is used as end-of-stream terminator.


< prev index next >