changeset 6647:0b8410de1365

removed targetClassInstruction from InstanceOfNode
author Doug Simon <doug.simon@oracle.com>
date Tue, 30 Oct 2012 08:57:28 +0100
parents c38f13903fdf
children 7bf5a6c42db7
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java
diffstat 5 files changed, 24 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java	Mon Oct 29 21:10:04 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/InstanceOfSnippets.java	Tue Oct 30 08:57:28 2012 +0100
@@ -179,10 +179,10 @@
         }
 
         public void lower(InstanceOfNode instanceOf, LoweringTool tool) {
-            ValueNode hub = instanceOf.targetClassInstruction();
             ValueNode object = instanceOf.object();
-            TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.targetClass(), instanceOf.profile(), tool.assumptions(), GraalOptions.CheckcastMinHintHitProbability, GraalOptions.CheckcastMaxHints);
-            final HotSpotResolvedJavaType target = (HotSpotResolvedJavaType) instanceOf.targetClass();
+            TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.type(), instanceOf.profile(), tool.assumptions(), GraalOptions.CheckcastMinHintHitProbability, GraalOptions.CheckcastMaxHints);
+            final HotSpotResolvedJavaType target = (HotSpotResolvedJavaType) instanceOf.type();
+            ConstantNode hub = ConstantNode.forObject(target.klassOop(), runtime, instanceOf.graph());
             boolean checkNull = !object.stamp().nonNull();
 
             for (Node usage : instanceOf.usages().snapshot()) {
@@ -191,7 +191,7 @@
 
                 // instanceof nodes are lowered separately for each usage. To simply graph modifications,
                 // we duplicate the instanceof node for each usage.
-                final InstanceOfNode duplicate = instanceOf.graph().add(new InstanceOfNode(instanceOf.targetClassInstruction(), instanceOf.targetClass(), instanceOf.object(), instanceOf.profile()));
+                final InstanceOfNode duplicate = instanceOf.graph().add(new InstanceOfNode(instanceOf.type(), instanceOf.object(), instanceOf.profile()));
                 usage.replaceFirstInput(instanceOf, duplicate);
 
                 if (usage instanceof IfNode) {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Oct 29 21:10:04 2012 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Tue Oct 30 08:57:28 2012 +0100
@@ -651,8 +651,7 @@
         ValueNode object = frameState.apop();
         if (type instanceof ResolvedJavaType) {
             ResolvedJavaType resolvedType = (ResolvedJavaType) type;
-            ConstantNode hub = appendConstant(resolvedType.getEncoding(Representation.ObjectHub));
-            InstanceOfNode instanceOfNode = new InstanceOfNode(hub, (ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType));
+            InstanceOfNode instanceOfNode = new InstanceOfNode((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType));
             frameState.ipush(append(MaterializeNode.create(currentGraph.unique(instanceOfNode))));
         } else {
             BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode());
@@ -1424,7 +1423,7 @@
             frameState.push(Kind.Object, exception);
             FixedNode nextDispatch = createTarget(nextBlock, frameState);
             checkCast.setNext(catchSuccessor);
-            IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new InstanceOfNode(typeInstruction, (ResolvedJavaType) catchType, exception)), checkCast, nextDispatch, 0.5, graphId));
+            IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5, graphId));
             append(ifNode);
         }
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Mon Oct 29 21:10:04 2012 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Tue Oct 30 08:57:28 2012 +0100
@@ -35,28 +35,21 @@
 public final class InstanceOfNode extends BooleanNode implements Canonicalizable, Lowerable, LIRLowerable {
 
     @Input private ValueNode object;
-    @Input private ValueNode targetClassInstruction;
-    private final ResolvedJavaType targetClass;
+    private final ResolvedJavaType type;
     private final JavaTypeProfile profile;
 
     /**
      * Constructs a new InstanceOfNode.
      *
-     * @param targetClassInstruction the instruction which produces the target class of the instanceof check
-     * @param targetClass the class which is the target of the instanceof check
-     * @param object the instruction producing the object input to this instruction
+     * @param type the target type of the instanceof check
+     * @param object the object being tested by the instanceof
      */
-    public InstanceOfNode(ValueNode targetClassInstruction, ResolvedJavaType targetClass, ValueNode object) {
-        this(targetClassInstruction, targetClass, object, null);
-    }
-
-    public InstanceOfNode(ValueNode targetClassInstruction, ResolvedJavaType targetClass, ValueNode object, JavaTypeProfile profile) {
+    public InstanceOfNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile) {
         super(StampFactory.condition());
-        this.targetClassInstruction = targetClassInstruction;
-        this.targetClass = targetClass;
+        this.type = type;
         this.object = object;
         this.profile = profile;
-        assert targetClass != null;
+        assert type != null;
     }
 
     @Override
@@ -73,10 +66,10 @@
         assert object() != null : this;
 
         ObjectStamp stamp = object().objectStamp();
-        ResolvedJavaType type = stamp.type();
+        ResolvedJavaType stampType = stamp.type();
 
         if (stamp.isExactType()) {
-            boolean subType = type.isSubtypeOf(targetClass());
+            boolean subType = stampType.isSubtypeOf(type());
 
             if (subType) {
                 if (stamp.nonNull()) {
@@ -92,8 +85,8 @@
                 // we also don't care about null values, since they will also make the check fail.
                 return ConstantNode.forBoolean(false, graph());
             }
-        } else if (type != null) {
-            boolean subType = type.isSubtypeOf(targetClass());
+        } else if (stampType != null) {
+            boolean subType = stampType.isSubtypeOf(type());
 
             if (subType) {
                 if (stamp.nonNull()) {
@@ -118,16 +111,11 @@
         return object;
     }
 
-    public ValueNode targetClassInstruction() {
-        return targetClassInstruction;
-    }
-
     /**
-     * Gets the target class, i.e. the class being cast to, or the class being tested against.
-     * @return the target class
+     * Gets the type being tested.
      */
-    public ResolvedJavaType targetClass() {
-        return targetClass;
+    public ResolvedJavaType type() {
+        return type;
     }
 
     public JavaTypeProfile profile() {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Mon Oct 29 21:10:04 2012 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Oct 30 08:57:28 2012 +0100
@@ -277,7 +277,7 @@
                         if ((node == ifNode.trueSuccessor())) {
                             ValueNode object = instanceOf.object();
                             state.knownNotNull.add(object);
-                            state.knownTypes.put(object, tighten(instanceOf.targetClass(), state.getNodeType(object)));
+                            state.knownTypes.put(object, tighten(instanceOf.type(), state.getNodeType(object)));
                             metricInstanceOfRegistered.increment();
                         }
                     } else if (ifNode.condition() instanceof IsNullNode) {
@@ -351,7 +351,7 @@
                             replaceWith = ConstantNode.forBoolean(false, graph);
                         } else if (state.knownNotNull.contains(object)) {
                             ResolvedJavaType type = state.getNodeType(object);
-                            if (type != null && type.isSubtypeOf(instanceOf.targetClass())) {
+                            if (type != null && type.isSubtypeOf(instanceOf.type())) {
                                 replaceWith = ConstantNode.forBoolean(true, graph);
                             }
                         }
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Mon Oct 29 21:10:04 2012 +0100
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Tue Oct 30 08:57:28 2012 +0100
@@ -30,6 +30,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.common.*;
 import com.oracle.graal.snippets.CheckCastTest.Depth12;
 import com.oracle.graal.snippets.CheckCastTest.Depth13;
 import com.oracle.graal.snippets.CheckCastTest.Depth14;
@@ -42,14 +43,14 @@
 
     @Override
     protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) {
-    //    phasePlan.disablePhase(InliningPhase.class);
+        phasePlan.disablePhase(InliningPhase.class);
     }
 
     @Override
     protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) {
         InstanceOfNode ion = graph.getNodes().filter(InstanceOfNode.class).first();
         if (ion != null) {
-            InstanceOfNode ionNew = graph.add(new InstanceOfNode(ion.targetClassInstruction(), ion.targetClass(), ion.object(), profile));
+            InstanceOfNode ionNew = graph.add(new InstanceOfNode(ion.type(), ion.object(), profile));
             graph.replaceFloating(ion, ionNew);
         }
     }