@Override public TriState implies(boolean thisNegated, LogicNode other) { if (other instanceof UnaryOpLogicNode) { UnaryOpLogicNode unaryY = (UnaryOpLogicNode) other; if (this.getValue() == unaryY.getValue() || // fast path skipThroughPisAndProxies(this.getValue()) == skipThroughPisAndProxies(unaryY.getValue())) { Stamp succStamp = this.getSucceedingStampForValue(thisNegated); TriState fold = unaryY.tryFold(succStamp); if (fold.isKnown()) { return fold; } } } return super.implies(thisNegated, other); }
protected TriState tryProveCondition(LogicNode condition) { Stamp conditionStamp = this.getBestStamp(condition); if (conditionStamp == StampFactory.tautology()) { return TriState.TRUE; } else if (conditionStamp == StampFactory.contradiction()) { return TriState.FALSE; } if (condition instanceof UnaryOpLogicNode) { UnaryOpLogicNode unaryOpLogicNode = (UnaryOpLogicNode) condition; return unaryOpLogicNode.tryFold(this.getBestStamp(unaryOpLogicNode.getValue())); } else if (condition instanceof BinaryOpLogicNode) { BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) condition; return binaryOpLogicNode.tryFold(this.getBestStamp(binaryOpLogicNode.getX()), this.getBestStamp(binaryOpLogicNode.getY())); } return TriState.UNKNOWN; }
protected void registerNewCondition(LogicNode condition, boolean negated) { if (condition instanceof UnaryOpLogicNode) { UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) condition; ValueNode value = unaryLogicNode.getValue(); Stamp newStamp = unaryLogicNode.getSucceedingStampForValue(negated); registerNewValueStamp(value, newStamp); } else if (condition instanceof BinaryOpLogicNode) { BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) condition; ValueNode x = binaryOpLogicNode.getX(); ValueNode y = binaryOpLogicNode.getY(); Stamp xStamp = getBestStamp(x); Stamp yStamp = getBestStamp(y); registerNewValueStamp(x, binaryOpLogicNode.getSucceedingStampForX(negated, xStamp, yStamp)); registerNewValueStamp(y, binaryOpLogicNode.getSucceedingStampForY(negated, xStamp, yStamp)); } registerCondition(condition, negated); }
ValueNode value = unaryLogicNode.getValue(); infoElement = getInfoElements(value); while (infoElement != null) { Stamp stamp = infoElement.getStamp(); TriState result = unaryLogicNode.tryFold(stamp); if (result.isKnown()) { return rewireGuards(infoElement.getGuard(), result.toBoolean(), infoElement.getProxifiedInput(), infoElement.getStamp(), rewireGuardFunction); TriState result = unaryLogicNode.tryFold(foldResult.getRight()); if (result.isKnown()) { return rewireGuards(foldResult.getLeft().getGuard(), result.toBoolean(), foldResult.getLeft().getProxifiedInput(), foldResult.getRight(), rewireGuardFunction); Stamp newStamp = unaryLogicNode.getSucceedingStampForValue(thisGuard.isNegated()); if (newStamp != null && foldPendingTest(thisGuard, value, newStamp, rewireGuardFunction)) { return true;
ValueNode value = node.getValue(); if (value instanceof ParameterNode) {
/** * In general the input stamp cannot be trusted, this method is reserved for the cases when it's * "safe" to use the input stamp. To ensure safety use * {@link #getSucceedingStampForValue(boolean)} instead. */ public Stamp getSucceedingStampForValue(boolean negated, Stamp valueStamp) { Stamp succStamp = getSucceedingStampForValue(negated); if (succStamp != null) { succStamp = succStamp.join(valueStamp); } return succStamp; }
@Override public boolean verify() { assertTrue(getValue() != null, "is null input must not be null"); assertTrue(getValue().stamp(NodeView.DEFAULT) instanceof AbstractPointerStamp, "input must be a pointer not %s", getValue().stamp(NodeView.DEFAULT)); return super.verify(); }
@Override public TriState implies(boolean thisNegated, LogicNode other) { if (other instanceof InstanceOfNode) { InstanceOfNode instanceOfNode = (InstanceOfNode) other; if (instanceOfNode.getValue() == getValue()) { if (thisNegated) { // !X => Y if (this.getCheckedStamp().meet(instanceOfNode.getCheckedStamp()).equals(this.getCheckedStamp())) { return TriState.get(false); } } else { // X => Y if (instanceOfNode.getCheckedStamp().meet(this.getCheckedStamp()).equals(instanceOfNode.getCheckedStamp())) { return TriState.get(true); } } } } return super.implies(thisNegated, other); } }
protected void registerNewCondition(LogicNode condition, boolean negated, GuardingNode guard) { if (condition instanceof UnaryOpLogicNode) { UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) condition; ValueNode value = unaryLogicNode.getValue(); if (maybeMultipleUsages(value)) { Stamp newStamp = unaryLogicNode.getSucceedingStampForValue(negated); registerNewStamp(value, newStamp, guard, true);