Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 18184:49898cb251d8
Make MethodCallTargetNode Simplifiable (instead of Canonicalizable).
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 29 Oct 2014 16:20:02 +0100 |
parents | 45b45f902bed |
children | 839f97696479 |
comparison
equal
deleted
inserted
replaced
18183:d3dfd1f9545f | 18184:49898cb251d8 |
---|---|
29 import com.oracle.graal.nodeinfo.*; | 29 import com.oracle.graal.nodeinfo.*; |
30 import com.oracle.graal.nodes.*; | 30 import com.oracle.graal.nodes.*; |
31 import com.oracle.graal.nodes.type.*; | 31 import com.oracle.graal.nodes.type.*; |
32 | 32 |
33 @NodeInfo | 33 @NodeInfo |
34 public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Canonicalizable { | 34 public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Simplifiable { |
35 protected final JavaType returnType; | 35 protected final JavaType returnType; |
36 | 36 |
37 /** | 37 /** |
38 * @param arguments | 38 * @param arguments |
39 */ | 39 */ |
98 return super.toString(verbosity); | 98 return super.toString(verbosity); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 @Override | 102 @Override |
103 public Node canonical(CanonicalizerTool tool) { | 103 public void simplify(SimplifierTool tool) { |
104 if (invokeKind() == InvokeKind.Interface || invokeKind() == InvokeKind.Virtual) { | 104 if (invokeKind() == InvokeKind.Interface || invokeKind() == InvokeKind.Virtual) { |
105 // attempt to devirtualize the call | 105 // attempt to devirtualize the call |
106 | 106 |
107 // check for trivial cases (e.g. final methods, nonvirtual methods) | 107 // check for trivial cases (e.g. final methods, nonvirtual methods) |
108 if (targetMethod().canBeStaticallyBound()) { | 108 if (targetMethod().canBeStaticallyBound()) { |
109 setInvokeKind(InvokeKind.Special); | 109 setInvokeKind(InvokeKind.Special); |
110 return this; | 110 return; |
111 } | 111 } |
112 | 112 |
113 // check if the type of the receiver can narrow the result | 113 // check if the type of the receiver can narrow the result |
114 ValueNode receiver = receiver(); | 114 ValueNode receiver = receiver(); |
115 ResolvedJavaType type = StampTool.typeOrNull(receiver); | 115 ResolvedJavaType type = StampTool.typeOrNull(receiver); |
120 */ | 120 */ |
121 ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod(), invoke().getContextType()); | 121 ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod(), invoke().getContextType()); |
122 if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver) || type.isArray())) { | 122 if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver) || type.isArray())) { |
123 setInvokeKind(InvokeKind.Special); | 123 setInvokeKind(InvokeKind.Special); |
124 setTargetMethod(resolvedMethod); | 124 setTargetMethod(resolvedMethod); |
125 return this; | 125 return; |
126 } | 126 } |
127 if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { | 127 if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { |
128 ResolvedJavaType uniqueConcreteType = type.findUniqueConcreteSubtype(); | 128 ResolvedJavaType uniqueConcreteType = type.findUniqueConcreteSubtype(); |
129 if (uniqueConcreteType != null) { | 129 if (uniqueConcreteType != null) { |
130 ResolvedJavaMethod methodFromUniqueType = uniqueConcreteType.resolveMethod(targetMethod(), invoke().getContextType()); | 130 ResolvedJavaMethod methodFromUniqueType = uniqueConcreteType.resolveMethod(targetMethod(), invoke().getContextType()); |
131 if (methodFromUniqueType != null) { | 131 if (methodFromUniqueType != null) { |
132 tool.assumptions().recordConcreteSubtype(type, uniqueConcreteType); | 132 tool.assumptions().recordConcreteSubtype(type, uniqueConcreteType); |
133 setInvokeKind(InvokeKind.Special); | 133 setInvokeKind(InvokeKind.Special); |
134 setTargetMethod(methodFromUniqueType); | 134 setTargetMethod(methodFromUniqueType); |
135 return this; | 135 return; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 ResolvedJavaMethod uniqueConcreteMethod = type.findUniqueConcreteMethod(targetMethod()); | 139 ResolvedJavaMethod uniqueConcreteMethod = type.findUniqueConcreteMethod(targetMethod()); |
140 if (uniqueConcreteMethod != null) { | 140 if (uniqueConcreteMethod != null) { |
141 tool.assumptions().recordConcreteMethod(targetMethod(), type, uniqueConcreteMethod); | 141 tool.assumptions().recordConcreteMethod(targetMethod(), type, uniqueConcreteMethod); |
142 setInvokeKind(InvokeKind.Special); | 142 setInvokeKind(InvokeKind.Special); |
143 setTargetMethod(uniqueConcreteMethod); | 143 setTargetMethod(uniqueConcreteMethod); |
144 return this; | 144 return; |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 } | 148 } |
149 return this; | |
150 } | 149 } |
151 | 150 |
152 @Override | 151 @Override |
153 public Stamp returnStamp() { | 152 public Stamp returnStamp() { |
154 Kind returnKind = targetMethod().getSignature().getReturnKind(); | 153 Kind returnKind = targetMethod().getSignature().getReturnKind(); |