changeset 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
files graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRBuilder.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/CallTargetNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DirectCallTargetNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IndirectCallTargetNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoweredCallTargetNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java
diffstat 10 files changed, 49 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Mon Jul 14 14:00:55 2014 +0200
@@ -52,7 +52,7 @@
     protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
         AllocatableValue targetAddress = AMD64.rax.asValue();
         gen.emitMove(targetAddress, operand(callTarget.computedAddress()));
-        append(new AMD64Call.IndirectCallOp(callTarget.target(), result, parameters, temps, targetAddress, callState));
+        append(new AMD64Call.IndirectCallOp(callTarget.targetMethod(), result, parameters, temps, targetAddress, callState));
     }
 
     @Override
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRBuilder.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRBuilder.java	Mon Jul 14 14:00:55 2014 +0200
@@ -47,12 +47,12 @@
 
     @Override
     protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented(callTarget.target().format("direct call to %H.%n(%p)"));
+        throw GraalInternalError.unimplemented(callTarget.targetMethod().format("direct call to %H.%n(%p)"));
     }
 
     @Override
     protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented(callTarget.target().format("direct call to %H.%n(%p)"));
+        throw GraalInternalError.unimplemented(callTarget.targetMethod().format("direct call to %H.%n(%p)"));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Mon Jul 14 14:00:55 2014 +0200
@@ -148,12 +148,12 @@
     protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
         InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind();
         if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
-            append(new AMD64HotspotDirectVirtualCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
+            append(new AMD64HotspotDirectVirtualCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind));
         } else {
             assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
-            HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target();
+            HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod();
             assert !resolvedMethod.isAbstract() : "Cannot make direct call to abstract method.";
-            append(new AMD64HotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
+            append(new AMD64HotspotDirectStaticCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind));
         }
     }
 
@@ -164,7 +164,7 @@
             gen.emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod()));
             AllocatableValue targetAddress = AMD64.rax.asValue();
             gen.emitMove(targetAddress, operand(callTarget.computedAddress()));
-            append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState));
+            append(new AMD64IndirectCallOp(callTarget.targetMethod(), result, parameters, temps, metaspaceMethod, targetAddress, callState));
         } else {
             super.emitIndirectCall(callTarget, result, parameters, temps, callState);
         }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Mon Jul 14 14:00:55 2014 +0200
@@ -96,12 +96,12 @@
     protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
         InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind();
         if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
-            append(new SPARCHotspotDirectVirtualCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
+            append(new SPARCHotspotDirectVirtualCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind));
         } else {
             assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
-            HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target();
+            HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod();
             assert !resolvedMethod.isAbstract() : "Cannot make direct call to abstract method.";
-            append(new SPARCHotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
+            append(new SPARCHotspotDirectStaticCallOp(callTarget.targetMethod(), result, parameters, temps, callState, invokeKind));
         }
     }
 
@@ -111,7 +111,7 @@
         gen.emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod()));
         AllocatableValue targetAddress = g3.asValue();
         gen.emitMove(targetAddress, operand(callTarget.computedAddress()));
-        append(new SPARCIndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState));
+        append(new SPARCIndirectCallOp(callTarget.targetMethod(), result, parameters, temps, metaspaceMethod, targetAddress, callState));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ArrayCopyIntrinsificationTest.java	Mon Jul 14 14:00:55 2014 +0200
@@ -52,7 +52,7 @@
                         Invoke invoke = (Invoke) node;
                         Assert.assertTrue(invoke.callTarget() instanceof DirectCallTargetNode);
                         LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
-                        JavaMethod callee = directCall.target();
+                        JavaMethod callee = directCall.targetMethod();
                         Assert.assertTrue(callee.getName().equals("<init>"));
                         Assert.assertTrue(getMetaAccess().lookupJavaType(ArrayIndexOutOfBoundsException.class).equals(callee.getDeclaringClass()) ||
                                         getMetaAccess().lookupJavaType(NullPointerException.class).equals(callee.getDeclaringClass()));
@@ -64,7 +64,7 @@
                     if (node instanceof Invoke) {
                         Invoke invoke = (Invoke) node;
                         LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
-                        JavaMethod callee = directCall.target();
+                        JavaMethod callee = directCall.targetMethod();
                         if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) {
                             found = true;
                         } else {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/CallTargetNode.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/CallTargetNode.java	Mon Jul 14 14:00:55 2014 +0200
@@ -24,13 +24,13 @@
 
 import java.util.*;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Extension})
 public abstract class CallTargetNode extends ValueNode implements LIRLowerable {
-
     public enum InvokeKind {
         Interface,
         Special,
@@ -39,14 +39,17 @@
     }
 
     @Input private final NodeInputList<ValueNode> arguments;
+    private ResolvedJavaMethod targetMethod;
 
-    public CallTargetNode(ValueNode[] arguments) {
+    public CallTargetNode(ValueNode[] arguments, ResolvedJavaMethod targetMethod) {
         super(StampFactory.forVoid());
+        this.targetMethod = targetMethod;
         this.arguments = new NodeInputList<>(this, arguments);
     }
 
-    public CallTargetNode(List<ValueNode> arguments) {
+    public CallTargetNode(List<ValueNode> arguments, ResolvedJavaMethod targetMethod) {
         super(StampFactory.forVoid());
+        this.targetMethod = targetMethod;
         this.arguments = new NodeInputList<>(this, arguments);
     }
 
@@ -65,4 +68,17 @@
     public void generate(NodeLIRBuilderTool gen) {
         // nop
     }
+
+    public void setTargetMethod(ResolvedJavaMethod method) {
+        targetMethod = method;
+    }
+
+    /**
+     * Gets the target method for this invocation instruction.
+     *
+     * @return the target method
+     */
+    public ResolvedJavaMethod targetMethod() {
+        return targetMethod;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DirectCallTargetNode.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DirectCallTargetNode.java	Mon Jul 14 14:00:55 2014 +0200
@@ -36,6 +36,6 @@
 
     @Override
     public String targetName() {
-        return target().format("Direct#%h.%n");
+        return targetMethod().format("Direct#%h.%n");
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IndirectCallTargetNode.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IndirectCallTargetNode.java	Mon Jul 14 14:00:55 2014 +0200
@@ -43,6 +43,6 @@
 
     @Override
     public String targetName() {
-        return target().format("Indirect#%h.%n");
+        return targetMethod().format("Indirect#%h.%n");
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoweredCallTargetNode.java	Mon Jul 14 13:55:01 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoweredCallTargetNode.java	Mon Jul 14 14:00:55 2014 +0200
@@ -32,14 +32,12 @@
 
     private final Stamp returnStamp;
     private final JavaType[] signature;
-    private final ResolvedJavaMethod target;
     private final CallingConvention.Type callType;
 
     public LoweredCallTargetNode(List<ValueNode> arguments, Stamp returnStamp, JavaType[] signature, ResolvedJavaMethod target, CallingConvention.Type callType) {
-        super(arguments);
+        super(arguments, target);
         this.returnStamp = returnStamp;
         this.signature = signature;
-        this.target = target;
         this.callType = callType;
     }
 
@@ -52,10 +50,6 @@
         return signature;
     }
 
-    public ResolvedJavaMethod target() {
-        return target;
-    }
-
     public CallingConvention.Type callType() {
         return callType;
     }
--- 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;
             }
         }