src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/GuardedValueNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes

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

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.nodes;
  24 
  25 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
  26 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
  27 
  28 import org.graalvm.compiler.core.common.type.Stamp;
  29 import org.graalvm.compiler.graph.IterableNodeType;
  30 import org.graalvm.compiler.graph.Node;
  31 import org.graalvm.compiler.graph.NodeClass;
  32 import org.graalvm.compiler.graph.spi.Canonicalizable;
  33 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  34 import org.graalvm.compiler.nodeinfo.NodeInfo;
  35 import org.graalvm.compiler.nodes.extended.GuardingNode;
  36 import org.graalvm.compiler.nodes.spi.LIRLowerable;
  37 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
  38 import org.graalvm.compiler.nodes.spi.ValueProxy;
  39 import org.graalvm.compiler.nodes.spi.Virtualizable;
  40 import org.graalvm.compiler.nodes.spi.VirtualizerTool;
  41 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
  42 
  43 import jdk.vm.ci.meta.JavaKind;
  44 
  45 /**
  46  * A node that changes the type of its input, usually narrowing it. For example, a GuardedValueNode
  47  * is used to keep the nodes depending on guards inside a loop during speculative guard movement.
  48  *
  49  * A GuardedValueNode will only go away if its guard is null or {@link StructuredGraph#start()}.
  50  */
  51 @NodeInfo(cycles = CYCLES_0, size = SIZE_0)
  52 public final class GuardedValueNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, IterableNodeType, Canonicalizable, ValueProxy {
  53 
  54     public static final NodeClass<GuardedValueNode> TYPE = NodeClass.create(GuardedValueNode.class);
  55     @Input ValueNode object;
  56     protected final Stamp piStamp;
  57 
  58     public GuardedValueNode(ValueNode object, GuardingNode guard, Stamp stamp) {
  59         super(TYPE, computeStamp(stamp, object), guard);
  60         this.object = object;
  61         this.piStamp = stamp;
  62     }
  63 
  64     public GuardedValueNode(ValueNode object, GuardingNode guard) {
  65         this(object, guard, object.stamp());

  66     }
  67 
  68     public ValueNode object() {
  69         return object;
  70     }
  71 
  72     @Override
  73     public void generate(NodeLIRBuilderTool generator) {
  74         if (object.getStackKind() != JavaKind.Void && object.getStackKind() != JavaKind.Illegal) {
  75             generator.setResult(this, generator.operand(object));
  76         }
  77     }
  78 
  79     @Override
  80     public boolean inferStamp() {
  81         return updateStamp(computeStamp(piStamp, object()));
  82     }
  83 
  84     static Stamp computeStamp(Stamp piStamp, ValueNode object) {
  85         return piStamp.improveWith(object.stamp());
  86     }
  87 
  88     @Override
  89     public void virtualize(VirtualizerTool tool) {
  90         ValueNode alias = tool.getAlias(object());
  91         if (alias instanceof VirtualObjectNode) {
  92             tool.replaceWithVirtual((VirtualObjectNode) alias);
  93         }
  94     }
  95 
  96     @Override
  97     public Node canonical(CanonicalizerTool tool) {
  98         if (getGuard() == null) {
  99             if (stamp().equals(object().stamp())) {
 100                 return object();
 101             } else {
 102                 return new PiNode(object(), stamp());
 103             }
 104         }
 105         return this;


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.nodes;
  24 
  25 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
  26 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
  27 


  28 import org.graalvm.compiler.graph.Node;
  29 import org.graalvm.compiler.graph.NodeClass;
  30 import org.graalvm.compiler.graph.spi.Canonicalizable;
  31 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  32 import org.graalvm.compiler.nodeinfo.NodeInfo;
  33 import org.graalvm.compiler.nodes.extended.GuardingNode;
  34 import org.graalvm.compiler.nodes.spi.LIRLowerable;
  35 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
  36 import org.graalvm.compiler.nodes.spi.ValueProxy;
  37 import org.graalvm.compiler.nodes.spi.Virtualizable;
  38 import org.graalvm.compiler.nodes.spi.VirtualizerTool;
  39 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
  40 
  41 import jdk.vm.ci.meta.JavaKind;
  42 
  43 /**
  44  * A node that changes the type of its input, usually narrowing it. For example, a GuardedValueNode
  45  * is used to keep the nodes depending on guards inside a loop during speculative guard movement.
  46  *
  47  * A GuardedValueNode will only go away if its guard is null or {@link StructuredGraph#start()}.
  48  */
  49 @NodeInfo(cycles = CYCLES_0, size = SIZE_0)
  50 public final class GuardedValueNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, Canonicalizable, ValueProxy {
  51 
  52     public static final NodeClass<GuardedValueNode> TYPE = NodeClass.create(GuardedValueNode.class);
  53     @Input ValueNode object;







  54 
  55     public GuardedValueNode(ValueNode object, GuardingNode guard) {
  56         super(TYPE, object.stamp(), guard);
  57         this.object = object;
  58     }
  59 
  60     public ValueNode object() {
  61         return object;
  62     }
  63 
  64     @Override
  65     public void generate(NodeLIRBuilderTool generator) {
  66         if (object.getStackKind() != JavaKind.Void && object.getStackKind() != JavaKind.Illegal) {
  67             generator.setResult(this, generator.operand(object));
  68         }
  69     }
  70 
  71     @Override
  72     public boolean inferStamp() {
  73         return updateStamp(object().stamp());




  74     }
  75 
  76     @Override
  77     public void virtualize(VirtualizerTool tool) {
  78         ValueNode alias = tool.getAlias(object());
  79         if (alias instanceof VirtualObjectNode) {
  80             tool.replaceWithVirtual((VirtualObjectNode) alias);
  81         }
  82     }
  83 
  84     @Override
  85     public Node canonical(CanonicalizerTool tool) {
  86         if (getGuard() == null) {
  87             if (stamp().equals(object().stamp())) {
  88                 return object();
  89             } else {
  90                 return new PiNode(object(), stamp());
  91             }
  92         }
  93         return this;
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/GuardedValueNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File