Mercurial > hg > graal-compiler
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 16564:688f84e397a3
Move the target method from MethodCallTargetNode and LoweredCallTargetNode to their superclass CallTargetNode
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 14 Jul 2014 14:00:55 +0200 |
parents | 1e63cb55f61d |
children | 2b63e51e7789 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Jul 14 13:55:01 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Jul 14 14:00:55 2014 +0200 @@ -32,26 +32,15 @@ public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Canonicalizable { private final JavaType returnType; - private ResolvedJavaMethod targetMethod; private InvokeKind invokeKind; /** * @param arguments */ public MethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType) { - super(arguments); + super(arguments, targetMethod); this.invokeKind = invokeKind; this.returnType = returnType; - this.targetMethod = targetMethod; - } - - /** - * Gets the target method for this invocation instruction. - * - * @return the target method - */ - public ResolvedJavaMethod targetMethod() { - return targetMethod; } public InvokeKind invokeKind() { @@ -62,10 +51,6 @@ this.invokeKind = kind; } - public void setTargetMethod(ResolvedJavaMethod method) { - targetMethod = method; - } - /** * Gets the instruction that produces the receiver object for this invocation, if any. * @@ -100,12 +85,12 @@ assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n); } if (invokeKind == InvokeKind.Special || invokeKind == InvokeKind.Static) { - assertFalse(targetMethod.isAbstract(), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod); + assertFalse(targetMethod().isAbstract(), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod()); } if (invokeKind == InvokeKind.Static) { - assertTrue(targetMethod.isStatic(), "static calls are only allowed for static methods (%s)", targetMethod); + assertTrue(targetMethod().isStatic(), "static calls are only allowed for static methods (%s)", targetMethod()); } else { - assertFalse(targetMethod.isStatic(), "static calls are only allowed for non-static methods (%s)", targetMethod); + assertFalse(targetMethod().isStatic(), "static calls are only allowed for non-static methods (%s)", targetMethod()); } return super.verify(); } @@ -125,7 +110,7 @@ // attempt to devirtualize the call // check for trivial cases (e.g. final methods, nonvirtual methods) - if (targetMethod.canBeStaticallyBound()) { + if (targetMethod().canBeStaticallyBound()) { invokeKind = InvokeKind.Special; return this; } @@ -138,29 +123,29 @@ * either the holder class is exact, or the receiver object has an exact type, or * it's an array type */ - ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod, invoke().getContextType()); + ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod(), invoke().getContextType()); if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver) || type.isArray())) { invokeKind = InvokeKind.Special; - targetMethod = resolvedMethod; + setTargetMethod(resolvedMethod); return this; } if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { ResolvedJavaType uniqueConcreteType = type.findUniqueConcreteSubtype(); if (uniqueConcreteType != null) { - ResolvedJavaMethod methodFromUniqueType = uniqueConcreteType.resolveMethod(targetMethod, invoke().getContextType()); + ResolvedJavaMethod methodFromUniqueType = uniqueConcreteType.resolveMethod(targetMethod(), invoke().getContextType()); if (methodFromUniqueType != null) { tool.assumptions().recordConcreteSubtype(type, uniqueConcreteType); invokeKind = InvokeKind.Special; - targetMethod = methodFromUniqueType; + setTargetMethod(methodFromUniqueType); return this; } } - ResolvedJavaMethod uniqueConcreteMethod = type.findUniqueConcreteMethod(targetMethod); + ResolvedJavaMethod uniqueConcreteMethod = type.findUniqueConcreteMethod(targetMethod()); if (uniqueConcreteMethod != null) { - tool.assumptions().recordConcreteMethod(targetMethod, type, uniqueConcreteMethod); + tool.assumptions().recordConcreteMethod(targetMethod(), type, uniqueConcreteMethod); invokeKind = InvokeKind.Special; - targetMethod = uniqueConcreteMethod; + setTargetMethod(uniqueConcreteMethod); return this; } } @@ -171,7 +156,7 @@ @Override public Stamp returnStamp() { - Kind returnKind = targetMethod.getSignature().getReturnKind(); + Kind returnKind = targetMethod().getSignature().getReturnKind(); if (returnKind == Kind.Object && returnType instanceof ResolvedJavaType) { return StampFactory.declared((ResolvedJavaType) returnType); } else { @@ -193,7 +178,7 @@ public static MethodCallTargetNode find(StructuredGraph graph, ResolvedJavaMethod method) { for (MethodCallTargetNode target : graph.getNodes(MethodCallTargetNode.class)) { - if (target.targetMethod.equals(method)) { + if (target.targetMethod().equals(method)) { return target; } }