# HG changeset patch # User Lukas Stadler # Date 1399307969 -7200 # Node ID d968c2db220b91aab6f09d1246ec493cfd2ec6ad # Parent ef1342e0f9f28870a3887865110b807f3d3bcc40# Parent 49a917f9fa073973109052d62671c922af3c86cf Merge ([flow-sensitive] refactoring, factor out evidence-search) diff -r ef1342e0f9f2 -r d968c2db220b 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 Mon May 05 18:39:09 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Mon May 05 18:39:29 2014 +0200 @@ -267,6 +267,10 @@ } if (FlowUtil.hasLegalObjectStamp(v)) { + if (state.isNull(v)) { + // it's ok to return nullConstant in deverbosify unlike in downcast + return nullConstant; + } return downcast(v); } @@ -441,6 +445,8 @@ return baseCaseIsNullNode((IsNullNode) condition); } else if (condition instanceof ObjectEqualsNode) { return baseCaseObjectEqualsNode((ObjectEqualsNode) condition); + } else if (condition instanceof ShortCircuitOrNode) { + return baseCaseShortCircuitOrNode((ShortCircuitOrNode) condition); } } return condition; @@ -483,7 +489,7 @@ return isNull; } ValueNode scrutinee = GraphUtil.unproxify(isNull.object()); - GuardingNode evidence = nonTrivialNullAnchor(scrutinee); + GuardingNode evidence = state.nonTrivialNullAnchor(scrutinee); if (evidence != null) { metricNullCheckRemoved.increment(); return trueConstant; @@ -515,6 +521,38 @@ } /** + * The following is tried: + * + *
    + *
  1. + * A {@link com.oracle.graal.phases.common.cfs.Witness} that is at check-cast level level + * doesn't entail {@link com.oracle.graal.nodes.calc.IsNullNode} (on its own) nor + * {@link com.oracle.graal.nodes.java.InstanceOfNode} (also on its own) but of course it entails + * (IsNull || IsInstanceOf). Good thing + * {@link com.oracle.graal.phases.common.cfs.CastCheckExtractor} detects that very pattern.
  2. + *
  3. + * Otherwise return the unmodified argument (later on, + * {@link #deverbosifyFloatingNode(com.oracle.graal.nodes.calc.FloatingNode)} will attempt to + * simplify the {@link com.oracle.graal.nodes.ShortCircuitOrNode}).
  4. + *
+ * + * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made; + * otherwise the unmodified argument. + */ + private LogicNode baseCaseShortCircuitOrNode(ShortCircuitOrNode orNode) { + CastCheckExtractor cast = CastCheckExtractor.extract(orNode); + if (cast != null) { + if (state.knownToConform(cast.subject, cast.type)) { + return trueConstant; + } else if (state.knownNotToConform(cast.subject, cast.type)) { + return falseConstant; + } + return orNode; + } + return orNode; + } + + /** * It's always ok to use "downcast(object)" instead of " object" * because this method re-wraps the argument in a {@link com.oracle.graal.nodes.PiNode} only if * the new stamp is strictly more refined than the original. @@ -646,24 +684,6 @@ } /** - *

- * If the argument is known null due to its stamp, there's no need to have an anchor for that - * fact and this method returns null. - *

- * - *

- * Otherwise, if an anchor is found it is returned, null otherwise. - *

- */ - public GuardingNode nonTrivialNullAnchor(ValueNode object) { - assert FlowUtil.hasLegalObjectStamp(object); - if (StampTool.isObjectAlwaysNull(object)) { - return null; - } - return state.knownNull.get(GraphUtil.unproxify(object)); - } - - /** * * This method returns: *