< prev index next >

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

Print this page
rev 52509 : [mq]: graal2

@@ -43,10 +43,12 @@
 @NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor})
 public abstract class AbstractBeginNode extends FixedWithNextNode implements LIRLowerable, GuardingNode, AnchoringNode, IterableNodeType {
 
     public static final NodeClass<AbstractBeginNode> TYPE = NodeClass.create(AbstractBeginNode.class);
 
+    private boolean withSpeculationFence;
+
     protected AbstractBeginNode(NodeClass<? extends AbstractBeginNode> c) {
         this(c, StampFactory.forVoid());
     }
 
     protected AbstractBeginNode(NodeClass<? extends AbstractBeginNode> c, Stamp stamp) {

@@ -89,11 +91,13 @@
         return super.verify();
     }
 
     @Override
     public void generate(NodeLIRBuilderTool gen) {
-        // nop
+        if (withSpeculationFence) {
+            gen.getLIRGeneratorTool().emitSpeculationFence();
+        }
     }
 
     public NodeIterable<GuardNode> guards() {
         return usages().filter(GuardNode.class);
     }

@@ -110,10 +114,18 @@
                 return new BlockNodeIterator(AbstractBeginNode.this);
             }
         };
     }
 
+    /**
+     * Set this begin node to be a speculation fence. This will prevent speculative execution of
+     * this block.
+     */
+    public void setWithSpeculationFence() {
+        this.withSpeculationFence = true;
+    }
+
     private static class BlockNodeIterator implements Iterator<FixedNode> {
 
         private FixedNode current;
 
         BlockNodeIterator(FixedNode next) {
< prev index next >