author | shade |
Tue, 17 May 2016 22:28:00 +0300 | |
changeset 38372 | 017d7578731c |
parent 37792 | dd626e6f5967 |
child 39754 | a04d89a52ad9 |
permissions | -rw-r--r-- |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
1 |
/* |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
2 |
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
4 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
10 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
15 |
* accompanied this code). |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
16 |
* |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
24 |
*/ |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
25 |
|
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8821
diff
changeset
|
26 |
package java.lang.invoke; |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
27 |
|
33674
566777f73c32
8140606: Update library code to use internal Unsafe
chegar
parents:
32649
diff
changeset
|
28 |
import jdk.internal.misc.Unsafe; |
35252
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
29 |
import jdk.internal.vm.annotation.ForceInline; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
30 |
import sun.invoke.util.ValueConversions; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
31 |
import sun.invoke.util.VerifyAccess; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
32 |
import sun.invoke.util.VerifyType; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
33 |
import sun.invoke.util.Wrapper; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
34 |
|
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
35 |
import java.lang.ref.WeakReference; |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
36 |
import java.util.Arrays; |
35252
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
37 |
import java.util.Objects; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
38 |
|
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
39 |
import static java.lang.invoke.LambdaForm.*; |
8822
8145ab9f5f86
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
8821
diff
changeset
|
40 |
import static java.lang.invoke.MethodHandleNatives.Constants.*; |
35252
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
41 |
import static java.lang.invoke.MethodHandleStatics.UNSAFE; |
754852fba784
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
34384
diff
changeset
|
42 |
import static java.lang.invoke.MethodHandleStatics.newInternalError; |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
43 |
import static java.lang.invoke.MethodTypeForm.*; |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
44 |
|
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
45 |
/** |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
46 |
* The flavor of method handle which implements a constant reference |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
47 |
* to a class member. |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
48 |
* @author jrose |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
49 |
*/ |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
50 |
class DirectMethodHandle extends MethodHandle { |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
51 |
final MemberName member; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
52 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
53 |
// Constructors and factory methods in this class *must* be package scoped or private. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
54 |
private DirectMethodHandle(MethodType mtype, LambdaForm form, MemberName member) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
55 |
super(mtype, form); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
56 |
if (!member.isResolved()) throw new InternalError(); |
16119
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
57 |
|
16484
f24cb2927b7a
8009222: java.lang.IllegalArgumentException: not invocable, no method type when attempting to get getter method handle for a static field
vlivanov
parents:
16123
diff
changeset
|
58 |
if (member.getDeclaringClass().isInterface() && |
f24cb2927b7a
8009222: java.lang.IllegalArgumentException: not invocable, no method type when attempting to get getter method handle for a static field
vlivanov
parents:
16123
diff
changeset
|
59 |
member.isMethod() && !member.isAbstract()) { |
16119
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
60 |
// Check for corner case: invokeinterface of Object method |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
61 |
MemberName m = new MemberName(Object.class, member.getName(), member.getMethodType(), member.getReferenceKind()); |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
62 |
m = MemberName.getFactory().resolveOrNull(m.getReferenceKind(), m, null); |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
63 |
if (m != null && m.isPublic()) { |
26467
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
64 |
assert(member.getReferenceKind() == m.getReferenceKind()); // else this.form is wrong |
16119
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
65 |
member = m; |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
66 |
} |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
67 |
} |
ca09c1ad6a45
8006179: JSR292 MethodHandles lookup with interface using findVirtual()
vlivanov
parents:
14342
diff
changeset
|
68 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
69 |
this.member = member; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
70 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
71 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
72 |
// Factory methods: |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
73 |
static DirectMethodHandle make(byte refKind, Class<?> receiver, MemberName member) { |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
74 |
MethodType mtype = member.getMethodOrFieldType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
75 |
if (!member.isStatic()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
76 |
if (!member.getDeclaringClass().isAssignableFrom(receiver) || member.isConstructor()) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
77 |
throw new InternalError(member.toString()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
78 |
mtype = mtype.insertParameterTypes(0, receiver); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
79 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
80 |
if (!member.isField()) { |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
81 |
if (refKind == REF_invokeSpecial) { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
82 |
member = member.asSpecial(); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
83 |
LambdaForm lform = preparedLambdaForm(member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
84 |
return new Special(mtype, lform, member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
85 |
} else { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
86 |
LambdaForm lform = preparedLambdaForm(member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
87 |
return new DirectMethodHandle(mtype, lform, member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
88 |
} |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
89 |
} else { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
90 |
LambdaForm lform = preparedFieldLambdaForm(member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
91 |
if (member.isStatic()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
92 |
long offset = MethodHandleNatives.staticFieldOffset(member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
93 |
Object base = MethodHandleNatives.staticFieldBase(member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
94 |
return new StaticAccessor(mtype, lform, member, base, offset); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
95 |
} else { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
96 |
long offset = MethodHandleNatives.objectFieldOffset(member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
97 |
assert(offset == (int)offset); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
98 |
return new Accessor(mtype, lform, member, (int)offset); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
99 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
100 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
101 |
} |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
102 |
static DirectMethodHandle make(Class<?> receiver, MemberName member) { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
103 |
byte refKind = member.getReferenceKind(); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
104 |
if (refKind == REF_invokeSpecial) |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
105 |
refKind = REF_invokeVirtual; |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
106 |
return make(refKind, receiver, member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
107 |
} |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
108 |
static DirectMethodHandle make(MemberName member) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
109 |
if (member.isConstructor()) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
110 |
return makeAllocator(member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
111 |
return make(member.getDeclaringClass(), member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
112 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
113 |
private static DirectMethodHandle makeAllocator(MemberName ctor) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
114 |
assert(ctor.isConstructor() && ctor.getName().equals("<init>")); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
115 |
Class<?> instanceClass = ctor.getDeclaringClass(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
116 |
ctor = ctor.asConstructor(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
117 |
assert(ctor.isConstructor() && ctor.getReferenceKind() == REF_newInvokeSpecial) : ctor; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
118 |
MethodType mtype = ctor.getMethodType().changeReturnType(instanceClass); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
119 |
LambdaForm lform = preparedLambdaForm(ctor); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
120 |
MemberName init = ctor.asSpecial(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
121 |
assert(init.getMethodType().returnType() == void.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
122 |
return new Constructor(mtype, lform, ctor, init, instanceClass); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
123 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
124 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
125 |
@Override |
26472
71b6a6f208c0
8050057: Improve caching of MethodHandle reinvokers
vlivanov
parents:
26470
diff
changeset
|
126 |
BoundMethodHandle rebind() { |
71b6a6f208c0
8050057: Improve caching of MethodHandle reinvokers
vlivanov
parents:
26470
diff
changeset
|
127 |
return BoundMethodHandle.makeReinvoker(this); |
71b6a6f208c0
8050057: Improve caching of MethodHandle reinvokers
vlivanov
parents:
26470
diff
changeset
|
128 |
} |
71b6a6f208c0
8050057: Improve caching of MethodHandle reinvokers
vlivanov
parents:
26470
diff
changeset
|
129 |
|
71b6a6f208c0
8050057: Improve caching of MethodHandle reinvokers
vlivanov
parents:
26470
diff
changeset
|
130 |
@Override |
26470
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
131 |
MethodHandle copyWith(MethodType mt, LambdaForm lf) { |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
132 |
assert(this.getClass() == DirectMethodHandle.class); // must override in subclasses |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
133 |
return new DirectMethodHandle(mt, lf, member); |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
134 |
} |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
135 |
|
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
136 |
@Override |
13610
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
13423
diff
changeset
|
137 |
String internalProperties() { |
26467
d69abed3a07d
8050052: Small cleanups in java.lang.invoke code
vlivanov
parents:
26464
diff
changeset
|
138 |
return "\n& DMH.MN="+internalMemberName(); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
139 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
140 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
141 |
//// Implementation methods. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
142 |
@Override |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
143 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
144 |
MemberName internalMemberName() { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
145 |
return member; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
146 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
147 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
148 |
private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
149 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
150 |
/** |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
151 |
* Create a LF which can invoke the given method. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
152 |
* Cache and share this structure among all methods with |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
153 |
* the same basicType and refKind. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
154 |
*/ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
155 |
private static LambdaForm preparedLambdaForm(MemberName m) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
156 |
assert(m.isInvocable()) : m; // call preparedFieldLambdaForm instead |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
157 |
MethodType mtype = m.getInvocationType().basicType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
158 |
assert(!m.isMethodHandleInvoke() || "invokeBasic".equals(m.getName())) : m; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
159 |
int which; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
160 |
switch (m.getReferenceKind()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
161 |
case REF_invokeVirtual: which = LF_INVVIRTUAL; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
162 |
case REF_invokeStatic: which = LF_INVSTATIC; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
163 |
case REF_invokeSpecial: which = LF_INVSPECIAL; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
164 |
case REF_invokeInterface: which = LF_INVINTERFACE; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
165 |
case REF_newInvokeSpecial: which = LF_NEWINVSPECIAL; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
166 |
default: throw new InternalError(m.toString()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
167 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
168 |
if (which == LF_INVSTATIC && shouldBeInitialized(m)) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
169 |
// precompute the barrier-free version: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
170 |
preparedLambdaForm(mtype, which); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
171 |
which = LF_INVSTATIC_INIT; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
172 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
173 |
LambdaForm lform = preparedLambdaForm(mtype, which); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
174 |
maybeCompile(lform, m); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
175 |
assert(lform.methodType().dropParameterTypes(0, 1) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
176 |
.equals(m.getInvocationType().basicType())) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
177 |
: Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
178 |
return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
179 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
180 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
181 |
private static LambdaForm preparedLambdaForm(MethodType mtype, int which) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
182 |
LambdaForm lform = mtype.form().cachedLambdaForm(which); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
183 |
if (lform != null) return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
184 |
lform = makePreparedLambdaForm(mtype, which); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
185 |
return mtype.form().setCachedLambdaForm(which, lform); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
186 |
} |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
187 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
188 |
private static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
189 |
boolean needsInit = (which == LF_INVSTATIC_INIT); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
190 |
boolean doesAlloc = (which == LF_NEWINVSPECIAL); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
191 |
String linkerName, lambdaName; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
192 |
switch (which) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
193 |
case LF_INVVIRTUAL: linkerName = "linkToVirtual"; lambdaName = "DMH.invokeVirtual"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
194 |
case LF_INVSTATIC: linkerName = "linkToStatic"; lambdaName = "DMH.invokeStatic"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
195 |
case LF_INVSTATIC_INIT:linkerName = "linkToStatic"; lambdaName = "DMH.invokeStaticInit"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
196 |
case LF_INVSPECIAL: linkerName = "linkToSpecial"; lambdaName = "DMH.invokeSpecial"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
197 |
case LF_INVINTERFACE: linkerName = "linkToInterface"; lambdaName = "DMH.invokeInterface"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
198 |
case LF_NEWINVSPECIAL: linkerName = "linkToSpecial"; lambdaName = "DMH.newInvokeSpecial"; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
199 |
default: throw new InternalError("which="+which); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
200 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
201 |
MethodType mtypeWithArg = mtype.appendParameterTypes(MemberName.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
202 |
if (doesAlloc) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
203 |
mtypeWithArg = mtypeWithArg |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
204 |
.insertParameterTypes(0, Object.class) // insert newly allocated obj |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
205 |
.changeReturnType(void.class); // <init> returns void |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
206 |
MemberName linker = new MemberName(MethodHandle.class, linkerName, mtypeWithArg, REF_invokeStatic); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
207 |
try { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
208 |
linker = IMPL_NAMES.resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
209 |
} catch (ReflectiveOperationException ex) { |
14089
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13610
diff
changeset
|
210 |
throw newInternalError(ex); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
211 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
212 |
final int DMH_THIS = 0; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
213 |
final int ARG_BASE = 1; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
214 |
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
215 |
int nameCursor = ARG_LIMIT; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
216 |
final int NEW_OBJ = (doesAlloc ? nameCursor++ : -1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
217 |
final int GET_MEMBER = nameCursor++; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
218 |
final int LINKER_CALL = nameCursor++; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
219 |
Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
220 |
assert(names.length == nameCursor); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
221 |
if (doesAlloc) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
222 |
// names = { argx,y,z,... new C, init method } |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
223 |
names[NEW_OBJ] = new Name(NF_allocateInstance, names[DMH_THIS]); |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
224 |
names[GET_MEMBER] = new Name(NF_constructorMethod, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
225 |
} else if (needsInit) { |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
226 |
names[GET_MEMBER] = new Name(NF_internalMemberNameEnsureInit, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
227 |
} else { |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
228 |
names[GET_MEMBER] = new Name(NF_internalMemberName, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
229 |
} |
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
230 |
assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
231 |
Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
232 |
assert(outArgs[outArgs.length-1] == names[GET_MEMBER]); // look, shifted args! |
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
233 |
int result = LAST_RESULT; |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
234 |
if (doesAlloc) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
235 |
assert(outArgs[outArgs.length-2] == names[NEW_OBJ]); // got to move this one |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
236 |
System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
237 |
outArgs[0] = names[NEW_OBJ]; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
238 |
result = NEW_OBJ; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
239 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
240 |
names[LINKER_CALL] = new Name(linker, outArgs); |
24572
5c9e5961d21c
8037210: Get rid of char-based descriptions 'J' of basic types
vlivanov
parents:
20495
diff
changeset
|
241 |
lambdaName += "_" + shortenSignature(basicTypeSignature(mtype)); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
242 |
LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
243 |
// This is a tricky bit of code. Don't send it through the LF interpreter. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
244 |
lform.compileToBytecode(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
245 |
return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
246 |
} |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
247 |
|
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
248 |
static Object findDirectMethodHandle(Name name) { |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
249 |
if (name.function == NF_internalMemberName || |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
250 |
name.function == NF_internalMemberNameEnsureInit || |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
251 |
name.function == NF_constructorMethod) { |
26464
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
252 |
assert(name.arguments.length == 1); |
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
253 |
return name.arguments[0]; |
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
254 |
} |
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
255 |
return null; |
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
256 |
} |
65b37da18e06
8037209: Improvements and cleanups to bytecode assembly for lambda forms
vlivanov
parents:
25859
diff
changeset
|
257 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
258 |
private static void maybeCompile(LambdaForm lform, MemberName m) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
259 |
if (VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class)) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
260 |
// Help along bootstrapping... |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
261 |
lform.compileToBytecode(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
262 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
263 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
264 |
/** Static wrapper for DirectMethodHandle.internalMemberName. */ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
265 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
266 |
/*non-public*/ static Object internalMemberName(Object mh) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
267 |
return ((DirectMethodHandle)mh).member; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
268 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
269 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
270 |
/** Static wrapper for DirectMethodHandle.internalMemberName. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
271 |
* This one also forces initialization. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
272 |
*/ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
273 |
/*non-public*/ static Object internalMemberNameEnsureInit(Object mh) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
274 |
DirectMethodHandle dmh = (DirectMethodHandle)mh; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
275 |
dmh.ensureInitialized(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
276 |
return dmh.member; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
277 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
278 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
279 |
/*non-public*/ static |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
280 |
boolean shouldBeInitialized(MemberName member) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
281 |
switch (member.getReferenceKind()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
282 |
case REF_invokeStatic: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
283 |
case REF_getStatic: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
284 |
case REF_putStatic: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
285 |
case REF_newInvokeSpecial: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
286 |
break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
287 |
default: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
288 |
// No need to initialize the class on this kind of member. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
289 |
return false; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
290 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
291 |
Class<?> cls = member.getDeclaringClass(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
292 |
if (cls == ValueConversions.class || |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
293 |
cls == MethodHandleImpl.class || |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
294 |
cls == Invokers.class) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
295 |
// These guys have lots of <clinit> DMH creation but we know |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
296 |
// the MHs will not be used until the system is booted. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
297 |
return false; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
298 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
299 |
if (VerifyAccess.isSamePackage(MethodHandle.class, cls) || |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
300 |
VerifyAccess.isSamePackage(ValueConversions.class, cls)) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
301 |
// It is a system class. It is probably in the process of |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
302 |
// being initialized, but we will help it along just to be safe. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
303 |
if (UNSAFE.shouldBeInitialized(cls)) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
304 |
UNSAFE.ensureClassInitialized(cls); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
305 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
306 |
return false; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
307 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
308 |
return UNSAFE.shouldBeInitialized(cls); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
309 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
310 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
311 |
private static class EnsureInitialized extends ClassValue<WeakReference<Thread>> { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
312 |
@Override |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
313 |
protected WeakReference<Thread> computeValue(Class<?> type) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
314 |
UNSAFE.ensureClassInitialized(type); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
315 |
if (UNSAFE.shouldBeInitialized(type)) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
316 |
// If the previous call didn't block, this can happen. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
317 |
// We are executing inside <clinit>. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
318 |
return new WeakReference<>(Thread.currentThread()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
319 |
return null; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
320 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
321 |
static final EnsureInitialized INSTANCE = new EnsureInitialized(); |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
322 |
} |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
323 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
324 |
private void ensureInitialized() { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
325 |
if (checkInitialized(member)) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
326 |
// The coast is clear. Delete the <clinit> barrier. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
327 |
if (member.isField()) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
328 |
updateForm(preparedFieldLambdaForm(member)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
329 |
else |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
330 |
updateForm(preparedLambdaForm(member)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
331 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
332 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
333 |
private static boolean checkInitialized(MemberName member) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
334 |
Class<?> defc = member.getDeclaringClass(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
335 |
WeakReference<Thread> ref = EnsureInitialized.INSTANCE.get(defc); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
336 |
if (ref == null) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
337 |
return true; // the final state |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
338 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
339 |
Thread clinitThread = ref.get(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
340 |
// Somebody may still be running defc.<clinit>. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
341 |
if (clinitThread == Thread.currentThread()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
342 |
// If anybody is running defc.<clinit>, it is this thread. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
343 |
if (UNSAFE.shouldBeInitialized(defc)) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
344 |
// Yes, we are running it; keep the barrier for now. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
345 |
return false; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
346 |
} else { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
347 |
// We are in a random thread. Block. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
348 |
UNSAFE.ensureClassInitialized(defc); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
349 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
350 |
assert(!UNSAFE.shouldBeInitialized(defc)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
351 |
// put it into the final state |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
352 |
EnsureInitialized.INSTANCE.remove(defc); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
353 |
return true; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
354 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
355 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
356 |
/*non-public*/ static void ensureInitialized(Object mh) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
357 |
((DirectMethodHandle)mh).ensureInitialized(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
358 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
359 |
|
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
360 |
/** This subclass represents invokespecial instructions. */ |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
361 |
static class Special extends DirectMethodHandle { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
362 |
private Special(MethodType mtype, LambdaForm form, MemberName member) { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
363 |
super(mtype, form, member); |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
364 |
} |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
365 |
@Override |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
366 |
boolean isInvokeSpecial() { |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
367 |
return true; |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
368 |
} |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
369 |
@Override |
26470
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
370 |
MethodHandle copyWith(MethodType mt, LambdaForm lf) { |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
371 |
return new Special(mt, lf, member); |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
372 |
} |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
373 |
} |
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
374 |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
375 |
/** This subclass handles constructor references. */ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
376 |
static class Constructor extends DirectMethodHandle { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
377 |
final MemberName initMethod; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
378 |
final Class<?> instanceClass; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
379 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
380 |
private Constructor(MethodType mtype, LambdaForm form, MemberName constructor, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
381 |
MemberName initMethod, Class<?> instanceClass) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
382 |
super(mtype, form, constructor); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
383 |
this.initMethod = initMethod; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
384 |
this.instanceClass = instanceClass; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
385 |
assert(initMethod.isResolved()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
386 |
} |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
387 |
@Override |
26470
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
388 |
MethodHandle copyWith(MethodType mt, LambdaForm lf) { |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
389 |
return new Constructor(mt, lf, member, initMethod, instanceClass); |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
390 |
} |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
391 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
392 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
393 |
/*non-public*/ static Object constructorMethod(Object mh) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
394 |
Constructor dmh = (Constructor)mh; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
395 |
return dmh.initMethod; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
396 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
397 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
398 |
/*non-public*/ static Object allocateInstance(Object mh) throws InstantiationException { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
399 |
Constructor dmh = (Constructor)mh; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
400 |
return UNSAFE.allocateInstance(dmh.instanceClass); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
401 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
402 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
403 |
/** This subclass handles non-static field references. */ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
404 |
static class Accessor extends DirectMethodHandle { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
405 |
final Class<?> fieldType; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
406 |
final int fieldOffset; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
407 |
private Accessor(MethodType mtype, LambdaForm form, MemberName member, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
408 |
int fieldOffset) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
409 |
super(mtype, form, member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
410 |
this.fieldType = member.getFieldType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
411 |
this.fieldOffset = fieldOffset; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
412 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
413 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
414 |
@Override Object checkCast(Object obj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
415 |
return fieldType.cast(obj); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
416 |
} |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
417 |
@Override |
26470
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
418 |
MethodHandle copyWith(MethodType mt, LambdaForm lf) { |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
419 |
return new Accessor(mt, lf, member, fieldOffset); |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
420 |
} |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
421 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
422 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
423 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
424 |
/*non-public*/ static long fieldOffset(Object accessorObj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
425 |
// Note: We return a long because that is what Unsafe.getObject likes. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
426 |
// We store a plain int because it is more compact. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
427 |
return ((Accessor)accessorObj).fieldOffset; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
428 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
429 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
430 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
431 |
/*non-public*/ static Object checkBase(Object obj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
432 |
// Note that the object's class has already been verified, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
433 |
// since the parameter type of the Accessor method handle |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
434 |
// is either member.getDeclaringClass or a subclass. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
435 |
// This was verified in DirectMethodHandle.make. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
436 |
// Therefore, the only remaining check is for null. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
437 |
// Since this check is *not* guaranteed by Unsafe.getInt |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
438 |
// and its siblings, we need to make an explicit one here. |
29094
a4fd2b5e49f8
8073479: Replace obj.getClass hacks with Objects.requireNonNull
shade
parents:
29020
diff
changeset
|
439 |
return Objects.requireNonNull(obj); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
440 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
441 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
442 |
/** This subclass handles static field references. */ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
443 |
static class StaticAccessor extends DirectMethodHandle { |
32649
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30340
diff
changeset
|
444 |
private final Class<?> fieldType; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30340
diff
changeset
|
445 |
private final Object staticBase; |
2ee9017c7597
8136583: Core libraries should use blessed modifier order
martin
parents:
30340
diff
changeset
|
446 |
private final long staticOffset; |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
447 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
448 |
private StaticAccessor(MethodType mtype, LambdaForm form, MemberName member, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
449 |
Object staticBase, long staticOffset) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
450 |
super(mtype, form, member); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
451 |
this.fieldType = member.getFieldType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
452 |
this.staticBase = staticBase; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
453 |
this.staticOffset = staticOffset; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
454 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
455 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
456 |
@Override Object checkCast(Object obj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
457 |
return fieldType.cast(obj); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
458 |
} |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
459 |
@Override |
26470
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
460 |
MethodHandle copyWith(MethodType mt, LambdaForm lf) { |
1586df597397
8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
vlivanov
parents:
26469
diff
changeset
|
461 |
return new StaticAccessor(mt, lf, member, staticBase, staticOffset); |
16030
265a0d86c9ff
7087570: java.lang.invoke.MemberName information wrong for method handles created with findConstructor
kmo
parents:
14342
diff
changeset
|
462 |
} |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
463 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
464 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
465 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
466 |
/*non-public*/ static Object nullCheck(Object obj) { |
29094
a4fd2b5e49f8
8073479: Replace obj.getClass hacks with Objects.requireNonNull
shade
parents:
29020
diff
changeset
|
467 |
return Objects.requireNonNull(obj); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
468 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
469 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
470 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
471 |
/*non-public*/ static Object staticBase(Object accessorObj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
472 |
return ((StaticAccessor)accessorObj).staticBase; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
473 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
474 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
475 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
476 |
/*non-public*/ static long staticOffset(Object accessorObj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
477 |
return ((StaticAccessor)accessorObj).staticOffset; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
478 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
479 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
480 |
@ForceInline |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
481 |
/*non-public*/ static Object checkCast(Object mh, Object obj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
482 |
return ((DirectMethodHandle) mh).checkCast(obj); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
483 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
484 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
485 |
Object checkCast(Object obj) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
486 |
return member.getReturnType().cast(obj); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
487 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
488 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
489 |
// Caching machinery for field accessors: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
490 |
private static byte |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
491 |
AF_GETFIELD = 0, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
492 |
AF_PUTFIELD = 1, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
493 |
AF_GETSTATIC = 2, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
494 |
AF_PUTSTATIC = 3, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
495 |
AF_GETSTATIC_INIT = 4, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
496 |
AF_PUTSTATIC_INIT = 5, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
497 |
AF_LIMIT = 6; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
498 |
// Enumerate the different field kinds using Wrapper, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
499 |
// with an extra case added for checked references. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
500 |
private static int |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
501 |
FT_LAST_WRAPPER = Wrapper.values().length-1, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
502 |
FT_UNCHECKED_REF = Wrapper.OBJECT.ordinal(), |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
503 |
FT_CHECKED_REF = FT_LAST_WRAPPER+1, |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
504 |
FT_LIMIT = FT_LAST_WRAPPER+2; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
505 |
private static int afIndex(byte formOp, boolean isVolatile, int ftypeKind) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
506 |
return ((formOp * FT_LIMIT * 2) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
507 |
+ (isVolatile ? FT_LIMIT : 0) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
508 |
+ ftypeKind); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
509 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
510 |
private static final LambdaForm[] ACCESSOR_FORMS |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
511 |
= new LambdaForm[afIndex(AF_LIMIT, false, 0)]; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
512 |
private static int ftypeKind(Class<?> ftype) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
513 |
if (ftype.isPrimitive()) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
514 |
return Wrapper.forPrimitiveType(ftype).ordinal(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
515 |
else if (VerifyType.isNullReferenceConversion(Object.class, ftype)) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
516 |
return FT_UNCHECKED_REF; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
517 |
else |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
518 |
return FT_CHECKED_REF; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
519 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
520 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
521 |
/** |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
522 |
* Create a LF which can access the given field. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
523 |
* Cache and share this structure among all fields with |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
524 |
* the same basicType and refKind. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
525 |
*/ |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
526 |
private static LambdaForm preparedFieldLambdaForm(MemberName m) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
527 |
Class<?> ftype = m.getFieldType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
528 |
boolean isVolatile = m.isVolatile(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
529 |
byte formOp; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
530 |
switch (m.getReferenceKind()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
531 |
case REF_getField: formOp = AF_GETFIELD; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
532 |
case REF_putField: formOp = AF_PUTFIELD; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
533 |
case REF_getStatic: formOp = AF_GETSTATIC; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
534 |
case REF_putStatic: formOp = AF_PUTSTATIC; break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
535 |
default: throw new InternalError(m.toString()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
536 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
537 |
if (shouldBeInitialized(m)) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
538 |
// precompute the barrier-free version: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
539 |
preparedFieldLambdaForm(formOp, isVolatile, ftype); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
540 |
assert((AF_GETSTATIC_INIT - AF_GETSTATIC) == |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
541 |
(AF_PUTSTATIC_INIT - AF_PUTSTATIC)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
542 |
formOp += (AF_GETSTATIC_INIT - AF_GETSTATIC); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
543 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
544 |
LambdaForm lform = preparedFieldLambdaForm(formOp, isVolatile, ftype); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
545 |
maybeCompile(lform, m); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
546 |
assert(lform.methodType().dropParameterTypes(0, 1) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
547 |
.equals(m.getInvocationType().basicType())) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
548 |
: Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
549 |
return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
550 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
551 |
private static LambdaForm preparedFieldLambdaForm(byte formOp, boolean isVolatile, Class<?> ftype) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
552 |
int afIndex = afIndex(formOp, isVolatile, ftypeKind(ftype)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
553 |
LambdaForm lform = ACCESSOR_FORMS[afIndex]; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
554 |
if (lform != null) return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
555 |
lform = makePreparedFieldLambdaForm(formOp, isVolatile, ftypeKind(ftype)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
556 |
ACCESSOR_FORMS[afIndex] = lform; // don't bother with a CAS |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
557 |
return lform; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
558 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
559 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
560 |
private static LambdaForm makePreparedFieldLambdaForm(byte formOp, boolean isVolatile, int ftypeKind) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
561 |
boolean isGetter = (formOp & 1) == (AF_GETFIELD & 1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
562 |
boolean isStatic = (formOp >= AF_GETSTATIC); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
563 |
boolean needsInit = (formOp >= AF_GETSTATIC_INIT); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
564 |
boolean needsCast = (ftypeKind == FT_CHECKED_REF); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
565 |
Wrapper fw = (needsCast ? Wrapper.OBJECT : Wrapper.values()[ftypeKind]); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
566 |
Class<?> ft = fw.primitiveType(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
567 |
assert(ftypeKind(needsCast ? String.class : ft) == ftypeKind); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
568 |
String tname = fw.primitiveSimpleName(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
569 |
String ctname = Character.toUpperCase(tname.charAt(0)) + tname.substring(1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
570 |
if (isVolatile) ctname += "Volatile"; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
571 |
String getOrPut = (isGetter ? "get" : "put"); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
572 |
String linkerName = (getOrPut + ctname); // getObject, putIntVolatile, etc. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
573 |
MethodType linkerType; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
574 |
if (isGetter) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
575 |
linkerType = MethodType.methodType(ft, Object.class, long.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
576 |
else |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
577 |
linkerType = MethodType.methodType(void.class, Object.class, long.class, ft); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
578 |
MemberName linker = new MemberName(Unsafe.class, linkerName, linkerType, REF_invokeVirtual); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
579 |
try { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
580 |
linker = IMPL_NAMES.resolveOrFail(REF_invokeVirtual, linker, null, NoSuchMethodException.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
581 |
} catch (ReflectiveOperationException ex) { |
14089
0a41b980d62a
8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents:
13610
diff
changeset
|
582 |
throw newInternalError(ex); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
583 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
584 |
|
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
585 |
// What is the external type of the lambda form? |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
586 |
MethodType mtype; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
587 |
if (isGetter) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
588 |
mtype = MethodType.methodType(ft); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
589 |
else |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
590 |
mtype = MethodType.methodType(void.class, ft); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
591 |
mtype = mtype.basicType(); // erase short to int, etc. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
592 |
if (!isStatic) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
593 |
mtype = mtype.insertParameterTypes(0, Object.class); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
594 |
final int DMH_THIS = 0; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
595 |
final int ARG_BASE = 1; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
596 |
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
597 |
// if this is for non-static access, the base pointer is stored at this index: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
598 |
final int OBJ_BASE = isStatic ? -1 : ARG_BASE; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
599 |
// if this is for write access, the value to be written is stored at this index: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
600 |
final int SET_VALUE = isGetter ? -1 : ARG_LIMIT - 1; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
601 |
int nameCursor = ARG_LIMIT; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
602 |
final int F_HOLDER = (isStatic ? nameCursor++ : -1); // static base if any |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
603 |
final int F_OFFSET = nameCursor++; // Either static offset or field offset. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
604 |
final int OBJ_CHECK = (OBJ_BASE >= 0 ? nameCursor++ : -1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
605 |
final int INIT_BAR = (needsInit ? nameCursor++ : -1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
606 |
final int PRE_CAST = (needsCast && !isGetter ? nameCursor++ : -1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
607 |
final int LINKER_CALL = nameCursor++; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
608 |
final int POST_CAST = (needsCast && isGetter ? nameCursor++ : -1); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
609 |
final int RESULT = nameCursor-1; // either the call or the cast |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
610 |
Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
611 |
if (needsInit) |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
612 |
names[INIT_BAR] = new Name(NF_ensureInitialized, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
613 |
if (needsCast && !isGetter) |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
614 |
names[PRE_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[SET_VALUE]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
615 |
Object[] outArgs = new Object[1 + linkerType.parameterCount()]; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
616 |
assert(outArgs.length == (isGetter ? 3 : 4)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
617 |
outArgs[0] = UNSAFE; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
618 |
if (isStatic) { |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
619 |
outArgs[1] = names[F_HOLDER] = new Name(NF_staticBase, names[DMH_THIS]); |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
620 |
outArgs[2] = names[F_OFFSET] = new Name(NF_staticOffset, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
621 |
} else { |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
622 |
outArgs[1] = names[OBJ_CHECK] = new Name(NF_checkBase, names[OBJ_BASE]); |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
623 |
outArgs[2] = names[F_OFFSET] = new Name(NF_fieldOffset, names[DMH_THIS]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
624 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
625 |
if (!isGetter) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
626 |
outArgs[3] = (needsCast ? names[PRE_CAST] : names[SET_VALUE]); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
627 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
628 |
for (Object a : outArgs) assert(a != null); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
629 |
names[LINKER_CALL] = new Name(linker, outArgs); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
630 |
if (needsCast && isGetter) |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
631 |
names[POST_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[LINKER_CALL]); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
632 |
for (Name n : names) assert(n != null); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
633 |
String fieldOrStatic = (isStatic ? "Static" : "Field"); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
634 |
String lambdaName = (linkerName + fieldOrStatic); // significant only for debugging |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
635 |
if (needsCast) lambdaName += "Cast"; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
636 |
if (needsInit) lambdaName += "Init"; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
637 |
return new LambdaForm(lambdaName, ARG_LIMIT, names, RESULT); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
638 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
639 |
|
20495
6586c2f78d57
8024616: JSR292: lazily initialize core NamedFunctions used for bootstrapping
vlivanov
parents:
16484
diff
changeset
|
640 |
/** |
6586c2f78d57
8024616: JSR292: lazily initialize core NamedFunctions used for bootstrapping
vlivanov
parents:
16484
diff
changeset
|
641 |
* Pre-initialized NamedFunctions for bootstrapping purposes. |
6586c2f78d57
8024616: JSR292: lazily initialize core NamedFunctions used for bootstrapping
vlivanov
parents:
16484
diff
changeset
|
642 |
* Factored in an inner class to delay initialization until first usage. |
6586c2f78d57
8024616: JSR292: lazily initialize core NamedFunctions used for bootstrapping
vlivanov
parents:
16484
diff
changeset
|
643 |
*/ |
33841
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
644 |
static final NamedFunction |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
645 |
NF_internalMemberName, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
646 |
NF_internalMemberNameEnsureInit, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
647 |
NF_ensureInitialized, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
648 |
NF_fieldOffset, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
649 |
NF_checkBase, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
650 |
NF_staticBase, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
651 |
NF_staticOffset, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
652 |
NF_checkCast, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
653 |
NF_allocateInstance, |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
654 |
NF_constructorMethod; |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
655 |
static { |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
656 |
try { |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
657 |
NamedFunction nfs[] = { |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
658 |
NF_internalMemberName = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
659 |
.getDeclaredMethod("internalMemberName", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
660 |
NF_internalMemberNameEnsureInit = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
661 |
.getDeclaredMethod("internalMemberNameEnsureInit", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
662 |
NF_ensureInitialized = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
663 |
.getDeclaredMethod("ensureInitialized", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
664 |
NF_fieldOffset = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
665 |
.getDeclaredMethod("fieldOffset", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
666 |
NF_checkBase = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
667 |
.getDeclaredMethod("checkBase", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
668 |
NF_staticBase = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
669 |
.getDeclaredMethod("staticBase", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
670 |
NF_staticOffset = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
671 |
.getDeclaredMethod("staticOffset", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
672 |
NF_checkCast = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
673 |
.getDeclaredMethod("checkCast", Object.class, Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
674 |
NF_allocateInstance = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
675 |
.getDeclaredMethod("allocateInstance", Object.class)), |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
676 |
NF_constructorMethod = new NamedFunction(DirectMethodHandle.class |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
677 |
.getDeclaredMethod("constructorMethod", Object.class)) |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
678 |
}; |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
679 |
// Each nf must be statically invocable or we get tied up in our bootstraps. |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
680 |
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs)); |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
681 |
} catch (ReflectiveOperationException ex) { |
1d1d1ea6a5f2
8142334: Improve lazy initialization of java.lang.invoke
redestad
parents:
33674
diff
changeset
|
682 |
throw newInternalError(ex); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
8822
diff
changeset
|
683 |
} |
2707
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
684 |
} |
5a17df307cbc
6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff
changeset
|
685 |
} |