< prev index next >

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

Print this page




 105         return true;
 106     }
 107 
 108     protected abstract Stamp mkStamp(Stamp input);
 109 
 110     public CompressionOp getOp() {
 111         return op;
 112     }
 113 
 114     public CompressEncoding getEncoding() {
 115         return encoding;
 116     }
 117 
 118     @Override
 119     public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
 120         if (forValue.isConstant()) {
 121             if (GeneratePIC.getValue(tool.getOptions())) {
 122                 // We always want uncompressed constants
 123                 return this;
 124             }
 125             int stableDimension = ((ConstantNode) forValue).getStableDimension();
 126             boolean isDefaultStable = ((ConstantNode) forValue).isDefaultStable();
 127             return ConstantNode.forConstant(stamp(), convert(forValue.asConstant(), tool.getConstantReflection()), stableDimension, isDefaultStable, tool.getMetaAccess());
 128         } else if (forValue instanceof CompressionNode) {
 129             CompressionNode other = (CompressionNode) forValue;
 130             if (op != other.op && encoding.equals(other.encoding)) {
 131                 return other.getValue();
 132             }
 133         }
 134         return this;
 135     }
 136 
 137     @Override
 138     public void generate(NodeLIRBuilderTool gen) {
 139         LIRGeneratorTool hsGen = gen.getLIRGeneratorTool();
 140         boolean nonNull;
 141         if (getValue().stamp() instanceof AbstractObjectStamp) {
 142             nonNull = StampTool.isPointerNonNull(getValue().stamp());
 143         } else {
 144             // metaspace pointers are never null
 145             nonNull = true;
 146         }
 147 

 148         Value result;
 149         switch (op) {
 150             case Compress:
 151                 result = hsGen.emitCompress(gen.operand(getValue()), encoding, nonNull);
 152                 break;
 153             case Uncompress:
 154                 result = hsGen.emitUncompress(gen.operand(getValue()), encoding, nonNull);
 155                 break;
 156             default:
 157                 throw GraalError.shouldNotReachHere();
 158         }
 159 
 160         gen.setResult(this, result);
 161     }
 162 
 163     @Override
 164     public boolean mayNullCheckSkipConversion() {
 165         return true;
 166     }
 167 }


 105         return true;
 106     }
 107 
 108     protected abstract Stamp mkStamp(Stamp input);
 109 
 110     public CompressionOp getOp() {
 111         return op;
 112     }
 113 
 114     public CompressEncoding getEncoding() {
 115         return encoding;
 116     }
 117 
 118     @Override
 119     public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
 120         if (forValue.isConstant()) {
 121             if (GeneratePIC.getValue(tool.getOptions())) {
 122                 // We always want uncompressed constants
 123                 return this;
 124             }
 125 
 126             ConstantNode constant = (ConstantNode) forValue;
 127             return ConstantNode.forConstant(stamp(), convert(constant.getValue(), tool.getConstantReflection()), constant.getStableDimension(), constant.isDefaultStable(), tool.getMetaAccess());
 128         } else if (forValue instanceof CompressionNode) {
 129             CompressionNode other = (CompressionNode) forValue;
 130             if (op != other.op && encoding.equals(other.encoding)) {
 131                 return other.getValue();
 132             }
 133         }
 134         return this;
 135     }
 136 
 137     @Override
 138     public void generate(NodeLIRBuilderTool gen) {

 139         boolean nonNull;
 140         if (value.stamp() instanceof AbstractObjectStamp) {
 141             nonNull = StampTool.isPointerNonNull(value.stamp());
 142         } else {
 143             // metaspace pointers are never null
 144             nonNull = true;
 145         }
 146 
 147         LIRGeneratorTool tool = gen.getLIRGeneratorTool();
 148         Value result;
 149         switch (op) {
 150             case Compress:
 151                 result = tool.emitCompress(gen.operand(value), encoding, nonNull);
 152                 break;
 153             case Uncompress:
 154                 result = tool.emitUncompress(gen.operand(value), encoding, nonNull);
 155                 break;
 156             default:
 157                 throw GraalError.shouldNotReachHere();
 158         }
 159 
 160         gen.setResult(this, result);
 161     }
 162 
 163     @Override
 164     public boolean mayNullCheckSkipConversion() {
 165         return true;
 166     }
 167 }
< prev index next >