Mercurial > hg > truffle
comparison graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ResolvedMethodHandleCallTargetNode.java @ 20089:5ea03a00828a
allow direct call derived from constant MethodHandle if JDK version >= 1.8.0_60
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 30 Mar 2015 17:49:15 +0200 |
parents | 8470e81631f8 |
children |
comparison
equal
deleted
inserted
replaced
20081:8529bfcef6f5 | 20089:5ea03a00828a |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.graal.hotspot.nodes; | 23 package com.oracle.graal.hotspot.nodes; |
24 | 24 |
25 import static sun.misc.Version.*; | |
26 | |
25 import java.lang.invoke.*; | 27 import java.lang.invoke.*; |
26 | 28 |
27 import com.oracle.graal.api.meta.*; | 29 import com.oracle.graal.api.meta.*; |
28 import com.oracle.graal.compiler.common.*; | 30 import com.oracle.graal.compiler.common.*; |
29 import com.oracle.graal.graph.*; | 31 import com.oracle.graal.graph.*; |
33 import com.oracle.graal.nodes.java.*; | 35 import com.oracle.graal.nodes.java.*; |
34 import com.oracle.graal.nodes.spi.*; | 36 import com.oracle.graal.nodes.spi.*; |
35 | 37 |
36 /** | 38 /** |
37 * A call target that replaces itself in the graph when being lowered by restoring the original | 39 * A call target that replaces itself in the graph when being lowered by restoring the original |
38 * {@link MethodHandle} invocation target. This is required for when a {@link MethodHandle} call was | 40 * {@link MethodHandle} invocation target. Prior to |
39 * resolved to a constant target but the target was not inlined. In that case, the original | 41 * https://bugs.openjdk.java.net/browse/JDK-8072008, this is required for when a |
40 * invocation must be restored with all of its original arguments. Why? HotSpot linkage for | 42 * {@link MethodHandle} call is resolved to a constant target but the target was not inlined. In |
41 * {@link MethodHandle} intrinsics (see {@code MethodHandles::generate_method_handle_dispatch}) | 43 * that case, the original invocation must be restored with all of its original arguments. Why? |
42 * expects certain implicit arguments to be on the stack such as the MemberName suffix argument for | 44 * HotSpot linkage for {@link MethodHandle} intrinsics (see |
43 * a call to one of the MethodHandle.linkTo* methods. An | 45 * {@code MethodHandles::generate_method_handle_dispatch}) expects certain implicit arguments to be |
44 * {@linkplain MethodHandleNode#tryResolveTargetInvoke resolved} {@link MethodHandle} invocation | 46 * on the stack such as the MemberName suffix argument for a call to one of the MethodHandle.linkTo* |
45 * drops these arguments which means the interpreter won't find them. | 47 * methods. An {@linkplain MethodHandleNode#tryResolveTargetInvoke resolved} {@link MethodHandle} |
48 * invocation drops these arguments which means the interpreter won't find them. | |
46 */ | 49 */ |
47 @NodeInfo | 50 @NodeInfo |
48 public final class ResolvedMethodHandleCallTargetNode extends MethodCallTargetNode implements Lowerable { | 51 public final class ResolvedMethodHandleCallTargetNode extends MethodCallTargetNode implements Lowerable { |
49 | 52 |
50 public static final NodeClass<ResolvedMethodHandleCallTargetNode> TYPE = NodeClass.create(ResolvedMethodHandleCallTargetNode.class); | 53 public static final NodeClass<ResolvedMethodHandleCallTargetNode> TYPE = NodeClass.create(ResolvedMethodHandleCallTargetNode.class); |
54 | |
55 /** | |
56 * Creates a call target for an invocation on a direct target derived by resolving a constant | |
57 * {@link MethodHandle}. | |
58 */ | |
59 public static MethodCallTargetNode create(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod originalTargetMethod, | |
60 ValueNode[] originalArguments, JavaType originalReturnType) { | |
61 if (jdkMajorVersion() >= 1 && jdkMinorVersion() >= 8 && jdkMicroVersion() >= 0 && jdkUpdateVersion() >= 60) { | |
62 // https://bugs.openjdk.java.net/browse/JDK-8072008 is targeted for 8u60 | |
63 return new MethodCallTargetNode(invokeKind, targetMethod, arguments, returnType); | |
64 } | |
65 return new ResolvedMethodHandleCallTargetNode(invokeKind, targetMethod, arguments, returnType, originalTargetMethod, originalArguments, originalReturnType); | |
66 } | |
67 | |
51 protected final ResolvedJavaMethod originalTargetMethod; | 68 protected final ResolvedJavaMethod originalTargetMethod; |
52 protected final JavaType originalReturnType; | 69 protected final JavaType originalReturnType; |
53 @Input NodeInputList<ValueNode> originalArguments; | 70 @Input NodeInputList<ValueNode> originalArguments; |
54 | 71 |
55 public ResolvedMethodHandleCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod originalTargetMethod, | 72 protected ResolvedMethodHandleCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod originalTargetMethod, |
56 ValueNode[] originalArguments, JavaType originalReturnType) { | 73 ValueNode[] originalArguments, JavaType originalReturnType) { |
57 super(TYPE, invokeKind, targetMethod, arguments, returnType); | 74 super(TYPE, invokeKind, targetMethod, arguments, returnType); |
58 this.originalTargetMethod = originalTargetMethod; | 75 this.originalTargetMethod = originalTargetMethod; |
59 this.originalReturnType = originalReturnType; | 76 this.originalReturnType = originalReturnType; |
60 this.originalArguments = new NodeInputList<>(this, originalArguments); | 77 this.originalArguments = new NodeInputList<>(this, originalArguments); |