5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.*;
26 import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.*;
27
28 import jdk.vm.ci.common.*;
29 import jdk.vm.ci.meta.*;
30
31 public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified {
32
33 private final ConstantReflectionProvider constantReflection;
34
35 public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) {
36 this.constantReflection = constantReflection;
37 }
38
39 /**
40 * Lazy initialization to break class initialization cycle. Field and method lookup is only
41 * possible after the {@link HotSpotJVMCIRuntime} is fully initialized.
42 */
43 static class LazyInitialization {
44 static final ResolvedJavaField methodHandleFormField;
45 static final ResolvedJavaField lambdaFormVmentryField;
46 static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod;
47 static final HotSpotResolvedJavaField memberNameVmtargetField;
48
49 /**
138 memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
139 }
140 return getTargetMethod(memberName);
141 }
142
143 @Override
144 public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) {
145 return getTargetMethod(memberName);
146 }
147
148 /**
149 * Returns the {@link ResolvedJavaMethod} for the vmtarget of a java.lang.invoke.MemberName.
150 */
151 private static ResolvedJavaMethod getTargetMethod(JavaConstant memberName) {
152 if (memberName.isNull()) {
153 return null;
154 }
155
156 Object object = ((HotSpotObjectConstantImpl) memberName).object();
157 /* Read the ResolvedJavaMethod from the injected field MemberName.vmtarget */
158 return runtime().compilerToVm.getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset());
159 }
160 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
27 import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass;
28 import jdk.vm.ci.common.JVMCIError;
29 import jdk.vm.ci.meta.ConstantReflectionProvider;
30 import jdk.vm.ci.meta.JavaConstant;
31 import jdk.vm.ci.meta.MethodHandleAccessProvider;
32 import jdk.vm.ci.meta.ResolvedJavaField;
33 import jdk.vm.ci.meta.ResolvedJavaMethod;
34 import jdk.vm.ci.meta.ResolvedJavaType;
35
36 public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified {
37
38 private final ConstantReflectionProvider constantReflection;
39
40 public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) {
41 this.constantReflection = constantReflection;
42 }
43
44 /**
45 * Lazy initialization to break class initialization cycle. Field and method lookup is only
46 * possible after the {@link HotSpotJVMCIRuntime} is fully initialized.
47 */
48 static class LazyInitialization {
49 static final ResolvedJavaField methodHandleFormField;
50 static final ResolvedJavaField lambdaFormVmentryField;
51 static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod;
52 static final HotSpotResolvedJavaField memberNameVmtargetField;
53
54 /**
143 memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
144 }
145 return getTargetMethod(memberName);
146 }
147
148 @Override
149 public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) {
150 return getTargetMethod(memberName);
151 }
152
153 /**
154 * Returns the {@link ResolvedJavaMethod} for the vmtarget of a java.lang.invoke.MemberName.
155 */
156 private static ResolvedJavaMethod getTargetMethod(JavaConstant memberName) {
157 if (memberName.isNull()) {
158 return null;
159 }
160
161 Object object = ((HotSpotObjectConstantImpl) memberName).object();
162 /* Read the ResolvedJavaMethod from the injected field MemberName.vmtarget */
163 return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset());
164 }
165 }
|