public final class IfNode extends ControlSplitNode implements Simplifiable, LIRLowerable
IfNode
represents a branch that can go one of two directions depending on the outcome
of a comparison.Modifier and Type | Class and Description |
---|---|
private static class |
IfNode.MutableProfiledType |
Node.ConstantNodeParameter, Node.InjectedNodeParameter, Node.Input, Node.NodeIntrinsic, Node.OptionalInput, Node.Successor, Node.ValueNumberable
Modifier and Type | Field and Description |
---|---|
(package private) LogicNode |
condition |
private static DebugMetric |
CORRECTED_PROBABILITIES |
(package private) AbstractBeginNode |
falseSuccessor |
private static double |
NOT_RECORDED_CUTOFF
If the not-recorded fraction of types for the new profile of
instanceOfA is
above this threshold, no profile is used for this instanceof after the swap. |
private static double |
NOT_RECORDED_SUBTYPE_B
Arbitrary fraction of not recorded types that we'll guess are sub-types of B.
|
(package private) AbstractBeginNode |
trueSuccessor |
protected double |
trueSuccessorProbability |
static NodeClass<IfNode> |
TYPE |
NODE_LIST, NOT_ITERABLE, USE_UNSAFE_TO_CLONE, WithAllEdges, WithNoEdges, WithOnlyInputEdges, WithOnlySucessorEdges
Constructor and Description |
---|
IfNode(LogicNode condition,
AbstractBeginNode trueSuccessor,
AbstractBeginNode falseSuccessor,
double trueSuccessorProbability) |
IfNode(LogicNode condition,
FixedNode trueSuccessor,
FixedNode falseSuccessor,
double trueSuccessorProbability) |
Modifier and Type | Method and Description |
---|---|
private static void |
appendOrMerge(ResolvedJavaType type,
double probability,
int searchUntil,
List<IfNode.MutableProfiledType> list) |
private ConditionalNode |
canonicalizeConditionalCascade(ValueNode trueValue,
ValueNode falseValue) |
private boolean |
checkForUnsignedCompare(SimplifierTool tool)
Recognize a couple patterns that can be merged into an unsigned compare.
|
private static boolean |
checkFrameState(FixedNode start) |
private void |
cleanupMerge(SimplifierTool tool,
MergeNode merge) |
LogicNode |
condition() |
private void |
connectEnds(List<EndNode> ends,
Map<AbstractEndNode,ValueNode> phiValues,
AbstractBeginNode successor,
AbstractMergeNode oldMerge,
SimplifierTool tool)
Connects a set of ends to a given successor, inserting a merge node if there is more than one
end.
|
static Constant[] |
constantValues(ValueNode node,
AbstractMergeNode merge,
boolean allowNull)
Gets an array of constants derived from a node that is either a
ConstantNode or a
PhiNode whose input values are all constants. |
void |
eliminateNegation() |
AbstractBeginNode |
falseSuccessor()
Gets the false successor.
|
void |
generate(NodeLIRBuilderTool gen) |
AbstractBeginNode |
getPrimarySuccessor()
Primary successor of the control split.
|
AbstractBeginNode |
getSuccessor(boolean result) |
double |
getTrueSuccessorProbability() |
private MergeNode |
insertMerge(AbstractBeginNode begin) |
private static JavaTypeProfile |
makeProfile(double totalProbability,
double notRecorded,
List<IfNode.MutableProfiledType> profiledTypes,
TriState nullSeen) |
private static boolean |
prepareForSwap(ConstantReflectionProvider constantReflection,
LogicNode a,
LogicNode b,
double probabilityA,
double probabilityB) |
double |
probability(AbstractBeginNode successor) |
private void |
propagateZeroProbability(FixedNode startNode) |
private void |
pushNodesThroughIf(SimplifierTool tool) |
private boolean |
removeIntermediateMaterialization(SimplifierTool tool)
Tries to connect code that initializes a variable directly with the successors of an if
construct that switches on the variable.
|
private boolean |
removeOrMaterializeIf(SimplifierTool tool)
Tries to remove an empty if construct or replace an if construct with a materialization.
|
protected void |
removeThroughFalseBranch(SimplifierTool tool) |
private static boolean |
sameDestination(AbstractBeginNode succ1,
AbstractBeginNode succ2)
Check it these two blocks end up at the same place.
|
void |
setCondition(LogicNode x) |
void |
setFalseSuccessor(AbstractBeginNode node) |
void |
setTrueSuccessor(AbstractBeginNode node) |
void |
setTrueSuccessorProbability(double prob) |
void |
simplify(SimplifierTool tool)
Must be overridden by subclasses that implement
Simplifiable . |
private boolean |
splitIfAtPhi(SimplifierTool tool)
Take an if that is immediately dominated by a merge with a single phi and split off any paths
where the test would be statically decidable creating a new merge below the approriate side
of the IfNode.
|
AbstractBeginNode |
successor(boolean istrue)
Gets the node corresponding to the specified outcome of the branch.
|
private static void |
swapInstanceOfProfiles(double probabilityA,
double probabilityB,
InstanceOfNode instanceOfA,
InstanceOfNode instanceOfB)
Tries to reconstruct profiles for the swapped
instanceof checks. |
private static void |
transferProxies(AbstractBeginNode successor,
MergeNode falseMerge) |
AbstractBeginNode |
trueSuccessor()
Gets the true successor.
|
private static boolean |
valuesDistinct(ConstantReflectionProvider constantReflection,
ValueNode a,
ValueNode b) |
boolean |
verify() |
asConstant, asJavaConstant, getKind, graph, inferStamp, isAllowedUsageType, isConstant, isConstantPredicate, isNullConstant, setStamp, stamp, updateStamp
acceptInputs, acceptSuccessors, afterClone, assertFalse, assertTrue, cfgPredecessors, cfgSuccessors, clearInputs, clearSuccessors, copyWithInputs, copyWithInputs, equals, fail, formatTo, getDebugProperties, getDebugProperties, getId, getNodeClass, getUsageAt, getUsageCount, hashCode, hasNoUsages, hasUsages, inputs, isAlive, isDeleted, markDeleted, modCount, newIdentityMap, newIdentityMap, newIdentityMap, newMap, newMap, newMap, newSet, newSet, predecessor, pushInputs, removeUsage, replaceAndDelete, replaceAtMatchingUsages, replaceAtPredecessor, replaceAtUsages, replaceAtUsages, replaceAtUsages, replaceFirstInput, replaceFirstSuccessor, safeDelete, successors, toString, toString, updatePredecessor, updateUsages, updateUsagesInterface, usages, valueEquals, verifyEdges, verifyInputs
private static final DebugMetric CORRECTED_PROBABILITIES
AbstractBeginNode trueSuccessor
AbstractBeginNode falseSuccessor
protected double trueSuccessorProbability
private static final double NOT_RECORDED_SUBTYPE_B
private static final double NOT_RECORDED_CUTOFF
instanceOfA
is
above this threshold, no profile is used for this instanceof
after the swap.
The idea is that the reconstructed profile would contain too much unknowns to be of any use.public IfNode(LogicNode condition, FixedNode trueSuccessor, FixedNode falseSuccessor, double trueSuccessorProbability)
public IfNode(LogicNode condition, AbstractBeginNode trueSuccessor, AbstractBeginNode falseSuccessor, double trueSuccessorProbability)
public void setCondition(LogicNode x)
public AbstractBeginNode trueSuccessor()
public AbstractBeginNode falseSuccessor()
public double getTrueSuccessorProbability()
public void setTrueSuccessor(AbstractBeginNode node)
public void setFalseSuccessor(AbstractBeginNode node)
public AbstractBeginNode successor(boolean istrue)
istrue
- true
if the true successor is requested, false
otherwisepublic void setTrueSuccessorProbability(double prob)
public double probability(AbstractBeginNode successor)
probability
in class ControlSplitNode
public void generate(NodeLIRBuilderTool gen)
generate
in interface LIRLowerable
public void eliminateNegation()
public void simplify(SimplifierTool tool)
Node
Simplifiable
. The implementation in
Node
exists to obviate the need to cast a node before invoking
Simplifiable.simplify(SimplifierTool)
.simplify
in interface Simplifiable
simplify
in class Node
private void pushNodesThroughIf(SimplifierTool tool)
private boolean checkForUnsignedCompare(SimplifierTool tool)
tool
- private static boolean sameDestination(AbstractBeginNode succ1, AbstractBeginNode succ2)
private static boolean prepareForSwap(ConstantReflectionProvider constantReflection, LogicNode a, LogicNode b, double probabilityA, double probabilityB)
private static void swapInstanceOfProfiles(double probabilityA, double probabilityB, InstanceOfNode instanceOfA, InstanceOfNode instanceOfB)
instanceof
checks.
The tested types must be mutually exclusive.private static JavaTypeProfile makeProfile(double totalProbability, double notRecorded, List<IfNode.MutableProfiledType> profiledTypes, TriState nullSeen)
private static void appendOrMerge(ResolvedJavaType type, double probability, int searchUntil, List<IfNode.MutableProfiledType> list)
private static boolean valuesDistinct(ConstantReflectionProvider constantReflection, ValueNode a, ValueNode b)
private boolean removeOrMaterializeIf(SimplifierTool tool)
protected void removeThroughFalseBranch(SimplifierTool tool)
private ConditionalNode canonicalizeConditionalCascade(ValueNode trueValue, ValueNode falseValue)
private boolean splitIfAtPhi(SimplifierTool tool)
tool
- private static void transferProxies(AbstractBeginNode successor, MergeNode falseMerge)
private void cleanupMerge(SimplifierTool tool, MergeNode merge)
private MergeNode insertMerge(AbstractBeginNode begin)
private boolean removeIntermediateMaterialization(SimplifierTool tool)
contains(list, e, yes, no) { if (list == null || e == null) { condition = false; } else { condition = false; for (i in list) { if (i.equals(e)) { condition = true; break; } } } if (condition) { return yes; } else { return no; } }will be transformed into:
contains(list, e, yes, no) { if (list == null || e == null) { return no; } else { condition = false; for (i in list) { if (i.equals(e)) { return yes; } } return no; } }
private void propagateZeroProbability(FixedNode startNode)
private static boolean checkFrameState(FixedNode start)
private void connectEnds(List<EndNode> ends, Map<AbstractEndNode,ValueNode> phiValues, AbstractBeginNode successor, AbstractMergeNode oldMerge, SimplifierTool tool)
ends
is not empty, then successor
is added to tool
's
work list.oldMerge
- the merge being removedphiValues
- the values of the phi at the merge, keyed by the merge endspublic static Constant[] constantValues(ValueNode node, AbstractMergeNode merge, boolean allowNull)
ConstantNode
or a
PhiNode
whose input values are all constants. The length of the returned array is
equal to the number of ends terminating in a given merge node.node
is neither a ConstantNode
nor a PhiNode
whose
input values are all constantspublic AbstractBeginNode getPrimarySuccessor()
ControlSplitNode
getPrimarySuccessor
in class ControlSplitNode
public AbstractBeginNode getSuccessor(boolean result)