Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 15102:175111728365
improve canBeStaticallyBound
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 14 Apr 2014 15:08:30 -0700 |
parents | 8db6e76cb658 |
children | 2c0cfbf454b5 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Apr 14 15:07:55 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Apr 14 15:08:30 2014 -0700 @@ -55,7 +55,7 @@ /** * Gets the target method for this invocation instruction. - * + * * @return the target method */ public ResolvedJavaMethod targetMethod() { @@ -76,7 +76,7 @@ /** * Gets the instruction that produces the receiver object for this invocation, if any. - * + * * @return the instruction that produces the receiver object for this invocation if any, * {@code null} if this invocation does not take a receiver object */ @@ -86,7 +86,7 @@ /** * Checks whether this is an invocation of a static method. - * + * * @return {@code true} if the invocation is a static invocation */ public boolean isStatic() { @@ -138,18 +138,17 @@ return this; } - // check if the exact type of the receiver can be determined + assert targetMethod.getDeclaringClass().asExactType() == null : "should have been handled by canBeStaticallyBound"; + + // check if the type of the receiver can narrow the result ValueNode receiver = receiver(); - ResolvedJavaType exact = targetMethod.getDeclaringClass().asExactType(); - if (exact == null && ObjectStamp.isExactType(receiver)) { - exact = ObjectStamp.typeOrNull(receiver); - } - if (exact != null) { + ResolvedJavaType type = ObjectStamp.typeOrNull(receiver); + if (type != null) { // either the holder class is exact, or the receiver object has an exact type - ResolvedJavaMethod exactMethod = exact.resolveMethod(targetMethod); - if (exactMethod != null) { + ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod); + if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || ObjectStamp.isExactType(receiver))) { invokeKind = InvokeKind.Special; - targetMethod = exactMethod; + targetMethod = resolvedMethod; return this; } }