# HG changeset patch
# User Miguel Garcia
# Date 1398792638 -7200
# Node ID 2f684eda1938cc92a72a35461c8d00f1871fe389
# Parent bda013e0d8bb75f27560646d5d8bd8b638530046# Parent 10023073e8580d8effc91a970f060aab50ef3cd2
Merge
diff -r 10023073e858 -r 2f684eda1938 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/BaseReduction.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/BaseReduction.java Tue Apr 29 18:35:10 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/BaseReduction.java Tue Apr 29 19:30:38 2014 +0200
@@ -208,7 +208,7 @@
*
*
*/
- protected static boolean precisionLoss(ValueNode input, ValueNode output) {
+ public static boolean precisionLoss(ValueNode input, ValueNode output) {
ObjectStamp inputStamp = (ObjectStamp) input.stamp();
ObjectStamp outputStamp = (ObjectStamp) output.stamp();
if (FlowUtil.isMorePrecise(inputStamp.type(), outputStamp.type())) {
diff -r 10023073e858 -r 2f684eda1938 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CheckCastReduction.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CheckCastReduction.java Tue Apr 29 18:35:10 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CheckCastReduction.java Tue Apr 29 19:30:38 2014 +0200
@@ -299,9 +299,6 @@
ObjectStamp subjectStamp = (ObjectStamp) subject.stamp();
ResolvedJavaType subjectType = subjectStamp.type();
- // TODO move this check to downcast()
- assert !precisionLoss(checkCast.object(), subject);
-
/*
* At this point, two sources of (partial) information: the witness and the stamp of
* subject. The latter might be more precise than the witness (eg, subject might be
diff -r 10023073e858 -r 2f684eda1938 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Tue Apr 29 18:35:10 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Tue Apr 29 19:30:38 2014 +0200
@@ -547,7 +547,7 @@
return object;
}
if (StampTool.isObjectAlwaysNull(object.stamp())) {
- return nonTrivialNull(object);
+ return object;
}
// ------------------------------------------
@@ -586,6 +586,8 @@
result = downcastedUtil(object, w);
}
+ assert !BaseReduction.precisionLoss(object, result);
+
return result;
}
diff -r 10023073e858 -r 2f684eda1938 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReduction.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReduction.java Tue Apr 29 18:35:10 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReduction.java Tue Apr 29 19:30:38 2014 +0200
@@ -26,6 +26,7 @@
import com.oracle.graal.graph.Node;
import com.oracle.graal.nodes.*;
import com.oracle.graal.nodes.calc.FloatingNode;
+import com.oracle.graal.nodes.calc.IsNullNode;
import com.oracle.graal.nodes.extended.LoadHubNode;
import com.oracle.graal.nodes.extended.NullCheckNode;
import com.oracle.graal.nodes.java.*;
@@ -37,6 +38,7 @@
import java.lang.reflect.Modifier;
+import static com.oracle.graal.api.meta.DeoptimizationAction.InvalidateReprofile;
import static com.oracle.graal.api.meta.DeoptimizationReason.*;
/**
@@ -134,7 +136,7 @@
}
private static boolean isAliveWithoutUsages(FloatingNode node) {
- return node.isAlive() && node.usages().isEmpty();
+ return node.isAlive() && FlowUtil.lacksUsages(node);
}
private void registerControlSplit(Node pred, BeginNode begin) {
@@ -195,18 +197,13 @@
// `begin` denotes the default case of the TypeSwitchNode
return;
}
- // preferable would be trackExact, but not there yet
- state.addNullness(false, loadHub.object(), begin);
if (state.knownNotToConform(loadHub.object(), type)) {
postponedDeopts.addDeoptAfter(begin, UnreachedCode);
state.impossiblePath();
return;
}
- if (type.isInterface()) {
- state.trackNN(loadHub.object(), begin);
- } else {
- state.trackIO(loadHub.object(), type, begin);
- }
+ // it's unwarranted to assume loadHub.object() to be non-null
+ // it also seems unwarranted state.trackCC(loadHub.object(), type, begin);
}
}
@@ -437,6 +434,8 @@
*
* - is known to be null, an unconditional deopt is added.
* - is known to be non-null, the NullCheckNode is removed.
+ * - otherwise, the NullCheckNode is lowered to a FixedGuardNode which then allows using it as
+ * anchor for state-tracking.
*
*
*
@@ -459,7 +458,17 @@
graph.removeFixed(ncn);
return;
}
- // TODO ANCHOR NEEDED: state.trackNN(object, ncn);
+ /*
+ * Lower the NullCheckNode to a FixedGuardNode which then allows using it as anchor for
+ * state-tracking. TODO the assumption here is that the code emitted for the resulting
+ * FixedGuardNode is as efficient as for NullCheckNode.
+ */
+ IsNullNode isNN = graph.unique(new IsNullNode(object));
+ reasoner.added.add(isNN);
+ FixedGuardNode nullCheck = graph.add(new FixedGuardNode(isNN, UnreachedCode, InvalidateReprofile, true));
+ graph.replaceFixedWithFixed(ncn, nullCheck);
+
+ state.trackNN(object, nullCheck);
}
/**
diff -r 10023073e858 -r 2f684eda1938 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Tue Apr 29 18:35:10 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Tue Apr 29 19:30:38 2014 +0200
@@ -275,9 +275,11 @@
return true;
}
- for (State state : withReachableStates) {
- versionNr = Math.max(versionNr, state.versionNr) + 1;
- isUnreachable &= state.isUnreachable;
+ for (State other : withReachableStates) {
+ versionNr = Math.max(versionNr, other.versionNr) + 1;
+ if (!other.isUnreachable) {
+ isUnreachable = false;
+ }
}
if (isUnreachable) {
@@ -685,16 +687,6 @@
} else {
trackIO(object, instanceOf.type(), anchor);
}
- } else {
- if (knownToConform(object, instanceOf.type())) {
- impossiblePath(); // TODO this used to be a bug
- return;
- }
- if (instanceOf.type().isInterface()) {
- if (!knownNotToConform(object, instanceOf.type())) {
- addFactPrimordial(instanceOf, falseFacts, anchor);
- }
- }
}
}