Mercurial > hg > graal-jvmci-8
annotate src/share/vm/interpreter/linkResolver.cpp @ 12355:cefad50507d8
Merge with hs25-b53
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 11 Oct 2013 10:38:03 +0200 |
parents | 36b97be47bde |
children | 359f7e70ae7f ac9cb1d5a202 |
rev | line source |
---|---|
0 | 1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
3 * | |
4 * This code is free software; you can redistribute it and/or modify it | |
5 * under the terms of the GNU General Public License version 2 only, as | |
6 * published by the Free Software Foundation. | |
7 * | |
8 * This code is distributed in the hope that it will be useful, but WITHOUT | |
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
11 * version 2 for more details (a copy is included in the LICENSE file that | |
12 * accompanied this code). | |
13 * | |
14 * You should have received a copy of the GNU General Public License version | |
15 * 2 along with this work; if not, write to the Free Software Foundation, | |
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
19 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
20 * questions. |
0 | 21 * |
22 */ | |
23 | |
1972 | 24 #include "precompiled.hpp" |
6934 | 25 #include "classfile/defaultMethods.hpp" |
1972 | 26 #include "classfile/systemDictionary.hpp" |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "compiler/compileBroker.hpp" | |
29 #include "gc_interface/collectedHeap.inline.hpp" | |
30 #include "interpreter/bytecode.hpp" | |
31 #include "interpreter/interpreterRuntime.hpp" | |
32 #include "interpreter/linkResolver.hpp" | |
33 #include "memory/resourceArea.hpp" | |
34 #include "memory/universe.inline.hpp" | |
35 #include "oops/instanceKlass.hpp" | |
36 #include "oops/objArrayOop.hpp" | |
37 #include "prims/methodHandles.hpp" | |
38 #include "prims/nativeLookup.hpp" | |
39 #include "runtime/compilationPolicy.hpp" | |
40 #include "runtime/fieldDescriptor.hpp" | |
41 #include "runtime/frame.inline.hpp" | |
42 #include "runtime/handles.inline.hpp" | |
43 #include "runtime/reflection.hpp" | |
44 #include "runtime/signature.hpp" | |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
6983
diff
changeset
|
45 #include "runtime/thread.inline.hpp" |
1972 | 46 #include "runtime/vmThread.hpp" |
0 | 47 |
48 | |
49 //------------------------------------------------------------------------------------------------------------------------ | |
50 // Implementation of CallInfo | |
51 | |
52 | |
53 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
54 int vtable_index = Method::nonvirtual_vtable_index; |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
55 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
0 | 56 } |
57 | |
58 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
59 void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int itable_index, TRAPS) { |
0 | 60 // This is only called for interface methods. If the resolved_method |
61 // comes from java/lang/Object, it can be the subject of a virtual call, so | |
62 // we should pick the vtable index from the resolved method. | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
63 // In that case, the caller must call set_virtual instead of set_interface. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
64 assert(resolved_method->method_holder()->is_interface(), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
65 assert(itable_index == resolved_method()->itable_index(), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
66 set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); |
0 | 67 } |
68 | |
69 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
70 assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
71 assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
72 CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
73 set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
74 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
0 | 75 } |
76 | |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
77 void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
78 if (resolved_method.is_null()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
79 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
80 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
81 KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
82 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
83 resolved_method->is_compiled_lambda_form(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
84 "linkMethod must return one of these"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
85 int vtable_index = Method::nonvirtual_vtable_index; |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
86 assert(!resolved_method->has_vtable_index(), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
87 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
88 _resolved_appendix = resolved_appendix; |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
89 _resolved_method_type = resolved_method_type; |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1552
diff
changeset
|
90 } |
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1552
diff
changeset
|
91 |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
92 void CallInfo::set_common(KlassHandle resolved_klass, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
93 KlassHandle selected_klass, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
94 methodHandle resolved_method, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
95 methodHandle selected_method, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
96 CallKind kind, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
97 int index, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
98 TRAPS) { |
0 | 99 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); |
100 _resolved_klass = resolved_klass; | |
101 _selected_klass = selected_klass; | |
102 _resolved_method = resolved_method; | |
103 _selected_method = selected_method; | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
104 _call_kind = kind; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
105 _call_index = index; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
106 _resolved_appendix = Handle(); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
107 DEBUG_ONLY(verify()); // verify before making side effects |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
108 |
1783 | 109 if (CompilationPolicy::must_be_compiled(selected_method)) { |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
110 // This path is unusual, mostly used by the '-Xcomp' stress test mode. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
111 |
1783 | 112 // Note: with several active threads, the must_be_compiled may be true |
113 // while can_be_compiled is false; remove assert | |
114 // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); | |
0 | 115 if (THREAD->is_Compiler_thread()) { |
116 // don't force compilation, resolve was on behalf of compiler | |
117 return; | |
118 } | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
119 if (selected_method->method_holder()->is_not_initialized()) { |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
120 // 'is_not_initialized' means not only '!is_initialized', but also that |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
121 // initialization has not been started yet ('!being_initialized') |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
122 // Do not force compilation of methods in uninitialized classes. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
123 // Note that doing this would throw an assert later, |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
124 // in CompileBroker::compile_method. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
125 // We sometimes use the link resolver to do reflective lookups |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
126 // even before classes are initialized. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
127 return; |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1059
diff
changeset
|
128 } |
0 | 129 CompileBroker::compile_method(selected_method, InvocationEntryBci, |
3837
43f9d800f276
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
3785
diff
changeset
|
130 CompilationPolicy::policy()->initial_compile_level(), |
1783 | 131 methodHandle(), 0, "must_be_compiled", CHECK); |
0 | 132 } |
133 } | |
134 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
135 // utility query for unreflecting a method |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
136 CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
137 Klass* resolved_method_holder = resolved_method->method_holder(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
138 if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
139 resolved_klass = resolved_method_holder; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
140 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
141 _resolved_klass = resolved_klass; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
142 _selected_klass = resolved_klass; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
143 _resolved_method = resolved_method; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
144 _selected_method = resolved_method; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
145 // classify: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
146 CallKind kind = CallInfo::unknown_kind; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
147 int index = resolved_method->vtable_index(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
148 if (resolved_method->can_be_statically_bound()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
149 kind = CallInfo::direct_call; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
150 } else if (!resolved_method_holder->is_interface()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
151 // Could be an Object method inherited into an interface, but still a vtable call. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
152 kind = CallInfo::vtable_call; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
153 } else if (!resolved_klass->is_interface()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
154 // A miranda method. Compute the vtable index. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
155 ResourceMark rm; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
156 klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
157 index = vt->index_of_miranda(resolved_method->name(), |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
158 resolved_method->signature()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
159 kind = CallInfo::vtable_call; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
160 } else { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
161 // A regular interface call. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
162 kind = CallInfo::itable_call; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
163 index = resolved_method->itable_index(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
164 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
165 assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index)); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
166 _call_kind = kind; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
167 _call_index = index; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
168 _resolved_appendix = Handle(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
169 DEBUG_ONLY(verify()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
170 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
171 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
172 #ifdef ASSERT |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
173 void CallInfo::verify() { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
174 switch (call_kind()) { // the meaning and allowed value of index depends on kind |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
175 case CallInfo::direct_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
176 if (_call_index == Method::nonvirtual_vtable_index) break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
177 // else fall through to check vtable index: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
178 case CallInfo::vtable_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
179 assert(resolved_klass()->verify_vtable_index(_call_index), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
180 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
181 case CallInfo::itable_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
182 assert(resolved_method()->method_holder()->verify_itable_index(_call_index), ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
183 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
184 case CallInfo::unknown_kind: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
185 assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
186 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
187 default: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
188 fatal(err_msg_res("Unexpected call kind %d", call_kind())); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
189 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
190 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
191 #endif //ASSERT |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
192 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
193 |
0 | 194 |
195 //------------------------------------------------------------------------------------------------------------------------ | |
196 // Klass resolution | |
197 | |
198 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
199 if (!Reflection::verify_class_access(ref_klass(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
200 sel_klass(), |
0 | 201 true)) { |
202 ResourceMark rm(THREAD); | |
203 Exceptions::fthrow( | |
204 THREAD_AND_LOCATION, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
205 vmSymbols::java_lang_IllegalAccessError(), |
0 | 206 "tried to access class %s from class %s", |
207 sel_klass->external_name(), | |
208 ref_klass->external_name() | |
209 ); | |
210 return; | |
211 } | |
212 } | |
213 | |
214 void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
215 Klass* result_oop = pool->klass_ref_at(index, CHECK); |
0 | 216 result = KlassHandle(THREAD, result_oop); |
217 } | |
218 | |
219 //------------------------------------------------------------------------------------------------------------------------ | |
220 // Method resolution | |
221 // | |
222 // According to JVM spec. $5.4.3c & $5.4.3d | |
223 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
224 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
225 Method* result_oop = klass->uncached_lookup_method(name, signature); |
2416
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2359
diff
changeset
|
226 if (EnableInvokeDynamic && result_oop != NULL) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
227 vmIntrinsics::ID iid = result_oop->intrinsic_id(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
228 if (MethodHandles::is_signature_polymorphic(iid)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
229 // Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1142
diff
changeset
|
230 return; |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1142
diff
changeset
|
231 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1142
diff
changeset
|
232 } |
0 | 233 result = methodHandle(THREAD, result_oop); |
234 } | |
235 | |
236 // returns first instance method | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
237 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
238 Method* result_oop = klass->uncached_lookup_method(name, signature); |
0 | 239 result = methodHandle(THREAD, result_oop); |
240 while (!result.is_null() && result->is_static()) { | |
6983 | 241 klass = KlassHandle(THREAD, result->method_holder()->super()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
242 result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); |
0 | 243 } |
244 } | |
245 | |
246 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
247 int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
0 | 248 ResourceMark rm(THREAD); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
249 klassVtable *vt = InstanceKlass::cast(klass())->vtable(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
250 return vt->index_of_miranda(name, signature); |
0 | 251 } |
252 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
253 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
254 InstanceKlass *ik = InstanceKlass::cast(klass()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
255 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature)); |
0 | 256 } |
257 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
258 void LinkResolver::lookup_polymorphic_method(methodHandle& result, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
259 KlassHandle klass, Symbol* name, Symbol* full_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
260 KlassHandle current_klass, |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
261 Handle *appendix_result_or_null, |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
262 Handle *method_type_result, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
263 TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
264 vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
265 if (TraceMethodHandles) { |
9082 | 266 ResourceMark rm(THREAD); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
267 tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
268 vmIntrinsics::name_at(iid), klass->external_name(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
269 name->as_C_string(), full_signature->as_C_string()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
270 } |
2416
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2359
diff
changeset
|
271 if (EnableInvokeDynamic && |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1142
diff
changeset
|
272 klass() == SystemDictionary::MethodHandle_klass() && |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
273 iid != vmIntrinsics::_none) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
274 if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
275 // Most of these do not need an up-call to Java to resolve, so can be done anywhere. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
276 // Do not erase last argument type (MemberName) if it is a static linkTo method. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
277 bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
278 TempNewSymbol basic_signature = |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
279 MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
280 if (TraceMethodHandles) { |
9082 | 281 ResourceMark rm(THREAD); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
282 tty->print_cr("lookup_polymorphic_method %s %s => basic %s", |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
283 name->as_C_string(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
284 full_signature->as_C_string(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
285 basic_signature->as_C_string()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
286 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
287 result = SystemDictionary::find_method_handle_intrinsic(iid, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
288 basic_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
289 CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
290 if (result.not_null()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
291 assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
292 assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
293 assert(basic_signature == result->signature(), "predict the result signature"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
294 if (TraceMethodHandles) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
295 tty->print("lookup_polymorphic_method => intrinsic "); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
296 result->print_on(tty); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
297 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
298 return; |
1660
083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
1552
diff
changeset
|
299 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
300 } else if (iid == vmIntrinsics::_invokeGeneric |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
301 && !THREAD->is_Compiler_thread() |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
302 && appendix_result_or_null != NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
303 // This is a method with type-checking semantics. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
304 // We will ask Java code to spin an adapter method for it. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
305 if (!MethodHandles::enabled()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
306 // Make sure the Java part of the runtime has been booted up. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
307 Klass* natives = SystemDictionary::MethodHandleNatives_klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
308 if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
309 SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
310 Handle(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
311 Handle(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
312 true, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
313 CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
314 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
315 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
316 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
317 Handle appendix; |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
318 Handle method_type; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
319 result = SystemDictionary::find_method_handle_invoker(name, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
320 full_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
321 current_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
322 &appendix, |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
323 &method_type, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
324 CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
325 if (TraceMethodHandles) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
326 tty->print("lookup_polymorphic_method => (via Java) "); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
327 result->print_on(tty); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
328 tty->print(" lookup_polymorphic_method => appendix = "); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
329 if (appendix.is_null()) tty->print_cr("(none)"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
330 else appendix->print_on(tty); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
331 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
332 if (result.not_null()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
333 #ifdef ASSERT |
9082 | 334 ResourceMark rm(THREAD); |
335 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
336 TempNewSymbol basic_signature = |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
337 MethodHandles::lookup_basic_type_signature(full_signature, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
338 int actual_size_of_params = result->size_of_parameters(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
339 int expected_size_of_params = ArgumentSizeComputer(basic_signature).size(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
340 // +1 for MethodHandle.this, +1 for trailing MethodType |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
341 if (!MethodHandles::is_signature_polymorphic_static(iid)) expected_size_of_params += 1; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
342 if (appendix.not_null()) expected_size_of_params += 1; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
343 if (actual_size_of_params != expected_size_of_params) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
344 tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
345 tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
346 result->print(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
347 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
348 assert(actual_size_of_params == expected_size_of_params, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
349 err_msg("%d != %d", actual_size_of_params, expected_size_of_params)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
350 #endif //ASSERT |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
351 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
352 assert(appendix_result_or_null != NULL, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
353 (*appendix_result_or_null) = appendix; |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
354 (*method_type_result) = method_type; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
355 return; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
356 } |
710 | 357 } |
358 } | |
359 } | |
360 | |
0 | 361 void LinkResolver::check_method_accessability(KlassHandle ref_klass, |
362 KlassHandle resolved_klass, | |
363 KlassHandle sel_klass, | |
364 methodHandle sel_method, | |
365 TRAPS) { | |
366 | |
367 AccessFlags flags = sel_method->access_flags(); | |
368 | |
369 // Special case: arrays always override "clone". JVMS 2.15. | |
370 // If the resolved klass is an array class, and the declaring class | |
371 // is java.lang.Object and the method is "clone", set the flags | |
372 // to public. | |
373 // | |
374 // We'll check for the method name first, as that's most likely | |
375 // to be false (so we'll short-circuit out of these tests). | |
376 if (sel_method->name() == vmSymbols::clone_name() && | |
1142 | 377 sel_klass() == SystemDictionary::Object_klass() && |
0 | 378 resolved_klass->oop_is_array()) { |
379 // We need to change "protected" to "public". | |
380 assert(flags.is_protected(), "clone not protected?"); | |
381 jint new_flags = flags.as_int(); | |
382 new_flags = new_flags & (~JVM_ACC_PROTECTED); | |
383 new_flags = new_flags | JVM_ACC_PUBLIC; | |
384 flags.set_flags(new_flags); | |
385 } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
386 // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); |
0 | 387 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
388 if (!Reflection::verify_field_access(ref_klass(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
389 resolved_klass(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
390 sel_klass(), |
0 | 391 flags, |
392 true)) { | |
393 ResourceMark rm(THREAD); | |
394 Exceptions::fthrow( | |
395 THREAD_AND_LOCATION, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
396 vmSymbols::java_lang_IllegalAccessError(), |
0 | 397 "tried to access method %s.%s%s from class %s", |
398 sel_klass->external_name(), | |
399 sel_method->name()->as_C_string(), | |
400 sel_method->signature()->as_C_string(), | |
401 ref_klass->external_name() | |
402 ); | |
403 return; | |
404 } | |
405 } | |
406 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
407 void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
408 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) { |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
409 // This method is used only |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
410 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call), |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
411 // and |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
412 // (2) in Bytecode_invoke::static_target |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
413 // It appears to fail when applied to an invokeinterface call site. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
414 // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. |
0 | 415 // resolve klass |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
416 if (code == Bytecodes::_invokedynamic) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
417 resolved_klass = SystemDictionary::MethodHandle_klass(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
418 Symbol* method_name = vmSymbols::invoke_name(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
419 Symbol* method_signature = pool->signature_ref_at(index); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
420 KlassHandle current_klass(THREAD, pool->pool_holder()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
421 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
422 return; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
423 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
424 |
0 | 425 resolve_klass(resolved_klass, pool, index, CHECK); |
426 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
427 Symbol* method_name = pool->name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
428 Symbol* method_signature = pool->signature_ref_at(index); |
0 | 429 KlassHandle current_klass(THREAD, pool->pool_holder()); |
430 | |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
431 if (pool->has_preresolution() |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
432 || (resolved_klass() == SystemDictionary::MethodHandle_klass() && |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
433 MethodHandles::is_signature_polymorphic_name(resolved_klass(), method_name))) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
434 Method* result_oop = ConstantPool::method_at_if_loaded(pool, index); |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
435 if (result_oop != NULL) { |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
436 resolved_method = methodHandle(THREAD, result_oop); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
437 return; |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
438 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
439 } |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3744
diff
changeset
|
440 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
441 if (code == Bytecodes::_invokeinterface) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
442 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
443 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
444 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
445 } |
0 | 446 } |
447 | |
448 void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
449 Symbol* method_name, Symbol* method_signature, |
0 | 450 KlassHandle current_klass, bool check_access, TRAPS) { |
451 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
452 Handle nested_exception; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
453 |
6934 | 454 // 1. lookup method in resolved klass and its super klasses |
0 | 455 lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); |
456 | |
457 if (resolved_method.is_null()) { // not found in the class hierarchy | |
6934 | 458 // 2. lookup method in all the interfaces implemented by the resolved klass |
0 | 459 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); |
460 | |
461 if (resolved_method.is_null()) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
462 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
463 lookup_polymorphic_method(resolved_method, resolved_klass, method_name, method_signature, |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
464 current_klass, (Handle*)NULL, (Handle*)NULL, THREAD); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
465 if (HAS_PENDING_EXCEPTION) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
466 nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
467 CLEAR_PENDING_EXCEPTION; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
468 } |
710 | 469 } |
470 | |
471 if (resolved_method.is_null()) { | |
6934 | 472 // 3. method lookup failed |
0 | 473 ResourceMark rm(THREAD); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
474 THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), |
6983 | 475 Method::name_and_sig_as_C_string(resolved_klass(), |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
476 method_name, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
477 method_signature), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
478 nested_exception); |
0 | 479 } |
480 } | |
481 | |
6934 | 482 // 4. check if klass is not interface |
483 if (resolved_klass->is_interface() && resolved_method->is_abstract()) { | |
484 ResourceMark rm(THREAD); | |
485 char buf[200]; | |
486 jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", | |
487 resolved_klass()->external_name()); | |
488 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); | |
489 } | |
490 | |
0 | 491 // 5. check if method is concrete |
492 if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) { | |
493 ResourceMark rm(THREAD); | |
494 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 495 Method::name_and_sig_as_C_string(resolved_klass(), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
496 method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
497 method_signature)); |
0 | 498 } |
499 | |
500 // 6. access checks, access checking may be turned off when calling from within the VM. | |
501 if (check_access) { | |
502 assert(current_klass.not_null() , "current_klass should not be null"); | |
503 | |
504 // check if method can be accessed by the referring class | |
505 check_method_accessability(current_klass, | |
506 resolved_klass, | |
507 KlassHandle(THREAD, resolved_method->method_holder()), | |
508 resolved_method, | |
509 CHECK); | |
510 | |
511 // check loader constraints | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
512 Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
513 Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); |
0 | 514 { |
515 ResourceMark rm(THREAD); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
516 Symbol* failed_type_symbol = |
0 | 517 SystemDictionary::check_signature_loaders(method_signature, loader, |
518 class_loader, true, CHECK); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
519 if (failed_type_symbol != NULL) { |
0 | 520 const char* msg = "loader constraint violation: when resolving method" |
521 " \"%s\" the class loader (instance of %s) of the current class, %s," | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
522 " and the class loader (instance of %s) for the method's defining class, %s, have" |
0 | 523 " different Class objects for the type %s used in the signature"; |
6983 | 524 char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); |
0 | 525 const char* loader1 = SystemDictionary::loader_name(loader()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
526 char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); |
0 | 527 const char* loader2 = SystemDictionary::loader_name(class_loader()); |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
528 char* target = InstanceKlass::cast(resolved_method->method_holder()) |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
529 ->name()->as_C_string(); |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
530 char* failed_type_name = failed_type_symbol->as_C_string(); |
0 | 531 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
532 strlen(current) + strlen(loader2) + strlen(target) + |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
533 strlen(failed_type_name) + 1; |
0 | 534 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
535 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
536 target, failed_type_name); |
0 | 537 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
538 } | |
539 } | |
540 } | |
541 } | |
542 | |
543 void LinkResolver::resolve_interface_method(methodHandle& resolved_method, | |
544 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
545 Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
546 Symbol* method_signature, |
0 | 547 KlassHandle current_klass, |
548 bool check_access, TRAPS) { | |
549 | |
550 // check if klass is interface | |
551 if (!resolved_klass->is_interface()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
552 ResourceMark rm(THREAD); |
0 | 553 char buf[200]; |
6983 | 554 jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); |
0 | 555 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
556 } | |
557 | |
558 // lookup method in this interface or its super, java.lang.Object | |
559 lookup_instance_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); | |
560 | |
561 if (resolved_method.is_null()) { | |
562 // lookup method in all the super-interfaces | |
563 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); | |
564 if (resolved_method.is_null()) { | |
565 // no method found | |
566 ResourceMark rm(THREAD); | |
567 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), | |
6983 | 568 Method::name_and_sig_as_C_string(resolved_klass(), |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
569 method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
570 method_signature)); |
0 | 571 } |
572 } | |
573 | |
574 if (check_access) { | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
575 // JDK8 adds non-public interface methods, and accessability check requirement |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
576 assert(current_klass.not_null() , "current_klass should not be null"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
577 |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
578 // check if method can be accessed by the referring class |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
579 check_method_accessability(current_klass, |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
580 resolved_klass, |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
581 KlassHandle(THREAD, resolved_method->method_holder()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
582 resolved_method, |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
583 CHECK); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
584 |
0 | 585 HandleMark hm(THREAD); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
586 Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
587 Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); |
0 | 588 { |
589 ResourceMark rm(THREAD); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
590 Symbol* failed_type_symbol = |
0 | 591 SystemDictionary::check_signature_loaders(method_signature, loader, |
592 class_loader, true, CHECK); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
593 if (failed_type_symbol != NULL) { |
0 | 594 const char* msg = "loader constraint violation: when resolving " |
595 "interface method \"%s\" the class loader (instance of %s) of the " | |
596 "current class, %s, and the class loader (instance of %s) for " | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
597 "the method's defining class, %s, have different Class objects for the type %s " |
0 | 598 "used in the signature"; |
6983 | 599 char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); |
0 | 600 const char* loader1 = SystemDictionary::loader_name(loader()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
601 char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); |
0 | 602 const char* loader2 = SystemDictionary::loader_name(class_loader()); |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
603 char* target = InstanceKlass::cast(resolved_method->method_holder()) |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
604 ->name()->as_C_string(); |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
605 char* failed_type_name = failed_type_symbol->as_C_string(); |
0 | 606 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
607 strlen(current) + strlen(loader2) + strlen(target) + |
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
608 strlen(failed_type_name) + 1; |
0 | 609 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
610 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
611 target, failed_type_name); |
0 | 612 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
613 } | |
614 } | |
615 } | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
616 |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
617 if (TraceItables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
618 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
619 tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
620 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
621 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
622 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
623 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
624 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
625 resolved_method->method_holder()->internal_name() |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
626 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
627 resolved_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
628 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
629 } |
0 | 630 } |
631 | |
632 //------------------------------------------------------------------------------------------------------------------------ | |
633 // Field resolution | |
634 | |
635 void LinkResolver::check_field_accessability(KlassHandle ref_klass, | |
636 KlassHandle resolved_klass, | |
637 KlassHandle sel_klass, | |
638 fieldDescriptor& fd, | |
639 TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
640 if (!Reflection::verify_field_access(ref_klass(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
641 resolved_klass(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
642 sel_klass(), |
0 | 643 fd.access_flags(), |
644 true)) { | |
645 ResourceMark rm(THREAD); | |
646 Exceptions::fthrow( | |
647 THREAD_AND_LOCATION, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
648 vmSymbols::java_lang_IllegalAccessError(), |
0 | 649 "tried to access field %s.%s from class %s", |
650 sel_klass->external_name(), | |
651 fd.name()->as_C_string(), | |
652 ref_klass->external_name() | |
653 ); | |
654 return; | |
655 } | |
656 } | |
657 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
658 void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
659 // Load these early in case the resolve of the containing klass fails |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
660 Symbol* field = pool->name_ref_at(index); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
661 Symbol* sig = pool->signature_ref_at(index); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
662 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
663 // resolve specified klass |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
664 KlassHandle resolved_klass; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
665 resolve_klass(resolved_klass, pool, index, CHECK); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
666 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
667 KlassHandle current_klass(THREAD, pool->pool_holder()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
668 resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK); |
0 | 669 } |
670 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
671 void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
672 KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
673 TRAPS) { |
0 | 674 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
675 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
676 (byte == Bytecodes::_nop && !check_access), "bad field access bytecode"); |
0 | 677 |
678 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); | |
679 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic); | |
680 | |
681 // Check if there's a resolved klass containing the field | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
682 if (resolved_klass.is_null()) { |
0 | 683 ResourceMark rm(THREAD); |
684 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); | |
685 } | |
686 | |
687 // Resolve instance field | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
688 KlassHandle sel_klass(THREAD, InstanceKlass::cast(resolved_klass())->find_field(field, sig, &fd)); |
0 | 689 // check if field exists; i.e., if a klass containing the field def has been selected |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
690 if (sel_klass.is_null()) { |
0 | 691 ResourceMark rm(THREAD); |
692 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); | |
693 } | |
694 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
695 if (!check_access) |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
696 // Access checking may be turned off when calling from within the VM. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
697 return; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
698 |
0 | 699 // check access |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
700 check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |
0 | 701 |
702 // check for errors | |
703 if (is_static != fd.is_static()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
704 ResourceMark rm(THREAD); |
0 | 705 char msg[200]; |
6983 | 706 jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string()); |
0 | 707 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); |
708 } | |
709 | |
710 // Final fields can only be accessed from its own class. | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
711 if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) { |
0 | 712 THROW(vmSymbols::java_lang_IllegalAccessError()); |
713 } | |
714 | |
715 // initialize resolved_klass if necessary | |
716 // note 1: the klass which declared the field must be initialized (i.e, sel_klass) | |
717 // according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99) | |
718 // | |
719 // note 2: we don't want to force initialization if we are just checking | |
720 // if the field access is legal; e.g., during compilation | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
721 if (is_static && initialize_class) { |
0 | 722 sel_klass->initialize(CHECK); |
723 } | |
724 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
725 if (sel_klass() != current_klass()) { |
0 | 726 HandleMark hm(THREAD); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
727 Handle ref_loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
728 Handle sel_loader (THREAD, InstanceKlass::cast(sel_klass())->class_loader()); |
0 | 729 { |
730 ResourceMark rm(THREAD); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
731 Symbol* failed_type_symbol = |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
732 SystemDictionary::check_signature_loaders(sig, |
0 | 733 ref_loader, sel_loader, |
734 false, | |
735 CHECK); | |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
736 if (failed_type_symbol != NULL) { |
0 | 737 const char* msg = "loader constraint violation: when resolving field" |
738 " \"%s\" the class loader (instance of %s) of the referring class, " | |
739 "%s, and the class loader (instance of %s) for the field's resolved " | |
740 "type, %s, have different Class objects for that type"; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
741 char* field_name = field->as_C_string(); |
0 | 742 const char* loader1 = SystemDictionary::loader_name(ref_loader()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
743 char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string(); |
0 | 744 const char* loader2 = SystemDictionary::loader_name(sel_loader()); |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
745 char* failed_type_name = failed_type_symbol->as_C_string(); |
0 | 746 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) + |
8840
cd3089a56438
8009731: Confusing error message for loader constraint violation
acorn
parents:
8706
diff
changeset
|
747 strlen(sel) + strlen(loader2) + strlen(failed_type_name) + 1; |
0 | 748 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
749 jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2, | |
750 failed_type_name); | |
751 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); | |
752 } | |
753 } | |
754 } | |
755 | |
756 // return information. note that the klass is set to the actual klass containing the | |
757 // field, otherwise access of static fields in superclasses will not work. | |
758 } | |
759 | |
760 | |
761 //------------------------------------------------------------------------------------------------------------------------ | |
762 // Invoke resolution | |
763 // | |
764 // Naming conventions: | |
765 // | |
766 // resolved_method the specified method (i.e., static receiver specified via constant pool index) | |
767 // sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class) | |
768 // resolved_klass the specified klass (i.e., specified via constant pool index) | |
769 // recv_klass the receiver klass | |
770 | |
771 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
772 void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
773 Symbol* method_signature, KlassHandle current_klass, |
0 | 774 bool check_access, bool initialize_class, TRAPS) { |
775 methodHandle resolved_method; | |
776 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
6983 | 777 resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); |
0 | 778 |
779 // Initialize klass (this should only happen if everything is ok) | |
780 if (initialize_class && resolved_klass->should_be_initialized()) { | |
781 resolved_klass->initialize(CHECK); | |
782 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
783 } | |
784 | |
785 // setup result | |
786 result.set_static(resolved_klass, resolved_method, CHECK); | |
787 } | |
788 | |
789 // throws linktime exceptions | |
790 void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
791 Symbol* method_name, Symbol* method_signature, |
0 | 792 KlassHandle current_klass, bool check_access, TRAPS) { |
793 | |
794 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
795 assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); | |
796 | |
797 // check if static | |
798 if (!resolved_method->is_static()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
799 ResourceMark rm(THREAD); |
0 | 800 char buf[200]; |
6983 | 801 jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 802 resolved_method->name(), |
803 resolved_method->signature())); | |
804 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); | |
805 } | |
806 } | |
807 | |
808 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
809 void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
810 Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { |
0 | 811 methodHandle resolved_method; |
812 linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
813 runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK); | |
814 } | |
815 | |
816 // throws linktime exceptions | |
817 void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
818 Symbol* method_name, Symbol* method_signature, |
0 | 819 KlassHandle current_klass, bool check_access, TRAPS) { |
820 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
821 // Invokespecial is called for multiple special reasons: |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
822 // <init> |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
823 // local private method invocation, for classes and interfaces |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
824 // superclass.method, which can also resolve to a default method |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
825 // and the selected method is recalculated relative to the direct superclass |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
826 // superinterface.method, which explicitly does not check shadowing |
6934 | 827 |
0 | 828 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); |
829 | |
830 // check if method name is <init>, that it is found in same klass as static type | |
831 if (resolved_method->name() == vmSymbols::object_initializer_name() && | |
832 resolved_method->method_holder() != resolved_klass()) { | |
833 ResourceMark rm(THREAD); | |
834 Exceptions::fthrow( | |
835 THREAD_AND_LOCATION, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
836 vmSymbols::java_lang_NoSuchMethodError(), |
0 | 837 "%s: method %s%s not found", |
838 resolved_klass->external_name(), | |
839 resolved_method->name()->as_C_string(), | |
840 resolved_method->signature()->as_C_string() | |
841 ); | |
842 return; | |
843 } | |
844 | |
845 // check if not static | |
846 if (resolved_method->is_static()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
847 ResourceMark rm(THREAD); |
0 | 848 char buf[200]; |
849 jio_snprintf(buf, sizeof(buf), | |
850 "Expecting non-static method %s", | |
6983 | 851 Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 852 resolved_method->name(), |
853 resolved_method->signature())); | |
854 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); | |
855 } | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
856 if (TraceItables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
857 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
858 tty->print("invokespecial resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
859 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
860 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
861 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
862 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
863 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
864 resolved_method->method_holder()->internal_name() |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
865 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
866 resolved_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
867 if (resolved_method->method_holder()->is_interface() && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
868 !resolved_method->is_abstract()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
869 tty->print("default"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
870 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
871 if (resolved_method->is_overpass()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
872 tty->print("overpass"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
873 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
874 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
875 } |
0 | 876 } |
877 | |
878 // throws runtime exceptions | |
879 void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, | |
880 KlassHandle current_klass, bool check_access, TRAPS) { | |
881 | |
882 // resolved method is selected method unless we have an old-style lookup | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
883 // for a superclass method |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
884 // Invokespecial for a superinterface, resolved method is selected method, |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
885 // no checks for shadowing |
0 | 886 methodHandle sel_method(THREAD, resolved_method()); |
887 | |
888 // check if this is an old-style super call and do a new lookup if so | |
889 { KlassHandle method_klass = KlassHandle(THREAD, | |
890 resolved_method->method_holder()); | |
891 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
892 if (check_access && |
0 | 893 // a) check if ACC_SUPER flag is set for the current class |
8702 | 894 (current_klass->is_super() || !AllowNonVirtualCalls) && |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
895 // b) check if the class of the resolved_klass is a superclass |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
896 // (not supertype in order to exclude interface classes) of the current class. |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
897 // This check is not performed for super.invoke for interface methods |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
898 // in super interfaces. |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
899 current_klass->is_subclass_of(resolved_klass()) && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
900 current_klass() != resolved_klass() && |
0 | 901 // c) check if the method is not <init> |
902 resolved_method->name() != vmSymbols::object_initializer_name()) { | |
903 // Lookup super method | |
904 KlassHandle super_klass(THREAD, current_klass->super()); | |
905 lookup_instance_method_in_klasses(sel_method, super_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
906 resolved_method->name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
907 resolved_method->signature(), CHECK); |
0 | 908 // check if found |
909 if (sel_method.is_null()) { | |
910 ResourceMark rm(THREAD); | |
911 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 912 Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 913 resolved_method->name(), |
914 resolved_method->signature())); | |
915 } | |
916 } | |
917 } | |
918 | |
919 // check if not static | |
920 if (sel_method->is_static()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
921 ResourceMark rm(THREAD); |
0 | 922 char buf[200]; |
6983 | 923 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 924 resolved_method->name(), |
925 resolved_method->signature())); | |
926 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); | |
927 } | |
928 | |
929 // check if abstract | |
930 if (sel_method->is_abstract()) { | |
931 ResourceMark rm(THREAD); | |
932 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 933 Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 934 sel_method->name(), |
935 sel_method->signature())); | |
936 } | |
937 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
938 if (TraceItables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
939 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
940 tty->print("invokespecial selected method: resolved-class:%s, method:%s, method_holder:%s, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
941 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
942 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
943 sel_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
944 sel_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
945 sel_method->method_holder()->internal_name() |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
946 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
947 sel_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
948 if (sel_method->method_holder()->is_interface() && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
949 !sel_method->is_abstract()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
950 tty->print("default"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
951 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
952 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
953 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
954 |
0 | 955 // setup result |
956 result.set_static(resolved_klass, sel_method, CHECK); | |
957 } | |
958 | |
959 void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
960 Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, |
0 | 961 bool check_access, bool check_null_and_abstract, TRAPS) { |
962 methodHandle resolved_method; | |
963 linktime_resolve_virtual_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
964 runtime_resolve_virtual_method(result, resolved_method, resolved_klass, recv, receiver_klass, check_null_and_abstract, CHECK); | |
965 } | |
966 | |
967 // throws linktime exceptions | |
968 void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
969 Symbol* method_name, Symbol* method_signature, |
0 | 970 KlassHandle current_klass, bool check_access, TRAPS) { |
971 // normal method resolution | |
972 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
973 | |
974 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); | |
975 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); | |
976 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
977 // check if private interface method |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
978 if (resolved_klass->is_interface() && resolved_method->is_private()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
979 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
980 char buf[200]; |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
981 jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
982 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
983 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
984 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
985 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
986 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
987 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
988 |
0 | 989 // check if not static |
990 if (resolved_method->is_static()) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
991 ResourceMark rm(THREAD); |
0 | 992 char buf[200]; |
6983 | 993 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 994 resolved_method->name(), |
995 resolved_method->signature())); | |
996 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); | |
997 } | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
998 |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
999 if (PrintVtables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1000 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1001 tty->print("invokevirtual resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1002 (current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1003 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1004 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1005 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1006 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1007 resolved_method->method_holder()->internal_name() |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1008 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1009 resolved_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1010 if (resolved_method->method_holder()->is_interface() && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1011 !resolved_method->is_abstract()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1012 tty->print("default"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1013 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1014 if (resolved_method->is_overpass()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1015 tty->print("overpass"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1016 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1017 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1018 } |
0 | 1019 } |
1020 | |
1021 // throws runtime exceptions | |
1022 void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, | |
1023 methodHandle resolved_method, | |
1024 KlassHandle resolved_klass, | |
1025 Handle recv, | |
1026 KlassHandle recv_klass, | |
1027 bool check_null_and_abstract, | |
1028 TRAPS) { | |
1029 | |
1030 // setup default return values | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1031 int vtable_index = Method::invalid_vtable_index; |
0 | 1032 methodHandle selected_method; |
1033 | |
1034 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop"); | |
1035 | |
1036 // runtime method resolution | |
1037 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists | |
1038 THROW(vmSymbols::java_lang_NullPointerException()); | |
1039 } | |
1040 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1041 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s |
0 | 1042 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since |
1043 // a missing receiver might result in a bogus lookup. | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
1044 assert(resolved_method->method_holder()->is_linked(), "must be linked"); |
0 | 1045 |
1046 // do lookup based on receiver klass using the vtable index | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1047 if (resolved_method->method_holder()->is_interface()) { // miranda method |
0 | 1048 vtable_index = vtable_index_of_miranda_method(resolved_klass, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1049 resolved_method->name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1050 resolved_method->signature(), CHECK); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1051 |
0 | 1052 assert(vtable_index >= 0 , "we should have valid vtable index at this point"); |
1053 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1054 InstanceKlass* inst = InstanceKlass::cast(recv_klass()); |
0 | 1055 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); |
1056 } else { | |
1057 // at this point we are sure that resolved_method is virtual and not | |
1058 // a miranda method; therefore, it must have a valid vtable index. | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1059 assert(!resolved_method->has_itable_index(), ""); |
0 | 1060 vtable_index = resolved_method->vtable_index(); |
1061 // We could get a negative vtable_index for final methods, | |
1062 // because as an optimization they are they are never put in the vtable, | |
1063 // unless they override an existing method. | |
1064 // If we do get a negative, it means the resolved method is the the selected | |
1065 // method, and it can never be changed by an override. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1066 if (vtable_index == Method::nonvirtual_vtable_index) { |
0 | 1067 assert(resolved_method->can_be_statically_bound(), "cannot override this method"); |
1068 selected_method = resolved_method; | |
1069 } else { | |
1070 // recv_klass might be an arrayKlassOop but all vtables start at | |
1071 // the same place. The cast is to avoid virtual call and assertion. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1072 InstanceKlass* inst = (InstanceKlass*)recv_klass(); |
0 | 1073 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index)); |
1074 } | |
1075 } | |
1076 | |
1077 // check if method exists | |
1078 if (selected_method.is_null()) { | |
1079 ResourceMark rm(THREAD); | |
1080 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 1081 Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 1082 resolved_method->name(), |
1083 resolved_method->signature())); | |
1084 } | |
1085 | |
1086 // check if abstract | |
1087 if (check_null_and_abstract && selected_method->is_abstract()) { | |
1088 ResourceMark rm(THREAD); | |
1089 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 1090 Method::name_and_sig_as_C_string(resolved_klass(), |
0 | 1091 selected_method->name(), |
1092 selected_method->signature())); | |
1093 } | |
1094 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1095 if (PrintVtables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1096 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1097 tty->print("invokevirtual selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, vtable_index:%d, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1098 (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1099 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1100 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1101 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1102 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1103 selected_method->method_holder()->internal_name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1104 vtable_index |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1105 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1106 selected_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1107 if (selected_method->method_holder()->is_interface() && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1108 !selected_method->is_abstract()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1109 tty->print("default"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1110 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1111 if (resolved_method->is_overpass()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1112 tty->print("overpass"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1113 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1114 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1115 } |
0 | 1116 // setup result |
1117 result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); | |
1118 } | |
1119 | |
1120 void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1121 Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, |
0 | 1122 bool check_access, bool check_null_and_abstract, TRAPS) { |
1123 methodHandle resolved_method; | |
1124 linktime_resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
1125 runtime_resolve_interface_method(result, resolved_method, resolved_klass, recv, recv_klass, check_null_and_abstract, CHECK); | |
1126 } | |
1127 | |
1128 // throws linktime exceptions | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1129 void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1130 Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { |
0 | 1131 // normal interface method resolution |
1132 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); | |
1133 | |
1134 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); | |
1135 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); | |
1136 } | |
1137 | |
1138 // throws runtime exceptions | |
1139 void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, | |
1140 Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS) { | |
1141 // check if receiver exists | |
1142 if (check_null_and_abstract && recv.is_null()) { | |
1143 THROW(vmSymbols::java_lang_NullPointerException()); | |
1144 } | |
1145 | |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1146 // check if private interface method |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1147 if (resolved_klass->is_interface() && resolved_method->is_private()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1148 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1149 char buf[200]; |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1150 jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1151 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1152 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1153 resolved_method->signature())); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1154 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1155 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1156 |
0 | 1157 // check if receiver klass implements the resolved interface |
1158 if (!recv_klass->is_subtype_of(resolved_klass())) { | |
3324
acf5e660c71a
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
2460
diff
changeset
|
1159 ResourceMark rm(THREAD); |
0 | 1160 char buf[200]; |
1161 jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", | |
6983 | 1162 recv_klass()->external_name(), |
1163 resolved_klass()->external_name()); | |
0 | 1164 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1165 } | |
1166 // do lookup based on receiver klass | |
1167 methodHandle sel_method; | |
1168 lookup_instance_method_in_klasses(sel_method, recv_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1169 resolved_method->name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1170 resolved_method->signature(), CHECK); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1171 if (sel_method.is_null() && !check_null_and_abstract) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1172 // In theory this is a harmless placeholder value, but |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1173 // in practice leaving in null affects the nsk default method tests. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1174 // This needs further study. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1175 sel_method = resolved_method; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1176 } |
0 | 1177 // check if method exists |
1178 if (sel_method.is_null()) { | |
1179 ResourceMark rm(THREAD); | |
1180 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 1181 Method::name_and_sig_as_C_string(recv_klass(), |
0 | 1182 resolved_method->name(), |
1183 resolved_method->signature())); | |
1184 } | |
10128
41ed397cc0cd
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
9082
diff
changeset
|
1185 // check access |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1186 // Throw Illegal Access Error if sel_method is not public. |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1187 if (!sel_method->is_public()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1188 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1189 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1190 Method::name_and_sig_as_C_string(recv_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1191 sel_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1192 sel_method->signature())); |
10128
41ed397cc0cd
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
9082
diff
changeset
|
1193 } |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1194 |
0 | 1195 // check if abstract |
1196 if (check_null_and_abstract && sel_method->is_abstract()) { | |
1197 ResourceMark rm(THREAD); | |
1198 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), | |
6983 | 1199 Method::name_and_sig_as_C_string(recv_klass(), |
0 | 1200 sel_method->name(), |
1201 sel_method->signature())); | |
1202 } | |
1203 // setup result | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1204 if (!resolved_method->has_itable_index()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1205 int vtable_index = resolved_method->vtable_index(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1206 assert(vtable_index == sel_method->vtable_index(), "sanity check"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1207 result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1208 return; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1209 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1210 int itable_index = resolved_method()->itable_index(); |
12318
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1211 |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1212 if (TraceItables && Verbose) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1213 ResourceMark rm(THREAD); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1214 tty->print("invokeinterface selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, access_flags: ", |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1215 (recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1216 (resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1217 Method::name_and_sig_as_C_string(resolved_klass(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1218 resolved_method->name(), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1219 resolved_method->signature()), |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1220 sel_method->method_holder()->internal_name() |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1221 ); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1222 sel_method->access_flags().print_on(tty); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1223 if (sel_method->method_holder()->is_interface() && |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1224 !sel_method->is_abstract()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1225 tty->print("default"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1226 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1227 if (resolved_method->is_overpass()) { |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1228 tty->print("overpass"); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1229 } |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1230 tty->cr(); |
36b97be47bde
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
12316
diff
changeset
|
1231 } |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1232 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); |
0 | 1233 } |
1234 | |
1235 | |
1236 methodHandle LinkResolver::linktime_resolve_interface_method_or_null( | |
1237 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1238 Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1239 Symbol* method_signature, |
0 | 1240 KlassHandle current_klass, |
1241 bool check_access) { | |
1242 EXCEPTION_MARK; | |
1243 methodHandle method_result; | |
1244 linktime_resolve_interface_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD); | |
1245 if (HAS_PENDING_EXCEPTION) { | |
1246 CLEAR_PENDING_EXCEPTION; | |
1247 return methodHandle(); | |
1248 } else { | |
1249 return method_result; | |
1250 } | |
1251 } | |
1252 | |
1253 methodHandle LinkResolver::linktime_resolve_virtual_method_or_null( | |
1254 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1255 Symbol* method_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1256 Symbol* method_signature, |
0 | 1257 KlassHandle current_klass, |
1258 bool check_access) { | |
1259 EXCEPTION_MARK; | |
1260 methodHandle method_result; | |
1261 linktime_resolve_virtual_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD); | |
1262 if (HAS_PENDING_EXCEPTION) { | |
1263 CLEAR_PENDING_EXCEPTION; | |
1264 return methodHandle(); | |
1265 } else { | |
1266 return method_result; | |
1267 } | |
1268 } | |
1269 | |
1270 methodHandle LinkResolver::resolve_virtual_call_or_null( | |
1271 KlassHandle receiver_klass, | |
1272 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1273 Symbol* name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1274 Symbol* signature, |
0 | 1275 KlassHandle current_klass) { |
1276 EXCEPTION_MARK; | |
1277 CallInfo info; | |
1278 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD); | |
1279 if (HAS_PENDING_EXCEPTION) { | |
1280 CLEAR_PENDING_EXCEPTION; | |
1281 return methodHandle(); | |
1282 } | |
1283 return info.selected_method(); | |
1284 } | |
1285 | |
1286 methodHandle LinkResolver::resolve_interface_call_or_null( | |
1287 KlassHandle receiver_klass, | |
1288 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1289 Symbol* name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1290 Symbol* signature, |
0 | 1291 KlassHandle current_klass) { |
1292 EXCEPTION_MARK; | |
1293 CallInfo info; | |
1294 resolve_interface_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD); | |
1295 if (HAS_PENDING_EXCEPTION) { | |
1296 CLEAR_PENDING_EXCEPTION; | |
1297 return methodHandle(); | |
1298 } | |
1299 return info.selected_method(); | |
1300 } | |
1301 | |
1302 int LinkResolver::resolve_virtual_vtable_index( | |
1303 KlassHandle receiver_klass, | |
1304 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1305 Symbol* name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1306 Symbol* signature, |
0 | 1307 KlassHandle current_klass) { |
1308 EXCEPTION_MARK; | |
1309 CallInfo info; | |
1310 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD); | |
1311 if (HAS_PENDING_EXCEPTION) { | |
1312 CLEAR_PENDING_EXCEPTION; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1313 return Method::invalid_vtable_index; |
0 | 1314 } |
1315 return info.vtable_index(); | |
1316 } | |
1317 | |
1318 methodHandle LinkResolver::resolve_static_call_or_null( | |
1319 KlassHandle resolved_klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1320 Symbol* name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1321 Symbol* signature, |
0 | 1322 KlassHandle current_klass) { |
1323 EXCEPTION_MARK; | |
1324 CallInfo info; | |
1325 resolve_static_call(info, resolved_klass, name, signature, current_klass, true, false, THREAD); | |
1326 if (HAS_PENDING_EXCEPTION) { | |
1327 CLEAR_PENDING_EXCEPTION; | |
1328 return methodHandle(); | |
1329 } | |
1330 return info.selected_method(); | |
1331 } | |
1332 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1333 methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, Symbol* name, Symbol* signature, |
0 | 1334 KlassHandle current_klass) { |
1335 EXCEPTION_MARK; | |
1336 CallInfo info; | |
1337 resolve_special_call(info, resolved_klass, name, signature, current_klass, true, THREAD); | |
1338 if (HAS_PENDING_EXCEPTION) { | |
1339 CLEAR_PENDING_EXCEPTION; | |
1340 return methodHandle(); | |
1341 } | |
1342 return info.selected_method(); | |
1343 } | |
1344 | |
1345 | |
1346 | |
1347 //------------------------------------------------------------------------------------------------------------------------ | |
1348 // ConstantPool entries | |
1349 | |
1350 void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { | |
1351 switch (byte) { | |
1352 case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; | |
1353 case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break; | |
1354 case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break; | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1355 case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1356 case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; |
0 | 1357 case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; |
1358 } | |
1359 return; | |
1360 } | |
1361 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1362 void LinkResolver::resolve_pool(KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, |
0 | 1363 KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS) { |
1364 // resolve klass | |
1365 resolve_klass(resolved_klass, pool, index, CHECK); | |
1366 | |
1367 // Get name, signature, and static klass | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1368 method_name = pool->name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1369 method_signature = pool->signature_ref_at(index); |
0 | 1370 current_klass = KlassHandle(THREAD, pool->pool_holder()); |
1371 } | |
1372 | |
1373 | |
1374 void LinkResolver::resolve_invokestatic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { | |
1375 KlassHandle resolved_klass; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1376 Symbol* method_name = NULL; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1377 Symbol* method_signature = NULL; |
0 | 1378 KlassHandle current_klass; |
1379 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); | |
1380 resolve_static_call(result, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); | |
1381 } | |
1382 | |
1383 | |
1384 void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { | |
1385 KlassHandle resolved_klass; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1386 Symbol* method_name = NULL; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1387 Symbol* method_signature = NULL; |
0 | 1388 KlassHandle current_klass; |
1389 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); | |
1390 resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK); | |
1391 } | |
1392 | |
1393 | |
1394 void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv, | |
1395 constantPoolHandle pool, int index, | |
1396 TRAPS) { | |
1397 | |
1398 KlassHandle resolved_klass; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1399 Symbol* method_name = NULL; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1400 Symbol* method_signature = NULL; |
0 | 1401 KlassHandle current_klass; |
1402 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1403 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
0 | 1404 resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); |
1405 } | |
1406 | |
1407 | |
1408 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) { | |
1409 KlassHandle resolved_klass; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1410 Symbol* method_name = NULL; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
1411 Symbol* method_signature = NULL; |
0 | 1412 KlassHandle current_klass; |
1413 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1414 KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
0 | 1415 resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); |
1416 } | |
1417 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1418 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1419 void LinkResolver::resolve_invokehandle(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1420 assert(EnableInvokeDynamic, ""); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1421 // This guy is reached from InterpreterRuntime::resolve_invokehandle. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1422 KlassHandle resolved_klass; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1423 Symbol* method_name = NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1424 Symbol* method_signature = NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1425 KlassHandle current_klass; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1426 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); |
9082 | 1427 if (TraceMethodHandles) { |
1428 ResourceMark rm(THREAD); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1429 tty->print_cr("resolve_invokehandle %s %s", method_name->as_C_string(), method_signature->as_C_string()); |
9082 | 1430 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1431 resolve_handle_call(result, resolved_klass, method_name, method_signature, current_klass, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1432 } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1433 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1434 void LinkResolver::resolve_handle_call(CallInfo& result, KlassHandle resolved_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1435 Symbol* method_name, Symbol* method_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1436 KlassHandle current_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1437 TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1438 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1439 assert(resolved_klass() == SystemDictionary::MethodHandle_klass(), ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1440 assert(MethodHandles::is_signature_polymorphic_name(method_name), ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1441 methodHandle resolved_method; |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1442 Handle resolved_appendix; |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1443 Handle resolved_method_type; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1444 lookup_polymorphic_method(resolved_method, resolved_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1445 method_name, method_signature, |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1446 current_klass, &resolved_appendix, &resolved_method_type, CHECK); |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1447 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1448 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1449 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1450 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1451 void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1452 assert(EnableInvokeDynamic, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1453 |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1454 //resolve_pool(<resolved_klass>, method_name, method_signature, current_klass, pool, index, CHECK); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1455 Symbol* method_name = pool->name_ref_at(index); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1456 Symbol* method_signature = pool->signature_ref_at(index); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1457 KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1458 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1459 // Resolve the bootstrap specifier (BSM + optional arguments). |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1460 Handle bootstrap_specifier; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1461 // Check if CallSite has been bound already: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1462 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1463 if (cpce->is_f1_null()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1464 int pool_index = cpce->constant_pool_index(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1465 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1466 assert(bsm_info != NULL, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1467 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1468 bootstrap_specifier = Handle(THREAD, bsm_info); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1469 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1470 if (!cpce->is_f1_null()) { |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1471 methodHandle method( THREAD, cpce->f1_as_method()); |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1472 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1473 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1474 result.set_handle(method, appendix, method_type, CHECK); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1475 return; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1476 } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1477 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1478 if (TraceMethodHandles) { |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1479 ResourceMark rm(THREAD); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1480 tty->print_cr("resolve_invokedynamic #%d %s %s", |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1481 ConstantPool::decode_invokedynamic_index(index), |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1482 method_name->as_C_string(), method_signature->as_C_string()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1483 tty->print(" BSM info: "); bootstrap_specifier->print(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1484 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1485 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1486 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1487 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1488 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1489 void LinkResolver::resolve_dynamic_call(CallInfo& result, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1490 Handle bootstrap_specifier, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1491 Symbol* method_name, Symbol* method_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1492 KlassHandle current_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1493 TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1494 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1495 // The appendix argument is likely to be a freshly-created CallSite. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1496 Handle resolved_appendix; |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1497 Handle resolved_method_type; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1498 methodHandle resolved_method = |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1499 SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1500 bootstrap_specifier, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1501 method_name, method_signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1502 &resolved_appendix, |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1503 &resolved_method_type, |
6729
d17383603741
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
6725
diff
changeset
|
1504 THREAD); |
3744
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1505 if (HAS_PENDING_EXCEPTION) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1506 if (TraceMethodHandles) { |
12316
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
12264
diff
changeset
|
1507 tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, (void *)PENDING_EXCEPTION); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1508 PENDING_EXCEPTION->print(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1509 } |
3744
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1510 if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1511 // throw these guys, since they are already wrapped |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1512 return; |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1513 } |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1514 if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1515 // intercept only LinkageErrors which might have failed to wrap |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1516 return; |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1517 } |
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1518 // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
3960
diff
changeset
|
1519 Handle nested_exception(THREAD, PENDING_EXCEPTION); |
3744
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1520 CLEAR_PENDING_EXCEPTION; |
6729
d17383603741
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
6725
diff
changeset
|
1521 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) |
3744
60b8287df30e
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
3324
diff
changeset
|
1522 } |
6822
f6b0eb4e44cf
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
6729
diff
changeset
|
1523 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1524 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1525 |
0 | 1526 //------------------------------------------------------------------------------------------------------------------------ |
1527 #ifndef PRODUCT | |
1528 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1529 void CallInfo::print() { |
0 | 1530 ResourceMark rm; |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1531 const char* kindstr = "unknown"; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1532 switch (_call_kind) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1533 case direct_call: kindstr = "direct"; break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1534 case vtable_call: kindstr = "vtable"; break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1535 case itable_call: kindstr = "itable"; break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1536 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1537 tty->print_cr("Call %s@%d %s", kindstr, _call_index, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
10128
diff
changeset
|
1538 _resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); |
0 | 1539 } |
1540 | |
1541 #endif |