annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 14908:8db6e76cb658

Formatter: Keep one enum constant per line
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 14:09:03 +0200
parents 7544068e1a91
children 175111728365
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 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.nodes.java;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
25 import java.lang.reflect.*;
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
26
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5504
diff changeset
27 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import com.oracle.graal.graph.*;
11881
da9db8331658 moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11880
diff changeset
29 import com.oracle.graal.graph.spi.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 import com.oracle.graal.nodes.type.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11391
diff changeset
33 public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Canonicalizable {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
34
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 public enum InvokeKind {
14908
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14746
diff changeset
36 Interface,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14746
diff changeset
37 Special,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14746
diff changeset
38 Static,
8db6e76cb658 Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14746
diff changeset
39 Virtual
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
42 private final JavaType returnType;
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
43 private ResolvedJavaMethod targetMethod;
5299
0ebd9cfdc11f removed @Data annotation
Lukas Stadler <lukas.stadler@jku.at>
parents: 5283
diff changeset
44 private InvokeKind invokeKind;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 * @param arguments
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
49 public MethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 super(arguments);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 this.invokeKind = invokeKind;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 this.returnType = returnType;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 this.targetMethod = targetMethod;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 }
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 * Gets the target method for this invocation instruction.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
58 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 * @return the target method
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
61 public ResolvedJavaMethod targetMethod() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 return targetMethod;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 public InvokeKind invokeKind() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 return invokeKind;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 public void setInvokeKind(InvokeKind kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 this.invokeKind = kind;
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
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
73 public void setTargetMethod(ResolvedJavaMethod method) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 targetMethod = method;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 * Gets the instruction that produces the receiver object for this invocation, if any.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
79 *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
80 * @return the instruction that produces the receiver object for this invocation if any,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
81 * {@code null} if this invocation does not take a receiver object
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 public ValueNode receiver() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 return isStatic() ? null : arguments().get(0);
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 * Checks whether this is an invocation of a static method.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
89 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 * @return {@code true} if the invocation is a static invocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 public boolean isStatic() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 return invokeKind() == InvokeKind.Static;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
96 public Kind returnKind() {
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: 6409
diff changeset
97 return targetMethod().getSignature().getReturnKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 public Invoke invoke() {
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4309
diff changeset
101 return (Invoke) this.usages().first();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 public boolean verify() {
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6539
diff changeset
106 assert usages().count() <= 1 : "call target may only be used by a single invoke";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 for (Node n : usages()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 }
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
110 if (invokeKind == InvokeKind.Special || invokeKind == InvokeKind.Static) {
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
111 assertFalse(Modifier.isAbstract(targetMethod.getModifiers()), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod);
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
112 }
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
113 if (invokeKind == InvokeKind.Static) {
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
114 assertTrue(Modifier.isStatic(targetMethod.getModifiers()), "static calls are only allowed for static methods (%s)", targetMethod);
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
115 } else {
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
116 assertFalse(Modifier.isStatic(targetMethod.getModifiers()), "static calls are only allowed for non-static methods (%s)", targetMethod);
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
117 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 return super.verify();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 public String toString(Verbosity verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 if (verbosity == Verbosity.Long) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 return super.toString(Verbosity.Short) + "(" + targetMethod() + ")";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 return super.toString(verbosity);
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 @Override
11880
9a747d8e0d0f broadened types in Canonicalizable interface so that it can be moved to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
131 public Node canonical(CanonicalizerTool tool) {
14746
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
132 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
133 // attempt to devirtualize the call
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
134
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
135 // check for trivial cases (e.g. final methods, nonvirtual methods)
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
136 if (targetMethod.canBeStaticallyBound()) {
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
137 invokeKind = InvokeKind.Special;
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
138 return this;
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
139 }
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
140
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
141 // check if the exact type of the receiver can be determined
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 ValueNode receiver = receiver();
14746
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
143 ResolvedJavaType exact = targetMethod.getDeclaringClass().asExactType();
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
144 if (exact == null && ObjectStamp.isExactType(receiver)) {
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
145 exact = ObjectStamp.typeOrNull(receiver);
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
146 }
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
147 if (exact != null) {
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
148 // either the holder class is exact, or the receiver object has an exact type
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
149 ResolvedJavaMethod exactMethod = exact.resolveMethod(targetMethod);
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
150 if (exactMethod != null) {
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
151 invokeKind = InvokeKind.Special;
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
152 targetMethod = exactMethod;
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
153 return this;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 return this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
160 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 public Stamp returnStamp() {
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: 6409
diff changeset
162 Kind returnKind = targetMethod.getSignature().getReturnKind();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
163 if (returnKind == Kind.Object && returnType instanceof ResolvedJavaType) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
164 return StampFactory.declared((ResolvedJavaType) returnType);
5283
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
165 } else {
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
166 return StampFactory.forKind(returnKind);
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
167 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
169
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
170 public JavaType returnType() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
171 return returnType;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
172 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
173
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
174 @Override
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
175 public String targetName() {
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
176 if (targetMethod() == null) {
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
177 return "??Invalid!";
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
178 }
14019
9d864856336a support canonicalization of arraylength in ReadNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 11881
diff changeset
179 return MetaUtil.format("%h.%n", targetMethod());
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
180 }
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
181
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
182 public static MethodCallTargetNode find(StructuredGraph graph, ResolvedJavaMethod method) {
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
183 for (MethodCallTargetNode target : graph.getNodes(MethodCallTargetNode.class)) {
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14019
diff changeset
184 if (target.targetMethod.equals(method)) {
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
185 return target;
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
186 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
187 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
188 return null;
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
189 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }