changeset 21766:bb72c486714a

Lower TypeCheck node in first lowering.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 07 Jun 2015 01:08:35 +0200
parents a7a1b9b65bce
children 8c7e103521ef
files graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java
diffstat 3 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Sun Jun 07 00:47:10 2015 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Sun Jun 07 01:08:35 2015 +0200
@@ -2220,7 +2220,7 @@
             frameState.push(Kind.Object, exception);
             FixedNode nextDispatch = createTarget(nextBlock, frameState);
             checkCast.setNext(catchSuccessor);
-            append(new IfNode(graph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5));
+            append(new IfNode(graph.unique(InstanceOfNode.create((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5));
         } else {
             handleUnresolvedExceptionType(catchType);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Sun Jun 07 00:47:10 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Sun Jun 07 01:08:35 2015 +0200
@@ -120,6 +120,7 @@
     public void lower(LoweringTool tool) {
         Stamp newStamp = StampFactory.declaredTrusted(type).improveWith(object().stamp());
         LogicNode condition;
+        LogicNode innerNode = null;
         ValueNode theValue = object;
         if (newStamp.isEmpty()) {
             // This is a check cast that will always fail
@@ -127,11 +128,13 @@
             newStamp = StampFactory.declaredTrusted(type);
         } else if (StampTool.isPointerNonNull(object)) {
             condition = graph().addWithoutUnique(InstanceOfNode.create(type, object, profile));
+            innerNode = condition;
         } else {
             if (profile != null && profile.getNullSeen() == TriState.FALSE) {
                 FixedGuardNode nullCheck = graph().add(new FixedGuardNode(graph().unique(new IsNullNode(object)), UnreachedCode, InvalidateReprofile, true));
                 PiNode nullGuarded = graph().unique(new PiNode(object, object().stamp().join(StampFactory.objectNonNull()), nullCheck));
-                InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, nullGuarded, profile));
+                LogicNode typeTest = graph().addWithoutUnique(InstanceOfNode.create(type, nullGuarded, profile));
+                innerNode = typeTest;
                 graph().addBeforeFixed(this, nullCheck);
                 condition = typeTest;
                 /*
@@ -145,7 +148,8 @@
             } else {
                 // TODO (ds) replace with probability of null-seen when available
                 double shortCircuitProbability = NOT_FREQUENT_PROBABILITY;
-                InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, object, profile));
+                LogicNode typeTest = graph().addOrUnique(InstanceOfNode.create(type, object, profile));
+                innerNode = typeTest;
                 condition = LogicNode.or(graph().unique(new IsNullNode(object)), typeTest, shortCircuitProbability);
             }
         }
@@ -154,6 +158,10 @@
         PiNode piNode = graph().unique(new PiNode(theValue, newStamp, valueAnchor));
         this.replaceAtUsages(piNode);
         graph().replaceFixedWithFixed(this, valueAnchor);
+
+        if (innerNode instanceof Lowerable) {
+            tool.getLowerer().lower(innerNode, tool);
+        }
     }
 
     @Override
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Sun Jun 07 00:47:10 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Sun Jun 07 01:08:35 2015 +0200
@@ -73,6 +73,7 @@
 
     @Override
     public void lower(Node n, LoweringTool tool) {
+        assert n instanceof Lowerable;
         StructuredGraph graph = (StructuredGraph) n.graph();
         if (n instanceof LoadFieldNode) {
             lowerLoadFieldNode((LoadFieldNode) n, tool);
@@ -107,9 +108,7 @@
         } else if (n instanceof UnboxNode) {
             boxingSnippets.lower((UnboxNode) n, tool);
         } else if (n instanceof TypeCheckNode) {
-            if (graph.getGuardsStage().areDeoptsFixed()) {
-                lowerTypeCheckNode((TypeCheckNode) n, tool, graph);
-            }
+            lowerTypeCheckNode((TypeCheckNode) n, tool, graph);
         } else if (n instanceof VerifyHeapNode) {
             lowerVerifyHeap((VerifyHeapNode) n);
         } else {