Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java @ 23749:d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 07 Sep 2016 15:17:13 +0200 |
parents | 1d4ce2d19e52 |
children |
rev | line source |
---|---|
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
24 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
27 |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
28 import java.lang.invoke.MethodHandle; |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
29 import java.util.Objects; |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
30 |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
31 import jdk.vm.ci.common.JVMCIError; |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
32 import jdk.vm.ci.meta.ConstantReflectionProvider; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
33 import jdk.vm.ci.meta.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
34 import jdk.vm.ci.meta.MethodHandleAccessProvider; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
35 import jdk.vm.ci.meta.ResolvedJavaField; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
36 import jdk.vm.ci.meta.ResolvedJavaMethod; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22582
diff
changeset
|
37 import jdk.vm.ci.meta.ResolvedJavaType; |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
38 |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
39 public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider { |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
41 private final ConstantReflectionProvider constantReflection; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
42 |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
43 public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
44 this.constantReflection = constantReflection; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
45 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
46 |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
47 /** |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
48 * Lazy initialization to break class initialization cycle. Field and method lookup is only |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
49 * possible after the {@link HotSpotJVMCIRuntime} is fully initialized. |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 */ |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 static class LazyInitialization { |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
52 static final ResolvedJavaType lambdaFormType; |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
53 static final ResolvedJavaField methodHandleFormField; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
54 static final ResolvedJavaField lambdaFormVmentryField; |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22422
diff
changeset
|
55 static final HotSpotResolvedJavaField memberNameVmtargetField; |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
56 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 /** |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
58 * Search for an instance field with the given name in a class. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
59 * |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
60 * @param declaringType the type declaring the field |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 * @param fieldName name of the field to be searched |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 * @return resolved java field |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
63 * @throws NoSuchFieldError |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 */ |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
65 private static ResolvedJavaField findFieldInClass(ResolvedJavaType declaringType, String fieldName, ResolvedJavaType fieldType) { |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
66 ResolvedJavaField[] fields = declaringType.getInstanceFields(false); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 for (ResolvedJavaField field : fields) { |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
68 if (field.getName().equals(fieldName)) { |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
69 return field; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
70 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
71 } |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
72 throw new NoSuchFieldError(fieldType.getName() + " " + declaringType + "." + fieldName); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
73 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
74 |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
75 private static ResolvedJavaType resolveType(Class<?> c) { |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
76 return runtime().fromClass(c); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
77 } |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
78 |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
79 private static ResolvedJavaType resolveType(String className) throws ClassNotFoundException { |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
80 return resolveType(Class.forName(className)); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
81 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
82 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 static { |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
84 try { |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
85 ResolvedJavaType methodHandleType = resolveType(MethodHandle.class); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
86 ResolvedJavaType memberNameType = resolveType("java.lang.invoke.MemberName"); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
87 lambdaFormType = resolveType("java.lang.invoke.LambdaForm"); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
88 methodHandleFormField = findFieldInClass(methodHandleType, "form", lambdaFormType); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
89 lambdaFormVmentryField = findFieldInClass(lambdaFormType, "vmentry", memberNameType); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
90 memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass(memberNameType, "vmtarget", resolveType(long.class)); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 } catch (Throwable ex) { |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
92 throw new JVMCIError(ex); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
93 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
94 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
95 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
96 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
97 @Override |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
98 public IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method) { |
18222
a8cff27ca2e1
converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
99 int intrinsicId = ((HotSpotResolvedJavaMethodImpl) method).intrinsicId(); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
100 if (intrinsicId != 0) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
101 return getMethodHandleIntrinsic(intrinsicId); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
102 } |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
103 return null; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
104 } |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
105 |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
106 public static IntrinsicMethod getMethodHandleIntrinsic(int intrinsicId) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
107 HotSpotVMConfig config = runtime().getConfig(); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
108 if (intrinsicId == config.vmIntrinsicInvokeBasic) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
109 return IntrinsicMethod.INVOKE_BASIC; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
110 } else if (intrinsicId == config.vmIntrinsicLinkToInterface) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
111 return IntrinsicMethod.LINK_TO_INTERFACE; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
112 } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
113 return IntrinsicMethod.LINK_TO_SPECIAL; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
114 } else if (intrinsicId == config.vmIntrinsicLinkToStatic) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
115 return IntrinsicMethod.LINK_TO_STATIC; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
116 } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
117 return IntrinsicMethod.LINK_TO_VIRTUAL; |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
118 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
119 return null; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
120 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
121 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
122 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
123 public ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration) { |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
124 if (methodHandle.isNull()) { |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
125 return null; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
126 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
127 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
128 /* Load non-public field: LambdaForm MethodHandle.form */ |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
129 JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle); |
23363
56479400913e
jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
130 if (lambdaForm == null || lambdaForm.isNull()) { |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
131 return null; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
132 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
133 |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
134 JavaConstant memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
135 if (memberName.isNull() && forceBytecodeGeneration) { |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
136 Object lf = ((HotSpotObjectConstant) lambdaForm).asObject(LazyInitialization.lambdaFormType); |
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
137 compilerToVM().compileToBytecode(Objects.requireNonNull(lf)); |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18258
diff
changeset
|
138 memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm); |
23749
d6bd0b9cd0b6
remove uses of setAccessible (JDK-8165434)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
139 assert memberName.isNonNull(); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
140 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
141 return getTargetMethod(memberName); |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
142 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
143 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
144 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
145 public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) { |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
146 return getTargetMethod(memberName); |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
147 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
148 |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
149 /** |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
150 * Returns the {@link ResolvedJavaMethod} for the vmtarget of a java.lang.invoke.MemberName. |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
151 */ |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22422
diff
changeset
|
152 private static ResolvedJavaMethod getTargetMethod(JavaConstant memberName) { |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
153 if (memberName.isNull()) { |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
154 return null; |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
155 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
156 |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22422
diff
changeset
|
157 Object object = ((HotSpotObjectConstantImpl) memberName).object(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22422
diff
changeset
|
158 /* Read the ResolvedJavaMethod from the injected field MemberName.vmtarget */ |
22582
232c53e17ea0
added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
159 return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset()); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
160 } |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
161 } |