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