annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java @ 18530:2906b3cc3e2f

moved application of Remote marker interface to implementation classes only
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Nov 2014 13:20:14 +0100
parents f0a8b72315c1
children 7f4cb7587f4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.meta;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
24
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
18167
2bf5ea10eea7 sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
26 import static com.oracle.graal.hotspot.meta.HotSpotResolvedJavaType.*;
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
27 import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectTypeImpl.*;
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
28
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.compiler.common.*;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.hotspot.*;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
32
18530
2906b3cc3e2f moved application of Remote marker interface to implementation classes only
Doug Simon <doug.simon@oracle.com>
parents: 18465
diff changeset
33 public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, Remote {
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
34
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
35 private final ConstantReflectionProvider constantReflection;
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
36
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
37 public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) {
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
38 this.constantReflection = constantReflection;
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
39 }
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
40
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
41 /**
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
42 * Lazy initialization to break class initialization cycle. Field and method lookup is only
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
43 * possible after the {@link HotSpotGraalRuntime} is fully initialized.
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
44 */
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
45 static class LazyInitialization {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
46 static final ResolvedJavaField methodHandleFormField;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
47 static final ResolvedJavaField lambdaFormVmentryField;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
48 static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
49 static final ResolvedJavaField memberNameVmtargetField;
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 /**
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
52 * 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
53 *
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
54 * @param className name of the class to search in
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
55 * @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
56 * @return resolved java field
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
57 * @throws ClassNotFoundException
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
58 */
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
59 private static ResolvedJavaField findFieldInClass(String className, String fieldName) throws ClassNotFoundException {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
60 Class<?> clazz = Class.forName(className);
18167
2bf5ea10eea7 sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
61 ResolvedJavaType type = fromClass(clazz);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
62 ResolvedJavaField[] fields = type.getInstanceFields(false);
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
63 for (ResolvedJavaField field : fields) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
64 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
65 return field;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
66 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
67 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
68 return null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
69 }
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 private static ResolvedJavaMethod findMethodInClass(String className, String methodName) throws ClassNotFoundException {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
72 Class<?> clazz = Class.forName(className);
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
73 HotSpotResolvedObjectTypeImpl type = fromObjectClass(clazz);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
74 ResolvedJavaMethod result = null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
75 for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
76 if (method.getName().equals(methodName)) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
77 assert result == null : "more than one method found: " + className + "." + methodName;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
78 result = method;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
79 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
80 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
81 assert result != null : "method not found: " + className + "." + methodName;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
82 return result;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
83 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
84
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
85 static {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
86 try {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
87 methodHandleFormField = findFieldInClass("java.lang.invoke.MethodHandle", "form");
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
88 lambdaFormVmentryField = findFieldInClass("java.lang.invoke.LambdaForm", "vmentry");
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
89 lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode");
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
90 memberNameVmtargetField = findFieldInClass("java.lang.invoke.MemberName", "vmtarget");
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
91 } catch (Throwable ex) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
92 throw GraalInternalError.shouldNotReachHere();
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) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
101 HotSpotVMConfig config = runtime().getConfig();
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
102 if (intrinsicId == config.vmIntrinsicInvokeBasic) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
103 return IntrinsicMethod.INVOKE_BASIC;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
104 } else if (intrinsicId == config.vmIntrinsicLinkToInterface) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
105 return IntrinsicMethod.LINK_TO_INTERFACE;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
106 } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
107 return IntrinsicMethod.LINK_TO_SPECIAL;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
108 } else if (intrinsicId == config.vmIntrinsicLinkToStatic) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
109 return IntrinsicMethod.LINK_TO_STATIC;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
110 } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
111 return IntrinsicMethod.LINK_TO_VIRTUAL;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
112 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
113 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
114 return null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
115 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
116
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
117 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
118 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
119 if (methodHandle.isNull()) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
120 return null;
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
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
123 /* 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
124 JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
125 if (lambdaForm.isNull()) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
126 return null;
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
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
129 JavaConstant memberName;
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
130 if (forceBytecodeGeneration) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
131 /* Invoke non-public method: MemberName LambdaForm.compileToBytecode() */
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
132 memberName = LazyInitialization.lambdaFormCompileToBytecodeMethod.invoke(lambdaForm, new JavaConstant[0]);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
133 } else {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
134 /* Load non-public field: MemberName LambdaForm.vmentry */
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
135 memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
136 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
137 return getTargetMethod(memberName);
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
138 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
139
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
140 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
141 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
142 return getTargetMethod(memberName);
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
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
145 /**
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
146 * 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
147 */
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
148 private 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
149 if (memberName.isNull()) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
150 return null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
151 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
152
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
153 /* Load injected field: JVM_Method* MemberName.vmtarget */
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
154 JavaConstant vmtarget = constantReflection.readFieldValue(LazyInitialization.memberNameVmtargetField, memberName);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
155 /* Create a method from the vmtarget method pointer. */
18222
a8cff27ca2e1 converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
156 return HotSpotResolvedJavaMethodImpl.fromMetaspace(vmtarget.asLong());
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
157 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
158 }