src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/FixReadsPhase.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/FixReadsPhase.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/FixReadsPhase.java
Print this page
*** 25,36 ****
import org.graalvm.compiler.core.common.GraalOptions;
import org.graalvm.compiler.core.common.cfg.BlockMap;
import org.graalvm.compiler.core.common.type.FloatStamp;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.core.common.type.StampFactory;
! import org.graalvm.compiler.debug.Debug;
! import org.graalvm.compiler.debug.DebugCounter;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeMap;
import org.graalvm.compiler.graph.NodeStack;
import org.graalvm.compiler.graph.Position;
import org.graalvm.compiler.nodeinfo.InputType;
--- 25,36 ----
import org.graalvm.compiler.core.common.GraalOptions;
import org.graalvm.compiler.core.common.cfg.BlockMap;
import org.graalvm.compiler.core.common.type.FloatStamp;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.core.common.type.StampFactory;
! import org.graalvm.compiler.debug.CounterKey;
! import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeMap;
import org.graalvm.compiler.graph.NodeStack;
import org.graalvm.compiler.graph.Position;
import org.graalvm.compiler.nodeinfo.InputType;
*** 79,95 ****
/**
* This phase lowers {@link FloatingReadNode FloatingReadNodes} into corresponding fixed reads.
*/
public class FixReadsPhase extends BasePhase<LowTierContext> {
! private static final DebugCounter counterStampsRegistered = Debug.counter("FixReads_StampsRegistered");
! private static final DebugCounter counterIfsKilled = Debug.counter("FixReads_KilledIfs");
! private static final DebugCounter counterConditionalsKilled = Debug.counter("FixReads_KilledConditionals");
! private static final DebugCounter counterCanonicalizedSwitches = Debug.counter("FixReads_CanonicalizedSwitches");
! private static final DebugCounter counterConstantReplacements = Debug.counter("FixReads_ConstantReplacement");
! private static final DebugCounter counterConstantInputReplacements = Debug.counter("FixReads_ConstantInputReplacement");
! private static final DebugCounter counterBetterMergedStamps = Debug.counter("FixReads_BetterMergedStamp");
protected boolean replaceInputsWithConstants;
protected Phase schedulePhase;
@Override
--- 79,95 ----
/**
* This phase lowers {@link FloatingReadNode FloatingReadNodes} into corresponding fixed reads.
*/
public class FixReadsPhase extends BasePhase<LowTierContext> {
! private static final CounterKey counterStampsRegistered = DebugContext.counter("FixReads_StampsRegistered");
! private static final CounterKey counterIfsKilled = DebugContext.counter("FixReads_KilledIfs");
! private static final CounterKey counterConditionalsKilled = DebugContext.counter("FixReads_KilledConditionals");
! private static final CounterKey counterCanonicalizedSwitches = DebugContext.counter("FixReads_CanonicalizedSwitches");
! private static final CounterKey counterConstantReplacements = DebugContext.counter("FixReads_ConstantReplacement");
! private static final CounterKey counterConstantInputReplacements = DebugContext.counter("FixReads_ConstantInputReplacement");
! private static final CounterKey counterBetterMergedStamps = DebugContext.counter("FixReads_BetterMergedStamp");
protected boolean replaceInputsWithConstants;
protected Phase schedulePhase;
@Override
*** 135,147 ****
--- 135,149 ----
private final StructuredGraph graph;
private final MetaAccessProvider metaAccess;
private final boolean replaceConstantInputs;
private final BlockMap<Integer> blockActionStart;
private final EconomicMap<MergeNode, EconomicMap<ValueNode, Stamp>> endMaps;
+ private final DebugContext debug;
protected RawConditionalEliminationVisitor(StructuredGraph graph, ScheduleResult schedule, MetaAccessProvider metaAccess, boolean replaceInputsWithConstants) {
this.graph = graph;
+ this.debug = graph.getDebug();
this.schedule = schedule;
this.metaAccess = metaAccess;
blockActionStart = new BlockMap<>(schedule.getCFG());
endMaps = EconomicMap.create();
stampMap = graph.createNodeMap();
*** 172,182 ****
if (floatStamp.contains(0.0d)) {
// Could also be -0.0d.
continue;
}
}
! counterConstantInputReplacements.increment();
ConstantNode stampConstant = ConstantNode.forConstant(bestStamp, constant, metaAccess, graph);
assert stampConstant.stamp().isCompatible(valueNode.stamp());
replaceInput(p, node, stampConstant);
replacements++;
}
--- 174,184 ----
if (floatStamp.contains(0.0d)) {
// Could also be -0.0d.
continue;
}
}
! counterConstantInputReplacements.increment(node.getDebug());
ConstantNode stampConstant = ConstantNode.forConstant(bestStamp, constant, metaAccess, graph);
assert stampConstant.stamp().isCompatible(valueNode.stamp());
replaceInput(p, node, stampConstant);
replacements++;
}
*** 218,228 ****
protected void registerCombinedStamps(MergeNode node) {
EconomicMap<ValueNode, Stamp> endMap = endMaps.get(node);
MapCursor<ValueNode, Stamp> entries = endMap.getEntries();
while (entries.advance()) {
if (registerNewValueStamp(entries.getKey(), entries.getValue())) {
! counterBetterMergedStamps.increment();
}
}
}
protected void processEnd(EndNode node) {
--- 220,230 ----
protected void registerCombinedStamps(MergeNode node) {
EconomicMap<ValueNode, Stamp> endMap = endMaps.get(node);
MapCursor<ValueNode, Stamp> entries = endMap.getEntries();
while (entries.advance()) {
if (registerNewValueStamp(entries.getKey(), entries.getValue())) {
! counterBetterMergedStamps.increment(debug);
}
}
}
protected void processEnd(EndNode node) {
*** 318,329 ****
protected boolean checkReplaceWithConstant(Stamp newStamp, ValueNode node) {
Constant constant = newStamp.asConstant();
if (constant != null && !(node instanceof ConstantNode)) {
ConstantNode stampConstant = ConstantNode.forConstant(newStamp, constant, metaAccess, graph);
! Debug.log("RawConditionElimination: constant stamp replaces %1s with %1s", node, stampConstant);
! counterConstantReplacements.increment();
node.replaceAtUsages(InputType.Value, stampConstant);
GraphUtil.tryKillUnused(node);
return true;
}
return false;
--- 320,331 ----
protected boolean checkReplaceWithConstant(Stamp newStamp, ValueNode node) {
Constant constant = newStamp.asConstant();
if (constant != null && !(node instanceof ConstantNode)) {
ConstantNode stampConstant = ConstantNode.forConstant(newStamp, constant, metaAccess, graph);
! debug.log("RawConditionElimination: constant stamp replaces %1s with %1s", node, stampConstant);
! counterConstantReplacements.increment(debug);
node.replaceAtUsages(InputType.Value, stampConstant);
GraphUtil.tryKillUnused(node);
return true;
}
return false;
*** 339,350 ****
}
protected void processIntegerSwitch(IntegerSwitchNode node) {
Stamp bestStamp = getBestStamp(node.value());
if (node.tryRemoveUnreachableKeys(null, bestStamp)) {
! Debug.log("\t Canonicalized integer switch %s for value %s and stamp %s", node, node.value(), bestStamp);
! counterCanonicalizedSwitches.increment();
}
}
protected void processIf(IfNode node) {
TriState result = tryProveCondition(node.condition());
--- 341,352 ----
}
protected void processIntegerSwitch(IntegerSwitchNode node) {
Stamp bestStamp = getBestStamp(node.value());
if (node.tryRemoveUnreachableKeys(null, bestStamp)) {
! debug.log("\t Canonicalized integer switch %s for value %s and stamp %s", node, node.value(), bestStamp);
! counterCanonicalizedSwitches.increment(debug);
}
}
protected void processIf(IfNode node) {
TriState result = tryProveCondition(node.condition());
*** 354,372 ****
survivingSuccessor.replaceAtUsages(null);
survivingSuccessor.replaceAtPredecessor(null);
node.replaceAtPredecessor(survivingSuccessor);
GraphUtil.killCFG(node);
! counterIfsKilled.increment();
}
}
protected void processConditional(ConditionalNode node) {
TriState result = tryProveCondition(node.condition());
if (result != TriState.UNKNOWN) {
boolean isTrue = (result == TriState.TRUE);
! counterConditionalsKilled.increment();
node.replaceAndDelete(isTrue ? node.trueValue() : node.falseValue());
} else {
Stamp trueStamp = getBestStamp(node.trueValue());
Stamp falseStamp = getBestStamp(node.falseValue());
registerNewStamp(node, trueStamp.meet(falseStamp));
--- 356,374 ----
survivingSuccessor.replaceAtUsages(null);
survivingSuccessor.replaceAtPredecessor(null);
node.replaceAtPredecessor(survivingSuccessor);
GraphUtil.killCFG(node);
! counterIfsKilled.increment(debug);
}
}
protected void processConditional(ConditionalNode node) {
TriState result = tryProveCondition(node.condition());
if (result != TriState.UNKNOWN) {
boolean isTrue = (result == TriState.TRUE);
! counterConditionalsKilled.increment(debug);
node.replaceAndDelete(isTrue ? node.trueValue() : node.falseValue());
} else {
Stamp trueStamp = getBestStamp(node.trueValue());
Stamp falseStamp = getBestStamp(node.falseValue());
registerNewStamp(node, trueStamp.meet(falseStamp));
*** 442,453 ****
}
return false;
}
protected void registerNewStamp(ValueNode value, Stamp newStamp) {
! counterStampsRegistered.increment();
! Debug.log("\t Saving stamp for node %s stamp %s", value, newStamp);
ValueNode originalNode = value;
stampMap.setAndGrow(originalNode, new StampElement(newStamp, stampMap.getAndGrow(originalNode)));
undoOperations.push(originalNode);
}
--- 444,455 ----
}
return false;
}
protected void registerNewStamp(ValueNode value, Stamp newStamp) {
! counterStampsRegistered.increment(debug);
! debug.log("\t Saving stamp for node %s stamp %s", value, newStamp);
ValueNode originalNode = value;
stampMap.setAndGrow(originalNode, new StampElement(newStamp, stampMap.getAndGrow(originalNode)));
undoOperations.push(originalNode);
}
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/FixReadsPhase.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File