author | coleenp |
Wed, 13 Nov 2019 08:23:23 -0500 | |
changeset 59056 | 15936b142f86 |
parent 54600 | 69cfd80f8706 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
25 |
#ifndef SHARE_INTERPRETER_LINKRESOLVER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
26 |
#define SHARE_INTERPRETER_LINKRESOLVER_HPP |
7397 | 27 |
|
54600
69cfd80f8706
8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
54432
diff
changeset
|
28 |
#include "interpreter/bootstrapInfo.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
29 |
#include "oops/method.hpp" |
7397 | 30 |
|
1 | 31 |
// All the necessary definitions for run-time link resolution. |
32 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
33 |
// CallInfo provides all the information gathered for a particular |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
34 |
// linked call site after resolving it. A link is any reference |
1 | 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 |
||
31019 | 39 |
class CallInfo : public StackObj { |
1 | 40 |
public: |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
41 |
// Ways that a method call might be selected (or not) based on receiver type. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
42 |
// Note that an invokevirtual instruction might be linked with no_dispatch, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
43 |
// and an invokeinterface instruction might be linked with any of the three options |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
44 |
enum CallKind { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
45 |
direct_call, // jump into resolved_method (must be concrete) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
46 |
vtable_call, // select recv.klass.method_at_vtable(index) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
47 |
itable_call, // select recv.klass.method_at_itable(resolved_method.holder, index) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
48 |
unknown_kind = -1 |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
49 |
}; |
1 | 50 |
private: |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
51 |
Klass* _resolved_klass; // static receiver klass, resolved from a symbolic reference |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
52 |
Klass* _selected_klass; // dynamic receiver class (same as static, or subklass) |
1 | 53 |
methodHandle _resolved_method; // static target method |
54 |
methodHandle _selected_method; // dynamic (actual) target method |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
55 |
CallKind _call_kind; // kind of call (static(=bytecode static/special + |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
56 |
// others inferred), vtable, itable) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
57 |
int _call_index; // vtable or itable index of selected class method (if any) |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
58 |
Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
59 |
Handle _resolved_method_name; // Object holding the ResolvedMethodName |
1 | 60 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
61 |
void set_static(Klass* resolved_klass, const methodHandle& resolved_method, TRAPS); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
62 |
void set_interface(Klass* resolved_klass, Klass* selected_klass, |
31019 | 63 |
const methodHandle& resolved_method, |
64 |
const methodHandle& selected_method, |
|
65 |
int itable_index, TRAPS); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
66 |
void set_virtual(Klass* resolved_klass, Klass* selected_klass, |
31019 | 67 |
const methodHandle& resolved_method, |
68 |
const methodHandle& selected_method, |
|
69 |
int vtable_index, TRAPS); |
|
70 |
void set_handle(const methodHandle& resolved_method, |
|
53746
bdccafc038a2
8217998: Remove method_type field associated with the appendix field of an indy or method handle call
lfoltan
parents:
53244
diff
changeset
|
71 |
Handle resolved_appendix, TRAPS); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
72 |
void set_handle(Klass* resolved_klass, |
36819 | 73 |
const methodHandle& resolved_method, |
53746
bdccafc038a2
8217998: Remove method_type field associated with the appendix field of an indy or method handle call
lfoltan
parents:
53244
diff
changeset
|
74 |
Handle resolved_appendix, TRAPS); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
75 |
void set_common(Klass* resolved_klass, Klass* selected_klass, |
31019 | 76 |
const methodHandle& resolved_method, |
77 |
const methodHandle& selected_method, |
|
78 |
CallKind kind, |
|
79 |
int index, TRAPS); |
|
1 | 80 |
|
54600
69cfd80f8706
8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
54432
diff
changeset
|
81 |
friend class BootstrapInfo; |
1 | 82 |
friend class LinkResolver; |
83 |
||
84 |
public: |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
85 |
CallInfo() { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
86 |
#ifndef PRODUCT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
87 |
_call_kind = CallInfo::unknown_kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
88 |
_call_index = Method::garbage_vtable_index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
89 |
#endif //PRODUCT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
90 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
91 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
92 |
// utility to extract an effective CallInfo from a method and an optional receiver limit |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
93 |
// does not queue the method for compilation. This also creates a ResolvedMethodName |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
94 |
// object for the resolved_method. |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
95 |
CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
96 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
97 |
Klass* resolved_klass() const { return _resolved_klass; } |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
98 |
Klass* selected_klass() const { return _selected_klass; } |
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
99 |
Method* resolved_method() const { return _resolved_method(); } |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
100 |
Method* selected_method() const { return _selected_method(); } |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8921
diff
changeset
|
101 |
Handle resolved_appendix() const { return _resolved_appendix; } |
46505
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
102 |
Handle resolved_method_name() const { return _resolved_method_name; } |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
103 |
// Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method |
fd4bc78630b1
8174749: Use hash table/oops for MemberName table
coleenp
parents:
46458
diff
changeset
|
104 |
void set_resolved_method_name(TRAPS); |
1 | 105 |
|
106 |
BasicType result_type() const { return selected_method()->result_type(); } |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
107 |
CallKind call_kind() const { return _call_kind; } |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
108 |
int call_index() const { return _call_index; } |
1 | 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(), ""); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
113 |
assert(call_kind() == vtable_call || call_kind() == direct_call, ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
114 |
// The returned value is < 0 if the call is statically bound. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
115 |
// But, the returned value may be >= 0 even if the kind is direct_call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
116 |
// It is up to the caller to decide which way to go. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
117 |
return _call_index; |
1 | 118 |
} |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
119 |
int itable_index() const { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
120 |
assert(call_kind() == itable_call, ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
121 |
// The returned value is always >= 0, a valid itable index. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
122 |
return _call_index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
123 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
124 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
125 |
// debugging |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
126 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
127 |
bool has_vtable_index() const { return _call_index >= 0 && _call_kind != CallInfo::itable_call; } |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
128 |
bool is_statically_bound() const { return _call_index == Method::nonvirtual_vtable_index; } |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
129 |
#endif //ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
130 |
void verify() PRODUCT_RETURN; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
131 |
void print() PRODUCT_RETURN; |
1 | 132 |
}; |
133 |
||
31019 | 134 |
|
135 |
// Condensed information from constant pool to use to resolve the method or field. |
|
136 |
// resolved_klass = specified class (i.e., static receiver class) |
|
137 |
// current_klass = sending method holder (i.e., class containing the method |
|
138 |
// containing the call being resolved) |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
139 |
// current_method = sending method (relevant for field resolution) |
31019 | 140 |
class LinkInfo : public StackObj { |
141 |
Symbol* _name; // extracted from JVM_CONSTANT_NameAndType |
|
142 |
Symbol* _signature; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
143 |
Klass* _resolved_klass; // class that the constant pool entry points to |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
144 |
Klass* _current_klass; // class that owns the constant pool |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
145 |
methodHandle _current_method; // sending method |
31019 | 146 |
bool _check_access; |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
147 |
constantTag _tag; |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
148 |
|
31019 | 149 |
public: |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
150 |
enum AccessCheck { |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
151 |
needs_access_check, |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
152 |
skip_access_check |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
153 |
}; |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
154 |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
155 |
LinkInfo(const constantPoolHandle& pool, int index, const methodHandle& current_method, TRAPS); |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
156 |
LinkInfo(const constantPoolHandle& pool, int index, TRAPS); |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
157 |
|
31019 | 158 |
// Condensed information from other call sites within the vm. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
159 |
LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, Klass* current_klass, |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
160 |
AccessCheck check_access = needs_access_check, |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
161 |
constantTag tag = JVM_CONSTANT_Invalid) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
162 |
_name(name), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
163 |
_signature(signature), _resolved_klass(resolved_klass), _current_klass(current_klass), _current_method(methodHandle()), |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
164 |
_check_access(check_access == needs_access_check), _tag(tag) {} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
165 |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
166 |
LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, const methodHandle& current_method, |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
167 |
AccessCheck check_access = needs_access_check, |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
168 |
constantTag tag = JVM_CONSTANT_Invalid) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
169 |
_name(name), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
170 |
_signature(signature), _resolved_klass(resolved_klass), _current_klass(current_method->method_holder()), _current_method(current_method), |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
171 |
_check_access(check_access == needs_access_check), _tag(tag) {} |
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
172 |
|
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
173 |
// Case where we just find the method and don't check access against the current class |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
174 |
LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
175 |
_name(name), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
176 |
_signature(signature), _resolved_klass(resolved_klass), _current_klass(NULL), _current_method(methodHandle()), |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
177 |
_check_access(false), _tag(JVM_CONSTANT_Invalid) {} |
31019 | 178 |
|
179 |
// accessors |
|
180 |
Symbol* name() const { return _name; } |
|
181 |
Symbol* signature() const { return _signature; } |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
182 |
Klass* resolved_klass() const { return _resolved_klass; } |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
183 |
Klass* current_klass() const { return _current_klass; } |
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
184 |
Method* current_method() const { return _current_method(); } |
38719
133bf85c3f36
8145148: InterfaceMethod CP entry pointing to a class should cause ICCE
coleenp
parents:
38051
diff
changeset
|
185 |
constantTag tag() const { return _tag; } |
31019 | 186 |
bool check_access() const { return _check_access; } |
187 |
||
188 |
void print() PRODUCT_RETURN; |
|
189 |
}; |
|
190 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
191 |
// Link information for getfield/putfield & getstatic/putstatic bytecodes |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
192 |
// is represented using a fieldDescriptor. |
1 | 193 |
|
194 |
// The LinkResolver is used to resolve constant-pool references at run-time. |
|
195 |
// It does all necessary link-time checks & throws exceptions if necessary. |
|
196 |
||
197 |
class LinkResolver: AllStatic { |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
198 |
friend class klassVtable; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
199 |
friend class klassItable; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
13929
diff
changeset
|
200 |
|
1 | 201 |
private: |
31019 | 202 |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
203 |
static Method* lookup_method_in_klasses(const LinkInfo& link_info, |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
204 |
bool checkpolymorphism, |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
205 |
bool in_imethod_resolve); |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
206 |
static Method* lookup_method_in_interfaces(const LinkInfo& link_info); |
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46505
diff
changeset
|
207 |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
208 |
static Method* lookup_polymorphic_method(const LinkInfo& link_info, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
209 |
Handle *appendix_result_or_null, TRAPS); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31019
diff
changeset
|
210 |
JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() |
31019 | 211 |
// Not Linktime so doesn't take LinkInfo |
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
212 |
static Method* lookup_instance_method_in_klasses (Klass* klass, Symbol* name, Symbol* signature, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
213 |
Klass::PrivateLookupMode private_mode, TRAPS); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31019
diff
changeset
|
214 |
JVMCI_ONLY(private:) |
1 | 215 |
|
31019 | 216 |
// Similar loader constraint checking functions that throw |
217 |
// LinkageError with descriptive message. |
|
218 |
static void check_method_loader_constraints(const LinkInfo& link_info, |
|
219 |
const methodHandle& resolved_method, |
|
220 |
const char* method_type, TRAPS); |
|
221 |
static void check_field_loader_constraints(Symbol* field, Symbol* sig, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
222 |
Klass* current_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
223 |
Klass* sel_klass, TRAPS); |
1 | 224 |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
225 |
static Method* resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
226 |
static Method* resolve_method (const LinkInfo& link_info, Bytecodes::Code code, TRAPS); |
1 | 227 |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
228 |
static Method* linktime_resolve_static_method (const LinkInfo& link_info, TRAPS); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
229 |
static Method* linktime_resolve_special_method (const LinkInfo& link_info, TRAPS); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
230 |
static Method* linktime_resolve_virtual_method (const LinkInfo& link_info, TRAPS); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
231 |
static Method* linktime_resolve_interface_method (const LinkInfo& link_info, TRAPS); |
1 | 232 |
|
31019 | 233 |
static void runtime_resolve_special_method (CallInfo& result, |
47401 | 234 |
const LinkInfo& link_info, |
31019 | 235 |
const methodHandle& resolved_method, |
47401 | 236 |
Handle recv, TRAPS); |
237 |
||
31019 | 238 |
static void runtime_resolve_virtual_method (CallInfo& result, |
239 |
const methodHandle& resolved_method, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
240 |
Klass* resolved_klass, |
31019 | 241 |
Handle recv, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
242 |
Klass* recv_klass, |
31019 | 243 |
bool check_null_and_abstract, TRAPS); |
244 |
static void runtime_resolve_interface_method (CallInfo& result, |
|
245 |
const methodHandle& resolved_method, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
246 |
Klass* resolved_klass, |
31019 | 247 |
Handle recv, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
248 |
Klass* recv_klass, |
31019 | 249 |
bool check_null_and_abstract, TRAPS); |
1 | 250 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
251 |
static void check_field_accessability(Klass* ref_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
252 |
Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
253 |
Klass* sel_klass, |
31019 | 254 |
const fieldDescriptor& fd, TRAPS); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
255 |
static void check_method_accessability(Klass* ref_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
256 |
Klass* resolved_klass, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
257 |
Klass* sel_klass, |
31019 | 258 |
const methodHandle& sel_method, TRAPS); |
1 | 259 |
|
31019 | 260 |
// runtime resolving from constant pool |
261 |
static void resolve_invokestatic (CallInfo& result, |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
262 |
const constantPoolHandle& pool, int index, TRAPS); |
44738 | 263 |
static void resolve_invokespecial (CallInfo& result, Handle recv, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
264 |
const constantPoolHandle& pool, int index, TRAPS); |
31019 | 265 |
static void resolve_invokevirtual (CallInfo& result, Handle recv, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
266 |
const constantPoolHandle& pool, int index, TRAPS); |
31019 | 267 |
static void resolve_invokeinterface(CallInfo& result, Handle recv, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
268 |
const constantPoolHandle& pool, int index, TRAPS); |
31019 | 269 |
static void resolve_invokedynamic (CallInfo& result, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
270 |
const constantPoolHandle& pool, int index, TRAPS); |
31019 | 271 |
static void resolve_invokehandle (CallInfo& result, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
272 |
const constantPoolHandle& pool, int index, TRAPS); |
1 | 273 |
public: |
274 |
// constant pool resolving |
|
48826 | 275 |
static void check_klass_accessability(Klass* ref_klass, Klass* sel_klass, |
276 |
bool fold_type_to_class, TRAPS); |
|
277 |
// The optional 'fold_type_to_class' means that a derived type (array) |
|
278 |
// is first converted to the class it is derived from (element type). |
|
279 |
// If this element type is not a class, then the check passes quietly. |
|
280 |
// This is usually what is needed, but a few existing uses might break |
|
281 |
// if this flag were always turned on. FIXME: See if it can be, always. |
|
282 |
static void check_klass_accessability(Klass* ref_klass, Klass* sel_klass, TRAPS) { |
|
283 |
return check_klass_accessability(ref_klass, sel_klass, false, THREAD); |
|
284 |
} |
|
1 | 285 |
|
31019 | 286 |
// static resolving calls (will not run any Java code); |
287 |
// used only from Bytecode_invoke::static_target |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
288 |
static Method* resolve_method_statically(Bytecodes::Code code, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
289 |
const constantPoolHandle& pool, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
290 |
int index, TRAPS); |
1 | 291 |
|
31019 | 292 |
static void resolve_field_access(fieldDescriptor& result, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
293 |
const constantPoolHandle& pool, |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
294 |
int index, |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
295 |
const methodHandle& method, |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38719
diff
changeset
|
296 |
Bytecodes::Code byte, TRAPS); |
31019 | 297 |
static void resolve_field(fieldDescriptor& result, const LinkInfo& link_info, |
298 |
Bytecodes::Code access_kind, |
|
299 |
bool initialize_class, TRAPS); |
|
1 | 300 |
|
31019 | 301 |
static void resolve_static_call (CallInfo& result, |
302 |
const LinkInfo& link_info, |
|
303 |
bool initialize_klass, TRAPS); |
|
304 |
static void resolve_special_call (CallInfo& result, |
|
44738 | 305 |
Handle recv, |
31019 | 306 |
const LinkInfo& link_info, |
307 |
TRAPS); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
308 |
static void resolve_virtual_call (CallInfo& result, Handle recv, Klass* recv_klass, |
31019 | 309 |
const LinkInfo& link_info, |
310 |
bool check_null_and_abstract, TRAPS); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
311 |
static void resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass, |
31019 | 312 |
const LinkInfo& link_info, |
313 |
bool check_null_and_abstract, TRAPS); |
|
314 |
static void resolve_handle_call (CallInfo& result, |
|
315 |
const LinkInfo& link_info, TRAPS); |
|
54600
69cfd80f8706
8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
54432
diff
changeset
|
316 |
static void resolve_dynamic_call (CallInfo& result, |
69cfd80f8706
8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
54432
diff
changeset
|
317 |
BootstrapInfo& bootstrap_specifier, TRAPS); |
1 | 318 |
|
31019 | 319 |
// same as above for compile-time resolution; but returns null handle instead of throwing |
320 |
// an exception on error also, does not initialize klass (i.e., no side effects) |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
321 |
static Method* resolve_virtual_call_or_null(Klass* receiver_klass, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
322 |
const LinkInfo& link_info); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
323 |
static Method* resolve_interface_call_or_null(Klass* receiver_klass, |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
324 |
const LinkInfo& link_info); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
325 |
static Method* resolve_static_call_or_null(const LinkInfo& link_info); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
326 |
static Method* resolve_special_call_or_null(const LinkInfo& link_info); |
31019 | 327 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
328 |
static int vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method); |
1 | 329 |
|
330 |
// same as above for compile-time resolution; returns vtable_index if current_klass if linked |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39421
diff
changeset
|
331 |
static int resolve_virtual_vtable_index (Klass* receiver_klass, |
31019 | 332 |
const LinkInfo& link_info); |
1 | 333 |
|
334 |
// static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful) |
|
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
335 |
static Method* linktime_resolve_virtual_method_or_null (const LinkInfo& link_info); |
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
336 |
static Method* linktime_resolve_interface_method_or_null(const LinkInfo& link_info); |
1 | 337 |
|
338 |
// runtime resolving from constant pool |
|
31019 | 339 |
static void resolve_invoke(CallInfo& result, Handle recv, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
340 |
const constantPoolHandle& pool, int index, |
31019 | 341 |
Bytecodes::Code byte, TRAPS); |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
342 |
|
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
343 |
// runtime resolving from attached method |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
344 |
static void resolve_invoke(CallInfo& result, Handle& recv, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
345 |
const methodHandle& attached_method, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
346 |
Bytecodes::Code byte, TRAPS); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
347 |
|
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
348 |
public: |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
349 |
// Only resolved method known. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
350 |
static void throw_abstract_method_error(const methodHandle& resolved_method, TRAPS) { |
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
351 |
throw_abstract_method_error(resolved_method, methodHandle(), NULL, CHECK); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
352 |
} |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
353 |
// Resolved method and receiver klass know. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
354 |
static void throw_abstract_method_error(const methodHandle& resolved_method, Klass *recv_klass, TRAPS) { |
59056
15936b142f86
8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents:
54600
diff
changeset
|
355 |
throw_abstract_method_error(resolved_method, methodHandle(), recv_klass, CHECK); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
356 |
} |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
357 |
// Selected method is abstract. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
358 |
static void throw_abstract_method_error(const methodHandle& resolved_method, |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
359 |
const methodHandle& selected_method, |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48826
diff
changeset
|
360 |
Klass *recv_klass, TRAPS); |
1 | 361 |
}; |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51334
diff
changeset
|
362 |
#endif // SHARE_INTERPRETER_LINKRESOLVER_HPP |