32
33 // CallInfo provides all the information gathered for a particular
34 // linked call site after resolving it. A link is any reference
35 // made from within the bytecodes of a method to an object outside of
36 // that method. If the info is invalid, the link has not been resolved
37 // successfully.
38
39 class CallInfo : public StackObj {
40 public:
41 // Ways that a method call might be selected (or not) based on receiver type.
42 // Note that an invokevirtual instruction might be linked with no_dispatch,
43 // and an invokeinterface instruction might be linked with any of the three options
44 enum CallKind {
45 direct_call, // jump into resolved_method (must be concrete)
46 vtable_call, // select recv.klass.method_at_vtable(index)
47 itable_call, // select recv.klass.method_at_itable(resolved_method.holder, index)
48 unknown_kind = -1
49 };
50 private:
51 Klass* _resolved_klass; // static receiver klass, resolved from a symbolic reference
52 Klass* _selected_klass; // dynamic receiver class (same as static, or subklass)
53 methodHandle _resolved_method; // static target method
54 methodHandle _selected_method; // dynamic (actual) target method
55 CallKind _call_kind; // kind of call (static(=bytecode static/special +
56 // others inferred), vtable, itable)
57 int _call_index; // vtable or itable index of selected class method (if any)
58 Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix)
59 Handle _resolved_method_name; // Object holding the ResolvedMethodName
60
61 void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS);
62 void set_interface(Klass* resolved_klass, Klass* selected_klass,
63 const methodHandle& resolved_method,
64 const methodHandle& selected_method,
65 int itable_index, TRAPS);
66 void set_virtual(Klass* resolved_klass, Klass* selected_klass,
67 const methodHandle& resolved_method,
68 const methodHandle& selected_method,
69 int vtable_index, TRAPS);
70 void set_handle(const methodHandle& resolved_method,
71 Handle resolved_appendix, TRAPS);
72 void set_handle(Klass* resolved_klass,
73 const methodHandle& resolved_method,
74 Handle resolved_appendix, TRAPS);
75 void set_common(Klass* resolved_klass, Klass* selected_klass,
76 const methodHandle& resolved_method,
77 const methodHandle& selected_method,
78 CallKind kind,
79 int index, TRAPS);
80
81 friend class BootstrapInfo;
82 friend class LinkResolver;
83
84 public:
85 CallInfo() {
86 #ifndef PRODUCT
87 _call_kind = CallInfo::unknown_kind;
88 _call_index = Method::garbage_vtable_index;
89 #endif //PRODUCT
90 }
91
92 // utility to extract an effective CallInfo from a method and an optional receiver limit
93 // does not queue the method for compilation. This also creates a ResolvedMethodName
94 // object for the resolved_method.
95 CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS);
96
97 Klass* resolved_klass() const { return _resolved_klass; }
98 Klass* selected_klass() const { return _selected_klass; }
99 Method* resolved_method() const { return _resolved_method(); }
100 Method* selected_method() const { return _selected_method(); }
101 Handle resolved_appendix() const { return _resolved_appendix; }
102 Handle resolved_method_name() const { return _resolved_method_name; }
103 // Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method
104 void set_resolved_method_name(TRAPS);
105
106 BasicType result_type() const { return selected_method()->result_type(); }
107 CallKind call_kind() const { return _call_kind; }
108 int call_index() const { return _call_index; }
109 int vtable_index() const {
110 // Even for interface calls the vtable index could be non-negative.
111 // See CallInfo::set_interface.
112 assert(has_vtable_index() || is_statically_bound(), "");
113 assert(call_kind() == vtable_call || call_kind() == direct_call, "");
114 // The returned value is < 0 if the call is statically bound.
115 // But, the returned value may be >= 0 even if the kind is direct_call.
116 // It is up to the caller to decide which way to go.
117 return _call_index;
118 }
119 int itable_index() const {
120 assert(call_kind() == itable_call, "");
121 // The returned value is always >= 0, a valid itable index.
122 return _call_index;
123 }
124
125 // debugging
126 #ifdef ASSERT
127 bool has_vtable_index() const { return _call_index >= 0 && _call_kind != CallInfo::itable_call; }
128 bool is_statically_bound() const { return _call_index == Method::nonvirtual_vtable_index; }
|
32
33 // CallInfo provides all the information gathered for a particular
34 // linked call site after resolving it. A link is any reference
35 // made from within the bytecodes of a method to an object outside of
36 // that method. If the info is invalid, the link has not been resolved
37 // successfully.
38
39 class CallInfo : public StackObj {
40 public:
41 // Ways that a method call might be selected (or not) based on receiver type.
42 // Note that an invokevirtual instruction might be linked with no_dispatch,
43 // and an invokeinterface instruction might be linked with any of the three options
44 enum CallKind {
45 direct_call, // jump into resolved_method (must be concrete)
46 vtable_call, // select recv.klass.method_at_vtable(index)
47 itable_call, // select recv.klass.method_at_itable(resolved_method.holder, index)
48 unknown_kind = -1
49 };
50 private:
51 Klass* _resolved_klass; // static receiver klass, resolved from a symbolic reference
52 methodHandle _resolved_method; // static target method
53 methodHandle _selected_method; // dynamic (actual) target method
54 CallKind _call_kind; // kind of call (static(=bytecode static/special +
55 // others inferred), vtable, itable)
56 int _call_index; // vtable or itable index of selected class method (if any)
57 Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix)
58 Handle _resolved_method_name; // Object holding the ResolvedMethodName
59
60 void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS);
61 void set_interface(Klass* resolved_klass,
62 const methodHandle& resolved_method,
63 const methodHandle& selected_method,
64 int itable_index, TRAPS);
65 void set_virtual(Klass* resolved_klass,
66 const methodHandle& resolved_method,
67 const methodHandle& selected_method,
68 int vtable_index, TRAPS);
69 void set_handle(const methodHandle& resolved_method,
70 Handle resolved_appendix, TRAPS);
71 void set_handle(Klass* resolved_klass,
72 const methodHandle& resolved_method,
73 Handle resolved_appendix, TRAPS);
74 void set_common(Klass* resolved_klass,
75 const methodHandle& resolved_method,
76 const methodHandle& selected_method,
77 CallKind kind,
78 int index, TRAPS);
79
80 friend class BootstrapInfo;
81 friend class LinkResolver;
82
83 public:
84 CallInfo() {
85 #ifndef PRODUCT
86 _call_kind = CallInfo::unknown_kind;
87 _call_index = Method::garbage_vtable_index;
88 #endif //PRODUCT
89 }
90
91 // utility to extract an effective CallInfo from a method and an optional receiver limit
92 // does not queue the method for compilation. This also creates a ResolvedMethodName
93 // object for the resolved_method.
94 CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS);
95
96 Klass* resolved_klass() const { return _resolved_klass; }
97 Method* resolved_method() const { return _resolved_method(); }
98 Method* selected_method() const { return _selected_method(); }
99 Handle resolved_appendix() const { return _resolved_appendix; }
100 Handle resolved_method_name() const { return _resolved_method_name; }
101 // Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method
102 void set_resolved_method_name(TRAPS);
103
104 BasicType result_type() const { return selected_method()->result_type(); }
105 CallKind call_kind() const { return _call_kind; }
106 int vtable_index() const {
107 // Even for interface calls the vtable index could be non-negative.
108 // See CallInfo::set_interface.
109 assert(has_vtable_index() || is_statically_bound(), "");
110 assert(call_kind() == vtable_call || call_kind() == direct_call, "");
111 // The returned value is < 0 if the call is statically bound.
112 // But, the returned value may be >= 0 even if the kind is direct_call.
113 // It is up to the caller to decide which way to go.
114 return _call_index;
115 }
116 int itable_index() const {
117 assert(call_kind() == itable_call, "");
118 // The returned value is always >= 0, a valid itable index.
119 return _call_index;
120 }
121
122 // debugging
123 #ifdef ASSERT
124 bool has_vtable_index() const { return _call_index >= 0 && _call_kind != CallInfo::itable_call; }
125 bool is_statically_bound() const { return _call_index == Method::nonvirtual_vtable_index; }
|