private static LogicNode findSynonym(LogicNode value) {
   if (value instanceof LogicConstantNode) {
     LogicConstantNode logicConstantNode = (LogicConstantNode) value;
     return LogicConstantNode.forBoolean(!logicConstantNode.getValue());
   } else if (value instanceof LogicNegationNode) {
     return ((LogicNegationNode) value).getValue();
   }
   return null;
 }
示例#2
0
  private void registerIfNode(IfNode ifNode, BeginNode begin) {
    final boolean isThenBranch = (begin == ifNode.trueSuccessor());

    if (ifNode.condition() instanceof LogicConstantNode) {
      final LogicConstantNode constCond = (LogicConstantNode) ifNode.condition();
      if (isThenBranch != constCond.getValue()) {
        state.impossiblePath();
        // let IfNode(constant) prune the dead-code control-path
      }
    }

    if (state.isUnreachable) {
      if (!(ifNode.condition() instanceof LogicConstantNode)) {
        // if condition constant, no need to add a Deopt node
        postponedDeopts.addDeoptAfter(begin, UnreachedCode);
      }
    } else {
      state.addFact(isThenBranch, ifNode.condition(), begin);
    }
  }