< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/IsNullNode.java

Print this page




 104             }
 105         }
 106 
 107         if (self == null) {
 108             self = new IsNullNode(GraphUtil.skipPi(forValue));
 109         }
 110         return self;
 111     }
 112 
 113     @Override
 114     public void virtualize(VirtualizerTool tool) {
 115         ValueNode alias = tool.getAlias(getValue());
 116         TriState fold = tryFold(alias.stamp());
 117         if (fold != TriState.UNKNOWN) {
 118             tool.replaceWithValue(LogicConstantNode.forBoolean(fold.isTrue(), graph()));
 119         }
 120     }
 121 
 122     @Override
 123     public Stamp getSucceedingStampForValue(boolean negated) {
 124         AbstractPointerStamp pointerStamp = (AbstractPointerStamp) getValue().stamp();

 125         return negated ? pointerStamp.asNonNull() : pointerStamp.asAlwaysNull();
 126     }
 127 
 128     @Override
 129     public TriState tryFold(Stamp valueStamp) {
 130         if (valueStamp instanceof ObjectStamp) {
 131             ObjectStamp objectStamp = (ObjectStamp) valueStamp;
 132             if (objectStamp.alwaysNull()) {
 133                 return TriState.TRUE;
 134             } else if (objectStamp.nonNull()) {
 135                 return TriState.FALSE;
 136             }
 137         }
 138         return TriState.UNKNOWN;
 139     }
 140 }


 104             }
 105         }
 106 
 107         if (self == null) {
 108             self = new IsNullNode(GraphUtil.skipPi(forValue));
 109         }
 110         return self;
 111     }
 112 
 113     @Override
 114     public void virtualize(VirtualizerTool tool) {
 115         ValueNode alias = tool.getAlias(getValue());
 116         TriState fold = tryFold(alias.stamp());
 117         if (fold != TriState.UNKNOWN) {
 118             tool.replaceWithValue(LogicConstantNode.forBoolean(fold.isTrue(), graph()));
 119         }
 120     }
 121 
 122     @Override
 123     public Stamp getSucceedingStampForValue(boolean negated) {
 124         // Ignore any more precise input stamp since canonicalization will skip through PiNodes
 125         AbstractPointerStamp pointerStamp = (AbstractPointerStamp) getValue().stamp().unrestricted();
 126         return negated ? pointerStamp.asNonNull() : pointerStamp.asAlwaysNull();
 127     }
 128 
 129     @Override
 130     public TriState tryFold(Stamp valueStamp) {
 131         if (valueStamp instanceof ObjectStamp) {
 132             ObjectStamp objectStamp = (ObjectStamp) valueStamp;
 133             if (objectStamp.alwaysNull()) {
 134                 return TriState.TRUE;
 135             } else if (objectStamp.nonNull()) {
 136                 return TriState.FALSE;
 137             }
 138         }
 139         return TriState.UNKNOWN;
 140     }
 141 }
< prev index next >