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 24 25 package org.graalvm.compiler.phases.common; 26 27 import jdk.internal.vm.compiler.collections.EconomicMap; 28 import jdk.internal.vm.compiler.collections.MapCursor; 29 import org.graalvm.compiler.core.common.GraalOptions; 30 import org.graalvm.compiler.core.common.cfg.BlockMap; 31 import org.graalvm.compiler.core.common.type.FloatStamp; 32 import org.graalvm.compiler.core.common.type.Stamp; 33 import org.graalvm.compiler.core.common.type.StampFactory; 34 import org.graalvm.compiler.debug.CounterKey; 35 import org.graalvm.compiler.debug.DebugContext; 36 import org.graalvm.compiler.graph.Node; 37 import org.graalvm.compiler.graph.NodeMap; 38 import org.graalvm.compiler.graph.NodeStack; 39 import org.graalvm.compiler.graph.Position; 40 import org.graalvm.compiler.nodeinfo.InputType; 41 import org.graalvm.compiler.nodes.AbstractBeginNode; 42 import org.graalvm.compiler.nodes.AbstractMergeNode; 43 import org.graalvm.compiler.nodes.BinaryOpLogicNode; 44 import org.graalvm.compiler.nodes.ConstantNode; 45 import org.graalvm.compiler.nodes.EndNode; 46 import org.graalvm.compiler.nodes.IfNode; 47 import org.graalvm.compiler.nodes.LogicNode; 48 import org.graalvm.compiler.nodes.MergeNode; 49 import org.graalvm.compiler.nodes.NodeView; 50 import org.graalvm.compiler.nodes.PhiNode; 51 import org.graalvm.compiler.nodes.PiNode; 52 import org.graalvm.compiler.nodes.StructuredGraph; 53 import org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult; 54 import org.graalvm.compiler.nodes.UnaryOpLogicNode; 55 import org.graalvm.compiler.nodes.ValueNode; 56 import org.graalvm.compiler.nodes.ValuePhiNode; 57 import org.graalvm.compiler.nodes.calc.BinaryNode; 58 import org.graalvm.compiler.nodes.calc.ConditionalNode; 59 import org.graalvm.compiler.nodes.calc.UnaryNode; 60 import org.graalvm.compiler.nodes.cfg.Block; 61 import org.graalvm.compiler.nodes.cfg.ControlFlowGraph; 62 import org.graalvm.compiler.nodes.cfg.ControlFlowGraph.RecursiveVisitor; 63 import org.graalvm.compiler.nodes.extended.GuardingNode; 64 import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; 65 import org.graalvm.compiler.nodes.memory.FixedAccessNode; 66 import org.graalvm.compiler.nodes.memory.FloatingAccessNode; 67 import org.graalvm.compiler.nodes.memory.FloatingReadNode; 68 import org.graalvm.compiler.nodes.memory.MemoryAccess; 69 import org.graalvm.compiler.nodes.memory.MemoryPhiNode; 70 import org.graalvm.compiler.nodes.util.GraphUtil; 71 import org.graalvm.compiler.phases.BasePhase; 72 import org.graalvm.compiler.phases.Phase; 73 import org.graalvm.compiler.phases.graph.ScheduledNodeIterator; 74 import org.graalvm.compiler.phases.schedule.SchedulePhase; 75 import org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy; 76 import org.graalvm.compiler.phases.tiers.LowTierContext; 77 import org.graalvm.compiler.phases.tiers.PhaseContext; 78 79 import jdk.vm.ci.meta.Constant; 80 import jdk.vm.ci.meta.MetaAccessProvider; 81 import jdk.vm.ci.meta.TriState; 82 83 /** 84 * This phase lowers {@link FloatingReadNode FloatingReadNodes} into corresponding fixed reads. 85 */ 86 public class FixReadsPhase extends BasePhase<LowTierContext> { 87 88 private static final CounterKey counterStampsRegistered = DebugContext.counter("FixReads_StampsRegistered"); 89 private static final CounterKey counterIfsKilled = DebugContext.counter("FixReads_KilledIfs"); 90 private static final CounterKey counterConditionalsKilled = DebugContext.counter("FixReads_KilledConditionals"); 91 private static final CounterKey counterCanonicalizedSwitches = DebugContext.counter("FixReads_CanonicalizedSwitches"); 92 private static final CounterKey counterConstantReplacements = DebugContext.counter("FixReads_ConstantReplacement"); 93 private static final CounterKey counterConstantInputReplacements = DebugContext.counter("FixReads_ConstantInputReplacement"); 94 private static final CounterKey counterBetterMergedStamps = DebugContext.counter("FixReads_BetterMergedStamp"); 95 96 protected boolean replaceInputsWithConstants; 97 protected Phase schedulePhase; 98 99 @Override 119 if (guard != null) { 120 floatingAccessNode.setGuard(null); 121 GraphUtil.tryKillUnused(guard.asNode()); 122 } 123 FixedAccessNode fixedAccess = floatingAccessNode.asFixedNode(); 124 replaceCurrent(fixedAccess); 125 } else if (node instanceof PiNode) { 126 PiNode piNode = (PiNode) node; 127 if (piNode.stamp(NodeView.DEFAULT).isCompatible(piNode.getOriginalNode().stamp(NodeView.DEFAULT))) { 128 // Pi nodes are no longer necessary at this point. 129 piNode.replaceAndDelete(piNode.getOriginalNode()); 130 } 131 } else if (node instanceof MemoryAccess) { 132 MemoryAccess memoryAccess = (MemoryAccess) node; 133 memoryAccess.setLastLocationAccess(null); 134 } 135 } 136 137 } 138 139 protected static class RawConditionalEliminationVisitor implements RecursiveVisitor<Integer> { 140 141 protected final NodeMap<StampElement> stampMap; 142 protected final NodeStack undoOperations; 143 private final ScheduleResult schedule; 144 private final StructuredGraph graph; 145 private final MetaAccessProvider metaAccess; 146 private final boolean replaceConstantInputs; 147 private final BlockMap<Integer> blockActionStart; 148 private final EconomicMap<MergeNode, EconomicMap<ValueNode, Stamp>> endMaps; 149 private final DebugContext debug; 150 151 protected RawConditionalEliminationVisitor(StructuredGraph graph, ScheduleResult schedule, MetaAccessProvider metaAccess, boolean replaceInputsWithConstants) { 152 this.graph = graph; 153 this.debug = graph.getDebug(); 154 this.schedule = schedule; 155 this.metaAccess = metaAccess; 156 blockActionStart = new BlockMap<>(schedule.getCFG()); 157 endMaps = EconomicMap.create(); 158 stampMap = graph.createNodeMap(); 159 undoOperations = new NodeStack(); 160 replaceConstantInputs = replaceInputsWithConstants && GraalOptions.ReplaceInputsWithConstantsBasedOnStamps.getValue(graph.getOptions()); 161 } 162 163 protected void replaceInput(Position p, Node oldInput, Node newConstantInput) { 164 p.set(oldInput, newConstantInput); 165 } 166 167 protected int replaceConstantInputs(Node node) { 168 int replacements = 0; 169 // Check if we can replace any of the inputs with a constant. 170 for (Position p : node.inputPositions()) { 171 Node input = p.get(node); 309 } 310 } 311 } 312 currentBlock = currentBlock.getDominator(); 313 } 314 315 endMaps.put(merge, endMap); 316 } 317 } 318 } 319 320 private static Block getBlock(ValueNode node, NodeMap<Block> blockToNodeMap) { 321 if (node instanceof PhiNode) { 322 PhiNode phiNode = (PhiNode) node; 323 return blockToNodeMap.get(phiNode.merge()); 324 } 325 return blockToNodeMap.get(node); 326 } 327 328 protected void processUnary(UnaryNode node) { 329 Stamp newStamp = node.foldStamp(getBestStamp(node.getValue())); 330 if (!checkReplaceWithConstant(newStamp, node)) { 331 registerNewValueStamp(node, newStamp); 332 } 333 } 334 335 protected boolean checkReplaceWithConstant(Stamp newStamp, ValueNode node) { 336 Constant constant = newStamp.asConstant(); 337 if (constant != null && !(node instanceof ConstantNode)) { 338 ConstantNode stampConstant = ConstantNode.forConstant(newStamp, constant, metaAccess, graph); 339 debug.log("RawConditionElimination: constant stamp replaces %1s with %1s", node, stampConstant); 340 counterConstantReplacements.increment(debug); 341 node.replaceAtUsages(InputType.Value, stampConstant); 342 GraphUtil.tryKillUnused(node); 343 return true; 344 } 345 return false; 346 } 347 348 protected void processBinary(BinaryNode node) { 349 Stamp xStamp = getBestStamp(node.getX()); 350 Stamp yStamp = getBestStamp(node.getY()); 351 Stamp newStamp = node.foldStamp(xStamp, yStamp); 352 if (!checkReplaceWithConstant(newStamp, node)) { 353 registerNewValueStamp(node, newStamp); 354 } 355 } 356 357 protected void processIntegerSwitch(IntegerSwitchNode node) { 358 Stamp bestStamp = getBestStamp(node.value()); 359 if (node.tryRemoveUnreachableKeys(null, bestStamp)) { 360 debug.log("\t Canonicalized integer switch %s for value %s and stamp %s", node, node.value(), bestStamp); 361 counterCanonicalizedSwitches.increment(debug); 362 } 363 } 364 365 protected void processIf(IfNode node) { 366 TriState result = tryProveCondition(node.condition()); 367 if (result != TriState.UNKNOWN) { 368 boolean isTrue = (result == TriState.TRUE); 369 AbstractBeginNode survivingSuccessor = node.getSuccessor(isTrue); 370 survivingSuccessor.replaceAtUsages(null); 371 survivingSuccessor.replaceAtPredecessor(null); 372 node.replaceAtPredecessor(survivingSuccessor); 452 Stamp currentStamp = getBestStamp(value); 453 Stamp betterStamp = currentStamp.tryImproveWith(newStamp); 454 if (betterStamp != null) { 455 registerNewStamp(value, betterStamp); 456 return true; 457 } 458 } 459 return false; 460 } 461 462 protected void registerNewStamp(ValueNode value, Stamp newStamp) { 463 counterStampsRegistered.increment(debug); 464 debug.log("\t Saving stamp for node %s stamp %s", value, newStamp); 465 ValueNode originalNode = value; 466 stampMap.setAndGrow(originalNode, new StampElement(newStamp, stampMap.getAndGrow(originalNode))); 467 undoOperations.push(originalNode); 468 } 469 470 protected Stamp getBestStamp(ValueNode value) { 471 ValueNode originalNode = value; 472 StampElement currentStamp = stampMap.getAndGrow(originalNode); 473 if (currentStamp == null) { 474 return value.stamp(NodeView.DEFAULT); 475 } 476 return currentStamp.getStamp(); 477 } 478 479 @Override 480 public Integer enter(Block b) { 481 int mark = undoOperations.size(); 482 blockActionStart.put(b, mark); 483 for (Node n : schedule.getBlockToNodesMap().get(b)) { 484 if (n.isAlive()) { 485 processNode(n); 486 } 487 } 488 return mark; 489 } 490 491 @Override | 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 24 25 package org.graalvm.compiler.phases.common; 26 27 import jdk.internal.vm.compiler.collections.EconomicMap; 28 import jdk.internal.vm.compiler.collections.MapCursor; 29 import org.graalvm.compiler.core.common.GraalOptions; 30 import org.graalvm.compiler.core.common.cfg.BlockMap; 31 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider; 32 import org.graalvm.compiler.core.common.type.FloatStamp; 33 import org.graalvm.compiler.core.common.type.Stamp; 34 import org.graalvm.compiler.core.common.type.StampFactory; 35 import org.graalvm.compiler.debug.CounterKey; 36 import org.graalvm.compiler.debug.DebugContext; 37 import org.graalvm.compiler.graph.Node; 38 import org.graalvm.compiler.graph.NodeMap; 39 import org.graalvm.compiler.graph.NodeStack; 40 import org.graalvm.compiler.graph.Position; 41 import org.graalvm.compiler.graph.spi.CanonicalizerTool; 42 import org.graalvm.compiler.nodeinfo.InputType; 43 import org.graalvm.compiler.nodes.AbstractBeginNode; 44 import org.graalvm.compiler.nodes.AbstractMergeNode; 45 import org.graalvm.compiler.nodes.BinaryOpLogicNode; 46 import org.graalvm.compiler.nodes.ConstantNode; 47 import org.graalvm.compiler.nodes.EndNode; 48 import org.graalvm.compiler.nodes.IfNode; 49 import org.graalvm.compiler.nodes.LogicNode; 50 import org.graalvm.compiler.nodes.MergeNode; 51 import org.graalvm.compiler.nodes.NodeView; 52 import org.graalvm.compiler.nodes.PhiNode; 53 import org.graalvm.compiler.nodes.PiNode; 54 import org.graalvm.compiler.nodes.StructuredGraph; 55 import org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult; 56 import org.graalvm.compiler.nodes.UnaryOpLogicNode; 57 import org.graalvm.compiler.nodes.ValueNode; 58 import org.graalvm.compiler.nodes.ValuePhiNode; 59 import org.graalvm.compiler.nodes.calc.BinaryNode; 60 import org.graalvm.compiler.nodes.calc.ConditionalNode; 61 import org.graalvm.compiler.nodes.calc.UnaryNode; 62 import org.graalvm.compiler.nodes.cfg.Block; 63 import org.graalvm.compiler.nodes.cfg.ControlFlowGraph; 64 import org.graalvm.compiler.nodes.cfg.ControlFlowGraph.RecursiveVisitor; 65 import org.graalvm.compiler.nodes.extended.GuardingNode; 66 import org.graalvm.compiler.nodes.extended.IntegerSwitchNode; 67 import org.graalvm.compiler.nodes.memory.FixedAccessNode; 68 import org.graalvm.compiler.nodes.memory.FloatingAccessNode; 69 import org.graalvm.compiler.nodes.memory.FloatingReadNode; 70 import org.graalvm.compiler.nodes.memory.MemoryAccess; 71 import org.graalvm.compiler.nodes.memory.MemoryPhiNode; 72 import org.graalvm.compiler.nodes.util.GraphUtil; 73 import org.graalvm.compiler.options.OptionValues; 74 import org.graalvm.compiler.phases.BasePhase; 75 import org.graalvm.compiler.phases.Phase; 76 import org.graalvm.compiler.phases.graph.ScheduledNodeIterator; 77 import org.graalvm.compiler.phases.schedule.SchedulePhase; 78 import org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy; 79 import org.graalvm.compiler.phases.tiers.LowTierContext; 80 import org.graalvm.compiler.phases.tiers.PhaseContext; 81 82 import jdk.vm.ci.meta.Assumptions; 83 import jdk.vm.ci.meta.Constant; 84 import jdk.vm.ci.meta.ConstantReflectionProvider; 85 import jdk.vm.ci.meta.MetaAccessProvider; 86 import jdk.vm.ci.meta.TriState; 87 88 /** 89 * This phase lowers {@link FloatingReadNode FloatingReadNodes} into corresponding fixed reads. 90 */ 91 public class FixReadsPhase extends BasePhase<LowTierContext> { 92 93 private static final CounterKey counterStampsRegistered = DebugContext.counter("FixReads_StampsRegistered"); 94 private static final CounterKey counterIfsKilled = DebugContext.counter("FixReads_KilledIfs"); 95 private static final CounterKey counterConditionalsKilled = DebugContext.counter("FixReads_KilledConditionals"); 96 private static final CounterKey counterCanonicalizedSwitches = DebugContext.counter("FixReads_CanonicalizedSwitches"); 97 private static final CounterKey counterConstantReplacements = DebugContext.counter("FixReads_ConstantReplacement"); 98 private static final CounterKey counterConstantInputReplacements = DebugContext.counter("FixReads_ConstantInputReplacement"); 99 private static final CounterKey counterBetterMergedStamps = DebugContext.counter("FixReads_BetterMergedStamp"); 100 101 protected boolean replaceInputsWithConstants; 102 protected Phase schedulePhase; 103 104 @Override 124 if (guard != null) { 125 floatingAccessNode.setGuard(null); 126 GraphUtil.tryKillUnused(guard.asNode()); 127 } 128 FixedAccessNode fixedAccess = floatingAccessNode.asFixedNode(); 129 replaceCurrent(fixedAccess); 130 } else if (node instanceof PiNode) { 131 PiNode piNode = (PiNode) node; 132 if (piNode.stamp(NodeView.DEFAULT).isCompatible(piNode.getOriginalNode().stamp(NodeView.DEFAULT))) { 133 // Pi nodes are no longer necessary at this point. 134 piNode.replaceAndDelete(piNode.getOriginalNode()); 135 } 136 } else if (node instanceof MemoryAccess) { 137 MemoryAccess memoryAccess = (MemoryAccess) node; 138 memoryAccess.setLastLocationAccess(null); 139 } 140 } 141 142 } 143 144 public static class RawConditionalEliminationVisitor implements RecursiveVisitor<Integer> { 145 146 protected final NodeMap<StampElement> stampMap; 147 protected final NodeStack undoOperations; 148 private final ScheduleResult schedule; 149 private final StructuredGraph graph; 150 private final MetaAccessProvider metaAccess; 151 private final boolean replaceConstantInputs; 152 private final BlockMap<Integer> blockActionStart; 153 private final EconomicMap<MergeNode, EconomicMap<ValueNode, Stamp>> endMaps; 154 private final DebugContext debug; 155 private final RawCanonicalizerTool rawCanonicalizerTool = new RawCanonicalizerTool(); 156 157 private class RawCanonicalizerTool implements NodeView, CanonicalizerTool { 158 159 @Override 160 public Assumptions getAssumptions() { 161 return graph.getAssumptions(); 162 } 163 164 @Override 165 public MetaAccessProvider getMetaAccess() { 166 return metaAccess; 167 } 168 169 @Override 170 public ConstantReflectionProvider getConstantReflection() { 171 return null; 172 } 173 174 @Override 175 public ConstantFieldProvider getConstantFieldProvider() { 176 return null; 177 } 178 179 @Override 180 public boolean canonicalizeReads() { 181 return false; 182 } 183 184 @Override 185 public boolean allUsagesAvailable() { 186 return true; 187 } 188 189 @Override 190 public Integer smallestCompareWidth() { 191 return null; 192 } 193 194 @Override 195 public OptionValues getOptions() { 196 return graph.getOptions(); 197 } 198 199 @Override 200 public Stamp stamp(ValueNode node) { 201 return getBestStamp(node); 202 } 203 204 } 205 206 public RawConditionalEliminationVisitor(StructuredGraph graph, ScheduleResult schedule, MetaAccessProvider metaAccess, boolean replaceInputsWithConstants) { 207 this.graph = graph; 208 this.debug = graph.getDebug(); 209 this.schedule = schedule; 210 this.metaAccess = metaAccess; 211 blockActionStart = new BlockMap<>(schedule.getCFG()); 212 endMaps = EconomicMap.create(); 213 stampMap = graph.createNodeMap(); 214 undoOperations = new NodeStack(); 215 replaceConstantInputs = replaceInputsWithConstants && GraalOptions.ReplaceInputsWithConstantsBasedOnStamps.getValue(graph.getOptions()); 216 } 217 218 protected void replaceInput(Position p, Node oldInput, Node newConstantInput) { 219 p.set(oldInput, newConstantInput); 220 } 221 222 protected int replaceConstantInputs(Node node) { 223 int replacements = 0; 224 // Check if we can replace any of the inputs with a constant. 225 for (Position p : node.inputPositions()) { 226 Node input = p.get(node); 364 } 365 } 366 } 367 currentBlock = currentBlock.getDominator(); 368 } 369 370 endMaps.put(merge, endMap); 371 } 372 } 373 } 374 375 private static Block getBlock(ValueNode node, NodeMap<Block> blockToNodeMap) { 376 if (node instanceof PhiNode) { 377 PhiNode phiNode = (PhiNode) node; 378 return blockToNodeMap.get(phiNode.merge()); 379 } 380 return blockToNodeMap.get(node); 381 } 382 383 protected void processUnary(UnaryNode node) { 384 ValueNode value = node.getValue(); 385 Stamp bestStamp = getBestStamp(value); 386 Stamp newStamp = node.foldStamp(bestStamp); 387 if (!checkReplaceWithConstant(newStamp, node)) { 388 if (!bestStamp.equals(value.stamp(NodeView.DEFAULT))) { 389 ValueNode newNode = node.canonical(rawCanonicalizerTool); 390 if (newNode != node) { 391 // Canonicalization successfully triggered. 392 if (newNode != null && !newNode.isAlive()) { 393 newNode = graph.addWithoutUniqueWithInputs(newNode); 394 } 395 node.replaceAndDelete(newNode); 396 GraphUtil.tryKillUnused(value); 397 return; 398 } 399 } 400 registerNewValueStamp(node, newStamp); 401 } 402 } 403 404 protected boolean checkReplaceWithConstant(Stamp newStamp, ValueNode node) { 405 Constant constant = newStamp.asConstant(); 406 if (constant != null && !(node instanceof ConstantNode)) { 407 ConstantNode stampConstant = ConstantNode.forConstant(newStamp, constant, metaAccess, graph); 408 debug.log("RawConditionElimination: constant stamp replaces %1s with %1s", node, stampConstant); 409 counterConstantReplacements.increment(debug); 410 node.replaceAtUsages(InputType.Value, stampConstant); 411 GraphUtil.tryKillUnused(node); 412 return true; 413 } 414 return false; 415 } 416 417 protected void processBinary(BinaryNode node) { 418 419 ValueNode x = node.getX(); 420 ValueNode y = node.getY(); 421 422 Stamp xStamp = getBestStamp(x); 423 Stamp yStamp = getBestStamp(y); 424 Stamp newStamp = node.foldStamp(xStamp, yStamp); 425 if (!checkReplaceWithConstant(newStamp, node)) { 426 427 if (!xStamp.equals(x.stamp(NodeView.DEFAULT)) || !yStamp.equals(y.stamp(NodeView.DEFAULT))) { 428 // At least one of the inputs has an improved stamp => attempt to canonicalize 429 // based on that improvement. 430 ValueNode newNode = node.canonical(rawCanonicalizerTool); 431 if (newNode != node) { 432 // Canonicalization successfully triggered. 433 if (newNode != null && !newNode.isAlive()) { 434 newNode = graph.addWithoutUniqueWithInputs(newNode); 435 } 436 node.replaceAndDelete(newNode); 437 GraphUtil.tryKillUnused(x); 438 GraphUtil.tryKillUnused(y); 439 return; 440 } 441 } 442 443 registerNewValueStamp(node, newStamp); 444 } 445 } 446 447 protected void processIntegerSwitch(IntegerSwitchNode node) { 448 Stamp bestStamp = getBestStamp(node.value()); 449 if (node.tryRemoveUnreachableKeys(null, bestStamp)) { 450 debug.log("\t Canonicalized integer switch %s for value %s and stamp %s", node, node.value(), bestStamp); 451 counterCanonicalizedSwitches.increment(debug); 452 } 453 } 454 455 protected void processIf(IfNode node) { 456 TriState result = tryProveCondition(node.condition()); 457 if (result != TriState.UNKNOWN) { 458 boolean isTrue = (result == TriState.TRUE); 459 AbstractBeginNode survivingSuccessor = node.getSuccessor(isTrue); 460 survivingSuccessor.replaceAtUsages(null); 461 survivingSuccessor.replaceAtPredecessor(null); 462 node.replaceAtPredecessor(survivingSuccessor); 542 Stamp currentStamp = getBestStamp(value); 543 Stamp betterStamp = currentStamp.tryImproveWith(newStamp); 544 if (betterStamp != null) { 545 registerNewStamp(value, betterStamp); 546 return true; 547 } 548 } 549 return false; 550 } 551 552 protected void registerNewStamp(ValueNode value, Stamp newStamp) { 553 counterStampsRegistered.increment(debug); 554 debug.log("\t Saving stamp for node %s stamp %s", value, newStamp); 555 ValueNode originalNode = value; 556 stampMap.setAndGrow(originalNode, new StampElement(newStamp, stampMap.getAndGrow(originalNode))); 557 undoOperations.push(originalNode); 558 } 559 560 protected Stamp getBestStamp(ValueNode value) { 561 ValueNode originalNode = value; 562 if (!value.isAlive()) { 563 return value.stamp(NodeView.DEFAULT); 564 } 565 566 StampElement currentStamp = stampMap.getAndGrow(originalNode); 567 if (currentStamp == null) { 568 return value.stamp(NodeView.DEFAULT); 569 } 570 return currentStamp.getStamp(); 571 } 572 573 @Override 574 public Integer enter(Block b) { 575 int mark = undoOperations.size(); 576 blockActionStart.put(b, mark); 577 for (Node n : schedule.getBlockToNodesMap().get(b)) { 578 if (n.isAlive()) { 579 processNode(n); 580 } 581 } 582 return mark; 583 } 584 585 @Override |