< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/nodes/aot/ResolveConstantStubCall.java

Print this page




  26 
  27 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN;
  28 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_16;
  29 
  30 import org.graalvm.compiler.core.common.PermanentBailoutException;
  31 import org.graalvm.compiler.graph.Node;
  32 import org.graalvm.compiler.graph.NodeClass;
  33 import org.graalvm.compiler.graph.spi.Canonicalizable;
  34 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  35 import org.graalvm.compiler.hotspot.HotSpotLIRGenerator;
  36 import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction;
  37 import org.graalvm.compiler.hotspot.nodes.DeoptimizingStubCall;
  38 import org.graalvm.compiler.hotspot.word.KlassPointer;
  39 import org.graalvm.compiler.lir.LIRFrameState;
  40 import org.graalvm.compiler.nodeinfo.NodeInfo;
  41 import org.graalvm.compiler.nodes.NodeView;
  42 import org.graalvm.compiler.nodes.ValueNode;
  43 import org.graalvm.compiler.nodes.spi.LIRLowerable;
  44 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
  45 import org.graalvm.compiler.nodes.util.GraphUtil;

  46 
  47 import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
  48 import jdk.vm.ci.hotspot.HotSpotObjectConstant;
  49 import jdk.vm.ci.meta.Constant;
  50 import jdk.vm.ci.meta.Value;
  51 
  52 /**
  53  * A call to the VM via a regular stub.
  54  */
  55 @NodeInfo(cycles = CYCLES_UNKNOWN, size = SIZE_16)
  56 public class ResolveConstantStubCall extends DeoptimizingStubCall implements Canonicalizable, LIRLowerable {
  57     public static final NodeClass<ResolveConstantStubCall> TYPE = NodeClass.create(ResolveConstantStubCall.class);
  58 
  59     @OptionalInput protected ValueNode value;
  60     @Input protected ValueNode string;
  61     protected Constant constant;
  62     protected HotSpotConstantLoadAction action;
  63 
  64     public ResolveConstantStubCall(ValueNode value, ValueNode string) {
  65         super(TYPE, value.stamp(NodeView.DEFAULT));
  66         this.value = value;
  67         this.string = string;
  68         this.action = HotSpotConstantLoadAction.RESOLVE;
  69     }
  70 
  71     public ResolveConstantStubCall(ValueNode value, ValueNode string, HotSpotConstantLoadAction action) {
  72         super(TYPE, value.stamp(NodeView.DEFAULT));
  73         this.value = value;
  74         this.string = string;
  75         this.action = action;
  76     }
  77 
  78     @NodeIntrinsic
  79     public static native Object resolveObject(Object value, Object symbol);
  80 
  81     @NodeIntrinsic
  82     public static native KlassPointer resolveKlass(KlassPointer value, Object symbol);
  83 
  84     @NodeIntrinsic
  85     public static native KlassPointer resolveKlass(KlassPointer value, Object symbol, @ConstantNodeParameter HotSpotConstantLoadAction action);
  86 
  87     @Override
  88     public Node canonical(CanonicalizerTool tool) {
  89         if (value != null) {
  90             constant = GraphUtil.foldIfConstantAndRemove(this, value);
  91         }
  92         return this;
  93     }
  94 
  95     @Override
  96     public void generate(NodeLIRBuilderTool gen) {
  97         assert constant != null : "Expected the value to fold: " + value;
  98         Value stringValue = gen.operand(string);
  99         Value result;
 100         LIRFrameState fs = gen.state(this);
 101         assert fs != null : "The stateAfter is null";
 102         if (constant instanceof HotSpotObjectConstant) {
 103             result = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitObjectConstantRetrieval(constant, stringValue, fs);
 104         } else if (constant instanceof HotSpotMetaspaceConstant) {
 105             if (action == HotSpotConstantLoadAction.RESOLVE) {


  26 
  27 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN;
  28 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_16;
  29 
  30 import org.graalvm.compiler.core.common.PermanentBailoutException;
  31 import org.graalvm.compiler.graph.Node;
  32 import org.graalvm.compiler.graph.NodeClass;
  33 import org.graalvm.compiler.graph.spi.Canonicalizable;
  34 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  35 import org.graalvm.compiler.hotspot.HotSpotLIRGenerator;
  36 import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction;
  37 import org.graalvm.compiler.hotspot.nodes.DeoptimizingStubCall;
  38 import org.graalvm.compiler.hotspot.word.KlassPointer;
  39 import org.graalvm.compiler.lir.LIRFrameState;
  40 import org.graalvm.compiler.nodeinfo.NodeInfo;
  41 import org.graalvm.compiler.nodes.NodeView;
  42 import org.graalvm.compiler.nodes.ValueNode;
  43 import org.graalvm.compiler.nodes.spi.LIRLowerable;
  44 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
  45 import org.graalvm.compiler.nodes.util.GraphUtil;
  46 import org.graalvm.compiler.word.Word;
  47 
  48 import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
  49 import jdk.vm.ci.hotspot.HotSpotObjectConstant;
  50 import jdk.vm.ci.meta.Constant;
  51 import jdk.vm.ci.meta.Value;
  52 
  53 /**
  54  * A call to the VM via a regular stub.
  55  */
  56 @NodeInfo(cycles = CYCLES_UNKNOWN, size = SIZE_16)
  57 public class ResolveConstantStubCall extends DeoptimizingStubCall implements Canonicalizable, LIRLowerable {
  58     public static final NodeClass<ResolveConstantStubCall> TYPE = NodeClass.create(ResolveConstantStubCall.class);
  59 
  60     @OptionalInput protected ValueNode value;
  61     @Input protected ValueNode string;
  62     protected Constant constant;
  63     protected HotSpotConstantLoadAction action;
  64 
  65     public ResolveConstantStubCall(ValueNode value, ValueNode string) {
  66         super(TYPE, value.stamp(NodeView.DEFAULT));
  67         this.value = value;
  68         this.string = string;
  69         this.action = HotSpotConstantLoadAction.RESOLVE;
  70     }
  71 
  72     public ResolveConstantStubCall(ValueNode value, ValueNode string, HotSpotConstantLoadAction action) {
  73         super(TYPE, value.stamp(NodeView.DEFAULT));
  74         this.value = value;
  75         this.string = string;
  76         this.action = action;
  77     }
  78 
  79     @NodeIntrinsic
  80     public static native Object resolveObject(Object value, Object symbol);
  81 
  82     @NodeIntrinsic
  83     public static native KlassPointer resolveKlass(KlassPointer value, Word symbol);
  84 
  85     @NodeIntrinsic
  86     public static native KlassPointer resolveKlass(KlassPointer value, Word symbol, @ConstantNodeParameter HotSpotConstantLoadAction action);
  87 
  88     @Override
  89     public Node canonical(CanonicalizerTool tool) {
  90         if (value != null) {
  91             constant = GraphUtil.foldIfConstantAndRemove(this, value);
  92         }
  93         return this;
  94     }
  95 
  96     @Override
  97     public void generate(NodeLIRBuilderTool gen) {
  98         assert constant != null : "Expected the value to fold: " + value;
  99         Value stringValue = gen.operand(string);
 100         Value result;
 101         LIRFrameState fs = gen.state(this);
 102         assert fs != null : "The stateAfter is null";
 103         if (constant instanceof HotSpotObjectConstant) {
 104             result = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitObjectConstantRetrieval(constant, stringValue, fs);
 105         } else if (constant instanceof HotSpotMetaspaceConstant) {
 106             if (action == HotSpotConstantLoadAction.RESOLVE) {
< prev index next >