Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 14746:7544068e1a91
Perform de-virtualization of calls only in canonicalizer and not in graph builder
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 25 Mar 2014 13:32:32 -0700 |
parents | fd7fcd2d2072 |
children | 8db6e76cb658 |
comparison
equal
deleted
inserted
replaced
14745:65b005b58825 | 14746:7544068e1a91 |
---|---|
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 @Override | 127 @Override |
128 public Node canonical(CanonicalizerTool tool) { | 128 public Node canonical(CanonicalizerTool tool) { |
129 if (!isStatic()) { | 129 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) { |
130 // attempt to devirtualize the call | |
131 | |
132 // check for trivial cases (e.g. final methods, nonvirtual methods) | |
133 if (targetMethod.canBeStaticallyBound()) { | |
134 invokeKind = InvokeKind.Special; | |
135 return this; | |
136 } | |
137 | |
138 // check if the exact type of the receiver can be determined | |
130 ValueNode receiver = receiver(); | 139 ValueNode receiver = receiver(); |
131 if (receiver != null && ObjectStamp.isExactType(receiver) && ObjectStamp.typeOrNull(receiver) != null) { | 140 ResolvedJavaType exact = targetMethod.getDeclaringClass().asExactType(); |
132 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) { | 141 if (exact == null && ObjectStamp.isExactType(receiver)) { |
133 ResolvedJavaMethod method = ObjectStamp.typeOrNull(receiver).resolveMethod(targetMethod); | 142 exact = ObjectStamp.typeOrNull(receiver); |
134 if (method != null) { | 143 } |
135 invokeKind = InvokeKind.Special; | 144 if (exact != null) { |
136 targetMethod = method; | 145 // either the holder class is exact, or the receiver object has an exact type |
137 } | 146 ResolvedJavaMethod exactMethod = exact.resolveMethod(targetMethod); |
147 if (exactMethod != null) { | |
148 invokeKind = InvokeKind.Special; | |
149 targetMethod = exactMethod; | |
150 return this; | |
138 } | 151 } |
139 } | 152 } |
140 } | 153 } |
141 return this; | 154 return this; |
142 } | 155 } |