Mercurial > hg > truffle
annotate src/share/vm/prims/methodHandles.cpp @ 12685:478c82dde838
commented choice of data structure in NodeClass.addGraphDuplicate()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 05 Nov 2013 19:44:09 +0100 |
parents | cefad50507d8 |
children | 096c224171c4 |
rev | line source |
---|---|
710 | 1 /* |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
710 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
21 * questions. |
710 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" | |
3461
81d815b05abb
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3451
diff
changeset
|
27 #include "compiler/compileBroker.hpp" |
1972 | 28 #include "interpreter/interpreter.hpp" |
3388
a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
never
parents:
3371
diff
changeset
|
29 #include "interpreter/oopMapCache.hpp" |
1972 | 30 #include "memory/allocation.inline.hpp" |
31 #include "memory/oopFactory.hpp" | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
32 #include "prims/jvmtiRedefineClassesTrace.hpp" |
1972 | 33 #include "prims/methodHandles.hpp" |
3461
81d815b05abb
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3451
diff
changeset
|
34 #include "runtime/compilationPolicy.hpp" |
1972 | 35 #include "runtime/javaCalls.hpp" |
36 #include "runtime/reflection.hpp" | |
37 #include "runtime/signature.hpp" | |
38 #include "runtime/stubRoutines.hpp" | |
39 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
40 |
710 | 41 /* |
42 * JSR 292 reference implementation: method handles | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
43 * The JDK 7 reference implementation represented method handle |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
44 * combinations as chains. Each link in the chain had a "vmentry" |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
45 * field which pointed at a bit of assembly code which performed |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
46 * one transformation before dispatching to the next link in the chain. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
47 * |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
48 * The current reference implementation pushes almost all code generation |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
49 * responsibility to (trusted) Java code. A method handle contains a |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
50 * pointer to its "LambdaForm", which embodies all details of the method |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
51 * handle's behavior. The LambdaForm is a normal Java object, managed |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
52 * by a runtime coded in Java. |
710 | 53 */ |
54 | |
55 bool MethodHandles::_enabled = false; // set true after successful native linkage | |
3442
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3417
diff
changeset
|
56 MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL; |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
57 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
58 //------------------------------------------------------------------------------ |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
59 // MethodHandles::generate_adapters |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
60 // |
2116
d810e9a3fc33
7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents:
2088
diff
changeset
|
61 void MethodHandles::generate_adapters() { |
2416
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2357
diff
changeset
|
62 if (!EnableInvokeDynamic || SystemDictionary::MethodHandle_klass() == NULL) return; |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
63 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
64 assert(_adapter_code == NULL, "generate only once"); |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
65 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
66 ResourceMark rm; |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
67 TraceTime timer("MethodHandles adapters generation", TraceStartupTime); |
3442
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
3417
diff
changeset
|
68 _adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size); |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
69 if (_adapter_code == NULL) |
10161
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
10137
diff
changeset
|
70 vm_exit_out_of_memory(adapter_code_size, OOM_MALLOC_ERROR, |
746b070f5022
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
10137
diff
changeset
|
71 "CodeCache: no room for MethodHandles adapters"); |
4059
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
72 { |
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
73 CodeBuffer code(_adapter_code); |
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
74 MethodHandlesAdapterGenerator g(&code); |
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
75 g.generate(); |
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
76 code.log_section_sizes("MethodHandlesAdapterBlob"); |
44ce519bc3d1
7104960: JSR 292: +VerifyMethodHandles in product JVM can overflow buffer
never
parents:
4043
diff
changeset
|
77 } |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
78 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
79 |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
80 //------------------------------------------------------------------------------ |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
81 // MethodHandlesAdapterGenerator::generate |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
82 // |
2116
d810e9a3fc33
7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents:
2088
diff
changeset
|
83 void MethodHandlesAdapterGenerator::generate() { |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
84 // Generate generic method handle adapters. |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
85 // Generate interpreter entries |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
86 for (Interpreter::MethodKind mk = Interpreter::method_handle_invoke_FIRST; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
87 mk <= Interpreter::method_handle_invoke_LAST; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
88 mk = Interpreter::MethodKind(1 + (int)mk)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
89 vmIntrinsics::ID iid = Interpreter::method_handle_intrinsic(mk); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
90 StubCodeMark mark(this, "MethodHandle::interpreter_entry", vmIntrinsics::name_at(iid)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
91 address entry = MethodHandles::generate_method_handle_interpreter_entry(_masm, iid); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
92 if (entry != NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
93 Interpreter::set_entry_for_kind(mk, entry); |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3274
diff
changeset
|
94 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
95 // If the entry is not set, it will throw AbstractMethodError. |
1299
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
96 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
97 } |
9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
twisti
parents:
1142
diff
changeset
|
98 |
710 | 99 void MethodHandles::set_enabled(bool z) { |
100 if (_enabled != z) { | |
2416
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2357
diff
changeset
|
101 guarantee(z && EnableInvokeDynamic, "can only enable once, and only if -XX:+EnableInvokeDynamic"); |
710 | 102 _enabled = z; |
103 } | |
104 } | |
105 | |
106 // MemberName support | |
107 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
108 // import java_lang_invoke_MemberName.* |
710 | 109 enum { |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
110 IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
111 IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
112 IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
113 IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
114 CALLER_SENSITIVE = java_lang_invoke_MemberName::MN_CALLER_SENSITIVE, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
115 REFERENCE_KIND_SHIFT = java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
116 REFERENCE_KIND_MASK = java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK, |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
117 SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
118 SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
119 ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE |
710 | 120 }; |
121 | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
122 Handle MethodHandles::new_MemberName(TRAPS) { |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
123 Handle empty; |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
124 instanceKlassHandle k(THREAD, SystemDictionary::MemberName_klass()); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
125 if (!k->is_initialized()) k->initialize(CHECK_(empty)); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
126 return Handle(THREAD, k->allocate_instance(THREAD)); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
127 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
128 |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
129 oop MethodHandles::init_MemberName(Handle mname, Handle target) { |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
130 // This method is used from java.lang.invoke.MemberName constructors. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
131 // It fills in the new MemberName from a java.lang.reflect.Member. |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
132 Thread* thread = Thread::current(); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
133 oop target_oop = target(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
134 Klass* target_klass = target_oop->klass(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
135 if (target_klass == SystemDictionary::reflect_Field_klass()) { |
710 | 136 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() |
137 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
138 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
139 if (!k.is_null() && k->oop_is_instance()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
140 fieldDescriptor fd(InstanceKlass::cast(k()), slot); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
141 oop mname2 = init_field_MemberName(mname, fd); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
142 if (mname2 != NULL) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
143 // Since we have the reified name and type handy, add them to the result. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
144 if (java_lang_invoke_MemberName::name(mname2) == NULL) |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
145 java_lang_invoke_MemberName::set_name(mname2, java_lang_reflect_Field::name(target_oop)); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
146 if (java_lang_invoke_MemberName::type(mname2) == NULL) |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
147 java_lang_invoke_MemberName::set_type(mname2, java_lang_reflect_Field::type(target_oop)); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
148 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
149 return mname2; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
150 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
151 } else if (target_klass == SystemDictionary::reflect_Method_klass()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
152 oop clazz = java_lang_reflect_Method::clazz(target_oop); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
153 int slot = java_lang_reflect_Method::slot(target_oop); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
154 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
155 if (!k.is_null() && k->oop_is_instance()) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
156 Method* m = InstanceKlass::cast(k())->method_with_idnum(slot); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
157 if (m == NULL || is_signature_polymorphic(m->intrinsic_id())) |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
158 return NULL; // do not resolve unless there is a concrete signature |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
159 CallInfo info(m, k()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
160 return init_method_MemberName(mname, info); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
161 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
162 } else if (target_klass == SystemDictionary::reflect_Constructor_klass()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
163 oop clazz = java_lang_reflect_Constructor::clazz(target_oop); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
164 int slot = java_lang_reflect_Constructor::slot(target_oop); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
165 KlassHandle k(thread, java_lang_Class::as_Klass(clazz)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
166 if (!k.is_null() && k->oop_is_instance()) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
167 Method* m = InstanceKlass::cast(k())->method_with_idnum(slot); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
168 if (m == NULL) return NULL; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
169 CallInfo info(m, k()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
170 return init_method_MemberName(mname, info); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
171 } |
710 | 172 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
173 return NULL; |
710 | 174 } |
175 | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
176 oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
177 assert(info.resolved_appendix().is_null(), "only normal methods here"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
178 KlassHandle receiver_limit = info.resolved_klass(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
179 methodHandle m = info.resolved_method(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
180 int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
181 int vmindex = Method::invalid_vtable_index; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
182 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
183 switch (info.call_kind()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
184 case CallInfo::itable_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
185 vmindex = info.itable_index(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
186 // More importantly, the itable index only works with the method holder. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
187 receiver_limit = m->method_holder(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
188 assert(receiver_limit->verify_itable_index(vmindex), ""); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
189 flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
190 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
191 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
192 case CallInfo::vtable_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
193 vmindex = info.vtable_index(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
194 flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
195 assert(receiver_limit->is_subtype_of(m->method_holder()), "virtual call must be type-safe"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
196 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
197 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
198 case CallInfo::direct_call: |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
199 vmindex = Method::nonvirtual_vtable_index; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
200 if (m->is_static()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
201 flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
202 } else if (m->is_initializer()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
203 flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
204 assert(receiver_limit == m->method_holder(), "constructor call must be exactly typed"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
205 } else { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
206 flags |= IS_METHOD | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
207 assert(receiver_limit->is_subtype_of(m->method_holder()), "special call must be type-safe"); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
208 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
209 break; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
210 |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
211 default: assert(false, "bad CallInfo"); return NULL; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
212 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
213 |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
214 // @CallerSensitive annotation detected |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
215 if (m->caller_sensitive()) { |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
216 flags |= CALLER_SENSITIVE; |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
217 } |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
218 |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
219 oop mname_oop = mname(); |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
220 java_lang_invoke_MemberName::set_flags( mname_oop, flags); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
221 java_lang_invoke_MemberName::set_vmtarget(mname_oop, m()); |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
222 java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index |
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
223 java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
224 // Note: name and type can be lazily computed by resolve_MemberName, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
225 // if Java code needs them as resolved String and MethodType objects. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
226 // The clazz must be eagerly stored, because it provides a GC |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
227 // root to help keep alive the Method*. |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
228 // If relevant, the vtable or itable value is stored as vmindex. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
229 // This is done eagerly, since it is readily available without |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
230 // constructing any new objects. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
231 // TO DO: maybe intern mname_oop |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
232 m->method_holder()->add_member_name(m->method_idnum(), mname); |
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
233 |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
234 return mname(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
235 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
236 |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
237 oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
238 int flags = (jushort)( fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
239 flags |= IS_FIELD | ((fd.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
240 if (is_setter) flags += ((JVM_REF_putField - JVM_REF_getField) << REFERENCE_KIND_SHIFT); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
241 Metadata* vmtarget = fd.field_holder(); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
242 int vmindex = fd.offset(); // determines the field uniquely when combined with static bit |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
243 oop mname_oop = mname(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
244 java_lang_invoke_MemberName::set_flags(mname_oop, flags); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
245 java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget); |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
246 java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
247 java_lang_invoke_MemberName::set_clazz(mname_oop, fd.field_holder()->java_mirror()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
248 oop type = field_signature_type_or_null(fd.signature()); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
249 oop name = field_name_or_null(fd.name()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
250 if (name != NULL) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
251 java_lang_invoke_MemberName::set_name(mname_oop, name); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
252 if (type != NULL) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
253 java_lang_invoke_MemberName::set_type(mname_oop, type); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
254 // Note: name and type can be lazily computed by resolve_MemberName, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
255 // if Java code needs them as resolved String and Class objects. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
256 // Note that the incoming type oop might be pre-resolved (non-null). |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
257 // The base clazz and field offset (vmindex) must be eagerly stored, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
258 // because they unambiguously identify the field. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
259 // Although the fieldDescriptor::_index would also identify the field, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
260 // we do not use it, because it is harder to decode. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
261 // TO DO: maybe intern mname_oop |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
262 return mname(); |
710 | 263 } |
264 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
265 // JVM 2.9 Special Methods: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
266 // A method is signature polymorphic if and only if all of the following conditions hold : |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
267 // * It is declared in the java.lang.invoke.MethodHandle class. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
268 // * It has a single formal parameter of type Object[]. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
269 // * It has a return type of Object. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
270 // * It has the ACC_VARARGS and ACC_NATIVE flags set. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
271 bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
272 if (klass == NULL) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
273 return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
274 // The following test will fail spuriously during bootstrap of MethodHandle itself: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
275 // if (klass != SystemDictionary::MethodHandle_klass()) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
276 // Test the name instead: |
6983 | 277 if (klass->name() != vmSymbols::java_lang_invoke_MethodHandle()) |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
278 return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
279 Symbol* poly_sig = vmSymbols::object_array_object_signature(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
280 Method* m = InstanceKlass::cast(klass)->find_method(name, poly_sig); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
281 if (m == NULL) return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
282 int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
283 int flags = m->access_flags().as_int(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
284 return (flags & required) == required; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
285 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
286 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
287 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
288 Symbol* MethodHandles::signature_polymorphic_intrinsic_name(vmIntrinsics::ID iid) { |
10684 | 289 assert(is_signature_polymorphic_intrinsic(iid), err_msg("%d %s", iid, vmIntrinsics::name_at(iid))); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
290 switch (iid) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
291 case vmIntrinsics::_invokeBasic: return vmSymbols::invokeBasic_name(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
292 case vmIntrinsics::_linkToVirtual: return vmSymbols::linkToVirtual_name(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
293 case vmIntrinsics::_linkToStatic: return vmSymbols::linkToStatic_name(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
294 case vmIntrinsics::_linkToSpecial: return vmSymbols::linkToSpecial_name(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
295 case vmIntrinsics::_linkToInterface: return vmSymbols::linkToInterface_name(); |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
296 } |
10684 | 297 fatal(err_msg("unknown intrinsic id: %d %s", iid, vmIntrinsics::name_at(iid))); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
298 return 0; |
710 | 299 } |
300 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
301 int MethodHandles::signature_polymorphic_intrinsic_ref_kind(vmIntrinsics::ID iid) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
302 switch (iid) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
303 case vmIntrinsics::_invokeBasic: return 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
304 case vmIntrinsics::_linkToVirtual: return JVM_REF_invokeVirtual; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
305 case vmIntrinsics::_linkToStatic: return JVM_REF_invokeStatic; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
306 case vmIntrinsics::_linkToSpecial: return JVM_REF_invokeSpecial; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
307 case vmIntrinsics::_linkToInterface: return JVM_REF_invokeInterface; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
308 } |
10684 | 309 fatal(err_msg("unknown intrinsic id: %d %s", iid, vmIntrinsics::name_at(iid))); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
310 return 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
311 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
312 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
313 vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Symbol* name) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
314 vmSymbols::SID name_id = vmSymbols::find_sid(name); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
315 switch (name_id) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
316 // The ID _invokeGeneric stands for all non-static signature-polymorphic methods, except built-ins. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
317 case vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name): return vmIntrinsics::_invokeGeneric; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
318 // The only built-in non-static signature-polymorphic method is MethodHandle.invokeBasic: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
319 case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeBasic_name): return vmIntrinsics::_invokeBasic; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
320 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
321 // There is one static signature-polymorphic method for each JVM invocation mode. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
322 case vmSymbols::VM_SYMBOL_ENUM_NAME(linkToVirtual_name): return vmIntrinsics::_linkToVirtual; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
323 case vmSymbols::VM_SYMBOL_ENUM_NAME(linkToStatic_name): return vmIntrinsics::_linkToStatic; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
324 case vmSymbols::VM_SYMBOL_ENUM_NAME(linkToSpecial_name): return vmIntrinsics::_linkToSpecial; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
325 case vmSymbols::VM_SYMBOL_ENUM_NAME(linkToInterface_name): return vmIntrinsics::_linkToInterface; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
326 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
327 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
328 // Cover the case of invokeExact and any future variants of invokeFoo. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
329 Klass* mh_klass = SystemDictionary::well_known_klass( |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
330 SystemDictionary::WK_KLASS_ENUM_NAME(MethodHandle_klass) ); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
331 if (mh_klass != NULL && is_method_handle_invoke_name(mh_klass, name)) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
332 return vmIntrinsics::_invokeGeneric; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
333 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
334 // Note: The pseudo-intrinsic _compiledLambdaForm is never linked against. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
335 // Instead it is used to mark lambda forms bound to invokehandle or invokedynamic. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
336 return vmIntrinsics::_none; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
337 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
338 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
339 vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Klass* klass, Symbol* name) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
340 if (klass != NULL && |
6983 | 341 klass->name() == vmSymbols::java_lang_invoke_MethodHandle()) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
342 vmIntrinsics::ID iid = signature_polymorphic_name_id(name); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
343 if (iid != vmIntrinsics::_none) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
344 return iid; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
345 if (is_method_handle_invoke_name(klass, name)) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
346 return vmIntrinsics::_invokeGeneric; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
347 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
348 return vmIntrinsics::_none; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
349 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
350 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
351 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
352 // convert the external string or reflective type to an internal signature |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
353 Symbol* MethodHandles::lookup_signature(oop type_str, bool intern_if_not_found, TRAPS) { |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
354 if (java_lang_invoke_MethodType::is_instance(type_str)) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
355 return java_lang_invoke_MethodType::as_signature(type_str, intern_if_not_found, CHECK_NULL); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
356 } else if (java_lang_Class::is_instance(type_str)) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
357 return java_lang_Class::as_signature(type_str, false, CHECK_NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
358 } else if (java_lang_String::is_instance(type_str)) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
359 if (intern_if_not_found) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
360 return java_lang_String::as_symbol(type_str, CHECK_NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
361 } else { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
362 return java_lang_String::as_symbol_or_null(type_str); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
363 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
364 } else { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
365 THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized type", NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
366 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
367 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
368 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
369 static const char OBJ_SIG[] = "Ljava/lang/Object;"; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
370 enum { OBJ_SIG_LEN = 18 }; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
371 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
372 bool MethodHandles::is_basic_type_signature(Symbol* sig) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
373 assert(vmSymbols::object_signature()->utf8_length() == (int)OBJ_SIG_LEN, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
374 assert(vmSymbols::object_signature()->equals(OBJ_SIG), ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
375 const int len = sig->utf8_length(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
376 for (int i = 0; i < len; i++) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
377 switch (sig->byte_at(i)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
378 case 'L': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
379 // only java/lang/Object is valid here |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
380 if (sig->index_of_at(i, OBJ_SIG, OBJ_SIG_LEN) != i) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
381 return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
382 i += OBJ_SIG_LEN-1; //-1 because of i++ in loop |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
383 continue; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
384 case '(': case ')': case 'V': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
385 case 'I': case 'J': case 'F': case 'D': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
386 continue; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
387 //case '[': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
388 //case 'Z': case 'B': case 'C': case 'S': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
389 default: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
390 return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
391 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
392 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
393 return true; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
394 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
395 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
396 Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_arg, TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
397 Symbol* bsig = NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
398 if (sig == NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
399 return sig; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
400 } else if (is_basic_type_signature(sig)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
401 sig->increment_refcount(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
402 return sig; // that was easy |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
403 } else if (sig->byte_at(0) != '(') { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
404 BasicType bt = char2type(sig->byte_at(0)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
405 if (is_subword_type(bt)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
406 bsig = vmSymbols::int_signature(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
407 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
408 assert(bt == T_OBJECT || bt == T_ARRAY, "is_basic_type_signature was false"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
409 bsig = vmSymbols::object_signature(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
410 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
411 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
412 ResourceMark rm; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
413 stringStream buffer(128); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
414 buffer.put('('); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
415 int arg_pos = 0, keep_arg_pos = -1; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
416 if (keep_last_arg) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
417 keep_arg_pos = ArgumentCount(sig).size() - 1; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
418 for (SignatureStream ss(sig); !ss.is_done(); ss.next()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
419 BasicType bt = ss.type(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
420 size_t this_arg_pos = buffer.size(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
421 if (ss.at_return_type()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
422 buffer.put(')'); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
423 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
424 if (arg_pos == keep_arg_pos) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
425 buffer.write((char*) ss.raw_bytes(), |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
426 (int) ss.raw_length()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
427 } else if (bt == T_OBJECT || bt == T_ARRAY) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
428 buffer.write(OBJ_SIG, OBJ_SIG_LEN); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
429 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
430 if (is_subword_type(bt)) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
431 bt = T_INT; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
432 buffer.put(type2char(bt)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
433 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
434 arg_pos++; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
435 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
436 const char* sigstr = buffer.base(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
437 int siglen = (int) buffer.size(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
438 bsig = SymbolTable::new_symbol(sigstr, siglen, THREAD); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
439 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
440 assert(is_basic_type_signature(bsig) || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
441 // detune assert in case the injected argument is not a basic type: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
442 keep_last_arg, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
443 return bsig; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
444 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
445 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
446 void MethodHandles::print_as_basic_type_signature_on(outputStream* st, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
447 Symbol* sig, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
448 bool keep_arrays, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
449 bool keep_basic_names) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
450 st = st ? st : tty; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
451 int len = sig->utf8_length(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
452 int array = 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
453 bool prev_type = false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
454 for (int i = 0; i < len; i++) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
455 char ch = sig->byte_at(i); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
456 switch (ch) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
457 case '(': case ')': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
458 prev_type = false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
459 st->put(ch); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
460 continue; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
461 case '[': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
462 if (!keep_basic_names && keep_arrays) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
463 st->put(ch); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
464 array++; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
465 continue; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
466 case 'L': |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
467 { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
468 if (prev_type) st->put(','); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
469 int start = i+1, slash = start; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
470 while (++i < len && (ch = sig->byte_at(i)) != ';') { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
471 if (ch == '/' || ch == '.' || ch == '$') slash = i+1; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
472 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
473 if (slash < i) start = slash; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
474 if (!keep_basic_names) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
475 st->put('L'); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
476 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
477 for (int j = start; j < i; j++) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
478 st->put(sig->byte_at(j)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
479 prev_type = true; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
480 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
481 break; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
482 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
483 default: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
484 { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
485 if (array && char2type(ch) != T_ILLEGAL && !keep_arrays) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
486 ch = '['; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
487 array = 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
488 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
489 if (prev_type) st->put(','); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
490 const char* n = NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
491 if (keep_basic_names) |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
492 n = type2name(char2type(ch)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
493 if (n == NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
494 // unknown letter, or we don't want to know its name |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
495 st->put(ch); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
496 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
497 st->print(n); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
498 prev_type = true; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
499 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
500 break; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
501 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
502 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
503 // Switch break goes here to take care of array suffix: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
504 if (prev_type) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
505 while (array > 0) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
506 st->print("[]"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
507 --array; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
508 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
509 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
510 array = 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
511 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
512 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
513 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
514 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
515 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
516 static oop object_java_mirror() { |
6983 | 517 return SystemDictionary::Object_klass()->java_mirror(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
518 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
519 |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
520 oop MethodHandles::field_name_or_null(Symbol* s) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
521 if (s == NULL) return NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
522 return StringTable::lookup(s); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
523 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
524 |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
525 oop MethodHandles::field_signature_type_or_null(Symbol* s) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
526 if (s == NULL) return NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
527 BasicType bt = FieldType::basic_type(s); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
528 if (is_java_primitive(bt)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
529 assert(s->utf8_length() == 1, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
530 return java_lang_Class::primitive_mirror(bt); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
531 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
532 // Here are some more short cuts for common types. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
533 // They are optional, since reference types can be resolved lazily. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
534 if (bt == T_OBJECT) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
535 if (s == vmSymbols::object_signature()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
536 return object_java_mirror(); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
537 } else if (s == vmSymbols::class_signature()) { |
6983 | 538 return SystemDictionary::Class_klass()->java_mirror(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
539 } else if (s == vmSymbols::string_signature()) { |
6983 | 540 return SystemDictionary::String_klass()->java_mirror(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
541 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
542 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
543 return NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
544 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
545 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
546 |
710 | 547 // An unresolved member name is a mere symbolic reference. |
548 // Resolving it plants a vmtarget/vmindex in it, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
549 // which refers directly to JVM internals. |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
550 Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
551 Handle empty; |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
552 assert(java_lang_invoke_MemberName::is_instance(mname()), ""); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
553 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
554 if (java_lang_invoke_MemberName::vmtarget(mname()) != NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
555 // Already resolved. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
556 DEBUG_ONLY(int vmindex = java_lang_invoke_MemberName::vmindex(mname())); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
557 assert(vmindex >= Method::nonvirtual_vtable_index, ""); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
558 return mname; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
559 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
560 |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
561 Handle defc_oop(THREAD, java_lang_invoke_MemberName::clazz(mname())); |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
562 Handle name_str(THREAD, java_lang_invoke_MemberName::name( mname())); |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
563 Handle type_str(THREAD, java_lang_invoke_MemberName::type( mname())); |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
564 int flags = java_lang_invoke_MemberName::flags(mname()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
565 int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
566 if (!ref_kind_is_valid(ref_kind)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
567 THROW_MSG_(vmSymbols::java_lang_InternalError(), "obsolete MemberName format", empty); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
568 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
569 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
570 DEBUG_ONLY(int old_vmindex); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
571 assert((old_vmindex = java_lang_invoke_MemberName::vmindex(mname())) == 0, "clean input"); |
710 | 572 |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
573 if (defc_oop.is_null() || name_str.is_null() || type_str.is_null()) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
574 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "nothing to resolve", empty); |
710 | 575 } |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
576 |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
577 instanceKlassHandle defc; |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
578 { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
579 Klass* defc_klass = java_lang_Class::as_Klass(defc_oop()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
580 if (defc_klass == NULL) return empty; // a primitive; no resolution possible |
6983 | 581 if (!defc_klass->oop_is_instance()) { |
582 if (!defc_klass->oop_is_array()) return empty; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
583 defc_klass = SystemDictionary::Object_klass(); |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
584 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
585 defc = instanceKlassHandle(THREAD, defc_klass); |
710 | 586 } |
587 if (defc.is_null()) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
588 THROW_MSG_(vmSymbols::java_lang_InternalError(), "primitive class", empty); |
710 | 589 } |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
590 defc->link_class(CHECK_(empty)); // possible safepoint |
710 | 591 |
592 // convert the external string name to an internal symbol | |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
593 TempNewSymbol name = java_lang_String::as_symbol_or_null(name_str()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
594 if (name == NULL) return empty; // no such name |
3451
38fa55e5e792
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
3449
diff
changeset
|
595 if (name == vmSymbols::class_initializer_name()) |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
596 return empty; // illegal name |
710 | 597 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
598 vmIntrinsics::ID mh_invoke_id = vmIntrinsics::_none; |
1508
2ffde6cfe049
6939196: method handle signatures off the boot class path get linkage errors
jrose
parents:
1507
diff
changeset
|
599 if ((flags & ALL_KINDS) == IS_METHOD && |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
600 (defc() == SystemDictionary::MethodHandle_klass()) && |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
601 (ref_kind == JVM_REF_invokeVirtual || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
602 ref_kind == JVM_REF_invokeSpecial || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
603 // static invocation mode is required for _linkToVirtual, etc.: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
604 ref_kind == JVM_REF_invokeStatic)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
605 vmIntrinsics::ID iid = signature_polymorphic_name_id(name); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
606 if (iid != vmIntrinsics::_none && |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
607 ((ref_kind == JVM_REF_invokeStatic) == is_signature_polymorphic_static(iid))) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
608 // Virtual methods invoke and invokeExact, plus internal invokers like _invokeBasic. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
609 // For a static reference it could an internal linkage routine like _linkToVirtual, etc. |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
610 mh_invoke_id = iid; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
611 } |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
612 } |
1508
2ffde6cfe049
6939196: method handle signatures off the boot class path get linkage errors
jrose
parents:
1507
diff
changeset
|
613 |
710 | 614 // convert the external string or reflective type to an internal signature |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
615 TempNewSymbol type = lookup_signature(type_str(), (mh_invoke_id != vmIntrinsics::_none), CHECK_(empty)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
616 if (type == NULL) return empty; // no such signature exists in the VM |
710 | 617 |
618 // Time to do the lookup. | |
619 switch (flags & ALL_KINDS) { | |
620 case IS_METHOD: | |
621 { | |
622 CallInfo result; | |
623 { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
624 assert(!HAS_PENDING_EXCEPTION, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
625 if (ref_kind == JVM_REF_invokeStatic) { |
710 | 626 LinkResolver::resolve_static_call(result, |
627 defc, name, type, KlassHandle(), false, false, THREAD); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
628 } else if (ref_kind == JVM_REF_invokeInterface) { |
710 | 629 LinkResolver::resolve_interface_call(result, Handle(), defc, |
630 defc, name, type, KlassHandle(), false, false, THREAD); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
631 } else if (mh_invoke_id != vmIntrinsics::_none) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
632 assert(!is_signature_polymorphic_static(mh_invoke_id), ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
633 LinkResolver::resolve_handle_call(result, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
634 defc, name, type, KlassHandle(), THREAD); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
635 } else if (ref_kind == JVM_REF_invokeSpecial) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
636 LinkResolver::resolve_special_call(result, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
637 defc, name, type, KlassHandle(), false, THREAD); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
638 } else if (ref_kind == JVM_REF_invokeVirtual) { |
710 | 639 LinkResolver::resolve_virtual_call(result, Handle(), defc, |
640 defc, name, type, KlassHandle(), false, false, THREAD); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
641 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
642 assert(false, err_msg("ref_kind=%d", ref_kind)); |
710 | 643 } |
644 if (HAS_PENDING_EXCEPTION) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
645 return empty; |
710 | 646 } |
647 } | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
648 if (result.resolved_appendix().not_null()) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
649 // The resolved MemberName must not be accompanied by an appendix argument, |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
650 // since there is no way to bind this value into the MemberName. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
651 // Caller is responsible to prevent this from happening. |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
652 THROW_MSG_(vmSymbols::java_lang_InternalError(), "appendix", empty); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
653 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
654 oop mname2 = init_method_MemberName(mname, result); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
655 return Handle(THREAD, mname2); |
710 | 656 } |
657 case IS_CONSTRUCTOR: | |
658 { | |
659 CallInfo result; | |
660 { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
661 assert(!HAS_PENDING_EXCEPTION, ""); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
662 if (name == vmSymbols::object_initializer_name()) { |
710 | 663 LinkResolver::resolve_special_call(result, |
664 defc, name, type, KlassHandle(), false, THREAD); | |
665 } else { | |
666 break; // will throw after end of switch | |
667 } | |
668 if (HAS_PENDING_EXCEPTION) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
669 return empty; |
710 | 670 } |
671 } | |
672 assert(result.is_statically_bound(), ""); | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
673 oop mname2 = init_method_MemberName(mname, result); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
674 return Handle(THREAD, mname2); |
710 | 675 } |
676 case IS_FIELD: | |
677 { | |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
678 fieldDescriptor result; // find_field initializes fd if found |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
679 { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
680 assert(!HAS_PENDING_EXCEPTION, ""); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
681 LinkResolver::resolve_field(result, defc, name, type, KlassHandle(), Bytecodes::_nop, false, false, THREAD); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
682 if (HAS_PENDING_EXCEPTION) { |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
683 return empty; |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
684 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
685 } |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
686 oop mname2 = init_field_MemberName(mname, result, ref_kind_is_setter(ref_kind)); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
687 return Handle(THREAD, mname2); |
710 | 688 } |
1508
2ffde6cfe049
6939196: method handle signatures off the boot class path get linkage errors
jrose
parents:
1507
diff
changeset
|
689 default: |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
690 THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format", empty); |
710 | 691 } |
1508
2ffde6cfe049
6939196: method handle signatures off the boot class path get linkage errors
jrose
parents:
1507
diff
changeset
|
692 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
693 return empty; |
710 | 694 } |
695 | |
696 // Conversely, a member name which is only initialized from JVM internals | |
697 // may have null defc, name, and type fields. | |
698 // Resolving it plants a vmtarget/vmindex in it, | |
699 // which refers directly to JVM internals. | |
700 void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
701 assert(java_lang_invoke_MemberName::is_instance(mname()), ""); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
702 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(mname()); |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
703 int vmindex = java_lang_invoke_MemberName::vmindex(mname()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
704 if (vmtarget == NULL) { |
710 | 705 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to expand"); |
706 } | |
707 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
708 bool have_defc = (java_lang_invoke_MemberName::clazz(mname()) != NULL); |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
709 bool have_name = (java_lang_invoke_MemberName::name(mname()) != NULL); |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
710 bool have_type = (java_lang_invoke_MemberName::type(mname()) != NULL); |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
711 int flags = java_lang_invoke_MemberName::flags(mname()); |
710 | 712 |
713 if (suppress != 0) { | |
714 if (suppress & _suppress_defc) have_defc = true; | |
715 if (suppress & _suppress_name) have_name = true; | |
716 if (suppress & _suppress_type) have_type = true; | |
717 } | |
718 | |
719 if (have_defc && have_name && have_type) return; // nothing needed | |
720 | |
721 switch (flags & ALL_KINDS) { | |
722 case IS_METHOD: | |
723 case IS_CONSTRUCTOR: | |
724 { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
725 assert(vmtarget->is_method(), "method or constructor vmtarget is Method*"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
726 methodHandle m(THREAD, (Method*)vmtarget); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
727 DEBUG_ONLY(vmtarget = NULL); // safety |
710 | 728 if (m.is_null()) break; |
729 if (!have_defc) { | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6852
diff
changeset
|
730 InstanceKlass* defc = m->method_holder(); |
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6852
diff
changeset
|
731 java_lang_invoke_MemberName::set_clazz(mname(), defc->java_mirror()); |
710 | 732 } |
733 if (!have_name) { | |
734 //not java_lang_String::create_from_symbol; let's intern member names | |
735 Handle name = StringTable::intern(m->name(), CHECK); | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
736 java_lang_invoke_MemberName::set_name(mname(), name()); |
710 | 737 } |
738 if (!have_type) { | |
739 Handle type = java_lang_String::create_from_symbol(m->signature(), CHECK); | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
740 java_lang_invoke_MemberName::set_type(mname(), type()); |
710 | 741 } |
742 return; | |
743 } | |
744 case IS_FIELD: | |
745 { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
746 assert(vmtarget->is_klass(), "field vmtarget is Klass*"); |
6983 | 747 if (!((Klass*) vmtarget)->oop_is_instance()) break; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
748 instanceKlassHandle defc(THREAD, (Klass*) vmtarget); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
749 DEBUG_ONLY(vmtarget = NULL); // safety |
710 | 750 bool is_static = ((flags & JVM_ACC_STATIC) != 0); |
751 fieldDescriptor fd; // find_field initializes fd if found | |
752 if (!defc->find_field_from_offset(vmindex, is_static, &fd)) | |
753 break; // cannot expand | |
754 if (!have_defc) { | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
755 java_lang_invoke_MemberName::set_clazz(mname(), defc->java_mirror()); |
710 | 756 } |
757 if (!have_name) { | |
758 //not java_lang_String::create_from_symbol; let's intern member names | |
759 Handle name = StringTable::intern(fd.name(), CHECK); | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
760 java_lang_invoke_MemberName::set_name(mname(), name()); |
710 | 761 } |
762 if (!have_type) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
763 // If it is a primitive field type, don't mess with short strings like "I". |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
764 Handle type = field_signature_type_or_null(fd.signature()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
765 if (type.is_null()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
766 java_lang_String::create_from_symbol(fd.signature(), CHECK); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
767 } |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
768 java_lang_invoke_MemberName::set_type(mname(), type()); |
710 | 769 } |
770 return; | |
771 } | |
772 } | |
773 THROW_MSG(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format"); | |
774 } | |
775 | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
776 int MethodHandles::find_MemberNames(KlassHandle k, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
777 Symbol* name, Symbol* sig, |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
778 int mflags, KlassHandle caller, |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
779 int skip, objArrayHandle results) { |
710 | 780 // %%% take caller into account! |
781 | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
782 Thread* thread = Thread::current(); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
783 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
784 if (k.is_null() || !k->oop_is_instance()) return -1; |
710 | 785 |
786 int rfill = 0, rlimit = results->length(), rskip = skip; | |
787 // overflow measurement: | |
788 int overflow = 0, overflow_limit = MAX2(1000, rlimit); | |
789 | |
790 int match_flags = mflags; | |
791 bool search_superc = ((match_flags & SEARCH_SUPERCLASSES) != 0); | |
792 bool search_intfc = ((match_flags & SEARCH_INTERFACES) != 0); | |
793 bool local_only = !(search_superc | search_intfc); | |
794 bool classes_only = false; | |
795 | |
796 if (name != NULL) { | |
797 if (name->utf8_length() == 0) return 0; // a match is not possible | |
798 } | |
799 if (sig != NULL) { | |
800 if (sig->utf8_length() == 0) return 0; // a match is not possible | |
801 if (sig->byte_at(0) == '(') | |
802 match_flags &= ~(IS_FIELD | IS_TYPE); | |
803 else | |
804 match_flags &= ~(IS_CONSTRUCTOR | IS_METHOD); | |
805 } | |
806 | |
807 if ((match_flags & IS_TYPE) != 0) { | |
808 // NYI, and Core Reflection works quite well for this query | |
809 } | |
810 | |
811 if ((match_flags & IS_FIELD) != 0) { | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
812 for (FieldStream st(k(), local_only, !search_intfc); !st.eos(); st.next()) { |
710 | 813 if (name != NULL && st.name() != name) |
814 continue; | |
815 if (sig != NULL && st.signature() != sig) | |
816 continue; | |
817 // passed the filters | |
818 if (rskip > 0) { | |
819 --rskip; | |
820 } else if (rfill < rlimit) { | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
821 Handle result(thread, results->obj_at(rfill++)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
822 if (!java_lang_invoke_MemberName::is_instance(result())) |
710 | 823 return -99; // caller bug! |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
824 oop saved = MethodHandles::init_field_MemberName(result, st.field_descriptor()); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
825 if (saved != result()) |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
826 results->obj_at_put(rfill-1, saved); // show saved instance to user |
710 | 827 } else if (++overflow >= overflow_limit) { |
828 match_flags = 0; break; // got tired of looking at overflow | |
829 } | |
830 } | |
831 } | |
832 | |
833 if ((match_flags & (IS_METHOD | IS_CONSTRUCTOR)) != 0) { | |
834 // watch out for these guys: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
835 Symbol* init_name = vmSymbols::object_initializer_name(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
836 Symbol* clinit_name = vmSymbols::class_initializer_name(); |
710 | 837 if (name == clinit_name) clinit_name = NULL; // hack for exposing <clinit> |
838 bool negate_name_test = false; | |
839 // fix name so that it captures the intention of IS_CONSTRUCTOR | |
840 if (!(match_flags & IS_METHOD)) { | |
841 // constructors only | |
842 if (name == NULL) { | |
843 name = init_name; | |
844 } else if (name != init_name) { | |
845 return 0; // no constructors of this method name | |
846 } | |
847 } else if (!(match_flags & IS_CONSTRUCTOR)) { | |
848 // methods only | |
849 if (name == NULL) { | |
850 name = init_name; | |
851 negate_name_test = true; // if we see the name, we *omit* the entry | |
852 } else if (name == init_name) { | |
853 return 0; // no methods of this constructor name | |
854 } | |
855 } else { | |
856 // caller will accept either sort; no need to adjust name | |
857 } | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
858 for (MethodStream st(k(), local_only, !search_intfc); !st.eos(); st.next()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
859 Method* m = st.method(); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
860 Symbol* m_name = m->name(); |
710 | 861 if (m_name == clinit_name) |
862 continue; | |
863 if (name != NULL && ((m_name != name) ^ negate_name_test)) | |
864 continue; | |
865 if (sig != NULL && m->signature() != sig) | |
866 continue; | |
867 // passed the filters | |
868 if (rskip > 0) { | |
869 --rskip; | |
870 } else if (rfill < rlimit) { | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
871 Handle result(thread, results->obj_at(rfill++)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
872 if (!java_lang_invoke_MemberName::is_instance(result())) |
710 | 873 return -99; // caller bug! |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
874 CallInfo info(m); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
875 oop saved = MethodHandles::init_method_MemberName(result, info); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
876 if (saved != result()) |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
877 results->obj_at_put(rfill-1, saved); // show saved instance to user |
710 | 878 } else if (++overflow >= overflow_limit) { |
879 match_flags = 0; break; // got tired of looking at overflow | |
880 } | |
881 } | |
882 } | |
883 | |
884 // return number of elements we at leasted wanted to initialize | |
885 return rfill + overflow; | |
886 } | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
887 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
888 //------------------------------------------------------------------------------ |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
889 // MemberNameTable |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
890 // |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
891 |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
892 MemberNameTable::MemberNameTable(int methods_cnt) |
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
893 : GrowableArray<jweak>(methods_cnt, true) { |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
894 assert_locked_or_safepoint(MemberNameTable_lock); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
895 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
896 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
897 MemberNameTable::~MemberNameTable() { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
898 assert_locked_or_safepoint(MemberNameTable_lock); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
899 int len = this->length(); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
900 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
901 for (int idx = 0; idx < len; idx++) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
902 jweak ref = this->at(idx); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
903 JNIHandles::destroy_weak_global(ref); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
904 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
905 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
906 |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
907 void MemberNameTable::add_member_name(int index, jweak mem_name_wref) { |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
908 assert_locked_or_safepoint(MemberNameTable_lock); |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
909 this->at_put_grow(index, mem_name_wref); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
910 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
911 |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
912 // Return a member name oop or NULL. |
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
913 oop MemberNameTable::get_member_name(int index) { |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
914 assert_locked_or_safepoint(MemberNameTable_lock); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
915 |
10345
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
916 jweak ref = this->at(index); |
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
917 oop mem_name = JNIHandles::resolve(ref); |
b7fa10a3a69a
8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes
sspitsyn
parents:
10283
diff
changeset
|
918 return mem_name; |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
919 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
920 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
921 #if INCLUDE_JVMTI |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
922 oop MemberNameTable::find_member_name_by_method(Method* old_method) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
923 assert_locked_or_safepoint(MemberNameTable_lock); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
924 oop found = NULL; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
925 int len = this->length(); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
926 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
927 for (int idx = 0; idx < len; idx++) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
928 oop mem_name = JNIHandles::resolve(this->at(idx)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
929 if (mem_name == NULL) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
930 continue; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
931 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
932 Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
933 if (method == old_method) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
934 found = mem_name; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
935 break; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
936 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
937 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
938 return found; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
939 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
940 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
941 // It is called at safepoint only |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
942 void MemberNameTable::adjust_method_entries(Method** old_methods, Method** new_methods, |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
943 int methods_length, bool *trace_name_printed) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
944 assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
945 // search the MemberNameTable for uses of either obsolete or EMCP methods |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
946 for (int j = 0; j < methods_length; j++) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
947 Method* old_method = old_methods[j]; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
948 Method* new_method = new_methods[j]; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
949 oop mem_name = find_member_name_by_method(old_method); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
950 if (mem_name != NULL) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
951 java_lang_invoke_MemberName::adjust_vmtarget(mem_name, new_method); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
952 |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
953 if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
954 if (!(*trace_name_printed)) { |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
955 // RC_TRACE_MESG macro has an embedded ResourceMark |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
956 RC_TRACE_MESG(("adjust: name=%s", |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
957 old_method->method_holder()->external_name())); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
958 *trace_name_printed = true; |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
959 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
960 // RC_TRACE macro has an embedded ResourceMark |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
961 RC_TRACE(0x00400000, ("MemberName method update: %s(%s)", |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
962 new_method->name()->as_C_string(), |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
963 new_method->signature()->as_C_string())); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
964 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
965 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
966 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
967 } |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
968 #endif // INCLUDE_JVMTI |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
969 |
710 | 970 // |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
971 // Here are the native methods in java.lang.invoke.MethodHandleNatives |
710 | 972 // They are the private interface between this JVM and the HotSpot-specific |
973 // Java code that implements JSR 292 method handles. | |
974 // | |
975 // Note: We use a JVM_ENTRY macro to define each of these, for this is the way | |
976 // that intrinsic (non-JNI) native methods are defined in HotSpot. | |
977 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
978 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
979 JVM_ENTRY(jint, MHN_getConstant(JNIEnv *env, jobject igcls, jint which)) { |
710 | 980 switch (which) { |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
981 case MethodHandles::GC_COUNT_GWT: |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
982 #ifdef COMPILER2 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
983 return true; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
984 #else |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
985 return false; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3837
diff
changeset
|
986 #endif |
710 | 987 } |
988 return 0; | |
989 } | |
990 JVM_END | |
991 | |
992 #ifndef PRODUCT | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
993 #define EACH_NAMED_CON(template, requirement) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
994 template(MethodHandles,GC_COUNT_GWT) \ |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
995 template(java_lang_invoke_MemberName,MN_IS_METHOD) \ |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
996 template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \ |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
997 template(java_lang_invoke_MemberName,MN_IS_FIELD) \ |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
998 template(java_lang_invoke_MemberName,MN_IS_TYPE) \ |
8866
16885e702c88
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
7418
diff
changeset
|
999 template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \ |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1000 template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \ |
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1001 template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \ |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1002 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1003 template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_MASK) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1004 template(MethodHandles,GC_LAMBDA_SUPPORT) \ |
710 | 1005 /*end*/ |
1006 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1007 #define IGNORE_REQ(req_expr) /* req_expr */ |
710 | 1008 #define ONE_PLUS(scope,value) 1+ |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1009 static const int con_value_count = EACH_NAMED_CON(ONE_PLUS, IGNORE_REQ) 0; |
710 | 1010 #define VALUE_COMMA(scope,value) scope::value, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1011 static const int con_values[con_value_count+1] = { EACH_NAMED_CON(VALUE_COMMA, IGNORE_REQ) 0 }; |
710 | 1012 #define STRING_NULL(scope,value) #value "\0" |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1013 static const char con_names[] = { EACH_NAMED_CON(STRING_NULL, IGNORE_REQ) }; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1014 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1015 static bool advertise_con_value(int which) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1016 if (which < 0) return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1017 bool ok = true; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1018 int count = 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1019 #define INC_COUNT(scope,value) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1020 ++count; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1021 #define CHECK_REQ(req_expr) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1022 if (which < count) return ok; \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1023 ok = (req_expr); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1024 EACH_NAMED_CON(INC_COUNT, CHECK_REQ); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1025 #undef INC_COUNT |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1026 #undef CHECK_REQ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1027 assert(count == con_value_count, ""); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1028 if (which < count) return ok; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1029 return false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1030 } |
710 | 1031 |
1032 #undef ONE_PLUS | |
1033 #undef VALUE_COMMA | |
1034 #undef STRING_NULL | |
1035 #undef EACH_NAMED_CON | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1036 #endif // PRODUCT |
710 | 1037 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1038 JVM_ENTRY(jint, MHN_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectArray box_jh)) { |
710 | 1039 #ifndef PRODUCT |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1040 if (advertise_con_value(which)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1041 assert(which >= 0 && which < con_value_count, ""); |
710 | 1042 int con = con_values[which]; |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1043 objArrayHandle box(THREAD, (objArrayOop) JNIHandles::resolve(box_jh)); |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1044 if (box.not_null() && box->klass() == Universe::objectArrayKlassObj() && box->length() > 0) { |
710 | 1045 const char* str = &con_names[0]; |
1046 for (int i = 0; i < which; i++) | |
1047 str += strlen(str) + 1; // skip name and null | |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1048 oop name = java_lang_String::create_oop_from_str(str, CHECK_0); // possible safepoint |
710 | 1049 box->obj_at_put(0, name); |
1050 } | |
1051 return con; | |
1052 } | |
1053 #endif | |
1054 return 0; | |
1055 } | |
1056 JVM_END | |
1057 | |
1058 // void init(MemberName self, AccessibleObject ref) | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1059 JVM_ENTRY(void, MHN_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) { |
3412
88559690c95a
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3389
diff
changeset
|
1060 if (mname_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } |
88559690c95a
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3389
diff
changeset
|
1061 if (target_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "target is null"); } |
710 | 1062 Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
1063 Handle target(THREAD, JNIHandles::resolve_non_null(target_jh)); |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
1064 MethodHandles::init_MemberName(mname, target); |
710 | 1065 } |
1066 JVM_END | |
1067 | |
1068 // void expand(MemberName self) | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1069 JVM_ENTRY(void, MHN_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) { |
3412
88559690c95a
7047961: JSR 292 MethodHandleWalk swap args doesn't handle T_LONG and T_DOUBLE properly
never
parents:
3389
diff
changeset
|
1070 if (mname_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } |
710 | 1071 Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); |
1072 MethodHandles::expand_MemberName(mname, 0, CHECK); | |
1073 } | |
1074 JVM_END | |
1075 | |
1076 // void resolve(MemberName self, Class<?> caller) | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1077 JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1078 if (mname_jh == NULL) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "mname is null"); } |
710 | 1079 Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1080 |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1081 // The trusted Java code that calls this method should already have performed |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1082 // access checks on behalf of the given caller. But, we can verify this. |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1083 if (VerifyMethodHandles && caller_jh != NULL && |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1084 java_lang_invoke_MemberName::clazz(mname()) != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1085 Klass* reference_klass = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(mname())); |
11081
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1086 if (reference_klass != NULL && reference_klass->oop_is_objArray()) { |
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1087 reference_klass = ObjArrayKlass::cast(reference_klass)->bottom_klass(); |
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1088 } |
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1089 |
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1090 // Reflection::verify_class_access can only handle instance classes. |
c1bd7b5bdc70
8017571: JSR292: JVM crashing on assert "cast to instanceKlass" while producing MethodHandle for array methods with MethodHandle.findVirtual
twisti
parents:
10345
diff
changeset
|
1091 if (reference_klass != NULL && reference_klass->oop_is_instance()) { |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1092 // Emulate LinkResolver::check_klass_accessability. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1093 Klass* caller = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1094 if (!Reflection::verify_class_access(caller, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1095 reference_klass, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1096 true)) { |
6983 | 1097 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name()); |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1098 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1099 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1100 } |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1299
diff
changeset
|
1101 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1102 Handle resolved = MethodHandles::resolve_MemberName(mname, CHECK_NULL); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1103 if (resolved.is_null()) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1104 int flags = java_lang_invoke_MemberName::flags(mname()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1105 int ref_kind = (flags >> REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1106 if (!MethodHandles::ref_kind_is_valid(ref_kind)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1107 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "obsolete MemberName format"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1108 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1109 if ((flags & ALL_KINDS) == IS_FIELD) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1110 THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), "field resolution failed"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1111 } else if ((flags & ALL_KINDS) == IS_METHOD || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1112 (flags & ALL_KINDS) == IS_CONSTRUCTOR) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1113 THROW_MSG_NULL(vmSymbols::java_lang_NoSuchFieldError(), "method resolution failed"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1114 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1115 THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "resolution failed"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1116 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1117 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1118 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1119 return JNIHandles::make_local(THREAD, resolved()); |
710 | 1120 } |
1121 JVM_END | |
1122 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1123 static jlong find_member_field_offset(oop mname, bool must_be_static, TRAPS) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1124 if (mname == NULL || |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1125 java_lang_invoke_MemberName::vmtarget(mname) == NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1126 THROW_MSG_0(vmSymbols::java_lang_InternalError(), "mname not resolved"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1127 } else { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1128 int flags = java_lang_invoke_MemberName::flags(mname); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1129 if ((flags & IS_FIELD) != 0 && |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1130 (must_be_static |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1131 ? (flags & JVM_ACC_STATIC) != 0 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1132 : (flags & JVM_ACC_STATIC) == 0)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1133 int vmindex = java_lang_invoke_MemberName::vmindex(mname); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1134 return (jlong) vmindex; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1135 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1136 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1137 const char* msg = (must_be_static ? "static field required" : "non-static field required"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1138 THROW_MSG_0(vmSymbols::java_lang_InternalError(), msg); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1139 return 0; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1140 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1141 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1142 JVM_ENTRY(jlong, MHN_objectFieldOffset(JNIEnv *env, jobject igcls, jobject mname_jh)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1143 return find_member_field_offset(JNIHandles::resolve(mname_jh), false, THREAD); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1144 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1145 JVM_END |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1146 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1147 JVM_ENTRY(jlong, MHN_staticFieldOffset(JNIEnv *env, jobject igcls, jobject mname_jh)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1148 return find_member_field_offset(JNIHandles::resolve(mname_jh), true, THREAD); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1149 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1150 JVM_END |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1151 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1152 JVM_ENTRY(jobject, MHN_staticFieldBase(JNIEnv *env, jobject igcls, jobject mname_jh)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1153 // use the other function to perform sanity checks: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1154 jlong ignore = find_member_field_offset(JNIHandles::resolve(mname_jh), true, CHECK_NULL); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1155 oop clazz = java_lang_invoke_MemberName::clazz(JNIHandles::resolve_non_null(mname_jh)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1156 return JNIHandles::make_local(THREAD, clazz); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1157 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1158 JVM_END |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1159 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1160 JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname_jh)) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1161 if (mname_jh == NULL) return NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1162 Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1163 intptr_t vmindex = java_lang_invoke_MemberName::vmindex(mname()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1164 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(mname()); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1165 objArrayHandle result = oopFactory::new_objArray(SystemDictionary::Object_klass(), 2, CHECK_NULL); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1166 jvalue vmindex_value; vmindex_value.j = (long)vmindex; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1167 oop x = java_lang_boxing_object::create(T_LONG, &vmindex_value, CHECK_NULL); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1168 result->obj_at_put(0, x); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1169 x = NULL; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1170 if (vmtarget == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1171 x = NULL; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1172 } else if (vmtarget->is_klass()) { |
6983 | 1173 x = ((Klass*) vmtarget)->java_mirror(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1174 } else if (vmtarget->is_method()) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1175 Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL); |
12264
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
1176 CallInfo info((Method*)vmtarget); |
b2e698d2276c
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
11081
diff
changeset
|
1177 x = MethodHandles::init_method_MemberName(mname2, info); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1178 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1179 result->obj_at_put(1, x); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1180 return JNIHandles::make_local(env, result()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1181 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1182 JVM_END |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1183 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1184 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1185 |
710 | 1186 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
1187 // int matchFlags, Class<?> caller, int skip, MemberName[] results); | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2356
diff
changeset
|
1188 JVM_ENTRY(jint, MHN_getMembers(JNIEnv *env, jobject igcls, |
710 | 1189 jclass clazz_jh, jstring name_jh, jstring sig_jh, |
1190 int mflags, jclass caller_jh, jint skip, jobjectArray results_jh)) { | |
1191 if (clazz_jh == NULL || results_jh == NULL) return -1; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1192 KlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz_jh))); |
710 | 1193 |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1194 objArrayHandle results(THREAD, (objArrayOop) JNIHandles::resolve(results_jh)); |
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1195 if (results.is_null() || !results->is_objArray()) return -1; |
710 | 1196 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
1197 TempNewSymbol name = NULL; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
2116
diff
changeset
|
1198 TempNewSymbol sig = NULL; |
710 | 1199 if (name_jh != NULL) { |
1200 name = java_lang_String::as_symbol_or_null(JNIHandles::resolve_non_null(name_jh)); | |
1201 if (name == NULL) return 0; // a match is not possible | |
1202 } | |
1203 if (sig_jh != NULL) { | |
1204 sig = java_lang_String::as_symbol_or_null(JNIHandles::resolve_non_null(sig_jh)); | |
1205 if (sig == NULL) return 0; // a match is not possible | |
1206 } | |
1207 | |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1208 KlassHandle caller; |
710 | 1209 if (caller_jh != NULL) { |
1210 oop caller_oop = JNIHandles::resolve_non_null(caller_jh); | |
1211 if (!java_lang_Class::is_instance(caller_oop)) return -1; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6271
diff
changeset
|
1212 caller = KlassHandle(THREAD, java_lang_Class::as_Klass(caller_oop)); |
710 | 1213 } |
1214 | |
3274
2a23b1b5a0a8
7018355: JSR 292: VM crash in DefNewGeneration::copy_to_survivor_space
twisti
parents:
2478
diff
changeset
|
1215 if (name != NULL && sig != NULL && results.not_null()) { |
710 | 1216 // try a direct resolve |
1217 // %%% TO DO | |
1218 } | |
1219 | |
10133
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
1220 int res = MethodHandles::find_MemberNames(k, name, sig, mflags, |
6337ca4dcad8
8008511: JSR 292: MemberName vmtarget refs to methods must be updated at class redefinition
sspitsyn
parents:
10128
diff
changeset
|
1221 caller, skip, results); |
710 | 1222 // TO DO: expand at least some of the MemberNames, to avoid massive callbacks |
1223 return res; | |
1224 } | |
1225 JVM_END | |
1226 | |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1227 JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) { |
4043
12d38ffcba2a
7094138: JSR 292: JRuby junit test fails in CallSite.setTargetNormal: obj->is_oop() failed: sanity check
twisti
parents:
3938
diff
changeset
|
1228 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh)); |
12d38ffcba2a
7094138: JSR 292: JRuby junit test fails in CallSite.setTargetNormal: obj->is_oop() failed: sanity check
twisti
parents:
3938
diff
changeset
|
1229 Handle target (THREAD, JNIHandles::resolve(target_jh)); |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1230 { |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1231 // Walk all nmethods depending on this call site. |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1232 MutexLocker mu(Compile_lock, thread); |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1233 Universe::flush_dependents_on(call_site, target); |
7418
5c0931d15474
8003238: JSR 292: intermittent exception failure with java/lang/invoke/CallSiteTest.java
twisti
parents:
6983
diff
changeset
|
1234 java_lang_invoke_CallSite::set_target(call_site(), target()); |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1235 } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1236 } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1237 JVM_END |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1238 |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1239 JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) { |
4043
12d38ffcba2a
7094138: JSR 292: JRuby junit test fails in CallSite.setTargetNormal: obj->is_oop() failed: sanity check
twisti
parents:
3938
diff
changeset
|
1240 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh)); |
12d38ffcba2a
7094138: JSR 292: JRuby junit test fails in CallSite.setTargetNormal: obj->is_oop() failed: sanity check
twisti
parents:
3938
diff
changeset
|
1241 Handle target (THREAD, JNIHandles::resolve(target_jh)); |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1242 { |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1243 // Walk all nmethods depending on this call site. |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1244 MutexLocker mu(Compile_lock, thread); |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1245 Universe::flush_dependents_on(call_site, target); |
7418
5c0931d15474
8003238: JSR 292: intermittent exception failure with java/lang/invoke/CallSiteTest.java
twisti
parents:
6983
diff
changeset
|
1246 java_lang_invoke_CallSite::set_target_volatile(call_site(), target()); |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1247 } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1248 } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1249 JVM_END |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1250 |
10276
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1251 /** |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1252 * Throws a java/lang/UnsupportedOperationException unconditionally. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1253 * This is required by the specification of MethodHandle.invoke if |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1254 * invoked directly. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1255 */ |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1256 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1257 THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively"); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1258 return NULL; |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1259 } |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1260 JVM_END |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1261 |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1262 /** |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1263 * Throws a java/lang/UnsupportedOperationException unconditionally. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1264 * This is required by the specification of MethodHandle.invokeExact if |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1265 * invoked directly. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1266 */ |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1267 JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv* env, jobject mh, jobjectArray args)) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1268 THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invokeExact cannot be invoked reflectively"); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1269 return NULL; |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1270 } |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1271 JVM_END |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1272 |
710 | 1273 /// JVM_RegisterMethodHandleMethods |
1274 | |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1275 #undef CS // Solaris builds complain |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1276 |
710 | 1277 #define LANG "Ljava/lang/" |
2460 | 1278 #define JLINV "Ljava/lang/invoke/" |
710 | 1279 |
1280 #define OBJ LANG"Object;" | |
1281 #define CLS LANG"Class;" | |
1282 #define STRG LANG"String;" | |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1283 #define CS JLINV"CallSite;" |
2460 | 1284 #define MT JLINV"MethodType;" |
1285 #define MH JLINV"MethodHandle;" | |
1286 #define MEM JLINV"MemberName;" | |
710 | 1287 |
1288 #define CC (char*) /*cast a literal from (const char*)*/ | |
1289 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) | |
1290 | |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1291 // These are the native methods on java.lang.invoke.MethodHandleNatives. |
10276
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1292 static JNINativeMethod MHN_methods[] = { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1293 {CC"init", CC"("MEM""OBJ")V", FN_PTR(MHN_init_Mem)}, |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1294 {CC"expand", CC"("MEM")V", FN_PTR(MHN_expand_Mem)}, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1295 {CC"resolve", CC"("MEM""CLS")"MEM, FN_PTR(MHN_resolve_Mem)}, |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1296 {CC"getConstant", CC"(I)I", FN_PTR(MHN_getConstant)}, |
710 | 1297 // static native int getNamedCon(int which, Object[] name) |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1298 {CC"getNamedCon", CC"(I["OBJ")I", FN_PTR(MHN_getNamedCon)}, |
710 | 1299 // static native int getMembers(Class<?> defc, String matchName, String matchSig, |
1300 // int matchFlags, Class<?> caller, int skip, MemberName[] results); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1301 {CC"getMembers", CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)}, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1302 {CC"objectFieldOffset", CC"("MEM")J", FN_PTR(MHN_objectFieldOffset)}, |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1303 {CC"setCallSiteTargetNormal", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetNormal)}, |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1304 {CC"setCallSiteTargetVolatile", CC"("CS""MH")V", FN_PTR(MHN_setCallSiteTargetVolatile)}, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1305 {CC"staticFieldOffset", CC"("MEM")J", FN_PTR(MHN_staticFieldOffset)}, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1306 {CC"staticFieldBase", CC"("MEM")"OBJ, FN_PTR(MHN_staticFieldBase)}, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1307 {CC"getMemberVMInfo", CC"("MEM")"OBJ, FN_PTR(MHN_getMemberVMInfo)} |
710 | 1308 }; |
1309 | |
10276
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1310 static JNINativeMethod MH_methods[] = { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1311 // UnsupportedOperationException throwers |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1312 {CC"invoke", CC"(["OBJ")"OBJ, FN_PTR(MH_invoke_UOE)}, |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1313 {CC"invokeExact", CC"(["OBJ")"OBJ, FN_PTR(MH_invokeExact_UOE)} |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1314 }; |
710 | 1315 |
10276
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1316 /** |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1317 * Helper method to register native methods. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1318 */ |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1319 static bool register_natives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1320 int status = env->RegisterNatives(clazz, methods, nMethods); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1321 if (status != JNI_OK || env->ExceptionOccurred()) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1322 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1323 env->ExceptionClear(); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1324 return false; |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1325 } |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1326 return true; |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1327 } |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1328 |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1329 /** |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1330 * This one function is exported, used by NativeLookup. |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1331 */ |
710 | 1332 JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { |
2416
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2357
diff
changeset
|
1333 if (!EnableInvokeDynamic) { |
38fea01eb669
6817525: turn on method handle functionality by default for JSR 292
twisti
parents:
2357
diff
changeset
|
1334 warning("JSR 292 is disabled in this JVM. Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable."); |
710 | 1335 return; // bind nothing |
1336 } | |
1337 | |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1338 assert(!MethodHandles::enabled(), "must not be enabled"); |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1339 bool enable_MH = true; |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1340 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1341 jclass MH_class = NULL; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1342 if (SystemDictionary::MethodHandle_klass() == NULL) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1343 enable_MH = false; |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1344 } else { |
6983 | 1345 oop mirror = SystemDictionary::MethodHandle_klass()->java_mirror(); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1346 MH_class = (jclass) JNIHandles::make_local(env, mirror); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1347 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1348 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1349 if (enable_MH) { |
710 | 1350 ThreadToNativeFromVM ttnfv(thread); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1351 |
10276
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1352 if (enable_MH) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1353 enable_MH = register_natives(env, MHN_class, MHN_methods, sizeof(MHN_methods)/sizeof(JNINativeMethod)); |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1354 } |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1355 if (enable_MH) { |
f0bc60565ba8
7196277: JSR 292: Two jck/runtime tests crash on java.lang.invoke.MethodHandle.invokeExact
twisti
parents:
10161
diff
changeset
|
1356 enable_MH = register_natives(env, MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod)); |
710 | 1357 } |
1358 } | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1359 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1360 if (TraceInvokeDynamic) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6224
diff
changeset
|
1361 tty->print_cr("MethodHandle support loaded (using LambdaForms)"); |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1362 } |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1363 |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1364 if (enable_MH) { |
2116
d810e9a3fc33
7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
twisti
parents:
2088
diff
changeset
|
1365 MethodHandles::generate_adapters(); |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1366 MethodHandles::set_enabled(true); |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1367 } |
710 | 1368 } |
1369 JVM_END |