src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/BranchProbabilityNode.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/extended

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

Print this page




 115                             usageFound = node.usages().filter(NodePredicates.isA(FixedGuardNode.class).or(ConditionalNode.class)).isNotEmpty();
 116                         }
 117                     }
 118                 }
 119             }
 120             if (usageFound) {
 121                 ValueNode currentCondition = condition;
 122                 replaceAndDelete(currentCondition);
 123                 if (tool != null) {
 124                     tool.addToWorkList(currentCondition.usages());
 125                 }
 126             } else {
 127                 if (!isSubstitutionGraph()) {
 128                     throw new GraalError("Wrong usage of branch probability injection!");
 129                 }
 130             }
 131         }
 132     }
 133 
 134     private boolean isSubstitutionGraph() {
 135         return getUsageCount() == 1 && usages().first() instanceof ReturnNode;
 136     }
 137 
 138     /**
 139      * This intrinsic should only be used for the condition of an if statement. The parameter
 140      * condition should also only denote a simple condition and not a combined condition involving
 141      * && or || operators. It injects the probability of the condition into the if
 142      * statement.
 143      *
 144      * @param probability the probability that the given condition is true as a double value between
 145      *            0.0 and 1.0.
 146      * @param condition the simple condition without any && or || operators
 147      * @return the condition
 148      */
 149     @NodeIntrinsic
 150     public static native boolean probability(double probability, boolean condition);
 151 
 152     @Override
 153     public void lower(LoweringTool tool) {
 154         throw new GraalError("Branch probability could not be injected, because the probability value did not reduce to a constant value.");
 155     }


 115                             usageFound = node.usages().filter(NodePredicates.isA(FixedGuardNode.class).or(ConditionalNode.class)).isNotEmpty();
 116                         }
 117                     }
 118                 }
 119             }
 120             if (usageFound) {
 121                 ValueNode currentCondition = condition;
 122                 replaceAndDelete(currentCondition);
 123                 if (tool != null) {
 124                     tool.addToWorkList(currentCondition.usages());
 125                 }
 126             } else {
 127                 if (!isSubstitutionGraph()) {
 128                     throw new GraalError("Wrong usage of branch probability injection!");
 129                 }
 130             }
 131         }
 132     }
 133 
 134     private boolean isSubstitutionGraph() {
 135         return hasExactlyOneUsage() && usages().first() instanceof ReturnNode;
 136     }
 137 
 138     /**
 139      * This intrinsic should only be used for the condition of an if statement. The parameter
 140      * condition should also only denote a simple condition and not a combined condition involving
 141      * && or || operators. It injects the probability of the condition into the if
 142      * statement.
 143      *
 144      * @param probability the probability that the given condition is true as a double value between
 145      *            0.0 and 1.0.
 146      * @param condition the simple condition without any && or || operators
 147      * @return the condition
 148      */
 149     @NodeIntrinsic
 150     public static native boolean probability(double probability, boolean condition);
 151 
 152     @Override
 153     public void lower(LoweringTool tool) {
 154         throw new GraalError("Branch probability could not be injected, because the probability value did not reduce to a constant value.");
 155     }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/BranchProbabilityNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File