author | psandoz |
Thu, 24 Mar 2016 11:21:49 +0100 | |
changeset 36819 | bca375d368ed |
parent 35913 | 928548a43408 |
child 36822 | cdc493d7bc9a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
35900 | 2 |
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5421
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14385 | 26 |
#include "classfile/defaultMethods.hpp" |
34666 | 27 |
#include "classfile/symbolTable.hpp" |
7397 | 28 |
#include "classfile/systemDictionary.hpp" |
29 |
#include "classfile/vmSymbols.hpp" |
|
30 |
#include "compiler/compileBroker.hpp" |
|
30764 | 31 |
#include "gc/shared/collectedHeap.inline.hpp" |
7397 | 32 |
#include "interpreter/bytecode.hpp" |
33 |
#include "interpreter/interpreterRuntime.hpp" |
|
34 |
#include "interpreter/linkResolver.hpp" |
|
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
35 |
#include "logging/log.hpp" |
7397 | 36 |
#include "memory/resourceArea.hpp" |
37 |
#include "memory/universe.inline.hpp" |
|
38 |
#include "oops/instanceKlass.hpp" |
|
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
39 |
#include "oops/method.hpp" |
7397 | 40 |
#include "oops/objArrayOop.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28738
diff
changeset
|
41 |
#include "oops/oop.inline.hpp" |
7397 | 42 |
#include "prims/methodHandles.hpp" |
43 |
#include "prims/nativeLookup.hpp" |
|
44 |
#include "runtime/compilationPolicy.hpp" |
|
45 |
#include "runtime/fieldDescriptor.hpp" |
|
46 |
#include "runtime/frame.inline.hpp" |
|
47 |
#include "runtime/handles.inline.hpp" |
|
48 |
#include "runtime/reflection.hpp" |
|
49 |
#include "runtime/signature.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
14488
diff
changeset
|
50 |
#include "runtime/thread.inline.hpp" |
7397 | 51 |
#include "runtime/vmThread.hpp" |
1 | 52 |
|
53 |
||
54 |
//------------------------------------------------------------------------------------------------------------------------ |
|
55 |
// Implementation of CallInfo |
|
56 |
||
57 |
||
31019 | 58 |
void CallInfo::set_static(KlassHandle resolved_klass, const methodHandle& resolved_method, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
59 |
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
|
60 |
set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
1 | 61 |
} |
62 |
||
63 |
||
31019 | 64 |
void CallInfo::set_interface(KlassHandle resolved_klass, |
65 |
KlassHandle selected_klass, |
|
66 |
const methodHandle& resolved_method, |
|
67 |
const methodHandle& selected_method, |
|
68 |
int itable_index, TRAPS) { |
|
1 | 69 |
// This is only called for interface methods. If the resolved_method |
70 |
// comes from java/lang/Object, it can be the subject of a virtual call, so |
|
71 |
// 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
|
72 |
// 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
|
73 |
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
|
74 |
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
|
75 |
set_common(resolved_klass, selected_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); |
1 | 76 |
} |
77 |
||
31019 | 78 |
void CallInfo::set_virtual(KlassHandle resolved_klass, |
79 |
KlassHandle selected_klass, |
|
80 |
const methodHandle& resolved_method, |
|
81 |
const methodHandle& selected_method, |
|
82 |
int vtable_index, TRAPS) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
1 | 88 |
} |
89 |
||
31019 | 90 |
void CallInfo::set_handle(const methodHandle& resolved_method, |
91 |
Handle resolved_appendix, |
|
92 |
Handle resolved_method_type, TRAPS) { |
|
36819 | 93 |
set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); |
94 |
} |
|
95 |
||
96 |
void CallInfo::set_handle(KlassHandle resolved_klass, |
|
97 |
const methodHandle& resolved_method, |
|
98 |
Handle resolved_appendix, |
|
99 |
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
|
100 |
if (resolved_method.is_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
101 |
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
|
102 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
103 |
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
|
104 |
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
|
105 |
"linkMethod must return one of these"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
_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
|
110 |
_resolved_method_type = resolved_method_type; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
111 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
112 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
113 |
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
|
114 |
KlassHandle selected_klass, |
31019 | 115 |
const methodHandle& resolved_method, |
116 |
const methodHandle& selected_method, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
117 |
CallKind kind, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
118 |
int index, |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
119 |
TRAPS) { |
1 | 120 |
assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond"); |
121 |
_resolved_klass = resolved_klass; |
|
122 |
_selected_klass = selected_klass; |
|
123 |
_resolved_method = resolved_method; |
|
124 |
_selected_method = selected_method; |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
125 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
126 |
_call_index = index; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
127 |
_resolved_appendix = Handle(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
128 |
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
|
129 |
|
6453 | 130 |
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
|
131 |
// 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
|
132 |
|
6453 | 133 |
// Note: with several active threads, the must_be_compiled may be true |
134 |
// while can_be_compiled is false; remove assert |
|
135 |
// assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32189
diff
changeset
|
136 |
if (!THREAD->can_call_java()) { |
1 | 137 |
// don't force compilation, resolve was on behalf of compiler |
138 |
return; |
|
139 |
} |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
14385
diff
changeset
|
140 |
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
|
141 |
// '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
|
142 |
// 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
|
143 |
// 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
|
144 |
// 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
|
145 |
// in CompileBroker::compile_method. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
146 |
// 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
|
147 |
// even before classes are initialized. |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
148 |
return; |
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4429
diff
changeset
|
149 |
} |
1 | 150 |
CompileBroker::compile_method(selected_method, InvocationEntryBci, |
10250
0794cd144834
7066339: Tiered: policy should make consistent decisions about osr levels
iveresov
parents:
10008
diff
changeset
|
151 |
CompilationPolicy::policy()->initial_compile_level(), |
6453 | 152 |
methodHandle(), 0, "must_be_compiled", CHECK); |
1 | 153 |
} |
154 |
} |
|
155 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
156 |
// 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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
resolved_klass = resolved_method_holder; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
161 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
162 |
_resolved_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
163 |
_selected_klass = resolved_klass; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
164 |
_resolved_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
165 |
_selected_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
166 |
// classify: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
167 |
CallKind kind = CallInfo::unknown_kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
168 |
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
|
169 |
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
|
170 |
kind = CallInfo::direct_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
171 |
} 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
|
172 |
// 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
|
173 |
kind = CallInfo::vtable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
174 |
} else if (!resolved_klass->is_interface()) { |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
175 |
// A default or miranda method. Compute the vtable index. |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
176 |
ResourceMark rm; |
35900 | 177 |
klassVtable* vt = resolved_klass->vtable(); |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
178 |
index = LinkResolver::vtable_index_of_interface_method(resolved_klass, |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
179 |
resolved_method); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
180 |
assert(index >= 0 , "we should have valid vtable index at this point"); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
181 |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
182 |
kind = CallInfo::vtable_call; |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
183 |
} else if (resolved_method->has_vtable_index()) { |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
184 |
// Can occur if an interface redeclares a method of Object. |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
185 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
186 |
#ifdef ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
187 |
// Ensure that this is really the case. |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
188 |
KlassHandle object_klass = SystemDictionary::Object_klass(); |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
189 |
Method * object_resolved_method = object_klass()->vtable()->method_at(index); |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
190 |
assert(object_resolved_method->name() == resolved_method->name(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
191 |
"Object and interface method names should match at vtable index %d, %s != %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
192 |
index, object_resolved_method->name()->as_C_string(), resolved_method->name()->as_C_string()); |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
193 |
assert(object_resolved_method->signature() == resolved_method->signature(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
194 |
"Object and interface method signatures should match at vtable index %d, %s != %s", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
195 |
index, object_resolved_method->signature()->as_C_string(), resolved_method->signature()->as_C_string()); |
20712
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
196 |
#endif // ASSERT |
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
197 |
|
a06e1f01fb6e
8026124: JSR-292 bug: java.nio.file.Path.toString cores dump
drchase
parents:
20391
diff
changeset
|
198 |
kind = CallInfo::vtable_call; |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
199 |
} else { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
200 |
// A regular interface call. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
201 |
kind = CallInfo::itable_call; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
202 |
index = resolved_method->itable_index(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
203 |
} |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
204 |
assert(index == Method::nonvirtual_vtable_index || index >= 0, "bad index %d", index); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
205 |
_call_kind = kind; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
206 |
_call_index = index; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
207 |
_resolved_appendix = Handle(); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
208 |
DEBUG_ONLY(verify()); |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
209 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
210 |
|
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
211 |
#ifdef ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
212 |
void CallInfo::verify() { |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
213 |
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
|
214 |
case CallInfo::direct_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
215 |
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
|
216 |
// 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
|
217 |
case CallInfo::vtable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
218 |
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
|
219 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
220 |
case CallInfo::itable_call: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
221 |
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
|
222 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
223 |
case CallInfo::unknown_kind: |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
224 |
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
|
225 |
break; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
226 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
227 |
fatal("Unexpected call kind %d", call_kind()); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
228 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
229 |
} |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
230 |
#endif //ASSERT |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
231 |
|
31019 | 232 |
#ifndef PRODUCT |
233 |
void CallInfo::print() { |
|
234 |
ResourceMark rm; |
|
235 |
const char* kindstr = "unknown"; |
|
236 |
switch (_call_kind) { |
|
237 |
case direct_call: kindstr = "direct"; break; |
|
238 |
case vtable_call: kindstr = "vtable"; break; |
|
239 |
case itable_call: kindstr = "itable"; break; |
|
240 |
} |
|
241 |
tty->print_cr("Call %s@%d %s", kindstr, _call_index, |
|
242 |
_resolved_method.is_null() ? "(none)" : _resolved_method->name_and_sig_as_C_string()); |
|
243 |
} |
|
244 |
#endif |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
245 |
|
31019 | 246 |
//------------------------------------------------------------------------------------------------------------------------ |
247 |
// Implementation of LinkInfo |
|
1 | 248 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
249 |
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 250 |
// resolve klass |
251 |
Klass* result = pool->klass_ref_at(index, CHECK); |
|
252 |
_resolved_klass = KlassHandle(THREAD, result); |
|
253 |
||
254 |
// Get name, signature, and static klass |
|
255 |
_name = pool->name_ref_at(index); |
|
256 |
_signature = pool->signature_ref_at(index); |
|
257 |
_current_klass = KlassHandle(THREAD, pool->pool_holder()); |
|
258 |
||
259 |
// Coming from the constant pool always checks access |
|
260 |
_check_access = true; |
|
261 |
} |
|
262 |
||
263 |
char* LinkInfo::method_string() const { |
|
264 |
return Method::name_and_sig_as_C_string(_resolved_klass(), _name, _signature); |
|
265 |
} |
|
266 |
||
267 |
#ifndef PRODUCT |
|
268 |
void LinkInfo::print() { |
|
269 |
ResourceMark rm; |
|
270 |
tty->print_cr("Link resolved_klass=%s name=%s signature=%s current_klass=%s check_access=%s", |
|
271 |
_resolved_klass->name()->as_C_string(), |
|
272 |
_name->as_C_string(), |
|
273 |
_signature->as_C_string(), |
|
274 |
_current_klass.is_null() ? "(none)" : _current_klass->name()->as_C_string(), |
|
275 |
_check_access ? "true" : "false"); |
|
276 |
} |
|
277 |
#endif // PRODUCT |
|
1 | 278 |
//------------------------------------------------------------------------------------------------------------------------ |
279 |
// Klass resolution |
|
280 |
||
281 |
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
|
282 |
if (!Reflection::verify_class_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
283 |
sel_klass(), |
1 | 284 |
true)) { |
285 |
ResourceMark rm(THREAD); |
|
286 |
Exceptions::fthrow( |
|
287 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
288 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 289 |
"tried to access class %s from class %s", |
290 |
sel_klass->external_name(), |
|
291 |
ref_klass->external_name() |
|
292 |
); |
|
293 |
return; |
|
294 |
} |
|
295 |
} |
|
296 |
||
297 |
//------------------------------------------------------------------------------------------------------------------------ |
|
298 |
// Method resolution |
|
299 |
// |
|
300 |
// According to JVM spec. $5.4.3c & $5.4.3d |
|
301 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
302 |
// Look up method in klasses, including static methods |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
303 |
// Then look up local default methods |
31019 | 304 |
methodHandle LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, |
305 |
bool checkpolymorphism, |
|
306 |
bool in_imethod_resolve, TRAPS) { |
|
307 |
KlassHandle klass = link_info.resolved_klass(); |
|
308 |
Symbol* name = link_info.name(); |
|
309 |
Symbol* signature = link_info.signature(); |
|
310 |
||
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
311 |
// Ignore overpasses so statics can be found during resolution |
31019 | 312 |
Method* result = klass->uncached_lookup_method(name, signature, Klass::skip_overpass); |
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
313 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
314 |
if (klass->is_array_klass()) { |
27020 | 315 |
// Only consider klass and super klass for arrays |
31019 | 316 |
return methodHandle(THREAD, result); |
27020 | 317 |
} |
318 |
||
33602 | 319 |
InstanceKlass* ik = InstanceKlass::cast(klass()); |
320 |
||
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
321 |
// JDK 8, JVMS 5.4.3.4: Interface method resolution should |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
322 |
// ignore static and non-public methods of java.lang.Object, |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
323 |
// like clone, finalize, registerNatives. |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
324 |
if (in_imethod_resolve && |
31019 | 325 |
result != NULL && |
33602 | 326 |
ik->is_interface() && |
31019 | 327 |
(result->is_static() || !result->is_public()) && |
328 |
result->method_holder() == SystemDictionary::Object_klass()) { |
|
329 |
result = NULL; |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
330 |
} |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
331 |
|
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
332 |
// Before considering default methods, check for an overpass in the |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
333 |
// current class if a method has not been found. |
31019 | 334 |
if (result == NULL) { |
33602 | 335 |
result = ik->find_method(name, signature); |
23999
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
336 |
} |
22eb7be3d99d
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
22739
diff
changeset
|
337 |
|
31019 | 338 |
if (result == NULL) { |
33602 | 339 |
Array<Method*>* default_methods = ik->default_methods(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
340 |
if (default_methods != NULL) { |
31019 | 341 |
result = InstanceKlass::find_method(default_methods, name, signature); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
342 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
343 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
344 |
|
31019 | 345 |
if (checkpolymorphism && result != NULL) { |
346 |
vmIntrinsics::ID iid = result->intrinsic_id(); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
347 |
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
|
348 |
// Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. |
31019 | 349 |
return NULL; |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
350 |
} |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
4571
diff
changeset
|
351 |
} |
31019 | 352 |
return methodHandle(THREAD, result); |
1 | 353 |
} |
354 |
||
355 |
// returns first instance method |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
356 |
// Looks up method in classes, then looks up local default methods |
31019 | 357 |
methodHandle LinkResolver::lookup_instance_method_in_klasses(KlassHandle klass, |
358 |
Symbol* name, |
|
359 |
Symbol* signature, TRAPS) { |
|
360 |
Method* result = klass->uncached_lookup_method(name, signature, Klass::find_overpass); |
|
361 |
||
362 |
while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) { |
|
363 |
Klass* super_klass = result->method_holder()->super(); |
|
364 |
result = super_klass->uncached_lookup_method(name, signature, Klass::find_overpass); |
|
1 | 365 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
366 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
367 |
if (klass->is_array_klass()) { |
27020 | 368 |
// Only consider klass and super klass for arrays |
31019 | 369 |
return methodHandle(THREAD, result); |
27020 | 370 |
} |
371 |
||
31019 | 372 |
if (result == NULL) { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
373 |
Array<Method*>* default_methods = InstanceKlass::cast(klass())->default_methods(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
374 |
if (default_methods != NULL) { |
31019 | 375 |
result = InstanceKlass::find_method(default_methods, name, signature); |
376 |
assert(result == NULL || !result->is_static(), "static defaults not allowed"); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
377 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
378 |
} |
31019 | 379 |
return methodHandle(THREAD, result); |
1 | 380 |
} |
381 |
||
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
382 |
int LinkResolver::vtable_index_of_interface_method(KlassHandle klass, |
31019 | 383 |
const methodHandle& resolved_method) { |
1 | 384 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
385 |
int vtable_index = Method::invalid_vtable_index; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
386 |
Symbol* name = resolved_method->name(); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
387 |
Symbol* signature = resolved_method->signature(); |
33602 | 388 |
InstanceKlass* ik = InstanceKlass::cast(klass()); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
389 |
|
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
390 |
// First check in default method array |
33602 | 391 |
if (!resolved_method->is_abstract() && ik->default_methods() != NULL) { |
392 |
int index = InstanceKlass::find_method_index(ik->default_methods(), |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
393 |
name, signature, Klass::find_overpass, |
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
394 |
Klass::find_static, Klass::find_private); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
395 |
if (index >= 0 ) { |
33602 | 396 |
vtable_index = ik->default_vtable_indices()->at(index); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
397 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
398 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
399 |
if (vtable_index == Method::invalid_vtable_index) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
400 |
// get vtable_index for miranda methods |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
401 |
ResourceMark rm; |
33602 | 402 |
klassVtable *vt = ik->vtable(); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
403 |
vtable_index = vt->index_of_miranda(name, signature); |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
404 |
} |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
405 |
return vtable_index; |
1 | 406 |
} |
407 |
||
31019 | 408 |
methodHandle LinkResolver::lookup_method_in_interfaces(const LinkInfo& cp_info, TRAPS) { |
409 |
InstanceKlass *ik = InstanceKlass::cast(cp_info.resolved_klass()()); |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
410 |
|
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
411 |
// Specify 'true' in order to skip default methods when searching the |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
412 |
// interfaces. Function lookup_method_in_klasses() already looked for |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
413 |
// the method in the default methods table. |
31019 | 414 |
return methodHandle(THREAD, |
415 |
ik->lookup_method_in_all_interfaces(cp_info.name(), cp_info.signature(), |
|
416 |
Klass::skip_defaults)); |
|
1 | 417 |
} |
418 |
||
31019 | 419 |
methodHandle LinkResolver::lookup_polymorphic_method( |
420 |
const LinkInfo& link_info, |
|
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
|
421 |
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
|
422 |
Handle *method_type_result, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
423 |
TRAPS) { |
31019 | 424 |
KlassHandle klass = link_info.resolved_klass(); |
425 |
Symbol* name = link_info.name(); |
|
426 |
Symbol* full_signature = link_info.signature(); |
|
427 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
428 |
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
|
429 |
if (TraceMethodHandles) { |
16691 | 430 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
431 |
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
|
432 |
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
|
433 |
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
|
434 |
} |
36819 | 435 |
if ((klass() == SystemDictionary::MethodHandle_klass() || |
436 |
klass() == SystemDictionary::VarHandle_klass()) && |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
437 |
iid != vmIntrinsics::_none) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
438 |
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
|
439 |
// 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
|
440 |
// 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
|
441 |
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
|
442 |
TempNewSymbol basic_signature = |
31019 | 443 |
MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
444 |
if (TraceMethodHandles) { |
16691 | 445 |
ResourceMark rm(THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
446 |
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
|
447 |
name->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
448 |
full_signature->as_C_string(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
449 |
basic_signature->as_C_string()); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
450 |
} |
31019 | 451 |
methodHandle result = SystemDictionary::find_method_handle_intrinsic(iid, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
452 |
basic_signature, |
31019 | 453 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
454 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
459 |
ttyLocker ttyl; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
460 |
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
|
461 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
462 |
} |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5547
diff
changeset
|
463 |
} |
31019 | 464 |
return result; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
465 |
} else if (iid == vmIntrinsics::_invokeGeneric |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32189
diff
changeset
|
466 |
&& THREAD->can_call_java() |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
467 |
&& appendix_result_or_null != NULL) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
468 |
// 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
|
469 |
// 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
|
470 |
if (!MethodHandles::enabled()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
471 |
// 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
|
472 |
Klass* natives = SystemDictionary::MethodHandleNatives_klass(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
473 |
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
|
474 |
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
|
475 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
476 |
Handle(), |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
477 |
true, |
31019 | 478 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
479 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
480 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
481 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
482 |
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
|
483 |
Handle method_type; |
31019 | 484 |
methodHandle result = SystemDictionary::find_method_handle_invoker( |
36819 | 485 |
klass, |
31019 | 486 |
name, |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
487 |
full_signature, |
31019 | 488 |
link_info.current_klass(), |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
489 |
&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
|
490 |
&method_type, |
31019 | 491 |
CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
492 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
493 |
ttyLocker ttyl; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
494 |
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
|
495 |
result->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
496 |
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
|
497 |
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
|
498 |
else appendix->print_on(tty); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
499 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
500 |
if (result.not_null()) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
501 |
#ifdef ASSERT |
16691 | 502 |
ResourceMark rm(THREAD); |
503 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
504 |
TempNewSymbol basic_signature = |
31019 | 505 |
MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
// +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
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
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
|
513 |
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
|
514 |
result->print(); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
515 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
516 |
assert(actual_size_of_params == expected_size_of_params, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32189
diff
changeset
|
517 |
"%d != %d", actual_size_of_params, expected_size_of_params); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
518 |
#endif //ASSERT |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
519 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
520 |
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
|
521 |
(*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
|
522 |
(*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
|
523 |
} |
31019 | 524 |
return result; |
2534 | 525 |
} |
526 |
} |
|
31019 | 527 |
return NULL; |
2534 | 528 |
} |
529 |
||
1 | 530 |
void LinkResolver::check_method_accessability(KlassHandle ref_klass, |
531 |
KlassHandle resolved_klass, |
|
532 |
KlassHandle sel_klass, |
|
31019 | 533 |
const methodHandle& sel_method, |
1 | 534 |
TRAPS) { |
535 |
||
536 |
AccessFlags flags = sel_method->access_flags(); |
|
537 |
||
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
538 |
// Special case: arrays always override "clone". JVMS 2.15. |
1 | 539 |
// If the resolved klass is an array class, and the declaring class |
540 |
// is java.lang.Object and the method is "clone", set the flags |
|
541 |
// to public. |
|
542 |
// |
|
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
543 |
// We'll check for the method name first, as that's most likely |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
544 |
// to be false (so we'll short-circuit out of these tests). |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
545 |
if (sel_method->name() == vmSymbols::clone_name() && |
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
546 |
sel_klass() == SystemDictionary::Object_klass() && |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
547 |
resolved_klass->is_array_klass()) { |
1 | 548 |
// We need to change "protected" to "public". |
22219
4bfd5df70189
8028741: Interface Method Resolution should skip static and non-public methods in j.l.Object
hseigel
parents:
22218
diff
changeset
|
549 |
assert(flags.is_protected(), "clone not protected?"); |
1 | 550 |
jint new_flags = flags.as_int(); |
551 |
new_flags = new_flags & (~JVM_ACC_PROTECTED); |
|
552 |
new_flags = new_flags | JVM_ACC_PUBLIC; |
|
553 |
flags.set_flags(new_flags); |
|
554 |
} |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
555 |
// assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); |
1 | 556 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
557 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
558 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
559 |
sel_klass(), |
1 | 560 |
flags, |
561 |
true)) { |
|
562 |
ResourceMark rm(THREAD); |
|
563 |
Exceptions::fthrow( |
|
564 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
565 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 566 |
"tried to access method %s.%s%s from class %s", |
567 |
sel_klass->external_name(), |
|
568 |
sel_method->name()->as_C_string(), |
|
569 |
sel_method->signature()->as_C_string(), |
|
570 |
ref_klass->external_name() |
|
571 |
); |
|
572 |
return; |
|
573 |
} |
|
574 |
} |
|
575 |
||
31019 | 576 |
methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code, |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
577 |
const 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
|
578 |
// This method is used only |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
579 |
// (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
|
580 |
// and |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
581 |
// (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
|
582 |
// 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
|
583 |
// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. |
1 | 584 |
// resolve klass |
31019 | 585 |
KlassHandle resolved_klass; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
586 |
if (code == Bytecodes::_invokedynamic) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
587 |
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
|
588 |
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
|
589 |
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
|
590 |
KlassHandle current_klass(THREAD, pool->pool_holder()); |
31019 | 591 |
LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass); |
592 |
return resolve_method(link_info, /*require_methodref*/false, THREAD); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
593 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
594 |
|
31019 | 595 |
LinkInfo link_info(pool, index, CHECK_NULL); |
596 |
resolved_klass = link_info.resolved_klass(); |
|
1 | 597 |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
598 |
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
|
599 |
|| (resolved_klass() == SystemDictionary::MethodHandle_klass() && |
31019 | 600 |
MethodHandles::is_signature_polymorphic_name(resolved_klass(), link_info.name()))) { |
601 |
Method* result = ConstantPool::method_at_if_loaded(pool, index); |
|
602 |
if (result != NULL) { |
|
603 |
return methodHandle(THREAD, result); |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
604 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
605 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9967
diff
changeset
|
606 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
607 |
if (code == Bytecodes::_invokeinterface) { |
31019 | 608 |
return resolve_interface_method(link_info, true, THREAD); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
609 |
} else if (code == Bytecodes::_invokevirtual) { |
31019 | 610 |
return resolve_method(link_info, /*require_methodref*/true, THREAD); |
21912 | 611 |
} else if (!resolved_klass->is_interface()) { |
31019 | 612 |
return resolve_method(link_info, /*require_methodref*/false, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
613 |
} else { |
21912 | 614 |
bool nostatics = (code == Bytecodes::_invokestatic) ? false : true; |
31019 | 615 |
return resolve_interface_method(link_info, nostatics, THREAD); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
616 |
} |
1 | 617 |
} |
618 |
||
31019 | 619 |
// Check and print a loader constraint violation message for method or interface method |
620 |
void LinkResolver::check_method_loader_constraints(const LinkInfo& link_info, |
|
621 |
const methodHandle& resolved_method, |
|
622 |
const char* method_type, TRAPS) { |
|
623 |
Handle current_loader(THREAD, link_info.current_klass()->class_loader()); |
|
624 |
Handle resolved_loader(THREAD, resolved_method->method_holder()->class_loader()); |
|
625 |
||
626 |
ResourceMark rm(THREAD); |
|
627 |
Symbol* failed_type_symbol = |
|
628 |
SystemDictionary::check_signature_loaders(link_info.signature(), current_loader, |
|
629 |
resolved_loader, true, CHECK); |
|
630 |
if (failed_type_symbol != NULL) { |
|
631 |
const char* msg = "loader constraint violation: when resolving %s" |
|
632 |
" \"%s\" the class loader (instance of %s) of the current class, %s," |
|
633 |
" and the class loader (instance of %s) for the method's defining class, %s, have" |
|
634 |
" different Class objects for the type %s used in the signature"; |
|
635 |
char* sig = link_info.method_string(); |
|
636 |
const char* loader1_name = SystemDictionary::loader_name(current_loader()); |
|
637 |
char* current = link_info.current_klass()->name()->as_C_string(); |
|
638 |
const char* loader2_name = SystemDictionary::loader_name(resolved_loader()); |
|
639 |
char* target = resolved_method->method_holder()->name()->as_C_string(); |
|
640 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
|
641 |
size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1_name) + |
|
642 |
strlen(current) + strlen(loader2_name) + strlen(target) + |
|
643 |
strlen(failed_type_name) + strlen(method_type) + 1; |
|
644 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
|
645 |
jio_snprintf(buf, buflen, msg, method_type, sig, loader1_name, current, loader2_name, |
|
646 |
target, failed_type_name); |
|
647 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
|
648 |
} |
|
649 |
} |
|
650 |
||
651 |
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig, |
|
652 |
KlassHandle current_klass, |
|
653 |
KlassHandle sel_klass, TRAPS) { |
|
654 |
Handle ref_loader(THREAD, current_klass->class_loader()); |
|
655 |
Handle sel_loader(THREAD, sel_klass->class_loader()); |
|
656 |
||
657 |
ResourceMark rm(THREAD); // needed for check_signature_loaders |
|
658 |
Symbol* failed_type_symbol = |
|
659 |
SystemDictionary::check_signature_loaders(sig, |
|
660 |
ref_loader, sel_loader, |
|
661 |
false, |
|
662 |
CHECK); |
|
663 |
if (failed_type_symbol != NULL) { |
|
664 |
const char* msg = "loader constraint violation: when resolving field" |
|
665 |
" \"%s\" the class loader (instance of %s) of the referring class, " |
|
666 |
"%s, and the class loader (instance of %s) for the field's resolved " |
|
667 |
"type, %s, have different Class objects for that type"; |
|
668 |
char* field_name = field->as_C_string(); |
|
669 |
const char* loader1_name = SystemDictionary::loader_name(ref_loader()); |
|
670 |
char* sel = sel_klass->name()->as_C_string(); |
|
671 |
const char* loader2_name = SystemDictionary::loader_name(sel_loader()); |
|
672 |
char* failed_type_name = failed_type_symbol->as_C_string(); |
|
673 |
size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1_name) + |
|
674 |
strlen(sel) + strlen(loader2_name) + strlen(failed_type_name) + 1; |
|
675 |
char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); |
|
676 |
jio_snprintf(buf, buflen, msg, field_name, loader1_name, sel, loader2_name, |
|
677 |
failed_type_name); |
|
678 |
THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); |
|
679 |
} |
|
680 |
} |
|
681 |
||
682 |
methodHandle LinkResolver::resolve_method(const LinkInfo& link_info, |
|
683 |
bool require_methodref, TRAPS) { |
|
1 | 684 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
685 |
Handle nested_exception; |
31019 | 686 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
687 |
|
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
688 |
// 1. check if methodref required, that resolved_klass is not interfacemethodref |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
689 |
if (require_methodref && resolved_klass->is_interface()) { |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
690 |
ResourceMark rm(THREAD); |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
691 |
char buf[200]; |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
692 |
jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
693 |
resolved_klass()->external_name()); |
31019 | 694 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
695 |
} |
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
696 |
|
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
697 |
// 2. lookup method in resolved klass and its super klasses |
31019 | 698 |
methodHandle resolved_method = lookup_method_in_klasses(link_info, true, false, CHECK_NULL); |
1 | 699 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
700 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy |
20685
2feadfa49bb7
8026299: invokespecial gets ICCE when it should get AME.
acorn
parents:
20391
diff
changeset
|
701 |
// 3. lookup method in all the interfaces implemented by the resolved klass |
31019 | 702 |
resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); |
1 | 703 |
|
704 |
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
|
705 |
// JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
31019 | 706 |
resolved_method = lookup_polymorphic_method(link_info, (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
|
707 |
if (HAS_PENDING_EXCEPTION) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
708 |
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
|
709 |
CLEAR_PENDING_EXCEPTION; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
710 |
} |
2534 | 711 |
} |
27020 | 712 |
} |
2534 | 713 |
|
27020 | 714 |
if (resolved_method.is_null()) { |
715 |
// 4. method lookup failed |
|
716 |
ResourceMark rm(THREAD); |
|
31019 | 717 |
THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(), |
27020 | 718 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 719 |
link_info.name(), |
720 |
link_info.signature()), |
|
721 |
nested_exception, NULL); |
|
1 | 722 |
} |
723 |
||
22739
74105c330330
8032010: Attempt to resolve abstract method in concrete class fails with AbstractMethodError
ccheung
parents:
22521
diff
changeset
|
724 |
// 5. access checks, access checking may be turned off when calling from within the VM. |
31019 | 725 |
KlassHandle current_klass = link_info.current_klass(); |
726 |
if (link_info.check_access()) { |
|
1 | 727 |
assert(current_klass.not_null() , "current_klass should not be null"); |
728 |
||
729 |
// check if method can be accessed by the referring class |
|
730 |
check_method_accessability(current_klass, |
|
731 |
resolved_klass, |
|
732 |
KlassHandle(THREAD, resolved_method->method_holder()), |
|
733 |
resolved_method, |
|
31019 | 734 |
CHECK_NULL); |
1 | 735 |
|
736 |
// check loader constraints |
|
31019 | 737 |
check_method_loader_constraints(link_info, resolved_method, "method", CHECK_NULL); |
1 | 738 |
} |
31019 | 739 |
|
740 |
return resolved_method; |
|
1 | 741 |
} |
742 |
||
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
743 |
static void trace_method_resolution(const char* prefix, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
744 |
KlassHandle klass, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
745 |
KlassHandle resolved_klass, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
746 |
const methodHandle& method, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
747 |
bool logitables, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
748 |
int index = -1) { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
749 |
#ifndef PRODUCT |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
750 |
ResourceMark rm; |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
751 |
outputStream* st; |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
752 |
if (logitables) { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
753 |
st = LogHandle(itables)::trace_stream(); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
754 |
} else { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
755 |
st = LogHandle(vtables)::trace_stream(); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
756 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
757 |
st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ", |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
758 |
prefix, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
759 |
(klass.is_null() ? "<NULL>" : klass->internal_name()), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
760 |
(resolved_klass.is_null() ? "<NULL>" : resolved_klass->internal_name()), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
761 |
Method::name_and_sig_as_C_string(resolved_klass(), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
762 |
method->name(), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
763 |
method->signature()), |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
764 |
method->method_holder()->internal_name()); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
765 |
method->print_linkage_flags(st); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
766 |
if (index != -1) { |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
767 |
st->print("vtable_index:%d", index); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
768 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
769 |
st->cr(); |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
770 |
#endif // PRODUCT |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
771 |
} |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
772 |
|
31019 | 773 |
methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, |
774 |
bool nostatics, TRAPS) { |
|
775 |
||
776 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
|
1 | 777 |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
778 |
// check if klass is interface |
1 | 779 |
if (!resolved_klass->is_interface()) { |
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
780 |
ResourceMark rm(THREAD); |
1 | 781 |
char buf[200]; |
14488 | 782 |
jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass()->external_name()); |
31019 | 783 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 784 |
} |
785 |
||
786 |
// lookup method in this interface or its super, java.lang.Object |
|
21912 | 787 |
// JDK8: also look for static methods |
31019 | 788 |
methodHandle resolved_method = lookup_method_in_klasses(link_info, false, true, CHECK_NULL); |
1 | 789 |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
790 |
if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { |
1 | 791 |
// lookup method in all the super-interfaces |
31019 | 792 |
resolved_method = lookup_method_in_interfaces(link_info, CHECK_NULL); |
27020 | 793 |
} |
794 |
||
795 |
if (resolved_method.is_null()) { |
|
796 |
// no method found |
|
797 |
ResourceMark rm(THREAD); |
|
31019 | 798 |
THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), |
799 |
Method::name_and_sig_as_C_string(resolved_klass(), |
|
800 |
link_info.name(), |
|
801 |
link_info.signature())); |
|
1 | 802 |
} |
803 |
||
31019 | 804 |
if (link_info.check_access()) { |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
805 |
// JDK8 adds non-public interface methods, and accessability check requirement |
31019 | 806 |
KlassHandle current_klass = link_info.current_klass(); |
807 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
808 |
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
|
809 |
|
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
810 |
// 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
|
811 |
check_method_accessability(current_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
812 |
resolved_klass, |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
813 |
KlassHandle(THREAD, resolved_method->method_holder()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
814 |
resolved_method, |
31019 | 815 |
CHECK_NULL); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
816 |
|
31019 | 817 |
check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); |
1 | 818 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
819 |
|
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
820 |
if (nostatics && resolved_method->is_static()) { |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
821 |
ResourceMark rm(THREAD); |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
822 |
char buf[200]; |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
823 |
jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
824 |
Method::name_and_sig_as_C_string(resolved_klass(), |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
825 |
resolved_method->name(), resolved_method->signature())); |
31019 | 826 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
22521
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
827 |
} |
5387725ea99d
8031045: Access checks should precede additional per-instruction checks
hseigel
parents:
22232
diff
changeset
|
828 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
829 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 830 |
trace_method_resolution("invokeinterface resolved method: caller-class", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
831 |
link_info.current_klass(), resolved_klass, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
832 |
resolved_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
833 |
} |
31019 | 834 |
|
835 |
return resolved_method; |
|
1 | 836 |
} |
837 |
||
838 |
//------------------------------------------------------------------------------------------------------------------------ |
|
839 |
// Field resolution |
|
840 |
||
841 |
void LinkResolver::check_field_accessability(KlassHandle ref_klass, |
|
842 |
KlassHandle resolved_klass, |
|
843 |
KlassHandle sel_klass, |
|
31019 | 844 |
const fieldDescriptor& fd, |
1 | 845 |
TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
846 |
if (!Reflection::verify_field_access(ref_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
847 |
resolved_klass(), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
848 |
sel_klass(), |
1 | 849 |
fd.access_flags(), |
850 |
true)) { |
|
851 |
ResourceMark rm(THREAD); |
|
852 |
Exceptions::fthrow( |
|
853 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
854 |
vmSymbols::java_lang_IllegalAccessError(), |
1 | 855 |
"tried to access field %s.%s from class %s", |
856 |
sel_klass->external_name(), |
|
857 |
fd.name()->as_C_string(), |
|
858 |
ref_klass->external_name() |
|
859 |
); |
|
860 |
return; |
|
861 |
} |
|
862 |
} |
|
863 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
864 |
void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { |
31019 | 865 |
LinkInfo link_info(pool, index, CHECK); |
866 |
resolve_field(fd, link_info, byte, true, CHECK); |
|
1 | 867 |
} |
868 |
||
31019 | 869 |
void LinkResolver::resolve_field(fieldDescriptor& fd, |
870 |
const LinkInfo& link_info, |
|
871 |
Bytecodes::Code byte, bool initialize_class, |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
872 |
TRAPS) { |
1 | 873 |
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
|
874 |
byte == Bytecodes::_getfield || byte == Bytecodes::_putfield || |
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
875 |
byte == Bytecodes::_nofast_getfield || byte == Bytecodes::_nofast_putfield || |
31019 | 876 |
(byte == Bytecodes::_nop && !link_info.check_access()), "bad field access bytecode"); |
1 | 877 |
|
878 |
bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic); |
|
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
29081
diff
changeset
|
879 |
bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic || byte == Bytecodes::_nofast_putfield); |
1 | 880 |
// Check if there's a resolved klass containing the field |
31019 | 881 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
882 |
Symbol* field = link_info.name(); |
|
883 |
Symbol* sig = link_info.signature(); |
|
884 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
885 |
if (resolved_klass.is_null()) { |
1 | 886 |
ResourceMark rm(THREAD); |
887 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
888 |
} |
|
889 |
||
890 |
// Resolve instance field |
|
27020 | 891 |
KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); |
1 | 892 |
// 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
|
893 |
if (sel_klass.is_null()) { |
1 | 894 |
ResourceMark rm(THREAD); |
895 |
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string()); |
|
896 |
} |
|
897 |
||
31019 | 898 |
if (!link_info.check_access()) |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
899 |
// 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
|
900 |
return; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
901 |
|
1 | 902 |
// check access |
31019 | 903 |
KlassHandle current_klass = link_info.current_klass(); |
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
904 |
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK); |
1 | 905 |
|
906 |
// check for errors |
|
907 |
if (is_static != fd.is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
908 |
ResourceMark rm(THREAD); |
1 | 909 |
char msg[200]; |
14488 | 910 |
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 | 911 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg); |
912 |
} |
|
913 |
||
914 |
// 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
|
915 |
if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) { |
1 | 916 |
THROW(vmSymbols::java_lang_IllegalAccessError()); |
917 |
} |
|
918 |
||
919 |
// initialize resolved_klass if necessary |
|
920 |
// note 1: the klass which declared the field must be initialized (i.e, sel_klass) |
|
921 |
// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99) |
|
922 |
// |
|
923 |
// note 2: we don't want to force initialization if we are just checking |
|
924 |
// 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
|
925 |
if (is_static && initialize_class) { |
1 | 926 |
sel_klass->initialize(CHECK); |
927 |
} |
|
928 |
||
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
929 |
if (sel_klass() != current_klass()) { |
31019 | 930 |
check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK); |
1 | 931 |
} |
932 |
||
933 |
// return information. note that the klass is set to the actual klass containing the |
|
934 |
// field, otherwise access of static fields in superclasses will not work. |
|
935 |
} |
|
936 |
||
937 |
||
938 |
//------------------------------------------------------------------------------------------------------------------------ |
|
939 |
// Invoke resolution |
|
940 |
// |
|
941 |
// Naming conventions: |
|
942 |
// |
|
943 |
// resolved_method the specified method (i.e., static receiver specified via constant pool index) |
|
944 |
// sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class) |
|
945 |
// resolved_klass the specified klass (i.e., specified via constant pool index) |
|
946 |
// recv_klass the receiver klass |
|
947 |
||
948 |
||
31019 | 949 |
void LinkResolver::resolve_static_call(CallInfo& result, |
950 |
const LinkInfo& link_info, |
|
951 |
bool initialize_class, TRAPS) { |
|
952 |
methodHandle resolved_method = linktime_resolve_static_method(link_info, CHECK); |
|
1 | 953 |
|
31019 | 954 |
// The resolved class can change as a result of this resolution. |
955 |
KlassHandle resolved_klass = KlassHandle(THREAD, resolved_method->method_holder()); |
|
956 |
||
957 |
Method* save_resolved_method = resolved_method(); |
|
1 | 958 |
// Initialize klass (this should only happen if everything is ok) |
959 |
if (initialize_class && resolved_klass->should_be_initialized()) { |
|
960 |
resolved_klass->initialize(CHECK); |
|
31019 | 961 |
// Use updated LinkInfo (to reresolve with resolved_klass as method_holder?) |
962 |
LinkInfo new_info(resolved_klass, link_info.name(), link_info.signature(), |
|
34238 | 963 |
link_info.current_klass(), link_info.check_access()); |
31019 | 964 |
resolved_method = linktime_resolve_static_method(new_info, CHECK); |
1 | 965 |
} |
966 |
||
31019 | 967 |
assert(save_resolved_method == resolved_method(), "does this change?"); |
1 | 968 |
// setup result |
969 |
result.set_static(resolved_klass, resolved_method, CHECK); |
|
970 |
} |
|
971 |
||
972 |
// throws linktime exceptions |
|
31019 | 973 |
methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_info, TRAPS) { |
1 | 974 |
|
31019 | 975 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
976 |
methodHandle resolved_method; |
|
21912 | 977 |
if (!resolved_klass->is_interface()) { |
31019 | 978 |
resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); |
21912 | 979 |
} else { |
31019 | 980 |
resolved_method = resolve_interface_method(link_info, /*nostatics*/false, CHECK_NULL); |
21912 | 981 |
} |
1 | 982 |
assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); |
983 |
||
984 |
// check if static |
|
985 |
if (!resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
986 |
ResourceMark rm(THREAD); |
1 | 987 |
char buf[200]; |
14488 | 988 |
jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 989 |
resolved_method->name(), |
990 |
resolved_method->signature())); |
|
31019 | 991 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 992 |
} |
31019 | 993 |
return resolved_method; |
1 | 994 |
} |
995 |
||
996 |
||
31019 | 997 |
void LinkResolver::resolve_special_call(CallInfo& result, |
998 |
const LinkInfo& link_info, |
|
999 |
TRAPS) { |
|
1000 |
methodHandle resolved_method = linktime_resolve_special_method(link_info, CHECK); |
|
1001 |
runtime_resolve_special_method(result, resolved_method, |
|
1002 |
link_info.resolved_klass(), |
|
1003 |
link_info.current_klass(), |
|
1004 |
link_info.check_access(), CHECK); |
|
1 | 1005 |
} |
1006 |
||
1007 |
// throws linktime exceptions |
|
31019 | 1008 |
methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, |
1009 |
TRAPS) { |
|
1 | 1010 |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1011 |
// Invokespecial is called for multiple special reasons: |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1012 |
// <init> |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1013 |
// 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
|
1014 |
// 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
|
1015 |
// 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
|
1016 |
// superinterface.method, which explicitly does not check shadowing |
31019 | 1017 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
1018 |
methodHandle resolved_method; |
|
14385 | 1019 |
|
21912 | 1020 |
if (!resolved_klass->is_interface()) { |
31019 | 1021 |
resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); |
21912 | 1022 |
} else { |
31019 | 1023 |
resolved_method = resolve_interface_method(link_info, /*nostatics*/true, CHECK_NULL); |
21912 | 1024 |
} |
1 | 1025 |
|
1026 |
// check if method name is <init>, that it is found in same klass as static type |
|
1027 |
if (resolved_method->name() == vmSymbols::object_initializer_name() && |
|
1028 |
resolved_method->method_holder() != resolved_klass()) { |
|
1029 |
ResourceMark rm(THREAD); |
|
1030 |
Exceptions::fthrow( |
|
1031 |
THREAD_AND_LOCATION, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1032 |
vmSymbols::java_lang_NoSuchMethodError(), |
1 | 1033 |
"%s: method %s%s not found", |
1034 |
resolved_klass->external_name(), |
|
1035 |
resolved_method->name()->as_C_string(), |
|
1036 |
resolved_method->signature()->as_C_string() |
|
1037 |
); |
|
31019 | 1038 |
return NULL; |
1 | 1039 |
} |
1040 |
||
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1041 |
// check if invokespecial's interface method reference is in an indirect superinterface |
31019 | 1042 |
KlassHandle current_klass = link_info.current_klass(); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1043 |
if (!current_klass.is_null() && resolved_klass->is_interface()) { |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1044 |
Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ? |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1045 |
current_klass() : |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1046 |
InstanceKlass::cast(current_klass())->host_klass(); |
25057 | 1047 |
// Disable verification for the dynamically-generated reflection bytecodes. |
1048 |
bool is_reflect = klass_to_check->is_subclass_of( |
|
22218
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1049 |
SystemDictionary::reflect_MagicAccessorImpl_klass()); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1050 |
|
22218
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1051 |
if (!is_reflect && |
71cff6a30ec1
8029415: java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java fails on all platforms with hs25-b61
hseigel
parents:
21913
diff
changeset
|
1052 |
!InstanceKlass::cast(klass_to_check)->is_same_or_direct_interface(resolved_klass())) { |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1053 |
ResourceMark rm(THREAD); |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1054 |
char buf[200]; |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1055 |
jio_snprintf(buf, sizeof(buf), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1056 |
"Interface method reference: %s, is in an indirect superinterface of %s", |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1057 |
Method::name_and_sig_as_C_string(resolved_klass(), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1058 |
resolved_method->name(), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1059 |
resolved_method->signature()), |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1060 |
current_klass->external_name()); |
31019 | 1061 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
21768
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1062 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1063 |
} |
b7dba4cde1c6
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
21556
diff
changeset
|
1064 |
|
1 | 1065 |
// check if not static |
1066 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1067 |
ResourceMark rm(THREAD); |
1 | 1068 |
char buf[200]; |
1069 |
jio_snprintf(buf, sizeof(buf), |
|
1070 |
"Expecting non-static method %s", |
|
14488 | 1071 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 1072 |
resolved_method->name(), |
1073 |
resolved_method->signature())); |
|
1074 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
1 | 1075 |
} |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1076 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1077 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 1078 |
trace_method_resolution("invokespecial resolved method: caller-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1079 |
current_klass, resolved_klass, resolved_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1080 |
} |
31019 | 1081 |
|
1082 |
return resolved_method; |
|
1 | 1083 |
} |
1084 |
||
1085 |
// throws runtime exceptions |
|
31019 | 1086 |
void LinkResolver::runtime_resolve_special_method(CallInfo& result, |
1087 |
const methodHandle& resolved_method, |
|
1088 |
KlassHandle resolved_klass, |
|
1089 |
KlassHandle current_klass, |
|
1090 |
bool check_access, TRAPS) { |
|
1 | 1091 |
|
1092 |
// 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
|
1093 |
// for a superclass method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1094 |
// 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
|
1095 |
// no checks for shadowing |
1 | 1096 |
methodHandle sel_method(THREAD, resolved_method()); |
1097 |
||
1098 |
// check if this is an old-style super call and do a new lookup if so |
|
1099 |
{ KlassHandle method_klass = KlassHandle(THREAD, |
|
1100 |
resolved_method->method_holder()); |
|
1101 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1102 |
if (check_access && |
1 | 1103 |
// a) check if ACC_SUPER flag is set for the current class |
15918 | 1104 |
(current_klass->is_super() || !AllowNonVirtualCalls) && |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1105 |
// 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
|
1106 |
// (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
|
1107 |
// 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
|
1108 |
// in super interfaces. |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1109 |
current_klass->is_subclass_of(resolved_klass()) && |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1110 |
current_klass() != resolved_klass() && |
1 | 1111 |
// c) check if the method is not <init> |
1112 |
resolved_method->name() != vmSymbols::object_initializer_name()) { |
|
1113 |
// Lookup super method |
|
1114 |
KlassHandle super_klass(THREAD, current_klass->super()); |
|
31019 | 1115 |
sel_method = lookup_instance_method_in_klasses(super_klass, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1116 |
resolved_method->name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
1117 |
resolved_method->signature(), CHECK); |
1 | 1118 |
// check if found |
1119 |
if (sel_method.is_null()) { |
|
1120 |
ResourceMark rm(THREAD); |
|
1121 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1122 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1123 |
resolved_method->name(), |
1124 |
resolved_method->signature())); |
|
1125 |
} |
|
1126 |
} |
|
1127 |
} |
|
1128 |
||
1129 |
// check if not static |
|
1130 |
if (sel_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1131 |
ResourceMark rm(THREAD); |
1 | 1132 |
char buf[200]; |
14488 | 1133 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1134 |
resolved_method->name(), |
1135 |
resolved_method->signature())); |
|
1136 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
|
1137 |
} |
|
1138 |
||
1139 |
// check if abstract |
|
1140 |
if (sel_method->is_abstract()) { |
|
1141 |
ResourceMark rm(THREAD); |
|
1142 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1143 |
Method::name_and_sig_as_C_string(resolved_klass(), |
31019 | 1144 |
sel_method->name(), |
1145 |
sel_method->signature())); |
|
1 | 1146 |
} |
1147 |
||
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1148 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 1149 |
trace_method_resolution("invokespecial selected method: resolved-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1150 |
resolved_klass, resolved_klass, sel_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1151 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1152 |
|
1 | 1153 |
// setup result |
1154 |
result.set_static(resolved_klass, sel_method, CHECK); |
|
1155 |
} |
|
1156 |
||
31019 | 1157 |
void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, |
1158 |
const LinkInfo& link_info, |
|
1159 |
bool check_null_and_abstract, TRAPS) { |
|
1160 |
methodHandle resolved_method = linktime_resolve_virtual_method(link_info, CHECK); |
|
1161 |
runtime_resolve_virtual_method(result, resolved_method, |
|
1162 |
link_info.resolved_klass(), |
|
1163 |
recv, receiver_klass, |
|
1164 |
check_null_and_abstract, CHECK); |
|
1 | 1165 |
} |
1166 |
||
1167 |
// throws linktime exceptions |
|
31019 | 1168 |
methodHandle LinkResolver::linktime_resolve_virtual_method(const LinkInfo& link_info, |
1169 |
TRAPS) { |
|
1 | 1170 |
// normal method resolution |
31019 | 1171 |
methodHandle resolved_method = resolve_method(link_info, /*require_methodref*/true, CHECK_NULL); |
1 | 1172 |
|
1173 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
|
1174 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
1175 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1176 |
// check if private interface method |
31019 | 1177 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
1178 |
KlassHandle current_klass = link_info.current_klass(); |
|
1179 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1180 |
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
|
1181 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1182 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1183 |
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
|
1184 |
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
|
1185 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1186 |
resolved_method->signature()), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1187 |
(current_klass.is_null() ? "<NULL>" : current_klass->internal_name())); |
31019 | 1188 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1189 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1190 |
|
1 | 1191 |
// check if not static |
1192 |
if (resolved_method->is_static()) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1193 |
ResourceMark rm(THREAD); |
1 | 1194 |
char buf[200]; |
14488 | 1195 |
jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1196 |
resolved_method->name(), |
1197 |
resolved_method->signature())); |
|
31019 | 1198 |
THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1 | 1199 |
} |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1200 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1201 |
if (log_develop_is_enabled(Trace, vtables)) { |
31019 | 1202 |
trace_method_resolution("invokevirtual resolved method: caller-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1203 |
current_klass, resolved_klass, resolved_method, false); |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1204 |
} |
31019 | 1205 |
|
1206 |
return resolved_method; |
|
1 | 1207 |
} |
1208 |
||
1209 |
// throws runtime exceptions |
|
1210 |
void LinkResolver::runtime_resolve_virtual_method(CallInfo& result, |
|
31019 | 1211 |
const methodHandle& resolved_method, |
1 | 1212 |
KlassHandle resolved_klass, |
1213 |
Handle recv, |
|
1214 |
KlassHandle recv_klass, |
|
1215 |
bool check_null_and_abstract, |
|
1216 |
TRAPS) { |
|
1217 |
||
1218 |
// setup default return values |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1219 |
int vtable_index = Method::invalid_vtable_index; |
1 | 1220 |
methodHandle selected_method; |
1221 |
||
1222 |
assert(recv.is_null() || recv->is_oop(), "receiver is not an oop"); |
|
1223 |
||
1224 |
// runtime method resolution |
|
1225 |
if (check_null_and_abstract && recv.is_null()) { // check if receiver exists |
|
1226 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1227 |
} |
|
1228 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1229 |
// Virtual methods cannot be resolved before its klass has been linked, for otherwise the Method*'s |
1 | 1230 |
// has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since |
1231 |
// 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
|
1232 |
assert(resolved_method->method_holder()->is_linked(), "must be linked"); |
1 | 1233 |
|
1234 |
// do lookup based on receiver klass using the vtable index |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
1235 |
if (resolved_method->method_holder()->is_interface()) { // default or miranda method |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20284
diff
changeset
|
1236 |
vtable_index = vtable_index_of_interface_method(resolved_klass, |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1237 |
resolved_method); |
1 | 1238 |
assert(vtable_index >= 0 , "we should have valid vtable index at this point"); |
1239 |
||
35900 | 1240 |
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); |
1 | 1241 |
} else { |
1242 |
// at this point we are sure that resolved_method is virtual and not |
|
32189
5264b560ab1b
8087342: Crash in klassItable::initialize_itable_for_interface
acorn
parents:
31019
diff
changeset
|
1243 |
// a default or 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
|
1244 |
assert(!resolved_method->has_itable_index(), ""); |
1 | 1245 |
vtable_index = resolved_method->vtable_index(); |
1246 |
// We could get a negative vtable_index for final methods, |
|
1247 |
// because as an optimization they are they are never put in the vtable, |
|
1248 |
// unless they override an existing method. |
|
1249 |
// If we do get a negative, it means the resolved method is the the selected |
|
1250 |
// 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
|
1251 |
if (vtable_index == Method::nonvirtual_vtable_index) { |
1 | 1252 |
assert(resolved_method->can_be_statically_bound(), "cannot override this method"); |
1253 |
selected_method = resolved_method; |
|
1254 |
} else { |
|
35900 | 1255 |
selected_method = methodHandle(THREAD, recv_klass->method_at_vtable(vtable_index)); |
1 | 1256 |
} |
1257 |
} |
|
1258 |
||
1259 |
// check if method exists |
|
1260 |
if (selected_method.is_null()) { |
|
1261 |
ResourceMark rm(THREAD); |
|
1262 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1263 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1264 |
resolved_method->name(), |
1265 |
resolved_method->signature())); |
|
1266 |
} |
|
1267 |
||
1268 |
// check if abstract |
|
1269 |
if (check_null_and_abstract && selected_method->is_abstract()) { |
|
1270 |
ResourceMark rm(THREAD); |
|
1271 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1272 |
Method::name_and_sig_as_C_string(resolved_klass(), |
1 | 1273 |
selected_method->name(), |
1274 |
selected_method->signature())); |
|
1275 |
} |
|
1276 |
||
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1277 |
if (log_develop_is_enabled(Trace, vtables)) { |
31019 | 1278 |
trace_method_resolution("invokevirtual selected method: receiver-class:", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1279 |
recv_klass, resolved_klass, selected_method, |
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1280 |
false, vtable_index); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1281 |
} |
1 | 1282 |
// setup result |
1283 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK); |
|
1284 |
} |
|
1285 |
||
31019 | 1286 |
void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, |
1287 |
const LinkInfo& link_info, |
|
1288 |
bool check_null_and_abstract, TRAPS) { |
|
1289 |
// throws linktime exceptions |
|
1290 |
methodHandle resolved_method = linktime_resolve_interface_method(link_info, CHECK); |
|
1291 |
runtime_resolve_interface_method(result, resolved_method,link_info.resolved_klass(), |
|
1292 |
recv, recv_klass, check_null_and_abstract, CHECK); |
|
1 | 1293 |
} |
1294 |
||
31019 | 1295 |
methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info, |
1296 |
TRAPS) { |
|
1 | 1297 |
// normal interface method resolution |
31019 | 1298 |
methodHandle resolved_method = resolve_interface_method(link_info, true, CHECK_NULL); |
1 | 1299 |
assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); |
1300 |
assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); |
|
31019 | 1301 |
|
1302 |
return resolved_method; |
|
1 | 1303 |
} |
1304 |
||
1305 |
// throws runtime exceptions |
|
31019 | 1306 |
void LinkResolver::runtime_resolve_interface_method(CallInfo& result, |
1307 |
const methodHandle& resolved_method, |
|
1308 |
KlassHandle resolved_klass, |
|
1309 |
Handle recv, |
|
1310 |
KlassHandle recv_klass, |
|
1311 |
bool check_null_and_abstract, TRAPS) { |
|
1 | 1312 |
// check if receiver exists |
1313 |
if (check_null_and_abstract && recv.is_null()) { |
|
1314 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
1315 |
} |
|
1316 |
||
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1317 |
// check if private interface method |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1318 |
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
|
1319 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1320 |
char buf[200]; |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1321 |
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
|
1322 |
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
|
1323 |
resolved_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1324 |
resolved_method->signature())); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1325 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1326 |
} |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1327 |
|
1 | 1328 |
// check if receiver klass implements the resolved interface |
1329 |
if (!recv_klass->is_subtype_of(resolved_klass())) { |
|
9425
6da66b869573
6728025: LinkResolver is missing some ResourceMarks
jcoomes
parents:
9116
diff
changeset
|
1330 |
ResourceMark rm(THREAD); |
1 | 1331 |
char buf[200]; |
1332 |
jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s", |
|
14488 | 1333 |
recv_klass()->external_name(), |
1334 |
resolved_klass()->external_name()); |
|
1 | 1335 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); |
1336 |
} |
|
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1337 |
|
1 | 1338 |
// do lookup based on receiver klass |
22232
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1339 |
// This search must match the linktime preparation search for itable initialization |
26acfad336c0
8027804: JCK resolveMethod test fails expecting AbstractMethodError
hseigel
parents:
22219
diff
changeset
|
1340 |
// to correctly enforce loader constraints for interface method inheritance |
31019 | 1341 |
methodHandle sel_method = lookup_instance_method_in_klasses(recv_klass, |
1342 |
resolved_method->name(), |
|
1343 |
resolved_method->signature(), CHECK); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1344 |
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
|
1345 |
// 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
|
1346 |
// 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
|
1347 |
// This needs further study. |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1348 |
sel_method = resolved_method; |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
17024
diff
changeset
|
1349 |
} |
1 | 1350 |
// check if method exists |
1351 |
if (sel_method.is_null()) { |
|
1352 |
ResourceMark rm(THREAD); |
|
1353 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
31019 | 1354 |
Method::name_and_sig_as_C_string(recv_klass(), |
1355 |
resolved_method->name(), |
|
1356 |
resolved_method->signature())); |
|
1 | 1357 |
} |
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1358 |
// check access |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1359 |
// 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
|
1360 |
if (!sel_method->is_public()) { |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1361 |
ResourceMark rm(THREAD); |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1362 |
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1363 |
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
|
1364 |
sel_method->name(), |
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1365 |
sel_method->signature())); |
17024
49cbeca23983
8006267: InterfaceMethod_ref should allow invokestatic and invokespecial
bharadwaj
parents:
16691
diff
changeset
|
1366 |
} |
1 | 1367 |
// check if abstract |
1368 |
if (check_null_and_abstract && sel_method->is_abstract()) { |
|
1369 |
ResourceMark rm(THREAD); |
|
1370 |
THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), |
|
14488 | 1371 |
Method::name_and_sig_as_C_string(recv_klass(), |
1 | 1372 |
sel_method->name(), |
1373 |
sel_method->signature())); |
|
1374 |
} |
|
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1375 |
|
35901
f5028c67e7cb
8147918: Rename develop_log_is_enabled() to log_develop_is_enabled()
pliden
parents:
35900
diff
changeset
|
1376 |
if (log_develop_is_enabled(Trace, itables)) { |
31019 | 1377 |
trace_method_resolution("invokeinterface selected method: receiver-class", |
35463
b32e362563bb
8141564: Convert TraceItables and PrintVtables to Unified Logging
rprotacio
parents:
34666
diff
changeset
|
1378 |
recv_klass, resolved_klass, sel_method, true); |
20284
595a25ab9474
8011311: Private interface methods. Default conflicts:ICCE. no erased_super_default.
acorn
parents:
20282
diff
changeset
|
1379 |
} |
21556
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1380 |
// setup result |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1381 |
if (!resolved_method->has_itable_index()) { |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1382 |
int vtable_index = resolved_method->vtable_index(); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1383 |
assert(vtable_index == sel_method->vtable_index(), "sanity check"); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1384 |
result.set_virtual(resolved_klass, recv_klass, resolved_method, sel_method, vtable_index, CHECK); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1385 |
} else { |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1386 |
int itable_index = resolved_method()->itable_index(); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1387 |
result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, itable_index, CHECK); |
e75cd34a59e0
8027229: ICCE expected for >=2 maximally specific default methods.
acorn
parents:
21078
diff
changeset
|
1388 |
} |
1 | 1389 |
} |
1390 |
||
1391 |
||
1392 |
methodHandle LinkResolver::linktime_resolve_interface_method_or_null( |
|
31019 | 1393 |
const LinkInfo& link_info) { |
1 | 1394 |
EXCEPTION_MARK; |
31019 | 1395 |
methodHandle method_result = linktime_resolve_interface_method(link_info, THREAD); |
1 | 1396 |
if (HAS_PENDING_EXCEPTION) { |
1397 |
CLEAR_PENDING_EXCEPTION; |
|
1398 |
return methodHandle(); |
|
1399 |
} else { |
|
1400 |
return method_result; |
|
1401 |
} |
|
1402 |
} |
|
1403 |
||
1404 |
methodHandle LinkResolver::linktime_resolve_virtual_method_or_null( |
|
31019 | 1405 |
const LinkInfo& link_info) { |
1 | 1406 |
EXCEPTION_MARK; |
31019 | 1407 |
methodHandle method_result = linktime_resolve_virtual_method(link_info, THREAD); |
1 | 1408 |
if (HAS_PENDING_EXCEPTION) { |
1409 |
CLEAR_PENDING_EXCEPTION; |
|
1410 |
return methodHandle(); |
|
1411 |
} else { |
|
1412 |
return method_result; |
|
1413 |
} |
|
1414 |
} |
|
1415 |
||
1416 |
methodHandle LinkResolver::resolve_virtual_call_or_null( |
|
1417 |
KlassHandle receiver_klass, |
|
31019 | 1418 |
const LinkInfo& link_info) { |
1 | 1419 |
EXCEPTION_MARK; |
1420 |
CallInfo info; |
|
31019 | 1421 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1422 |
if (HAS_PENDING_EXCEPTION) { |
1423 |
CLEAR_PENDING_EXCEPTION; |
|
1424 |
return methodHandle(); |
|
1425 |
} |
|
1426 |
return info.selected_method(); |
|
1427 |
} |
|
1428 |
||
1429 |
methodHandle LinkResolver::resolve_interface_call_or_null( |
|
1430 |
KlassHandle receiver_klass, |
|
31019 | 1431 |
const LinkInfo& link_info) { |
1 | 1432 |
EXCEPTION_MARK; |
1433 |
CallInfo info; |
|
31019 | 1434 |
resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD); |
1 | 1435 |
if (HAS_PENDING_EXCEPTION) { |
1436 |
CLEAR_PENDING_EXCEPTION; |
|
1437 |
return methodHandle(); |
|
1438 |
} |
|
1439 |
return info.selected_method(); |
|
1440 |
} |
|
1441 |
||
31019 | 1442 |
int LinkResolver::resolve_virtual_vtable_index(KlassHandle receiver_klass, |
1443 |
const LinkInfo& link_info) { |
|
1 | 1444 |
EXCEPTION_MARK; |
1445 |
CallInfo info; |
|
31019 | 1446 |
resolve_virtual_call(info, Handle(), receiver_klass, link_info, |
1447 |
/*check_null_or_abstract*/false, THREAD); |
|
1 | 1448 |
if (HAS_PENDING_EXCEPTION) { |
1449 |
CLEAR_PENDING_EXCEPTION; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1450 |
return Method::invalid_vtable_index; |
1 | 1451 |
} |
1452 |
return info.vtable_index(); |
|
1453 |
} |
|
1454 |
||
31019 | 1455 |
methodHandle LinkResolver::resolve_static_call_or_null(const LinkInfo& link_info) { |
1 | 1456 |
EXCEPTION_MARK; |
1457 |
CallInfo info; |
|
31019 | 1458 |
resolve_static_call(info, link_info, /*initialize_class*/false, THREAD); |
1 | 1459 |
if (HAS_PENDING_EXCEPTION) { |
1460 |
CLEAR_PENDING_EXCEPTION; |
|
1461 |
return methodHandle(); |
|
1462 |
} |
|
1463 |
return info.selected_method(); |
|
1464 |
} |
|
1465 |
||
31019 | 1466 |
methodHandle LinkResolver::resolve_special_call_or_null(const LinkInfo& link_info) { |
1 | 1467 |
EXCEPTION_MARK; |
1468 |
CallInfo info; |
|
31019 | 1469 |
resolve_special_call(info, link_info, THREAD); |
1 | 1470 |
if (HAS_PENDING_EXCEPTION) { |
1471 |
CLEAR_PENDING_EXCEPTION; |
|
1472 |
return methodHandle(); |
|
1473 |
} |
|
1474 |
return info.selected_method(); |
|
1475 |
} |
|
1476 |
||
1477 |
||
1478 |
||
1479 |
//------------------------------------------------------------------------------------------------------------------------ |
|
1480 |
// ConstantPool entries |
|
1481 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1482 |
void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { |
1 | 1483 |
switch (byte) { |
1484 |
case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; |
|
1485 |
case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break; |
|
1486 |
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
|
1487 |
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
|
1488 |
case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; |
1 | 1489 |
case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; |
1490 |
} |
|
1491 |
return; |
|
1492 |
} |
|
1493 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1494 |
void LinkResolver::resolve_invoke(CallInfo& result, Handle& recv, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1495 |
const methodHandle& attached_method, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1496 |
Bytecodes::Code byte, TRAPS) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1497 |
KlassHandle defc = attached_method->method_holder(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1498 |
Symbol* name = attached_method->name(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1499 |
Symbol* type = attached_method->signature(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1500 |
LinkInfo link_info(defc, name, type, KlassHandle(), /*check_access=*/false); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1501 |
switch(byte) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1502 |
case Bytecodes::_invokevirtual: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1503 |
resolve_virtual_call(result, recv, recv->klass(), link_info, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1504 |
/*check_null_and_abstract=*/true, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1505 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1506 |
case Bytecodes::_invokeinterface: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1507 |
resolve_interface_call(result, recv, recv->klass(), link_info, |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1508 |
/*check_null_and_abstract=*/true, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1509 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1510 |
case Bytecodes::_invokestatic: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1511 |
resolve_static_call(result, link_info, /*initialize_class=*/false, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1512 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1513 |
case Bytecodes::_invokespecial: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1514 |
resolve_special_call(result, link_info, CHECK); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1515 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1516 |
default: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1517 |
fatal("bad call: %s", Bytecodes::name(byte)); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1518 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1519 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
34238
diff
changeset
|
1520 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1521 |
void LinkResolver::resolve_invokestatic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1522 |
LinkInfo link_info(pool, index, CHECK); |
1523 |
resolve_static_call(result, link_info, /*initialize_class*/true, CHECK); |
|
1 | 1524 |
} |
1525 |
||
1526 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1527 |
void LinkResolver::resolve_invokespecial(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1528 |
LinkInfo link_info(pool, index, CHECK); |
1529 |
resolve_special_call(result, link_info, CHECK); |
|
1 | 1530 |
} |
1531 |
||
1532 |
||
1533 |
void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv, |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1534 |
const constantPoolHandle& pool, int index, |
1 | 1535 |
TRAPS) { |
1536 |
||
31019 | 1537 |
LinkInfo link_info(pool, index, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1538 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
31019 | 1539 |
resolve_virtual_call(result, recv, recvrKlass, link_info, /*check_null_or_abstract*/true, CHECK); |
1 | 1540 |
} |
1541 |
||
1542 |
||
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1543 |
void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) { |
31019 | 1544 |
LinkInfo link_info(pool, index, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1545 |
KlassHandle recvrKlass (THREAD, recv.is_null() ? (Klass*)NULL : recv->klass()); |
31019 | 1546 |
resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK); |
1 | 1547 |
} |
1548 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1549 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1550 |
void LinkResolver::resolve_invokehandle(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1551 |
// This guy is reached from InterpreterRuntime::resolve_invokehandle. |
31019 | 1552 |
LinkInfo link_info(pool, index, CHECK); |
16691 | 1553 |
if (TraceMethodHandles) { |
1554 |
ResourceMark rm(THREAD); |
|
31019 | 1555 |
tty->print_cr("resolve_invokehandle %s %s", link_info.name()->as_C_string(), |
1556 |
link_info.signature()->as_C_string()); |
|
16691 | 1557 |
} |
31019 | 1558 |
resolve_handle_call(result, link_info, CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1559 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1560 |
|
31019 | 1561 |
void LinkResolver::resolve_handle_call(CallInfo& result, |
1562 |
const LinkInfo& link_info, |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1563 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1564 |
// JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar |
36819 | 1565 |
KlassHandle resolved_klass = link_info.resolved_klass(); |
1566 |
assert(resolved_klass() == SystemDictionary::MethodHandle_klass() || |
|
1567 |
resolved_klass() == SystemDictionary::VarHandle_klass(), ""); |
|
31019 | 1568 |
assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); |
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
|
1569 |
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
|
1570 |
Handle resolved_method_type; |
31019 | 1571 |
methodHandle resolved_method = lookup_polymorphic_method(link_info, |
1572 |
&resolved_appendix, &resolved_method_type, CHECK); |
|
36819 | 1573 |
result.set_handle(resolved_klass, 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
|
1574 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1575 |
|
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1576 |
static void wrap_invokedynamic_exception(TRAPS) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1577 |
if (HAS_PENDING_EXCEPTION) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1578 |
if (TraceMethodHandles) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1579 |
tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1580 |
PENDING_EXCEPTION->print(); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1581 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1582 |
if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1583 |
// throw these guys, since they are already wrapped |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1584 |
return; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1585 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1586 |
if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1587 |
// intercept only LinkageErrors which might have failed to wrap |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1588 |
return; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1589 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1590 |
// See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1591 |
Handle nested_exception(THREAD, PENDING_EXCEPTION); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1592 |
CLEAR_PENDING_EXCEPTION; |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1593 |
THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1594 |
} |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1595 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1596 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33198
diff
changeset
|
1597 |
void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1598 |
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
|
1599 |
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
|
1600 |
KlassHandle current_klass = KlassHandle(THREAD, pool->pool_holder()); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1601 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1602 |
// 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
|
1603 |
Handle bootstrap_specifier; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1604 |
// Check if CallSite has been bound already: |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1605 |
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
|
1606 |
if (cpce->is_f1_null()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1607 |
int pool_index = cpce->constant_pool_index(); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1608 |
oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1609 |
wrap_invokedynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1610 |
assert(bsm_info != NULL, ""); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1611 |
// 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
|
1612 |
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
|
1613 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1614 |
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
|
1615 |
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
|
1616 |
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
|
1617 |
Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1618 |
result.set_handle(method, appendix, method_type, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1619 |
wrap_invokedynamic_exception(CHECK); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1620 |
return; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1621 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1622 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1623 |
if (TraceMethodHandles) { |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1624 |
ResourceMark rm(THREAD); |
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1625 |
tty->print_cr("resolve_invokedynamic #%d %s %s in %s", |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13396
diff
changeset
|
1626 |
ConstantPool::decode_invokedynamic_index(index), |
35543
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1627 |
method_name->as_C_string(), method_signature->as_C_string(), |
0961315f4016
8140659: C1: invokedynamic call patching violates JVMS-6.5.invokedynamic
vlivanov
parents:
35135
diff
changeset
|
1628 |
current_klass->name()->as_C_string()); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1629 |
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
|
1630 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1631 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1632 |
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
|
1633 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1634 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1635 |
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
|
1636 |
Handle bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1637 |
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
|
1638 |
KlassHandle current_klass, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1639 |
TRAPS) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1640 |
// 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
|
1641 |
// 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
|
1642 |
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
|
1643 |
Handle resolved_method_type; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1644 |
methodHandle resolved_method = |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1645 |
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
|
1646 |
bootstrap_specifier, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1647 |
method_name, method_signature, |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10565
diff
changeset
|
1648 |
&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
|
1649 |
&resolved_method_type, |
13732
a9865f5514fc
7196120: NPG: JSR 2292 test fails because missing fix for 7188911
twisti
parents:
13728
diff
changeset
|
1650 |
THREAD); |
30746
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1651 |
wrap_invokedynamic_exception(CHECK); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1652 |
result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); |
dfce1db72058
8051045: HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError
aeriksso
parents:
30227
diff
changeset
|
1653 |
wrap_invokedynamic_exception(CHECK); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1654 |
} |