author | acorn |
Tue, 01 Oct 2013 08:10:42 -0400 | |
changeset 20284 | 595a25ab9474 |
parent 20282 | 7f9cbdf89af2 |
child 20391 | 7b146c5ebb18 |
permissions | -rw-r--r-- |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
18 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
19 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
20 |
* questions. |
1 | 21 |
* |
22 |
*/ |
|
23 |
||
7397 | 24 |
#include "precompiled.hpp" |
14385 | 25 |
#include "classfile/defaultMethods.hpp" |
7397 | 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" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14488
diff
changeset
|
45 |
#include "runtime/thread.inline.hpp" |
7397 | 46 |
#include "runtime/vmThread.hpp" |
1 | 47 |
|
48 |
||
49 |
//------------------------------------------------------------------------------------------------------------------------ |
|
50 |
// Implementation of CallInfo |
|
51 |
||
52 |
||
53 |
void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
54 |
int vtable_index = Method::nonvirtual_vtable_index; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
55 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
1 | 56 |
} |
57 |
||
58 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
59 |
void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int itable_index, TRAPS) { |
1 | 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. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
63 |
// In that case, the caller must call set_virtual instead of set_interface. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
64 |
assert(resolved_method->method_holder()->is_interface(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
65 |
assert(itable_index == resolved_method()->itable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
66 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); |
1 | 67 |
} |
68 |
||
69 |
void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
70 |
assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index"); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
71 |
assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
72 |
CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
73 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
74 |
assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
1 | 75 |
} |
76 |
||
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
77 |
void CallInfo::set_handle(methodHandle resolved_method, Handle resolved_appendix, Handle resolved_method_type, TRAPS) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
78 |
if (resolved_method.is_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
79 |
THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
80 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
81 |
KlassHandle resolved_klass = SystemDictionary::MethodHandle_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
82 |
assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
83 |
resolved_method->is_compiled_lambda_form(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
84 |
"linkMethod must return one of these"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
85 |
int vtable_index = Method::nonvirtual_vtable_index; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
86 |
assert(!resolved_method->has_vtable_index(), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
87 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
88 |
_resolved_appendix = resolved_appendix; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
89 |
_resolved_method_type = resolved_method_type; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
90 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
91 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
92 |
void CallInfo::set_common(KlassHandle resolved_klass, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
93 |
KlassHandle selected_klass, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
94 |
methodHandle resolved_method, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
95 |
methodHandle selected_method, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
96 |
CallKind kind, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
97 |
int index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
98 |
TRAPS) { |
1 | 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; |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
104 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
105 |
_call_index = index; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
106 |
_resolved_appendix = Handle(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
107 |
DEBUG_ONLY(verify()); // verify before making side effects |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
108 |
|
6453 | 109 |
if (CompilationPolicy::must_be_compiled(selected_method)) { |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
110 |
// This path is unusual, mostly used by the '-Xcomp' stress test mode. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
111 |
|
6453 | 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"); |
|
1 | 115 |
if (THREAD->is_Compiler_thread()) { |
116 |
// don't force compilation, resolve was on behalf of compiler |
|
117 |
return; |
|
118 |
} |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
119 |
if (selected_method->method_holder()->is_not_initialized()) { |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
120 |
// 'is_not_initialized' means not only '!is_initialized', but also that |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
121 |
// initialization has not been started yet ('!being_initialized') |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
122 |
// Do not force compilation of methods in uninitialized classes. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
123 |
// Note that doing this would throw an assert later, |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
124 |
// in CompileBroker::compile_method. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
125 |
// We sometimes use the link resolver to do reflective lookups |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
126 |
// even before classes are initialized. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
127 |
return; |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
128 |
} |
1 | 129 |
CompileBroker::compile_method(selected_method, InvocationEntryBci, |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10008
diff
changeset
|
130 |
CompilationPolicy::policy()->initial_compile_level(), |
6453 | 131 |
methodHandle(), 0, "must_be_compiled", CHECK); |
1 | 132 |
} |
133 |
} |
|
134 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
135 |
// utility query for unreflecting a method |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
136 |
CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
137 |
Klass* resolved_method_holder = resolved_method->method_holder(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
138 |
if (resolved_klass == NULL) { // 2nd argument defaults to holder of 1st |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
139 |
resolved_klass = resolved_method_holder; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
140 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
141 |
_resolved_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
142 |
_selected_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
143 |
_resolved_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
144 |
_selected_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
145 |
// classify: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
146 |
CallKind kind = CallInfo::unknown_kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
147 |
int index = resolved_method->vtable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
148 |
if (resolved_method->can_be_statically_bound()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
149 |
kind = CallInfo::direct_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
150 |
} else if (!resolved_method_holder->is_interface()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
151 |
// Could be an Object method inherited into an interface, but still a vtable call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
152 |
kind = CallInfo::vtable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
153 |
} else if (!resolved_klass->is_interface()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
154 |
// A miranda method. Compute the vtable index. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
155 |
ResourceMark rm; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
156 |
klassVtable* vt = InstanceKlass::cast(resolved_klass)->vtable(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
157 |
index = vt->index_of_miranda(resolved_method->name(), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
158 |
resolved_method->signature()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
159 |
kind = CallInfo::vtable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
160 |
} else { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
161 |
// A regular interface call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
162 |
kind = CallInfo::itable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
163 |
index = resolved_method->itable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
164 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
165 |
assert(index == Method::nonvirtual_vtable_index || index >= 0, err_msg("bad index %d", index)); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
166 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
167 |
_call_index = index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
168 |
_resolved_appendix = Handle(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
169 |
DEBUG_ONLY(verify()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
170 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
171 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
172 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
173 |
void CallInfo::verify() { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
174 |
switch (call_kind()) { // the meaning and allowed value of index depends on kind |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
175 |
case CallInfo::direct_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
176 |
if (_call_index == Method::nonvirtual_vtable_index) break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
177 |
// else fall through to check vtable index: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
178 |
case CallInfo::vtable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
179 |
assert(resolved_klass()->verify_vtable_index(_call_index), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
180 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
181 |
case CallInfo::itable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
182 |
assert(resolved_method()->method_holder()->verify_itable_index(_call_index), ""); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
183 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
184 |
case CallInfo::unknown_kind: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
185 |
assert(call_kind() != CallInfo::unknown_kind, "CallInfo must be set"); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
186 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
187 |
default: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
188 |
fatal(err_msg_res("Unexpected call kind %d", call_kind())); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
189 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
190 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
191 |
#endif //ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
192 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
193 |
|
1 | 194 |
|
195 |
//------------------------------------------------------------------------------------------------------------------------ |
|
196 |
// Klass resolution |
|
197 |
||
198 |
void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
199 |
if (!Reflection::verify_class_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
200 |
sel_klass(), |
1 | 201 |
true)) { |
202 |
ResourceMark rm(THREAD); |
|
203 |
Exceptions::fthrow( |
|
204 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
205 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 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) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
215 |
Klass* result_oop = pool->klass_ref_at(index, CHECK); |
1 | 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 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
224 |
void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
225 |
Method* result_oop = klass->uncached_lookup_method(name, signature); |
8883
5569135acca3
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
8678
diff
changeset
|
226 |
if (EnableInvokeDynamic && result_oop != NULL) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
227 |
vmIntrinsics::ID iid = result_oop->intrinsic_id(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
228 |
if (MethodHandles::is_signature_polymorphic(iid)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
229 |
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
230 |
return; |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
231 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
232 |
} |
1 | 233 |
result = methodHandle(THREAD, result_oop); |
234 |
} |
|
235 |
||
236 |
// returns first instance method |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
237 |
void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
238 |
Method* result_oop = klass->uncached_lookup_method(name, signature); |
1 | 239 |
result = methodHandle(THREAD, result_oop); |
240 |
while (!result.is_null() && result->is_static()) { |
|
14488 | 241 |
klass = KlassHandle(THREAD, result->method_holder()->super()); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
242 |
result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); |
1 | 243 |
} |
244 |
} |
|
245 |
||
246 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
247 |
int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
1 | 248 |
ResourceMark rm(THREAD); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
249 |
klassVtable *vt = InstanceKlass::cast(klass())->vtable(); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
250 |
return vt->index_of_miranda(name, signature); |
1 | 251 |
} |
252 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
253 |
void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
254 |
InstanceKlass *ik = InstanceKlass::cast(klass()); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
255 |
result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature)); |
1 | 256 |
} |
257 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
258 |
void LinkResolver::lookup_polymorphic_method(methodHandle& result, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
259 |
KlassHandle klass, Symbol* name, Symbol* full_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
260 |
KlassHandle current_klass, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
261 |
Handle *appendix_result_or_null, |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
262 |
Handle *method_type_result, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
263 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
264 |
vmIntrinsics::ID iid = MethodHandles::signature_polymorphic_name_id(name); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
265 |
if (TraceMethodHandles) { |
16691 | 266 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
267 |
tty->print_cr("lookup_polymorphic_method iid=%s %s.%s%s", |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
268 |
vmIntrinsics::name_at(iid), klass->external_name(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
269 |
name->as_C_string(), full_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
270 |
} |
8883
5569135acca3
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
8678
diff
changeset
|
271 |
if (EnableInvokeDynamic && |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
272 |
klass() == SystemDictionary::MethodHandle_klass() && |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
273 |
iid != vmIntrinsics::_none) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
274 |
if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
275 |
// Most of these do not need an up-call to Java to resolve, so can be done anywhere. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
276 |
// Do not erase last argument type (MemberName) if it is a static linkTo method. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
277 |
bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
278 |
TempNewSymbol basic_signature = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
279 |
MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
280 |
if (TraceMethodHandles) { |
16691 | 281 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
282 |
tty->print_cr("lookup_polymorphic_method %s %s => basic %s", |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
283 |
name->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
284 |
full_signature->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
285 |
basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
286 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
287 |
result = SystemDictionary::find_method_handle_intrinsic(iid, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
288 |
basic_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
289 |
CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
290 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
291 |
assert(result->is_method_handle_intrinsic(), "MH.invokeBasic or MH.linkTo* intrinsic"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
292 |
assert(result->intrinsic_id() != vmIntrinsics::_invokeGeneric, "wrong place to find this"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
293 |
assert(basic_signature == result->signature(), "predict the result signature"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
294 |
if (TraceMethodHandles) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
295 |
tty->print("lookup_polymorphic_method => intrinsic "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
296 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
297 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
298 |
return; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
299 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
300 |
} else if (iid == vmIntrinsics::_invokeGeneric |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
301 |
&& !THREAD->is_Compiler_thread() |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
302 |
&& appendix_result_or_null != NULL) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
303 |
// This is a method with type-checking semantics. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
304 |
// We will ask Java code to spin an adapter method for it. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
305 |
if (!MethodHandles::enabled()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
306 |
// Make sure the Java part of the runtime has been booted up. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
307 |
Klass* natives = SystemDictionary::MethodHandleNatives_klass(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
308 |
if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
309 |
SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
310 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
311 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
312 |
true, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
313 |
CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
314 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
315 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
316 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
317 |
Handle appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
318 |
Handle method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
319 |
result = SystemDictionary::find_method_handle_invoker(name, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
320 |
full_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
321 |
current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
322 |
&appendix, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
323 |
&method_type, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
324 |
CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
325 |
if (TraceMethodHandles) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
326 |
tty->print("lookup_polymorphic_method => (via Java) "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
327 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
328 |
tty->print(" lookup_polymorphic_method => appendix = "); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
329 |
if (appendix.is_null()) tty->print_cr("(none)"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
330 |
else appendix->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
331 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
332 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
333 |
#ifdef ASSERT |
16691 | 334 |
ResourceMark rm(THREAD); |
335 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
336 |
TempNewSymbol basic_signature = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
337 |
MethodHandles::lookup_basic_type_signature(full_signature, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
338 |
int actual_size_of_params = result->size_of_parameters(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
339 |
int expected_size_of_params = ArgumentSizeComputer(basic_signature).size(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
340 |
// +1 for MethodHandle.this, +1 for trailing MethodType |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
341 |
if (!MethodHandles::is_signature_polymorphic_static(iid)) expected_size_of_params += 1; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
342 |
if (appendix.not_null()) expected_size_of_params += 1; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
343 |
if (actual_size_of_params != expected_size_of_params) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
344 |
tty->print_cr("*** basic_signature=%s", basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
345 |
tty->print_cr("*** result for %s: ", vmIntrinsics::name_at(iid)); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
346 |
result->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
347 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
348 |
assert(actual_size_of_params == expected_size_of_params, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
349 |
err_msg("%d != %d", actual_size_of_params, expected_size_of_params)); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
350 |
#endif //ASSERT |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
351 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
352 |
assert(appendix_result_or_null != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
353 |
(*appendix_result_or_null) = appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
354 |
(*method_type_result) = method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
355 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
356 |
} |
2534 | 357 |
} |
358 |
} |
|
359 |
} |
|
360 |
||
1 | 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() && |
|
4571 | 377 |
sel_klass() == SystemDictionary::Object_klass() && |
1 | 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 |
} |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
386 |
// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); |
1 | 387 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
388 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
389 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
390 |
sel_klass(), |
1 | 391 |
flags, |
392 |
true)) { |
|
393 |
ResourceMark rm(THREAD); |
|
394 |
Exceptions::fthrow( |
|
395 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
396 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 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 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
407 |
void LinkResolver::resolve_method_statically(methodHandle& resolved_method, KlassHandle& resolved_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
408 |
Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS) { |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
409 |
// This method is used only |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
410 |
// (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call), |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
411 |
// and |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
412 |
// (2) in Bytecode_invoke::static_target |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
413 |
// It appears to fail when applied to an invokeinterface call site. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
414 |
// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. |
1 | 415 |
// resolve klass |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
416 |
if (code == Bytecodes::_invokedynamic) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
417 |
resolved_klass = SystemDictionary::MethodHandle_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
418 |
Symbol* method_name = vmSymbols::invoke_name(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
419 |
Symbol* method_signature = pool->signature_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
420 |
KlassHandle current_klass(THREAD, pool->pool_holder()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
421 |
resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
422 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
423 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
424 |
|
1 | 425 |
resolve_klass(resolved_klass, pool, index, CHECK); |
426 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
427 |
Symbol* method_name = pool->name_ref_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
428 |
Symbol* method_signature = pool->signature_ref_at(index); |
1 | 429 |
KlassHandle current_klass(THREAD, pool->pool_holder()); |
430 |
||
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
431 |
if (pool->has_preresolution() |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
432 |
|| (resolved_klass() == SystemDictionary::MethodHandle_klass() && |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
433 |
MethodHandles::is_signature_polymorphic_name(resolved_klass(), method_name))) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
434 |
Method* result_oop = ConstantPool::method_at_if_loaded(pool, index); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
435 |
if (result_oop != NULL) { |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
436 |
resolved_method = methodHandle(THREAD, result_oop); |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
437 |
return; |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
438 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
439 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
440 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
441 |
if (code == Bytecodes::_invokeinterface) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
442 |
resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
443 |
} else { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
444 |
resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
445 |
} |
1 | 446 |
} |
447 |
||
448 |
void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
449 |
Symbol* method_name, Symbol* method_signature, |
1 | 450 |
KlassHandle current_klass, bool check_access, TRAPS) { |
451 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
452 |
Handle nested_exception; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
453 |
|
14385 | 454 |
// 1. lookup method in resolved klass and its super klasses |
1 | 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 |
|
14385 | 458 |
// 2. lookup method in all the interfaces implemented by the resolved klass |
1 | 459 |
lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); |
460 |
||
461 |
if (resolved_method.is_null()) { |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
462 |
// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
463 |
lookup_polymorphic_method(resolved_method, resolved_klass, method_name, method_signature, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
464 |
current_klass, (Handle*)NULL, (Handle*)NULL, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
465 |
if (HAS_PENDING_EXCEPTION) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
466 |
nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
467 |
CLEAR_PENDING_EXCEPTION; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
468 |
} |
2534 | 469 |
} |
470 |
||
471 |
if (resolved_method.is_null()) { |
|
14385 | 472 |
// 3. method lookup failed |
1 | 473 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
474 |
THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), |
14488 | 475 |
Method::name_and_sig_as_C_string(resolved_klass(), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
476 |
method_name, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
477 |
method_signature), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
478 |
nested_exception); |
1 | 479 |
} |
480 |
} |
|
481 |
||
14385 | 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 |
||
1 | 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(), |
|
14488 | 495 |
Method::name_and_sig_as_C_string(resolved_klass(), |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
496 |
method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
497 |
method_signature)); |
1 | 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 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
512 |
Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
513 |
Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); |
1 | 514 |
{ |
515 |
ResourceMark rm(THREAD); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
516 |
Symbol* failed_type_symbol = |
1 | 517 |
SystemDictionary::check_signature_loaders(method_signature, loader, |
518 |
class_loader, true, CHECK); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
519 |
if (failed_type_symbol != NULL) { |
1 | 520 |
const char* msg = "loader constraint violation: when resolving method" |
521 |
" \"%s\" the class loader (instance of %s) of the current class, %s," |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
522 |
" and the class loader (instance of %s) for the method's defining class, %s, have" |
1 | 523 |
" different Class objects for the type %s used in the signature"; |
14488 | 524 |
char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); |
1 | 525 |
const char* loader1 = SystemDictionary::loader_name(loader()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
526 |
char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); |
1 | 527 |
const char* loader2 = SystemDictionary::loader_name(class_loader()); |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
528 |
char* target = InstanceKlass::cast(resolved_method->method_holder()) |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
529 |
->name()->as_C_string(); |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
530 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
1 | 531 |
size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
532 |
strlen(current) + strlen(loader2) + strlen(target) + |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
533 |
strlen(failed_type_name) + 1; |
1 | 534 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
535 |
jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
536 |
target, failed_type_name); |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
545 |
Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
546 |
Symbol* method_signature, |
1 | 547 |
KlassHandle current_klass, |
548 |
bool check_access, TRAPS) { |
|
549 |
||
550 |
// check if klass is interface |
|
551 |
if (!resolved_klass->is_interface()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
552 |
ResourceMark rm(THREAD); |
1 | 553 |
char buf[200]; |
14488 | 554 |
jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); |
1 | 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(), |
|
14488 | 568 |
Method::name_and_sig_as_C_string(resolved_klass(), |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
569 |
method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
570 |
method_signature)); |
1 | 571 |
} |
572 |
} |
|
573 |
||
574 |
if (check_access) { |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
575 |
// JDK8 adds non-public interface methods, and accessability check requirement |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
576 |
assert(current_klass.not_null() , "current_klass should not be null"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
577 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
578 |
// check if method can be accessed by the referring class |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
579 |
check_method_accessability(current_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
580 |
resolved_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
581 |
KlassHandle(THREAD, resolved_method->method_holder()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
582 |
resolved_method, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
583 |
CHECK); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
584 |
|
1 | 585 |
HandleMark hm(THREAD); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
586 |
Handle loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
587 |
Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); |
1 | 588 |
{ |
589 |
ResourceMark rm(THREAD); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
590 |
Symbol* failed_type_symbol = |
1 | 591 |
SystemDictionary::check_signature_loaders(method_signature, loader, |
592 |
class_loader, true, CHECK); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
593 |
if (failed_type_symbol != NULL) { |
1 | 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 " |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
597 |
"the method's defining class, %s, have different Class objects for the type %s " |
1 | 598 |
"used in the signature"; |
14488 | 599 |
char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); |
1 | 600 |
const char* loader1 = SystemDictionary::loader_name(loader()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
601 |
char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); |
1 | 602 |
const char* loader2 = SystemDictionary::loader_name(class_loader()); |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
603 |
char* target = InstanceKlass::cast(resolved_method->method_holder()) |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
604 |
->name()->as_C_string(); |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
605 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
1 | 606 |
size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
607 |
strlen(current) + strlen(loader2) + strlen(target) + |
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
608 |
strlen(failed_type_name) + 1; |
1 | 609 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
610 |
jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
611 |
target, failed_type_name); |
1 | 612 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
613 |
} |
|
614 |
} |
|
615 |
} |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
616 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
617 |
if (TraceItables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
618 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
619 |
tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
620 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
621 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
622 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
623 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
624 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
625 |
resolved_method->method_holder()->internal_name() |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
626 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
627 |
resolved_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
628 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
629 |
} |
1 | 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) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
640 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
641 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
642 |
sel_klass(), |
1 | 643 |
fd.access_flags(), |
644 |
true)) { |
|
645 |
ResourceMark rm(THREAD); |
|
646 |
Exceptions::fthrow( |
|
647 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
648 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 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 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
658 |
void LinkResolver::resolve_field_access(fieldDescriptor& result, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
659 |
// Load these early in case the resolve of the containing klass fails |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
660 |
Symbol* field = pool->name_ref_at(index); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
661 |
Symbol* sig = pool->signature_ref_at(index); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
662 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
663 |
// resolve specified klass |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
664 |
KlassHandle resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
665 |
resolve_klass(resolved_klass, pool, index, CHECK); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
666 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
667 |
KlassHandle current_klass(THREAD, pool->pool_holder()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
668 |
resolve_field(result, resolved_klass, field, sig, current_klass, byte, true, true, CHECK); |
1 | 669 |
} |
670 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
671 |
void LinkResolver::resolve_field(fieldDescriptor& fd, KlassHandle resolved_klass, Symbol* field, Symbol* sig, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
672 |
KlassHandle current_klass, Bytecodes::Code byte, bool check_access, bool initialize_class, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
673 |
TRAPS) { |
1 | 674 |
assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic || |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
675 |
byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
676 |
(byte == Bytecodes::_nop && !check_access), "bad field access bytecode"); |
1 | 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 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
682 |
if (resolved_klass.is_null()) { |
1 | 683 |
ResourceMark rm(THREAD); |
684 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
685 |
} |
|
686 |
||
687 |
// Resolve instance field |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
688 |
KlassHandle sel_klass(THREAD, InstanceKlass::cast(resolved_klass())->find_field(field, sig, &fd)); |
1 | 689 |
// check if field exists; i.e., if a klass containing the field def has been selected |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
690 |
if (sel_klass.is_null()) { |
1 | 691 |
ResourceMark rm(THREAD); |
692 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
693 |
} |
|
694 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
695 |
if (!check_access) |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
696 |
// Access checking may be turned off when calling from within the VM. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
697 |
return; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
698 |
|
1 | 699 |
// check access |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
700 |
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |
1 | 701 |
|
702 |
// check for errors |
|
703 |
if (is_static != fd.is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
704 |
ResourceMark rm(THREAD); |
1 | 705 |
char msg[200]; |
14488 | 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()); |
1 | 707 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); |
708 |
} |
|
709 |
||
710 |
// Final fields can only be accessed from its own class. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
711 |
if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) { |
1 | 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 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
721 |
if (is_static && initialize_class) { |
1 | 722 |
sel_klass->initialize(CHECK); |
723 |
} |
|
724 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
725 |
if (sel_klass() != current_klass()) { |
1 | 726 |
HandleMark hm(THREAD); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
727 |
Handle ref_loader (THREAD, InstanceKlass::cast(current_klass())->class_loader()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
728 |
Handle sel_loader (THREAD, InstanceKlass::cast(sel_klass())->class_loader()); |
1 | 729 |
{ |
730 |
ResourceMark rm(THREAD); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
731 |
Symbol* failed_type_symbol = |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
732 |
SystemDictionary::check_signature_loaders(sig, |
1 | 733 |
ref_loader, sel_loader, |
734 |
false, |
|
735 |
CHECK); |
|
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
736 |
if (failed_type_symbol != NULL) { |
1 | 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"; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
741 |
char* field_name = field->as_C_string(); |
1 | 742 |
const char* loader1 = SystemDictionary::loader_name(ref_loader()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
743 |
char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string(); |
1 | 744 |
const char* loader2 = SystemDictionary::loader_name(sel_loader()); |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
745 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
1 | 746 |
size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) + |
16591
73047b0eb568
8009731: Confusing error message for loader constraint violation
acorn
parents:
15922
diff
changeset
|
747 |
strlen(sel) + strlen(loader2) + strlen(failed_type_name) + 1; |
1 | 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 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
772 |
void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
773 |
Symbol* method_signature, KlassHandle current_klass, |
1 | 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); |
|
14488 | 777 |
resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
791 |
Symbol* method_name, Symbol* method_signature, |
1 | 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()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
799 |
ResourceMark rm(THREAD); |
1 | 800 |
char buf[200]; |
14488 | 801 |
jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 802 |
resolved_method->name(), |
803 |
resolved_method->signature())); |
|
804 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
805 |
} |
|
806 |
} |
|
807 |
||
808 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
809 |
void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
810 |
Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
818 |
Symbol* method_name, Symbol* method_signature, |
1 | 819 |
KlassHandle current_klass, bool check_access, TRAPS) { |
820 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
821 |
// Invokespecial is called for multiple special reasons: |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
822 |
// <init> |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
823 |
// local private method invocation, for classes and interfaces |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
824 |
// superclass.method, which can also resolve to a default method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
825 |
// and the selected method is recalculated relative to the direct superclass |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
826 |
// superinterface.method, which explicitly does not check shadowing |
14385 | 827 |
|
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
836 |
vmSymbols::java_lang_NoSuchMethodError(), |
1 | 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()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
847 |
ResourceMark rm(THREAD); |
1 | 848 |
char buf[200]; |
849 |
jio_snprintf(buf, sizeof(buf), |
|
850 |
"Expecting non-static method %s", |
|
14488 | 851 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 852 |
resolved_method->name(), |
853 |
resolved_method->signature())); |
|
854 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
855 |
} |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
856 |
if (TraceItables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
857 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
858 |
tty->print("invokespecial resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
859 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
860 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
861 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
862 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
863 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
864 |
resolved_method->method_holder()->internal_name() |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
865 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
866 |
resolved_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
867 |
if (resolved_method->method_holder()->is_interface() && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
868 |
!resolved_method->is_abstract()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
869 |
tty->print("default"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
870 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
871 |
if (resolved_method->is_overpass()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
872 |
tty->print("overpass"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
873 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
874 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
875 |
} |
1 | 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 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
883 |
// for a superclass method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
884 |
// Invokespecial for a superinterface, resolved method is selected method, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
885 |
// no checks for shadowing |
1 | 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 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
892 |
if (check_access && |
1 | 893 |
// a) check if ACC_SUPER flag is set for the current class |
15918 | 894 |
(current_klass->is_super() || !AllowNonVirtualCalls) && |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
895 |
// b) check if the class of the resolved_klass is a superclass |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
896 |
// (not supertype in order to exclude interface classes) of the current class. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
897 |
// This check is not performed for super.invoke for interface methods |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
898 |
// in super interfaces. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
899 |
current_klass->is_subclass_of(resolved_klass()) && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
900 |
current_klass() != resolved_klass() && |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
906 |
resolved_method->name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
907 |
resolved_method->signature(), CHECK); |
1 | 908 |
// check if found |
909 |
if (sel_method.is_null()) { |
|
910 |
ResourceMark rm(THREAD); |
|
911 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 912 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 913 |
resolved_method->name(), |
914 |
resolved_method->signature())); |
|
915 |
} |
|
916 |
} |
|
917 |
} |
|
918 |
||
919 |
// check if not static |
|
920 |
if (sel_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
921 |
ResourceMark rm(THREAD); |
1 | 922 |
char buf[200]; |
14488 | 923 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 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(), |
|
14488 | 933 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 934 |
sel_method->name(), |
935 |
sel_method->signature())); |
|
936 |
} |
|
937 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
938 |
if (TraceItables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
939 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
940 |
tty->print("invokespecial selected method: resolved-class:%s, method:%s, method_holder:%s, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
941 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
942 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
943 |
sel_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
944 |
sel_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
945 |
sel_method->method_holder()->internal_name() |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
946 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
947 |
sel_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
948 |
if (sel_method->method_holder()->is_interface() && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
949 |
!sel_method->is_abstract()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
950 |
tty->print("default"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
951 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
952 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
953 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
954 |
|
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
960 |
Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
969 |
Symbol* method_name, Symbol* method_signature, |
1 | 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 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
977 |
// check if private interface method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
978 |
if (resolved_klass->is_interface() && resolved_method->is_private()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
979 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
980 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
981 |
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
982 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
983 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
984 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
985 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
986 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
987 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
988 |
|
1 | 989 |
// check if not static |
990 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
991 |
ResourceMark rm(THREAD); |
1 | 992 |
char buf[200]; |
14488 | 993 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 994 |
resolved_method->name(), |
995 |
resolved_method->signature())); |
|
996 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
997 |
} |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
998 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
999 |
if (PrintVtables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1000 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1001 |
tty->print("invokevirtual resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1002 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1003 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1004 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1005 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1006 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1007 |
resolved_method->method_holder()->internal_name() |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1008 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1009 |
resolved_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1010 |
if (resolved_method->method_holder()->is_interface() && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1011 |
!resolved_method->is_abstract()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1012 |
tty->print("default"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1013 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1014 |
if (resolved_method->is_overpass()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1015 |
tty->print("overpass"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1016 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1017 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1018 |
} |
1 | 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 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1031 |
int vtable_index = Method::invalid_vtable_index; |
1 | 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 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1041 |
// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s |
1 | 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. |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
1044 |
assert(resolved_method->method_holder()->is_linked(), "must be linked"); |
1 | 1045 |
|
1046 |
// do lookup based on receiver klass using the vtable index |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1047 |
if (resolved_method->method_holder()->is_interface()) { // miranda method |
1 | 1048 |
vtable_index = vtable_index_of_miranda_method(resolved_klass, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1049 |
resolved_method->name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1050 |
resolved_method->signature(), CHECK); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1051 |
|
1 | 1052 |
assert(vtable_index >= 0 , "we should have valid vtable index at this point"); |
1053 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1054 |
InstanceKlass* inst = InstanceKlass::cast(recv_klass()); |
1 | 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. |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1059 |
assert(!resolved_method->has_itable_index(), ""); |
1 | 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. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1066 |
if (vtable_index == Method::nonvirtual_vtable_index) { |
1 | 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. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1072 |
InstanceKlass* inst = (InstanceKlass*)recv_klass(); |
1 | 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(), |
|
14488 | 1081 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 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(), |
|
14488 | 1090 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1091 |
selected_method->name(), |
1092 |
selected_method->signature())); |
|
1093 |
} |
|
1094 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1095 |
if (PrintVtables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1096 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1097 |
tty->print("invokevirtual selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, vtable_index:%d, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1098 |
(recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1099 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1100 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1101 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1102 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1103 |
selected_method->method_holder()->internal_name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1104 |
vtable_index |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1105 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1106 |
selected_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1107 |
if (selected_method->method_holder()->is_interface() && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1108 |
!selected_method->is_abstract()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1109 |
tty->print("default"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1110 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1111 |
if (resolved_method->is_overpass()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1112 |
tty->print("overpass"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1113 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1114 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1115 |
} |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1121 |
Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, |
1 | 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 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1129 |
void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1130 |
Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { |
1 | 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 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1146 |
// check if private interface method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1147 |
if (resolved_klass->is_interface() && resolved_method->is_private()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1148 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1149 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1150 |
jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1151 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1152 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1153 |
resolved_method->signature())); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1154 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1155 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1156 |
|
1 | 1157 |
// check if receiver klass implements the resolved interface |
1158 |
if (!recv_klass->is_subtype_of(resolved_klass())) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1159 |
ResourceMark rm(THREAD); |
1 | 1160 |
char buf[200]; |
1161 |
jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", |
|
14488 | 1162 |
recv_klass()->external_name(), |
1163 |
resolved_klass()->external_name()); |
|
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1169 |
resolved_method->name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1170 |
resolved_method->signature(), CHECK); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1171 |
if (sel_method.is_null() && !check_null_and_abstract) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1172 |
// In theory this is a harmless placeholder value, but |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1173 |
// in practice leaving in null affects the nsk default method tests. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1174 |
// This needs further study. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1175 |
sel_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1176 |
} |
1 | 1177 |
// check if method exists |
1178 |
if (sel_method.is_null()) { |
|
1179 |
ResourceMark rm(THREAD); |
|
1180 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1181 |
Method::name_and_sig_as_C_string(recv_klass(), |
1 | 1182 |
resolved_method->name(), |
1183 |
resolved_method->signature())); |
|
1184 |
} |
|
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1185 |
// check access |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1186 |
// Throw Illegal Access Error if sel_method is not public. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1187 |
if (!sel_method->is_public()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1188 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1189 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1190 |
Method::name_and_sig_as_C_string(recv_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1191 |
sel_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1192 |
sel_method->signature())); |
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1193 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1194 |
|
1 | 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(), |
|
14488 | 1199 |
Method::name_and_sig_as_C_string(recv_klass(), |
1 | 1200 |
sel_method->name(), |
1201 |
sel_method->signature())); |
|
1202 |
} |
|
1203 |
// setup result |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1204 |
if (!resolved_method->has_itable_index()) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1205 |
int vtable_index = resolved_method->vtable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1206 |
assert(vtable_index == sel_method->vtable_index(), "sanity check"); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1207 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1208 |
return; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1209 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1210 |
int itable_index = resolved_method()->itable_index(); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1211 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1212 |
if (TraceItables && Verbose) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1213 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1214 |
tty->print("invokeinterface selected method: receiver-class:%s, resolved-class:%s, method:%s, method_holder:%s, access_flags: ", |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1215 |
(recv_klass.is_null() ? "<NULL>" : recv_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1216 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1217 |
Method::name_and_sig_as_C_string(resolved_klass(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1218 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1219 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1220 |
sel_method->method_holder()->internal_name() |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1221 |
); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1222 |
sel_method->access_flags().print_on(tty); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1223 |
if (sel_method->method_holder()->is_interface() && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1224 |
!sel_method->is_abstract()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1225 |
tty->print("default"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1226 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1227 |
if (resolved_method->is_overpass()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1228 |
tty->print("overpass"); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1229 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1230 |
tty->cr(); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1231 |
} |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1232 |
result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); |
1 | 1233 |
} |
1234 |
||
1235 |
||
1236 |
methodHandle LinkResolver::linktime_resolve_interface_method_or_null( |
|
1237 |
KlassHandle resolved_klass, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1238 |
Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1239 |
Symbol* method_signature, |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1255 |
Symbol* method_name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1256 |
Symbol* method_signature, |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1273 |
Symbol* name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1274 |
Symbol* signature, |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1289 |
Symbol* name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1290 |
Symbol* signature, |
1 | 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, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1305 |
Symbol* name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1306 |
Symbol* signature, |
1 | 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; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1313 |
return Method::invalid_vtable_index; |
1 | 1314 |
} |
1315 |
return info.vtable_index(); |
|
1316 |
} |
|
1317 |
||
1318 |
methodHandle LinkResolver::resolve_static_call_or_null( |
|
1319 |
KlassHandle resolved_klass, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1320 |
Symbol* name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1321 |
Symbol* signature, |
1 | 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 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1333 |
methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, Symbol* name, Symbol* signature, |
1 | 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; |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1355 |
case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1356 |
case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; |
1 | 1357 |
case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; |
1358 |
} |
|
1359 |
return; |
|
1360 |
} |
|
1361 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1362 |
void LinkResolver::resolve_pool(KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, |
1 | 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 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1368 |
method_name = pool->name_ref_at(index); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1369 |
method_signature = pool->signature_ref_at(index); |
1 | 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; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1376 |
Symbol* method_name = NULL; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1377 |
Symbol* method_signature = NULL; |
1 | 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; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1386 |
Symbol* method_name = NULL; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1387 |
Symbol* method_signature = NULL; |
1 | 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; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1399 |
Symbol* method_name = NULL; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1400 |
Symbol* method_signature = NULL; |
1 | 1401 |
KlassHandle current_klass; |
1402 |
resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1403 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
1 | 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; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1410 |
Symbol* method_name = NULL; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1411 |
Symbol* method_signature = NULL; |
1 | 1412 |
KlassHandle current_klass; |
1413 |
resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1414 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
1 | 1415 |
resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); |
1416 |
} |
|
1417 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1418 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1419 |
void LinkResolver::resolve_invokehandle(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1420 |
assert(EnableInvokeDynamic, ""); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1421 |
// This guy is reached from InterpreterRuntime::resolve_invokehandle. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1422 |
KlassHandle resolved_klass; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1423 |
Symbol* method_name = NULL; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1424 |
Symbol* method_signature = NULL; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1425 |
KlassHandle current_klass; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1426 |
resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK); |
16691 | 1427 |
if (TraceMethodHandles) { |
1428 |
ResourceMark rm(THREAD); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1429 |
tty->print_cr("resolve_invokehandle %s %s", method_name->as_C_string(), method_signature->as_C_string()); |
16691 | 1430 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1431 |
resolve_handle_call(result, resolved_klass, method_name, method_signature, current_klass, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1432 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1433 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1434 |
void LinkResolver::resolve_handle_call(CallInfo& result, KlassHandle resolved_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1435 |
Symbol* method_name, Symbol* method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1436 |
KlassHandle current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1437 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1438 |
// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1439 |
assert(resolved_klass() == SystemDictionary::MethodHandle_klass(), ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1440 |
assert(MethodHandles::is_signature_polymorphic_name(method_name), ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1441 |
methodHandle resolved_method; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1442 |
Handle resolved_appendix; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1443 |
Handle resolved_method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1444 |
lookup_polymorphic_method(resolved_method, resolved_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1445 |
method_name, method_signature, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1446 |
current_klass, &resolved_appendix, &resolved_method_type, CHECK); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1447 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1448 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1449 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1450 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1451 |
void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1452 |
assert(EnableInvokeDynamic, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1453 |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1454 |
//resolve_pool(<resolved_klass>, method_name, method_signature, current_klass, pool, index, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1455 |
Symbol* method_name = pool->name_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1456 |
Symbol* method_signature = pool->signature_ref_at(index); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1457 |
KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1458 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1459 |
// Resolve the bootstrap specifier (BSM + optional arguments). |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1460 |
Handle bootstrap_specifier; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1461 |
// Check if CallSite has been bound already: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1462 |
ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1463 |
if (cpce->is_f1_null()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1464 |
int pool_index = cpce->constant_pool_index(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1465 |
oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1466 |
assert(bsm_info != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1467 |
// FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1468 |
bootstrap_specifier = Handle(THREAD, bsm_info); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1469 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1470 |
if (!cpce->is_f1_null()) { |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1471 |
methodHandle method( THREAD, cpce->f1_as_method()); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1472 |
Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1473 |
Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1474 |
result.set_handle(method, appendix, method_type, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1475 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1476 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1477 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1478 |
if (TraceMethodHandles) { |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1479 |
ResourceMark rm(THREAD); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1480 |
tty->print_cr("resolve_invokedynamic #%d %s %s", |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1481 |
ConstantPool::decode_invokedynamic_index(index), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1482 |
method_name->as_C_string(), method_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1483 |
tty->print(" BSM info: "); bootstrap_specifier->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1484 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1485 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1486 |
resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1487 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1488 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1489 |
void LinkResolver::resolve_dynamic_call(CallInfo& result, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1490 |
Handle bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1491 |
Symbol* method_name, Symbol* method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1492 |
KlassHandle current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1493 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1494 |
// JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1495 |
// The appendix argument is likely to be a freshly-created CallSite. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1496 |
Handle resolved_appendix; |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1497 |
Handle resolved_method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1498 |
methodHandle resolved_method = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1499 |
SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1500 |
bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1501 |
method_name, method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1502 |
&resolved_appendix, |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1503 |
&resolved_method_type, |
13732
a9865f5514fc
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
13728
diff
changeset
|
1504 |
THREAD); |
9967
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1505 |
if (HAS_PENDING_EXCEPTION) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1506 |
if (TraceMethodHandles) { |
20282
7f9cbdf89af2
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
20017
diff
changeset
|
1507 |
tty->print_cr("invokedynamic throws BSME for "INTPTR_FORMAT, (void *)PENDING_EXCEPTION); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1508 |
PENDING_EXCEPTION->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1509 |
} |
9967
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1510 |
if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1511 |
// throw these guys, since they are already wrapped |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1512 |
return; |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1513 |
} |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1514 |
if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1515 |
// intercept only LinkageErrors which might have failed to wrap |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1516 |
return; |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1517 |
} |
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1518 |
// See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1519 |
Handle nested_exception(THREAD, PENDING_EXCEPTION); |
9967
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1520 |
CLEAR_PENDING_EXCEPTION; |
13732
a9865f5514fc
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
13728
diff
changeset
|
1521 |
THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) |
9967
9ddc1c490930
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
jrose
parents:
9425
diff
changeset
|
1522 |
} |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13732
diff
changeset
|
1523 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1524 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1525 |
|
1 | 1526 |
//------------------------------------------------------------------------------------------------------------------------ |
1527 |
#ifndef PRODUCT |
|
1528 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1529 |
void CallInfo::print() { |
1 | 1530 |
ResourceMark rm; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1531 |
const char* kindstr = "unknown"; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1532 |
switch (_call_kind) { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1533 |
case direct_call: kindstr = "direct"; break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1534 |
case vtable_call: kindstr = "vtable"; break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1535 |
case itable_call: kindstr = "itable"; break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1536 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1537 |
tty->print_cr("Call %s@%d %s", kindstr, _call_index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1538 |
_resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); |
1 | 1539 |
} |
1540 |
||
1541 |
#endif |