annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java @ 18465:f0a8b72315c1

Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
author Andreas Woess <andreas.woess@jku.at>
date Wed, 19 Nov 2014 17:00:12 +0100
parents 6faee2dcebbf
children 3fb1231699de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
1 /*
16252
a762ddb12b43 change some node types from Canonicalizable to Simplifiable
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15481
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
4 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
8 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
13 * accompanied this code).
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
14 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
18 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
21 * questions.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
22 */
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
23 package com.oracle.graal.hotspot.replacements;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
24
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
25 import java.lang.invoke.*;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
26 import java.util.*;
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
27
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
28 import com.oracle.graal.api.meta.*;
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
29 import com.oracle.graal.api.meta.MethodHandleAccessProvider.IntrinsicMethod;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15018
diff changeset
30 import com.oracle.graal.compiler.common.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15260
diff changeset
31 import com.oracle.graal.compiler.common.type.*;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
32 import com.oracle.graal.graph.*;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11265
diff changeset
33 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16811
diff changeset
34 import com.oracle.graal.nodeinfo.*;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
35 import com.oracle.graal.nodes.*;
16563
1e63cb55f61d Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16329
diff changeset
36 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
37 import com.oracle.graal.nodes.java.*;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9784
diff changeset
38 import com.oracle.graal.nodes.type.*;
16252
a762ddb12b43 change some node types from Canonicalizable to Simplifiable
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15481
diff changeset
39 import com.oracle.graal.nodes.util.*;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
40 import com.oracle.graal.replacements.nodes.*;
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
41
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
42 /**
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
43 * Node for invocation methods defined on the class {@link MethodHandle}.
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
44 */
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16563
diff changeset
45 @NodeInfo
16290
e6622e77e8c7 split MacroNode into MacroNode and MacroStateSplitNode
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16252
diff changeset
46 public class MethodHandleNode extends MacroStateSplitNode implements Simplifiable {
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
47
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
48 // Replacement method data
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
49 protected ResolvedJavaMethod replacementTargetMethod;
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
50 protected JavaType replacementReturnType;
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
51 @Input NodeInputList<ValueNode> replacementArguments;
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
52
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
53 public static MethodHandleNode create(Invoke invoke) {
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
54 return new MethodHandleNode(invoke);
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
55 }
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
56
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
57 protected MethodHandleNode(Invoke invoke) {
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
58 super(invoke);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
59
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
60 MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
61
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
62 // See if we need to save some replacement method data.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
63 if (callTarget instanceof SelfReplacingMethodCallTargetNode) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
64 SelfReplacingMethodCallTargetNode selfReplacingMethodCallTargetNode = (SelfReplacingMethodCallTargetNode) callTarget;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
65 replacementTargetMethod = selfReplacingMethodCallTargetNode.replacementTargetMethod();
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
66 replacementReturnType = selfReplacingMethodCallTargetNode.replacementReturnType();
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
67 replacementArguments = selfReplacingMethodCallTargetNode.replacementArguments();
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
68 } else {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
69 // NodeInputList can't be null.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
70 replacementArguments = new NodeInputList<>(this);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
71 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
72 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
73
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
74 /**
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
75 * Returns the method handle method intrinsic identifier for the provided method, or
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
76 * {@code null} if the method is not a method that can be handled by this class.
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
77 */
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
78 public static IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method, MethodHandleAccessProvider methodHandleAccess) {
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
79 return methodHandleAccess.lookupMethodHandleIntrinsic(method);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
80 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
81
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
82 @Override
16252
a762ddb12b43 change some node types from Canonicalizable to Simplifiable
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15481
diff changeset
83 public void simplify(SimplifierTool tool) {
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
84 InvokeNode invoke;
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
85 IntrinsicMethod intrinsicMethod = lookupMethodHandleIntrinsic(targetMethod, tool.getConstantReflection().getMethodHandleAccess());
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
86 switch (intrinsicMethod) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
87 case INVOKE_BASIC:
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
88 invoke = getInvokeBasicTarget(tool, intrinsicMethod);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
89 break;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
90 case LINK_TO_STATIC:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
91 case LINK_TO_SPECIAL:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
92 case LINK_TO_VIRTUAL:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
93 case LINK_TO_INTERFACE:
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
94 invoke = getLinkToTarget(tool, intrinsicMethod);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
95 break;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
96 default:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
97 throw GraalInternalError.shouldNotReachHere();
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
98 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
99 if (invoke != null) {
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
100 FixedNode currentNext = next();
16252
a762ddb12b43 change some node types from Canonicalizable to Simplifiable
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15481
diff changeset
101 replaceAtUsages(invoke);
a762ddb12b43 change some node types from Canonicalizable to Simplifiable
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15481
diff changeset
102 GraphUtil.removeFixedWithUnusedInputs(this);
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
103 graph().addBeforeFixed(currentNext, invoke);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
104 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
105 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
106
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
107 /**
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
108 * Get the receiver of a MethodHandle.invokeBasic call.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
109 *
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
110 * @return the receiver argument node
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
111 */
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
112 private ValueNode getReceiver() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
113 return arguments.first();
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
114 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
115
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
116 /**
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
117 * Get the MemberName argument of a MethodHandle.linkTo* call.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
118 *
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
119 * @return the MemberName argument node (which is the last argument)
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
120 */
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
121 private ValueNode getMemberName() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
122 return arguments.last();
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
123 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
124
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
125 /**
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
126 * Used for the MethodHandle.invokeBasic method (the {@link IntrinsicMethod#INVOKE_BASIC }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
127 * method) to get the target {@link InvokeNode} if the method handle receiver is constant.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
128 *
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
129 * @return invoke node for the {@link java.lang.invoke.MethodHandle} target
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
130 */
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
131 protected InvokeNode getInvokeBasicTarget(SimplifierTool tool, IntrinsicMethod intrinsicMethod) {
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
132 ValueNode methodHandleNode = getReceiver();
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
133 if (methodHandleNode.isConstant()) {
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
134 return getTargetInvokeNode(tool.getConstantReflection().getMethodHandleAccess().resolveInvokeBasicTarget(methodHandleNode.asJavaConstant(), false), intrinsicMethod);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
135 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
136 return null;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
137 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
138
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
139 /**
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
140 * Used for the MethodHandle.linkTo* methods (the {@link IntrinsicMethod#LINK_TO_STATIC},
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
141 * {@link IntrinsicMethod#LINK_TO_SPECIAL}, {@link IntrinsicMethod#LINK_TO_VIRTUAL}, and
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
142 * {@link IntrinsicMethod#LINK_TO_INTERFACE} methods) to get the target {@link InvokeNode} if
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
143 * the member name argument is constant.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
144 *
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
145 * @return invoke node for the member name target
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
146 */
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
147 protected InvokeNode getLinkToTarget(SimplifierTool tool, IntrinsicMethod intrinsicMethod) {
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
148 ValueNode memberNameNode = getMemberName();
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
149 if (memberNameNode.isConstant()) {
18465
f0a8b72315c1 Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents: 18258
diff changeset
150 return getTargetInvokeNode(tool.getConstantReflection().getMethodHandleAccess().resolveLinkToTarget(memberNameNode.asJavaConstant()), intrinsicMethod);
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
151 }
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
152 return null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
153 }
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
154
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
155 /**
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
156 * Helper function to get the {@link InvokeNode} for the targetMethod of a
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
157 * java.lang.invoke.MemberName.
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
158 *
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
159 * @param target the target, already loaded from the member name node
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
160 * @return invoke node for the member name target
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
161 */
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
162 private InvokeNode getTargetInvokeNode(ResolvedJavaMethod target, IntrinsicMethod intrinsicMethod) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
163 if (target == null) {
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
164 return null;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
165 }
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
166
13656
cd14eb248cec get holder class from metaspace method when resolving MemberName target method; not necessarily the same as MemberName.clazz
Andreas Woess <andreas.woess@jku.at>
parents: 11881
diff changeset
167 // In lambda forms we erase signature types to avoid resolving issues
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
168 // involving class loaders. When we optimize a method handle invoke
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
169 // to a direct call we must cast the receiver and arguments to its
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
170 // actual types.
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
171 Signature signature = target.getSignature();
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
172 final boolean isStatic = target.isStatic();
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
173 final int receiverSkip = isStatic ? 0 : 1;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
174
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
175 // Cast receiver to its type.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
176 if (!isStatic) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
177 JavaType receiverType = target.getDeclaringClass();
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
178 maybeCastArgument(0, receiverType);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
179 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
180
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
181 // Cast reference arguments to its type.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
182 for (int index = 0; index < signature.getParameterCount(false); index++) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
183 JavaType parameterType = signature.getParameterType(index, target.getDeclaringClass());
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
184 maybeCastArgument(receiverSkip + index, parameterType);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
185 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
186
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
187 // Try to get the most accurate receiver type
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
188 if (intrinsicMethod == IntrinsicMethod.LINK_TO_VIRTUAL || intrinsicMethod == IntrinsicMethod.LINK_TO_INTERFACE) {
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
189 ResolvedJavaType receiverType = StampTool.typeOrNull(getReceiver().stamp());
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
190 if (receiverType != null) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
191 ResolvedJavaMethod concreteMethod = receiverType.findUniqueConcreteMethod(target);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
192 if (concreteMethod != null) {
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
193 return createTargetInvokeNode(concreteMethod, intrinsicMethod);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
194 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
195 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
196 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
197
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
198 if (target.canBeStaticallyBound()) {
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
199 return createTargetInvokeNode(target, intrinsicMethod);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
200 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
201
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
202 ResolvedJavaMethod concreteMethod = target.getDeclaringClass().findUniqueConcreteMethod(target);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
203 if (concreteMethod != null) {
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
204 return createTargetInvokeNode(concreteMethod, intrinsicMethod);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
205 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
206
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
207 return null;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
208 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
209
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
210 /**
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
211 * Inserts a node to cast the argument at index to the given type if the given type is more
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
212 * concrete than the argument type.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
213 *
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
214 * @param index of the argument to be cast
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
215 * @param type the type the argument should be cast to
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
216 */
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
217 private void maybeCastArgument(int index, JavaType type) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
218 if (type instanceof ResolvedJavaType) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
219 ResolvedJavaType targetType = (ResolvedJavaType) type;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
220 if (!targetType.isPrimitive()) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
221 ValueNode argument = arguments.get(index);
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
222 ResolvedJavaType argumentType = StampTool.typeOrNull(argument.stamp());
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
223 if (argumentType == null || (argumentType.isAssignableFrom(targetType) && !argumentType.equals(targetType))) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
224 PiNode piNode = graph().unique(PiNode.create(argument, StampFactory.declared(targetType)));
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
225 arguments.set(index, piNode);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
226 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
227 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
228 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
229 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
230
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
231 /**
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
232 * Creates an {@link InvokeNode} for the given target method. The {@link CallTargetNode} passed
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
233 * to the InvokeNode is in fact a {@link SelfReplacingMethodCallTargetNode}.
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
234 *
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
235 * @param target the method to be called
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
236 * @return invoke node for the member name target
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
237 */
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
238 private InvokeNode createTargetInvokeNode(ResolvedJavaMethod target, IntrinsicMethod intrinsicMethod) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
239 InvokeKind targetInvokeKind = target.isStatic() ? InvokeKind.Static : InvokeKind.Special;
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
240 JavaType targetReturnType = target.getSignature().getReturnType(null);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
241
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
242 // MethodHandleLinkTo* nodes have a trailing MemberName argument which
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
243 // needs to be popped.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
244 ValueNode[] originalArguments = arguments.toArray(new ValueNode[arguments.size()]);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
245 ValueNode[] targetArguments;
15481
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
246 switch (intrinsicMethod) {
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
247 case INVOKE_BASIC:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
248 targetArguments = originalArguments;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
249 break;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
250 case LINK_TO_STATIC:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
251 case LINK_TO_SPECIAL:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
252 case LINK_TO_VIRTUAL:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
253 case LINK_TO_INTERFACE:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
254 targetArguments = Arrays.copyOfRange(originalArguments, 0, arguments.size() - 1);
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
255 break;
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
256 default:
09d721bcffe2 Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15311
diff changeset
257 throw GraalInternalError.shouldNotReachHere();
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
258 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
259
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
260 // If there is already replacement information, use that instead.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
261 MethodCallTargetNode callTarget;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
262 if (replacementTargetMethod == null) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
263 callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, targetReturnType, getTargetMethod(), originalArguments, getReturnType());
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
264 } else {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
265 ValueNode[] args = replacementArguments.toArray(new ValueNode[replacementArguments.size()]);
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
266 callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, targetReturnType, replacementTargetMethod, args, replacementReturnType);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
267 }
9784
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
268 graph().add(callTarget);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
269
9784
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
270 // The call target can have a different return type than the invoker,
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
271 // e.g. the target returns an Object but the invoker void. In this case
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
272 // we need to use the stamp of the invoker. Note: always using the
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
273 // invoker's stamp would be wrong because it's a less concrete type
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
274 // (usually java.lang.Object).
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
275 InvokeNode invoke;
14022
2b5b3fcd65ba Separate singleton stamp for the void type.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
276 if (stamp() == StampFactory.forVoid()) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
277 invoke = InvokeNode.create(callTarget, getBci(), stamp());
9784
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
278 } else {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
279 invoke = InvokeNode.create(callTarget, getBci());
9784
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
280 }
747b2517feae use invoker's stamp if target's return stamp is of different type
twisti
parents: 9715
diff changeset
281 graph().add(invoke);
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
282 invoke.setStateAfter(stateAfter());
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
283 return invoke;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
284 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
285
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
286 }