102 class MethodData;
103 class ConstMethod;
104 class InlineTableSizes;
105 class KlassSizeStats;
106
107 class Method : public Metadata {
108 friend class VMStructs;
109 private:
110 ConstMethod* _constMethod; // Method read-only data.
111 MethodData* _method_data;
112 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
113 AccessFlags _access_flags; // Access flags
114 int _vtable_index; // vtable index of this method (see VtableIndexFlag)
115 // note: can have vtables with >2**16 elements (because of inheritance)
116 #ifdef CC_INTERP
117 int _result_index; // C++ interpreter needs for converting results to/from stack
118 #endif
119 u2 _method_size; // size of this object
120 u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none)
121 u1 _jfr_towrite : 1, // Flags
122 _force_inline : 1,
123 _hidden : 1,
124 _dont_inline : 1,
125 : 4;
126 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
127 u2 _number_of_breakpoints; // fullspeed debugging support
128 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations
129 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations
130
131 #ifdef TIERED
132 float _rate; // Events (invocation and backedge counter increments) per millisecond
133 jlong _prev_time; // Previous time the rate was acquired
134 #endif
135
136 #ifndef PRODUCT
137 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
138 #endif
139 // Entry point for calling both from and to the interpreter.
140 address _i2i_entry; // All-args-on-stack calling convention
141 // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
142 AdapterHandlerEntry* _adapter;
143 // Entry point for calling from compiled code, to compiled code if it exists
144 // or else the interpreter.
145 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
601 { return offset_of(Method, _interpreter_invocation_count); }
602 static int intrinsic_id_offset_in_bytes() { return offset_of(Method, _intrinsic_id); }
603 static int intrinsic_id_size_in_bytes() { return sizeof(u1); }
604
605 // Static methods that are used to implement member methods where an exposed this pointer
606 // is needed due to possible GCs
607 static objArrayHandle resolved_checked_exceptions_impl(Method* this_oop, TRAPS);
608
609 // Returns the byte code index from the byte code pointer
610 int bci_from(address bcp) const;
611 address bcp_from(int bci) const;
612 int validate_bci_from_bcx(intptr_t bcx) const;
613
614 // Returns the line number for a bci if debugging information for the method is prowided,
615 // -1 is returned otherwise.
616 int line_number_from_bci(int bci) const;
617
618 // Reflection support
619 bool is_overridden_in(Klass* k) const;
620
621 // JSR 292 support
622 bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
623 bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
624 bool has_member_arg() const; // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
625 static methodHandle make_method_handle_intrinsic(vmIntrinsics::ID iid, // _invokeBasic, _linkToVirtual
626 Symbol* signature, //anything at all
627 TRAPS);
628 static Klass* check_non_bcp_klass(Klass* klass);
629 // these operate only on invoke methods:
630 // presize interpreter frames for extra interpreter stack entries, if needed
631 // method handles want to be able to push a few extra values (e.g., a bound receiver), and
632 // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist,
633 // all without checking for a stack overflow
634 static int extra_stack_entries() { return EnableInvokeDynamic ? 2 : 0; }
635 static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize()
636
637 // RedefineClasses() support:
638 bool is_old() const { return access_flags().is_old(); }
639 void set_is_old() { _access_flags.set_is_old(); }
640 bool is_obsolete() const { return access_flags().is_obsolete(); }
689 // Lookup the jmethodID for this method. Return NULL if not found.
690 // NOTE that this function can be called from a signal handler
691 // (see AsyncGetCallTrace support for Forte Analyzer) and this
692 // needs to be async-safe. No allocation should be done and
693 // so handles are not used to avoid deadlock.
694 jmethodID find_jmethod_id_or_null() { return method_holder()->jmethod_id_or_null(this); }
695
696 // JNI static invoke cached itable index accessors
697 int cached_itable_index() { return method_holder()->cached_itable_index(method_idnum()); }
698 void set_cached_itable_index(int index) { method_holder()->set_cached_itable_index(method_idnum(), index); }
699
700 // Support for inlining of intrinsic methods
701 vmIntrinsics::ID intrinsic_id() const { return (vmIntrinsics::ID) _intrinsic_id; }
702 void set_intrinsic_id(vmIntrinsics::ID id) { _intrinsic_id = (u1) id; }
703
704 // Helper routines for intrinsic_id() and vmIntrinsics::method().
705 void init_intrinsic_id(); // updates from _none if a match
706 static vmSymbols::SID klass_id_for_intrinsics(Klass* holder);
707
708 bool jfr_towrite() { return _jfr_towrite; }
709 void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; }
710
711 bool force_inline() { return _force_inline; }
712 void set_force_inline(bool x) { _force_inline = x; }
713 bool dont_inline() { return _dont_inline; }
714 void set_dont_inline(bool x) { _dont_inline = x; }
715 bool is_hidden() { return _hidden; }
716 void set_hidden(bool x) { _hidden = x; }
717 ConstMethod::MethodType method_type() const {
718 return _constMethod->method_type();
719 }
720 bool is_overpass() const { return method_type() == ConstMethod::OVERPASS; }
721
722 // On-stack replacement support
723 bool has_osr_nmethod(int level, bool match_level) {
724 return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
725 }
726
727 nmethod* lookup_osr_nmethod_for(int bci, int level, bool match_level) {
728 return method_holder()->lookup_osr_nmethod(this, bci, level, match_level);
729 }
730
|
102 class MethodData;
103 class ConstMethod;
104 class InlineTableSizes;
105 class KlassSizeStats;
106
107 class Method : public Metadata {
108 friend class VMStructs;
109 private:
110 ConstMethod* _constMethod; // Method read-only data.
111 MethodData* _method_data;
112 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
113 AccessFlags _access_flags; // Access flags
114 int _vtable_index; // vtable index of this method (see VtableIndexFlag)
115 // note: can have vtables with >2**16 elements (because of inheritance)
116 #ifdef CC_INTERP
117 int _result_index; // C++ interpreter needs for converting results to/from stack
118 #endif
119 u2 _method_size; // size of this object
120 u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none)
121 u1 _jfr_towrite : 1, // Flags
122 _caller_sensitive : 1,
123 _force_inline : 1,
124 _hidden : 1,
125 _dont_inline : 1,
126 : 3;
127 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
128 u2 _number_of_breakpoints; // fullspeed debugging support
129 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations
130 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations
131
132 #ifdef TIERED
133 float _rate; // Events (invocation and backedge counter increments) per millisecond
134 jlong _prev_time; // Previous time the rate was acquired
135 #endif
136
137 #ifndef PRODUCT
138 int _compiled_invocation_count; // Number of nmethod invocations so far (for perf. debugging)
139 #endif
140 // Entry point for calling both from and to the interpreter.
141 address _i2i_entry; // All-args-on-stack calling convention
142 // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
143 AdapterHandlerEntry* _adapter;
144 // Entry point for calling from compiled code, to compiled code if it exists
145 // or else the interpreter.
146 volatile address _from_compiled_entry; // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
602 { return offset_of(Method, _interpreter_invocation_count); }
603 static int intrinsic_id_offset_in_bytes() { return offset_of(Method, _intrinsic_id); }
604 static int intrinsic_id_size_in_bytes() { return sizeof(u1); }
605
606 // Static methods that are used to implement member methods where an exposed this pointer
607 // is needed due to possible GCs
608 static objArrayHandle resolved_checked_exceptions_impl(Method* this_oop, TRAPS);
609
610 // Returns the byte code index from the byte code pointer
611 int bci_from(address bcp) const;
612 address bcp_from(int bci) const;
613 int validate_bci_from_bcx(intptr_t bcx) const;
614
615 // Returns the line number for a bci if debugging information for the method is prowided,
616 // -1 is returned otherwise.
617 int line_number_from_bci(int bci) const;
618
619 // Reflection support
620 bool is_overridden_in(Klass* k) const;
621
622 // Stack walking support
623 bool is_ignored_by_security_stack_walk() const;
624
625 // JSR 292 support
626 bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
627 bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
628 bool has_member_arg() const; // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
629 static methodHandle make_method_handle_intrinsic(vmIntrinsics::ID iid, // _invokeBasic, _linkToVirtual
630 Symbol* signature, //anything at all
631 TRAPS);
632 static Klass* check_non_bcp_klass(Klass* klass);
633 // these operate only on invoke methods:
634 // presize interpreter frames for extra interpreter stack entries, if needed
635 // method handles want to be able to push a few extra values (e.g., a bound receiver), and
636 // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist,
637 // all without checking for a stack overflow
638 static int extra_stack_entries() { return EnableInvokeDynamic ? 2 : 0; }
639 static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize()
640
641 // RedefineClasses() support:
642 bool is_old() const { return access_flags().is_old(); }
643 void set_is_old() { _access_flags.set_is_old(); }
644 bool is_obsolete() const { return access_flags().is_obsolete(); }
693 // Lookup the jmethodID for this method. Return NULL if not found.
694 // NOTE that this function can be called from a signal handler
695 // (see AsyncGetCallTrace support for Forte Analyzer) and this
696 // needs to be async-safe. No allocation should be done and
697 // so handles are not used to avoid deadlock.
698 jmethodID find_jmethod_id_or_null() { return method_holder()->jmethod_id_or_null(this); }
699
700 // JNI static invoke cached itable index accessors
701 int cached_itable_index() { return method_holder()->cached_itable_index(method_idnum()); }
702 void set_cached_itable_index(int index) { method_holder()->set_cached_itable_index(method_idnum(), index); }
703
704 // Support for inlining of intrinsic methods
705 vmIntrinsics::ID intrinsic_id() const { return (vmIntrinsics::ID) _intrinsic_id; }
706 void set_intrinsic_id(vmIntrinsics::ID id) { _intrinsic_id = (u1) id; }
707
708 // Helper routines for intrinsic_id() and vmIntrinsics::method().
709 void init_intrinsic_id(); // updates from _none if a match
710 static vmSymbols::SID klass_id_for_intrinsics(Klass* holder);
711
712 bool jfr_towrite() { return _jfr_towrite; }
713 void set_jfr_towrite(bool x) { _jfr_towrite = x; }
714 bool caller_sensitive() { return _caller_sensitive; }
715 void set_caller_sensitive(bool x) { _caller_sensitive = x; }
716 bool force_inline() { return _force_inline; }
717 void set_force_inline(bool x) { _force_inline = x; }
718 bool dont_inline() { return _dont_inline; }
719 void set_dont_inline(bool x) { _dont_inline = x; }
720 bool is_hidden() { return _hidden; }
721 void set_hidden(bool x) { _hidden = x; }
722 ConstMethod::MethodType method_type() const {
723 return _constMethod->method_type();
724 }
725 bool is_overpass() const { return method_type() == ConstMethod::OVERPASS; }
726
727 // On-stack replacement support
728 bool has_osr_nmethod(int level, bool match_level) {
729 return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
730 }
731
732 nmethod* lookup_osr_nmethod_for(int bci, int level, bool match_level) {
733 return method_holder()->lookup_osr_nmethod(this, bci, level, match_level);
734 }
735
|