annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java @ 9860:6a0da51dfba4

Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 04 Jun 2013 17:23:39 +0200
parents e7c396ce0f3d
children 2d5c0f7ce7a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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
9350
e7c396ce0f3d better error message for incorrect usage of @NodeIntrinsic
Doug Simon <doug.simon@oracle.com>
parents: 9147
diff changeset
25 import static com.oracle.graal.api.meta.MetaUtil.*;
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
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5503
diff changeset
30 import com.oracle.graal.api.meta.*;
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
31 import com.oracle.graal.debug.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.graph.Node.ConstantNodeParameter;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.graph.Node.NodeIntrinsic;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.nodes.*;
9860
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
36 import com.oracle.graal.nodes.PhiNode.PhiType;
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
37 import com.oracle.graal.nodes.calc.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.nodes.java.*;
6408
e5768e936147 Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5764
diff changeset
40 import com.oracle.graal.nodes.type.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 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
42 import com.oracle.graal.phases.*;
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
43 import com.oracle.graal.replacements.Snippet.Fold;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44
8409
c3fc0e257800 rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents: 8378
diff changeset
45 /**
c3fc0e257800 rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents: 8378
diff changeset
46 * 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
47 * {@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
48 */
c3fc0e257800 rename: SnippetIntrinsificationPhase -> NodeIntrinsificationPhase
Doug Simon <doug.simon@oracle.com>
parents: 8378
diff changeset
49 public class NodeIntrinsificationPhase extends Phase {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
5755
12e5956a8fdd Use MetaAccessProvider instead of CodeCacheProvider wherever possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5719
diff changeset
51 private final MetaAccessProvider runtime;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
53 public NodeIntrinsificationPhase(MetaAccessProvider runtime) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 this.runtime = runtime;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 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
59 ArrayList<Node> cleanUpReturnList = new ArrayList<>();
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
60 for (MethodCallTargetNode node : graph.getNodes(MethodCallTargetNode.class)) {
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
61 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
62 }
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
63
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
64 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
65 cleanUpReturnCheckCast(node);
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
66 }
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
67 }
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
68
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
69 private boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List<Node> cleanUpReturnList) {
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
70 ResolvedJavaMethod target = methodCallTargetNode.targetMethod();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class);
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
72 ResolvedJavaType declaringClass = target.getDeclaringClass();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 if (intrinsic != null) {
5576
a4d0ded32ddd moved @Fold from Node.java to Snippet.java
Doug Simon <doug.simon@oracle.com>
parents: 5572
diff changeset
74 assert target.getAnnotation(Fold.class) == 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
75 assert Modifier.isStatic(target.getModifiers()) : "node intrinsic must be static: " + target;
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
76
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
77 ResolvedJavaType[] parameterTypes = MetaUtil.resolveJavaTypes(MetaUtil.signatureToTypes(target), declaringClass);
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
78 ResolvedJavaType returnType = target.getSignature().getReturnType(declaringClass).resolve(declaringClass);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 // Prepare the arguments for the reflective constructor call on the node class.
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
81 Constant[] nodeConstructorArguments = prepareArguments(methodCallTargetNode, parameterTypes, target, false);
8175
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
82 if (nodeConstructorArguments == null) {
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
83 return false;
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
84 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 // Create the new node instance.
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
87 ResolvedJavaType c = getNodeClass(target, intrinsic);
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
88 Node newInstance = createNodeInstance(c, parameterTypes, returnType, intrinsic.setStampFromReturnType(), nodeConstructorArguments);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 // Replace the invoke with the new node.
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
91 methodCallTargetNode.graph().add(newInstance);
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
92 methodCallTargetNode.invoke().intrinsify(newInstance);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 // 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
95 cleanUpReturnList.add(newInstance);
5576
a4d0ded32ddd moved @Fold from Node.java to Snippet.java
Doug Simon <doug.simon@oracle.com>
parents: 5572
diff changeset
96 } else if (target.getAnnotation(Fold.class) != 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
97 ResolvedJavaType[] parameterTypes = MetaUtil.resolveJavaTypes(MetaUtil.signatureToTypes(target), declaringClass);
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
98
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
99 // Prepare the arguments for the reflective method call
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
100 Constant[] arguments = prepareArguments(methodCallTargetNode, parameterTypes, target, true);
8175
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
101 if (arguments == null) {
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
102 return false;
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
103 }
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
104 Constant receiver = null;
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
105 if (!methodCallTargetNode.isStatic()) {
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
106 receiver = arguments[0];
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
107 arguments = Arrays.copyOfRange(arguments, 1, arguments.length);
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
108 parameterTypes = Arrays.copyOfRange(parameterTypes, 1, parameterTypes.length);
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
109 }
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 // Call the method
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
112 Constant constant = target.invoke(receiver, 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
113
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
114 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
115 // Replace the invoke with the result of the call
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
116 ConstantNode node = ConstantNode.forConstant(constant, runtime, methodCallTargetNode.graph());
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
117 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
118
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 // 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
120 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
121 } 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
122 // Remove the invoke
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
123 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
124 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 }
8175
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
126 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128
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
129 /**
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
130 * Converts the arguments of an invoke node to object values suitable for use as the arguments
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
131 * to a reflective invocation of a Java constructor or method.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7257
diff changeset
132 *
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
133 * @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
134 * @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
135 * 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
136 */
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
137 private Constant[] prepareArguments(MethodCallTargetNode methodCallTargetNode, ResolvedJavaType[] parameterTypes, ResolvedJavaMethod target, boolean folding) {
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
138 NodeInputList<ValueNode> arguments = methodCallTargetNode.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
139 Constant[] reflectionCallArguments = new Constant[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
140 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
141 int parameterIndex = i;
9147
07f05f2a8149 Remove methodCallTarget() method from the Invoke interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9101
diff changeset
142 if (!methodCallTargetNode.isStatic()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 parameterIndex--;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 }
8913
653110156f8a refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents: 8575
diff changeset
145 ValueNode argument = arguments.get(i);
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5663
diff changeset
146 if (folding || MetaUtil.getParameterAnnotation(ConstantNodeParameter.class, parameterIndex, target) != null) {
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
147 if (!(argument instanceof ConstantNode)) {
8175
11298242e782 removed use of NonConstantParameterError (GRAAL-147)
Doug Simon <doug.simon@oracle.com>
parents: 7897
diff changeset
148 return null;
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
149 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 ConstantNode constantNode = (ConstantNode) argument;
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
151 Constant constant = constantNode.asConstant();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
152 Object o = constant.asBoxedValue();
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7257
diff changeset
153 if (o instanceof Class<?>) {
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
154 reflectionCallArguments[i] = Constant.forObject(runtime.lookupJavaType((Class<?>) o));
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
155 parameterTypes[i] = runtime.lookupJavaType(ResolvedJavaType.class);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 } else {
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
157 if (parameterTypes[i].getKind() == Kind.Boolean) {
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
158 reflectionCallArguments[i] = Constant.forObject(Boolean.valueOf(constant.asInt() != 0));
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
159 } else if (parameterTypes[i].getKind() == Kind.Byte) {
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
160 reflectionCallArguments[i] = Constant.forObject(Byte.valueOf((byte) constant.asInt()));
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
161 } else if (parameterTypes[i].getKind() == Kind.Short) {
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
162 reflectionCallArguments[i] = Constant.forObject(Short.valueOf((short) constant.asInt()));
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
163 } else if (parameterTypes[i].getKind() == Kind.Char) {
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
164 reflectionCallArguments[i] = Constant.forObject(Character.valueOf((char) constant.asInt()));
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
165 } else {
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
166 reflectionCallArguments[i] = constant;
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
167 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 } else {
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
170 reflectionCallArguments[i] = Constant.forObject(argument);
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
171 parameterTypes[i] = runtime.lookupJavaType(ValueNode.class);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 }
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
174 return reflectionCallArguments;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176
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
177 private ResolvedJavaType getNodeClass(ResolvedJavaMethod target, NodeIntrinsic intrinsic) {
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
178 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
179 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
180 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
181 } 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
182 result = runtime.lookupJavaType(intrinsic.value());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 }
9350
e7c396ce0f3d better error message for incorrect usage of @NodeIntrinsic
Doug Simon <doug.simon@oracle.com>
parents: 9147
diff changeset
184 assert runtime.lookupJavaType(ValueNode.class).isAssignableFrom(result) : "Node intrinsic class " + toJavaName(result, false) + " derived from @" + NodeIntrinsic.class.getSimpleName() +
e7c396ce0f3d better error message for incorrect usage of @NodeIntrinsic
Doug Simon <doug.simon@oracle.com>
parents: 9147
diff changeset
185 " annotation on " + format("%H.%n(%p)", target) + " is not a subclass of " + ValueNode.class;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188
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
189 private Node createNodeInstance(ResolvedJavaType nodeClass, ResolvedJavaType[] parameterTypes, ResolvedJavaType returnType, boolean setStampFromReturnType, Constant[] nodeConstructorArguments) {
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
190 ResolvedJavaMethod constructor = 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
191 Constant[] 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
192
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
193 for (ResolvedJavaMethod c : nodeClass.getDeclaredConstructors()) {
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
194 Constant[] match = match(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
195
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
196 if (match != 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
197 if (constructor == 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
198 constructor = c;
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
199 arguments = match;
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
200 } 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
201 throw new GraalInternalError("Found multiple constructors in " + nodeClass + " compatible with signature " + Arrays.toString(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
202 }
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
203 }
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
204 }
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
205 if (constructor == null) {
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
206 throw new GraalInternalError("Could not find constructor in " + nodeClass + " compatible with signature " + Arrays.toString(parameterTypes));
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
207 }
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
208
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 try {
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
210 ValueNode intrinsicNode = (ValueNode) constructor.newInstance(arguments).asObject();
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
211
6419
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
212 if (setStampFromReturnType) {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7059
diff changeset
213 if (returnType.getKind() == Kind.Object) {
6419
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
214 intrinsicNode.setStamp(StampFactory.declared(returnType));
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
215 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
216 intrinsicNode.setStamp(StampFactory.forKind(returnType.getKind()));
6419
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
217 }
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
218 }
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
219 return intrinsicNode;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 } catch (Exception e) {
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
221 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
222 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224
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
225 private Constant[] match(ResolvedJavaMethod c, ResolvedJavaType[] parameterTypes, Constant[] nodeConstructorArguments) {
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
226 Constant[] arguments = 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
227 boolean needsMetaAccessProviderArgument = false;
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
228
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
229 ResolvedJavaType[] signature = MetaUtil.resolveJavaTypes(MetaUtil.signatureToTypes(c.getSignature(), null), c.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
230 if (signature.length != 0 && signature[0].equals(runtime.lookupJavaType(MetaAccessProvider.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
231 // Chop off the MetaAccessProvider first parameter
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
232 signature = Arrays.copyOfRange(signature, 1, signature.length);
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
233 needsMetaAccessProviderArgument = true;
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
234 }
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
235
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
236 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
237 // Exact match
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
238 arguments = nodeConstructorArguments;
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
239
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
240 } else if (signature.length > 0 && signature[signature.length - 1].isArray()) {
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
241 // Last constructor parameter is an array, so check if we have a vararg match
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
242 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
243 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
244 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
245 }
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
246 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
247 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
248 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
249 }
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
250 }
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
251
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
252 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
253 assert componentType != 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
254 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
255 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
256 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
257 }
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
258 }
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
259 arguments = Arrays.copyOf(nodeConstructorArguments, fixedArgs + 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
260 arguments[fixedArgs] = componentType.newArray(nodeConstructorArguments.length - fixedArgs);
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
261
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
262 Object varargs = arguments[fixedArgs].asObject();
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
263 for (int i = fixedArgs; i < nodeConstructorArguments.length; 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
264 Array.set(varargs, i - fixedArgs, nodeConstructorArguments[i].asBoxedValue());
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
265 }
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
266 } 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
267 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
268 }
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
269
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
270 if (needsMetaAccessProviderArgument) {
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
271 Constant[] copy = new Constant[arguments.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
272 System.arraycopy(arguments, 0, copy, 1, arguments.length);
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 copy[0] = Constant.forObject(runtime);
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 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
275 }
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
276 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
277 }
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
278
5563
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
279 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
280 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
281 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
282 }
6a2671066204 added NewInstanceSnippets for lowering NewInstanceNodes (currently disabled by default)
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
283
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 public void cleanUpReturnCheckCast(Node newInstance) {
6408
e5768e936147 Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5764
diff changeset
285 if (newInstance instanceof ValueNode && (((ValueNode) newInstance).kind() != Kind.Object || ((ValueNode) newInstance).stamp() == StampFactory.forNodeIntrinsic())) {
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
286 StructuredGraph graph = (StructuredGraph) newInstance.graph();
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4310
diff changeset
287 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
288 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
289 checkCheckCastUsage(graph, newInstance, checkCastNode, checkCastUsage);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 }
5372
4485e0edd1af made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
291 FixedNode next = checkCastNode.next();
4485e0edd1af made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
292 checkCastNode.setNext(null);
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5463
diff changeset
293 checkCastNode.replaceAtPredecessor(next);
5372
4485e0edd1af made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
294 GraphUtil.killCFG(checkCastNode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 }
9860
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
298
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
299 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
300 if (usage instanceof ValueAnchorNode) {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
301 ValueAnchorNode valueAnchorNode = (ValueAnchorNode) usage;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
302 valueAnchorNode.removeAnchoredNode((ValueNode) input);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
303 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
304 } 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
305 UnboxNode unbox = (UnboxNode) usage;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
306 unbox.replaceAtUsages(intrinsifiedNode);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
307 graph.removeFixed(unbox);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
308 Debug.log("%s: Removed an UnboxNode", Debug.contextSnapshot(JavaMethod.class));
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
309 } 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
310 MethodCallTargetNode checkCastCallTarget = (MethodCallTargetNode) usage;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
311 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
312 " 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
313 usage.replaceFirstInput(input, intrinsifiedNode);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
314 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
315 } 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
316 usage.replaceFirstInput(input, null);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
317 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
318 } 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
319 usage.replaceFirstInput(input, intrinsifiedNode);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
320 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
321 } else if (usage instanceof IsNullNode) {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
322 assert usage.usages().count() == 1 && usage.usages().first().predecessor() == input;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
323 graph.replaceFloating((FloatingNode) usage, LogicConstantNode.contradiction(graph));
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
324 Debug.log("%s: Replaced IsNull with false", Debug.contextSnapshot(JavaMethod.class));
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
325 } 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
326 ProxyNode proxy = (ProxyNode) usage;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
327 assert proxy.type() == PhiType.Value;
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
328 ProxyNode newProxy = graph.unique(new ProxyNode((ValueNode) intrinsifiedNode, proxy.proxyPoint(), PhiType.Value, proxy.getIdentity()));
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
329 for (Node proxyUsage : usage.usages()) {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
330 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
331 }
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
332 } else if (usage instanceof PiNode) {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
333 for (Node piUsage : usage.usages()) {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
334 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
335 }
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
336 } else {
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
337 Debug.dump(graph, "exception");
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
338 assert false : sourceLocation(usage) + " has unexpected usage " + usage + " of checkcast at " + sourceLocation(input);
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
339 }
6a0da51dfba4 Handle Proxies and pi nodes better in the NodeIntrinsificationPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9350
diff changeset
340 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 }