Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java @ 22604:b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Tue, 08 Sep 2015 19:57:39 +0200 |
parents | b611fa9fef24 |
children | 9055e22b8661 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8409
diff
changeset
|
23 package com.oracle.graal.replacements; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22054 | 25 import static jdk.internal.jvmci.meta.MetaUtil.*; |
9350
e7c396ce0f3d
better error message for incorrect usage of @NodeIntrinsic
Doug Simon <doug.simon@oracle.com>
parents:
9147
diff
changeset
|
26 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.lang.reflect.*; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
28 import java.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
22054 | 30 import jdk.internal.jvmci.common.*; |
22317
e02fa353e88c
Pull ForeignCallsProvider and friends back into Graal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22300
diff
changeset
|
31 |
22300
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
32 import com.oracle.graal.debug.*; |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
33 import com.oracle.graal.debug.internal.*; |
22317
e02fa353e88c
Pull ForeignCallsProvider and friends back into Graal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22300
diff
changeset
|
34 |
22054 | 35 import jdk.internal.jvmci.meta.*; |
36 | |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14978
diff
changeset
|
37 import com.oracle.graal.api.replacements.*; |
22317
e02fa353e88c
Pull ForeignCallsProvider and friends back into Graal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22300
diff
changeset
|
38 import com.oracle.graal.compiler.common.spi.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
39 import com.oracle.graal.compiler.common.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 import com.oracle.graal.graph.*; |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14953
diff
changeset
|
41 import com.oracle.graal.graph.Node.ConstantNodeParameter; |
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14953
diff
changeset
|
42 import com.oracle.graal.graph.Node.InjectedNodeParameter; |
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14953
diff
changeset
|
43 import com.oracle.graal.graph.Node.NodeIntrinsic; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
44 import com.oracle.graal.nodes.*; |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
45 import com.oracle.graal.nodes.calc.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
46 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
47 import com.oracle.graal.nodes.java.*; |
18496
59ffee3765ec
LoadHubNode should always use StampProvider stamp
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18487
diff
changeset
|
48 import com.oracle.graal.nodes.spi.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
49 import com.oracle.graal.nodes.util.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
50 import com.oracle.graal.phases.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
8409
c3fc0e257800
rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents:
8378
diff
changeset
|
52 /** |
c3fc0e257800
rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents:
8378
diff
changeset
|
53 * Replaces calls to {@link NodeIntrinsic}s with nodes and calls to methods annotated with |
c3fc0e257800
rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents:
8378
diff
changeset
|
54 * {@link Fold} with the result of invoking the annotated method via reflection. |
c3fc0e257800
rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents:
8378
diff
changeset
|
55 */ |
c3fc0e257800
rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents:
8378
diff
changeset
|
56 public class NodeIntrinsificationPhase extends Phase { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
58 private final MetaAccessProvider metaAccess; |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
59 private final ConstantReflectionProvider constantReflection; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14978
diff
changeset
|
60 private final SnippetReflectionProvider snippetReflection; |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
61 private final ForeignCallsProvider foreignCalls; |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
62 private final StampProvider stampProvider; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
64 public NodeIntrinsificationPhase(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
65 StampProvider stampProvider) { |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
66 this.metaAccess = metaAccess; |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
67 this.constantReflection = constantReflection; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14978
diff
changeset
|
68 this.snippetReflection = snippetReflection; |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
69 this.foreignCalls = foreignCalls; |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
70 this.stampProvider = stampProvider; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 protected void run(StructuredGraph graph) { |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
75 ArrayList<Node> cleanUpReturnList = new ArrayList<>(); |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19357
diff
changeset
|
76 for (MethodCallTargetNode node : graph.getNodes(MethodCallTargetNode.TYPE)) { |
9147
07f05f2a8149
Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9101
diff
changeset
|
77 tryIntrinsify(node, cleanUpReturnList); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
78 } |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
79 |
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
80 for (Node node : cleanUpReturnList) { |
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
81 cleanUpReturnCheckCast(node); |
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
82 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
83 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
84 |
11588 | 85 protected boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List<Node> cleanUpReturnList) { |
9147
07f05f2a8149
Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9101
diff
changeset
|
86 ResolvedJavaMethod target = methodCallTargetNode.targetMethod(); |
7027
58dbea9fb973
CompilerToVM.lookupType() now fails with an exception if eagerResolve is true and resolution fails
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
87 ResolvedJavaType declaringClass = target.getDeclaringClass(); |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
88 StructuredGraph graph = methodCallTargetNode.graph(); |
14952
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
89 |
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
90 NodeIntrinsic intrinsic = getIntrinsic(target); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 if (intrinsic != null) { |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
92 Stamp stamp = methodCallTargetNode.invoke().asNode().stamp(); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
93 Node newInstance = createIntrinsicNode(methodCallTargetNode.arguments(), stamp, target, graph, intrinsic); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
94 if (newInstance == null) { |
8175
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
95 return false; |
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
96 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 // Replace the invoke with the new node. |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
99 newInstance = graph.addOrUnique(newInstance); |
9147
07f05f2a8149
Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9101
diff
changeset
|
100 methodCallTargetNode.invoke().intrinsify(newInstance); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 // Clean up checkcast instructions inserted by javac if the return type is generic. |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
103 cleanUpReturnList.add(newInstance); |
11588 | 104 } else if (isFoldable(target)) { |
16486
d3fc4779fc60
moved signatureToTypes(ResolvedJavaMethod method) from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16484
diff
changeset
|
105 ResolvedJavaType[] parameterTypes = resolveJavaTypes(target.toParameterTypes(), declaringClass); |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
106 JavaConstant constant = tryFold(methodCallTargetNode.arguments(), parameterTypes, target); |
19421
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
107 if (constant != null && constant.equals(COULD_NOT_FOLD)) { |
8175
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
108 return false; |
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
109 } |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
110 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
111 if (constant != null) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
112 // Replace the invoke with the result of the call |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
113 ConstantNode node = ConstantNode.forConstant(constant, metaAccess, methodCallTargetNode.graph()); |
9147
07f05f2a8149
Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9101
diff
changeset
|
114 methodCallTargetNode.invoke().intrinsify(node); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
115 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
116 // Clean up checkcast instructions inserted by javac if the return type is generic. |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
117 cleanUpReturnList.add(node); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
118 } else { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
119 // Remove the invoke |
9147
07f05f2a8149
Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9101
diff
changeset
|
120 methodCallTargetNode.invoke().intrinsify(null); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
121 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 } |
8175
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
123 return true; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
126 public static final JavaConstant COULD_NOT_FOLD = new PrimitiveConstant(JavaKind.Illegal, 100) { |
19421
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
127 @Override |
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
128 public boolean equals(Object o) { |
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
129 return this == o; |
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
130 } |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
131 }; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
132 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
133 public JavaConstant tryFold(List<ValueNode> args, ResolvedJavaType[] parameterTypes, ResolvedJavaMethod target) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
134 JavaConstant[] reflectArgs = (JavaConstant[]) prepareArguments(args, parameterTypes, target, true); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
135 if (reflectArgs == null) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
136 return COULD_NOT_FOLD; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
137 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
138 JavaConstant receiver = null; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
139 if (!target.isStatic()) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
140 receiver = reflectArgs[0]; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
141 reflectArgs = Arrays.copyOfRange(reflectArgs, 1, reflectArgs.length); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
142 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
143 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
144 // Call the method |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
145 return target.invoke(receiver, reflectArgs); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
146 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
147 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
148 private static boolean areAllConstant(List<ValueNode> arguments) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
149 for (ValueNode arg : arguments) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
150 if (!arg.isConstant()) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
151 return false; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
152 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
153 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
154 return true; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
155 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
156 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
157 /** |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
158 * Attempts to create a node to replace a call to a {@link NodeIntrinsic} annotated method. |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
159 * |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
160 * @param arguments the arguments of the call |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
161 * @param stamp the stamp to use for the returned node |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
162 * @param method the method annotated with {@link NodeIntrinsic} |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
163 * @param graph the graph into which the created node will be added |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
164 * @return a {@link ConstantNode} if the intrinsic could be |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
165 * {@linkplain NodeIntrinsic#foldable() folded}, {@code null} if intrinsification could |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
166 * not (yet) be performed, otherwise the node representing the intrinsic |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
167 */ |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
168 public ValueNode createIntrinsicNode(List<ValueNode> arguments, Stamp stamp, ResolvedJavaMethod method, StructuredGraph graph, NodeIntrinsic intrinsic) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
169 assert method.getAnnotation(Fold.class) == null; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
170 assert method.isStatic() : "node intrinsic must be static: " + method; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
171 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
172 ResolvedJavaType[] parameterTypes = resolveJavaTypes(method.toParameterTypes(), method.getDeclaringClass()); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
173 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
174 if (intrinsic.foldable() && areAllConstant(arguments)) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
175 JavaConstant res = tryFold(arguments, parameterTypes, method); |
19421
df00d80dbe59
fixed CheckGraalInvariants issue
Doug Simon <doug.simon@oracle.com>
parents:
19420
diff
changeset
|
176 if (!res.equals(COULD_NOT_FOLD)) { |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
177 return ConstantNode.forConstant(res, metaAccess); |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
178 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
179 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
180 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
181 // Prepare the arguments for the reflective constructor call on the node class. |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
182 Object[] nodeConstructorArguments = prepareArguments(arguments, parameterTypes, method, false); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
183 if (nodeConstructorArguments == null) { |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
184 return null; |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
185 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
186 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
187 // Create the new node instance. |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
188 ResolvedJavaType c = getNodeClass(method, intrinsic); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
189 return createNodeInstance(graph, c, parameterTypes, stamp, intrinsic.setStampFromReturnType(), nodeConstructorArguments); |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
190 } |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
191 |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
192 /** |
14952
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
193 * Permits a subclass to override the default definition of "intrinsic". |
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
194 */ |
19495
1fd4b4c20924
made more of NodeIntrinsificationPhase API public for use in graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents:
19422
diff
changeset
|
195 public NodeIntrinsic getIntrinsic(ResolvedJavaMethod method) { |
14952
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
196 return method.getAnnotation(Node.NodeIntrinsic.class); |
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
197 } |
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
198 |
6b29befc7f38
Make intrinsification decisions customizable by subclass
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
199 /** |
11588 | 200 * Permits a subclass to override the default definition of "foldable". |
201 */ | |
19495
1fd4b4c20924
made more of NodeIntrinsificationPhase API public for use in graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents:
19422
diff
changeset
|
202 public boolean isFoldable(ResolvedJavaMethod method) { |
11588 | 203 return method.getAnnotation(Fold.class) != null; |
204 } | |
205 | |
206 /** | |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
207 * Converts the arguments of an invoke node to object values suitable for use as the arguments |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
208 * to a reflective invocation of a Java constructor or method. |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14633
diff
changeset
|
209 * |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
210 * @param folding specifies if the invocation is for handling a {@link Fold} annotation |
8175
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
211 * @return the arguments for the reflective invocation or null if an argument of {@code invoke} |
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
212 * that is expected to be constant isn't |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
213 */ |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
214 private Object[] prepareArguments(List<ValueNode> arguments, ResolvedJavaType[] parameterTypes, ResolvedJavaMethod target, boolean folding) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
215 Object[] reflectionCallArguments = folding ? new JavaConstant[arguments.size()] : new Object[arguments.size()]; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
216 for (int i = 0; i < reflectionCallArguments.length; ++i) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 int parameterIndex = i; |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
218 if (!target.isStatic()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 parameterIndex--; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 } |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8575
diff
changeset
|
221 ValueNode argument = arguments.get(i); |
16477
46397dc87086
moved getParameterAnnotation() from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16450
diff
changeset
|
222 if (folding || target.getParameterAnnotation(ConstantNodeParameter.class, parameterIndex) != null) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
223 if (!(argument instanceof ConstantNode)) { |
8175
11298242e782
removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents:
7897
diff
changeset
|
224 return null; |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
225 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 ConstantNode constantNode = (ConstantNode) argument; |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18402
diff
changeset
|
227 Constant constant = constantNode.asConstant(); |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
228 /* |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
229 * For intrinsification (but not for folding) if we have a Class<?> object we want |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
230 * the corresponding ResolvedJavaType. |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
231 */ |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
232 ResolvedJavaType type = folding ? null : constantReflection.asJavaType(constant); |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
233 Object arg; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14978
diff
changeset
|
234 if (type != null) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
235 /* If we found such a type then it's our arg */ |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
236 arg = type; |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
237 parameterTypes[i] = metaAccess.lookupJavaType(ResolvedJavaType.class); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 } else { |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18402
diff
changeset
|
239 JavaConstant javaConstant = (JavaConstant) constant; |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
240 if (folding) { |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
241 /* For folding we want JavaConstants */ |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
242 arg = javaConstant; |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
243 } else { |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
244 /* For intrinsification we want want corresponding objects */ |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
245 if (parameterTypes[i].getJavaKind() == JavaKind.Boolean) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
246 arg = Boolean.valueOf(javaConstant.asInt() != 0); |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
247 } else if (parameterTypes[i].getJavaKind() == JavaKind.Byte) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
248 arg = Byte.valueOf((byte) javaConstant.asInt()); |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
249 } else if (parameterTypes[i].getJavaKind() == JavaKind.Short) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
250 arg = Short.valueOf((short) javaConstant.asInt()); |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
251 } else if (parameterTypes[i].getJavaKind() == JavaKind.Char) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
252 arg = Character.valueOf((char) javaConstant.asInt()); |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
253 } else if (parameterTypes[i].getJavaKind() == JavaKind.Object) { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
254 arg = snippetReflection.asObject(parameterTypes[i], javaConstant); |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
255 } else { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
256 arg = javaConstant.asBoxedPrimitive(); |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
257 } |
5463
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
258 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 } |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
260 |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
261 assert folding || !(arg instanceof JavaConstant); |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
262 reflectionCallArguments[i] = arg; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 } else { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
264 reflectionCallArguments[i] = argument; |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
265 parameterTypes[i] = metaAccess.lookupJavaType(ValueNode.class); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 } |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
268 return reflectionCallArguments; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
271 public ResolvedJavaType getNodeClass(ResolvedJavaMethod target, NodeIntrinsic intrinsic) { |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
272 ResolvedJavaType result; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
273 if (intrinsic.value() == NodeIntrinsic.class) { |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
274 result = target.getDeclaringClass(); |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
275 } else { |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
276 result = metaAccess.lookupJavaType(intrinsic.value()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 } |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
278 assert metaAccess.lookupJavaType(ValueNode.class).isAssignableFrom(result) : "Node intrinsic class " + result.toJavaName(false) + " derived from @" + NodeIntrinsic.class.getSimpleName() + |
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
279 " annotation on " + target.format("%H.%n(%p)") + " is not a subclass of " + ValueNode.class; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
19357
diff
changeset
|
283 protected ValueNode createNodeInstance(StructuredGraph graph, ResolvedJavaType nodeClass, ResolvedJavaType[] parameterTypes, Stamp invokeStamp, boolean setStampFromReturnType, |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
284 Object[] nodeConstructorArguments) { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
285 ResolvedJavaMethod constructor = null; |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
286 Object[] arguments = null; |
5578
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
287 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
288 for (ResolvedJavaMethod c : nodeClass.getDeclaredConstructors()) { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
289 Object[] match = match(graph, invokeStamp, c, parameterTypes, nodeConstructorArguments); |
5578
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
290 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
291 if (match != null) { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
292 if (constructor == null) { |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
293 constructor = c; |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
294 arguments = match; |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
295 if (!Debug.isEnabled()) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
296 // Don't verify there's a unique match in non-debug mode |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
297 break; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
298 } |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
299 } else { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
300 throw new JVMCIError("Found multiple constructors in %s compatible with signature %s: %s, %s", nodeClass.toJavaName(), sigString(parameterTypes), constructor, c); |
5578
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
301 } |
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
302 } |
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
303 } |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
304 if (constructor == null) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
305 throw new JVMCIError("Could not find constructor in %s compatible with signature %s", nodeClass.toJavaName(), sigString(parameterTypes)); |
5578
445dd1a9b8d8
enhanced @NodeIntrinsic intrinsification to take into account varargs in the node constructors when matching call arguments
Doug Simon <doug.simon@oracle.com>
parents:
5576
diff
changeset
|
306 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
307 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 try { |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
309 ValueNode intrinsicNode = (ValueNode) invokeConstructor(constructor, arguments); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
310 |
6419
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
6409
diff
changeset
|
311 if (setStampFromReturnType) { |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11652
diff
changeset
|
312 intrinsicNode.setStamp(invokeStamp); |
6419
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
6409
diff
changeset
|
313 } |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
6409
diff
changeset
|
314 return intrinsicNode; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 } catch (Exception e) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
316 throw new RuntimeException(constructor + Arrays.toString(nodeConstructorArguments), e); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 |
19357
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
320 protected Object invokeConstructor(ResolvedJavaMethod constructor, Object[] arguments) { |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
321 return snippetReflection.invoke(constructor, null, arguments); |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
322 } |
26777392b971
Fix prepareArguments for @Fold usecase
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18969
diff
changeset
|
323 |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
324 private static String sigString(ResolvedJavaType[] types) { |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
325 StringBuilder sb = new StringBuilder("("); |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
326 for (int i = 0; i < types.length; i++) { |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
327 if (i != 0) { |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
328 sb.append(", "); |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
329 } |
16479
558cf39c646b
moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents:
16478
diff
changeset
|
330 sb.append(types[i].toJavaName()); |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
331 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
332 return sb.append(")").toString(); |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
333 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
334 |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
335 private static boolean checkNoMoreInjected(ResolvedJavaMethod c, int start) { |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
336 int count = c.getSignature().getParameterCount(false); |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
337 for (int i = start; i < count; i++) { |
16477
46397dc87086
moved getParameterAnnotation() from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16450
diff
changeset
|
338 if (c.getParameterAnnotation(InjectedNodeParameter.class, i) != null) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
339 throw new JVMCIError("Injected parameter %d of type %s must precede all non-injected parameters of %s", i, |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
340 c.getSignature().getParameterType(i, c.getDeclaringClass()).toJavaName(false), c.format("%H.%n(%p)")); |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
341 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
342 } |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
343 return true; |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
344 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
345 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
346 private Object[] match(StructuredGraph graph, Stamp invokeStamp, ResolvedJavaMethod c, ResolvedJavaType[] parameterTypes, Object[] nodeConstructorArguments) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
347 Object[] arguments = null; |
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
348 Object[] injected = null; |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
349 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
350 ResolvedJavaType[] signature = resolveJavaTypes(c.getSignature().toParameterTypes(null), c.getDeclaringClass()); |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
351 for (int i = 0; i < signature.length; i++) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
352 if (c.getParameterAnnotation(InjectedNodeParameter.class, i) != null) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
353 injected = injected == null ? new Object[1] : Arrays.copyOf(injected, injected.length + 1); |
18515
e846c9e2f0e5
added support for binding arguments of arbitrary types to parameters of a node intrinsic constructor (or factory method)
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
354 Object injectedParameter = snippetReflection.getInjectedNodeIntrinsicParameter(signature[i]); |
e846c9e2f0e5
added support for binding arguments of arbitrary types to parameters of a node intrinsic constructor (or factory method)
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
355 if (injectedParameter != null) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
356 injected[injected.length - 1] = injectedParameter; |
18515
e846c9e2f0e5
added support for binding arguments of arbitrary types to parameters of a node intrinsic constructor (or factory method)
Doug Simon <doug.simon@oracle.com>
parents:
18496
diff
changeset
|
357 } else if (signature[i].equals(metaAccess.lookupJavaType(MetaAccessProvider.class))) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
358 injected[injected.length - 1] = metaAccess; |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
359 } else if (signature[i].equals(metaAccess.lookupJavaType(StructuredGraph.class))) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
360 injected[injected.length - 1] = graph; |
12362
f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12361
diff
changeset
|
361 } else if (signature[i].equals(metaAccess.lookupJavaType(ForeignCallsProvider.class))) { |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
362 injected[injected.length - 1] = foreignCalls; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14978
diff
changeset
|
363 } else if (signature[i].equals(metaAccess.lookupJavaType(SnippetReflectionProvider.class))) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
364 injected[injected.length - 1] = snippetReflection; |
18402
64c042352f00
Make stamp of LoadHubNode flexible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18370
diff
changeset
|
365 } else if (signature[i].isAssignableFrom(metaAccess.lookupJavaType(Stamp.class))) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
366 injected[injected.length - 1] = invokeStamp; |
18496
59ffee3765ec
LoadHubNode should always use StampProvider stamp
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18487
diff
changeset
|
367 } else if (signature[i].isAssignableFrom(metaAccess.lookupJavaType(StampProvider.class))) { |
19818
6a684aeb1590
NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
368 injected[injected.length - 1] = stampProvider; |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
369 } else { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
370 throw new JVMCIError("Cannot handle injected argument of type %s in %s", signature[i].toJavaName(), c.format("%H.%n(%p)")); |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
371 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
372 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
373 assert checkNoMoreInjected(c, i); |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
374 break; |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
375 } |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
376 } |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
377 if (injected != null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
378 // Chop injected arguments from signature |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
379 signature = Arrays.copyOfRange(signature, injected.length, signature.length); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19495
diff
changeset
|
380 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
381 |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
382 if (Arrays.equals(parameterTypes, signature)) { |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
383 // Exact match |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
384 arguments = nodeConstructorArguments; |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
385 |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
386 } else if (signature.length > 0 && signature[signature.length - 1].isArray()) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
387 // Last constructor parameter is an array, so check if we have a vararg match |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
388 int fixedArgs = signature.length - 1; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
389 if (parameterTypes.length < fixedArgs) { |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
390 return null; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
391 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
392 for (int i = 0; i < fixedArgs; i++) { |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
393 if (!parameterTypes[i].equals(signature[i])) { |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
394 return null; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
395 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
396 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
397 |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
398 ResolvedJavaType componentType = signature[fixedArgs].getComponentType(); |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
399 assert componentType != null; |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
400 for (int i = fixedArgs; i < nodeConstructorArguments.length; i++) { |
9101
cfe822a31f67
Use same type check for varargs and non-varargs parameters
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9100
diff
changeset
|
401 if (!parameterTypes[i].equals(componentType)) { |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
402 return null; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
403 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
404 } |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
405 arguments = Arrays.copyOf(nodeConstructorArguments, fixedArgs + 1); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
406 arguments[fixedArgs] = snippetReflection.newArray(componentType, nodeConstructorArguments.length - fixedArgs); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
407 |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
408 Object varargs = arguments[fixedArgs]; |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
409 for (int i = fixedArgs; i < nodeConstructorArguments.length; i++) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
410 if (componentType.isPrimitive()) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
411 Array.set(varargs, i - fixedArgs, nodeConstructorArguments[i]); |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
412 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18533
diff
changeset
|
413 ((Object[]) varargs)[i - fixedArgs] = nodeConstructorArguments[i]; |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
414 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
415 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
416 } else { |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
417 return null; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
418 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
419 |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
420 if (injected != null) { |
18533
25a21e1794ec
modified SnippetReflectionProvider to support both VM-side and compiler-side constants in a compilation replay context
Doug Simon <doug.simon@oracle.com>
parents:
18515
diff
changeset
|
421 Object[] copy = new Object[injected.length + arguments.length]; |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
422 System.arraycopy(injected, 0, copy, 0, injected.length); |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
423 System.arraycopy(arguments, 0, copy, injected.length, arguments.length); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
424 arguments = copy; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
425 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9089
diff
changeset
|
426 return arguments; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
427 } |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
428 |
5563
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5547
diff
changeset
|
429 private static String sourceLocation(Node n) { |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5547
diff
changeset
|
430 String loc = GraphUtil.approxSourceLocation(n); |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5547
diff
changeset
|
431 return loc == null ? "<unknown>" : loc; |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5547
diff
changeset
|
432 } |
6a2671066204
added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents:
5547
diff
changeset
|
433 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 public void cleanUpReturnCheckCast(Node newInstance) { |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22400
diff
changeset
|
435 if (newInstance instanceof ValueNode && (((ValueNode) newInstance).getStackKind() != JavaKind.Object || ((ValueNode) newInstance).stamp() == StampFactory.forNodeIntrinsic())) { |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4199
diff
changeset
|
436 StructuredGraph graph = (StructuredGraph) newInstance.graph(); |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
437 for (CheckCastNode checkCastNode : newInstance.usages().filter(CheckCastNode.class).snapshot()) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
438 for (Node checkCastUsage : checkCastNode.usages().snapshot()) { |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
439 checkCheckCastUsage(graph, newInstance, checkCastNode, checkCastUsage); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 } |
16450
b650d0a98146
new GraphUtil.unlinkFixedNode utility method
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15311
diff
changeset
|
441 GraphUtil.unlinkFixedNode(checkCastNode); |
5372
4485e0edd1af
made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
442 GraphUtil.killCFG(checkCastNode); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 } |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
446 |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
447 private static void checkCheckCastUsage(StructuredGraph graph, Node intrinsifiedNode, Node input, Node usage) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
448 if (usage instanceof ValueAnchorNode) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
449 ValueAnchorNode valueAnchorNode = (ValueAnchorNode) usage; |
11711
f12b418ebc74
Allow only single input for value anchors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11698
diff
changeset
|
450 valueAnchorNode.removeAnchoredNode(); |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
451 Debug.log("%s: Removed a ValueAnchor input", Debug.contextSnapshot(JavaMethod.class)); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
452 } else if (usage instanceof UnboxNode) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
453 UnboxNode unbox = (UnboxNode) usage; |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
454 unbox.replaceAtUsages(intrinsifiedNode); |
19838
8aa5bd9935b3
Turn UnboxNode into a fixed node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19775
diff
changeset
|
455 graph.removeFixed(unbox); |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
456 Debug.log("%s: Removed an UnboxNode", Debug.contextSnapshot(JavaMethod.class)); |
12738
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
457 } else if (usage instanceof UnsafeStoreNode) { |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
458 UnsafeStoreNode store = (UnsafeStoreNode) usage; |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
459 store.replaceFirstInput(input, intrinsifiedNode); |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
460 } else if (usage instanceof LoadFieldNode) { |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
461 LoadFieldNode load = (LoadFieldNode) usage; |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
462 load.replaceAtUsages(intrinsifiedNode); |
9a56121f285b
Add missing cases for CheckCast usages in NodeIntrisification when BoxingSubstitutions are disabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12655
diff
changeset
|
463 graph.removeFixed(load); |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
464 } else if (usage instanceof MethodCallTargetNode) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
465 MethodCallTargetNode checkCastCallTarget = (MethodCallTargetNode) usage; |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
466 assert checkCastCallTarget.targetMethod().getAnnotation(NodeIntrinsic.class) != null : "checkcast at " + sourceLocation(input) + |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
467 " not used by an unboxing method or node intrinsic, but by a call at " + sourceLocation(checkCastCallTarget.usages().first()) + " to " + checkCastCallTarget.targetMethod(); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
468 usage.replaceFirstInput(input, intrinsifiedNode); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
469 Debug.log("%s: Checkcast used in an other node intrinsic", Debug.contextSnapshot(JavaMethod.class)); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
470 } else if (usage instanceof FrameState) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
471 usage.replaceFirstInput(input, null); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
472 Debug.log("%s: Checkcast used in a FS", Debug.contextSnapshot(JavaMethod.class)); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
473 } else if (usage instanceof ReturnNode && ((ValueNode) intrinsifiedNode).stamp() == StampFactory.forNodeIntrinsic()) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
474 usage.replaceFirstInput(input, intrinsifiedNode); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
475 Debug.log("%s: Checkcast used in a return with forNodeIntrinsic stamp", Debug.contextSnapshot(JavaMethod.class)); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
476 } else if (usage instanceof IsNullNode) { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
477 if (!usage.hasNoUsages()) { |
18969
14496953435e
Use Node#getUsageCount wherever possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
478 assert usage.getUsageCount() == 1 && usage.usages().first().predecessor() == input : usage + " " + input; |
10635 | 479 graph.replaceFloating((FloatingNode) usage, LogicConstantNode.contradiction(graph)); |
480 Debug.log("%s: Replaced IsNull with false", Debug.contextSnapshot(JavaMethod.class)); | |
481 } else { | |
482 // Removed as usage of a GuardingPiNode | |
483 } | |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
484 } else if (usage instanceof ProxyNode) { |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
485 ProxyNode proxy = (ProxyNode) usage; |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14953
diff
changeset
|
486 assert proxy instanceof ValueProxyNode; |
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14953
diff
changeset
|
487 ProxyNode newProxy = ProxyNode.forValue((ValueNode) intrinsifiedNode, proxy.proxyPoint(), graph); |
9861
2d5c0f7ce7a1
Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9860
diff
changeset
|
488 for (Node proxyUsage : usage.usages().snapshot()) { |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
489 checkCheckCastUsage(graph, newProxy, proxy, proxyUsage); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
490 } |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
491 } else if (usage instanceof PiNode) { |
9861
2d5c0f7ce7a1
Add a PiNode for the null-checked receiver during inlining
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9860
diff
changeset
|
492 for (Node piUsage : usage.usages().snapshot()) { |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
493 checkCheckCastUsage(graph, intrinsifiedNode, usage, piUsage); |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
494 } |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
495 } else { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14633
diff
changeset
|
496 DebugScope.forceDump(graph, "exception"); |
10635 | 497 assert false : sourceLocation(usage) + " has unexpected usage " + usage + " of checkcast " + input + " at " + sourceLocation(input); |
9860
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
498 } |
6a0da51dfba4
Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9350
diff
changeset
|
499 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 } |