Mercurial > hg > truffle
changeset 17064:3c54a098455f
removed Node.recordsUsages()
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Sep 08 21:00:12 2014 +0200 @@ -269,7 +269,7 @@ } result.append("\n"); for (Node node : schedule.getBlockToNodesMap().get(block)) { - if (node.isAlive() && node.recordsUsages()) { + if (node.isAlive()) { if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode)) { int id; if (canonicalId.get(node) != null) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Mon Sep 08 21:00:12 2014 +0200 @@ -242,7 +242,7 @@ } private static void outputNode(Node node) { - TTY.print(" " + node + " (usage count: " + (node.recordsUsages() ? node.usages().count() : "?") + ") (inputs:"); + TTY.print(" " + node + " (usage count: " + node.usages().count() + ") (inputs:"); for (Node input : node.inputs()) { TTY.print(" " + input.toString(Verbosity.Id)); }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Mon Sep 08 21:00:12 2014 +0200 @@ -479,7 +479,7 @@ int minCount = Integer.MAX_VALUE; Node minCountNode = null; for (Node input : node.inputs()) { - if (input != null && input.recordsUsages()) { + if (input != null) { int estimate = input.getUsageCountUpperBound(); if (estimate == 0) { return null;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Sep 08 21:00:12 2014 +0200 @@ -223,8 +223,10 @@ return getNodeClass().getSuccessorIterable(this); } + /** + * Gets the maximum number of usages this node has had at any point in time. + */ int getUsageCountUpperBound() { - assert recordsUsages(); if (usage0 == null) { return 0; } @@ -238,20 +240,10 @@ * Gets the list of nodes that use this node (i.e., as an input). */ public final NodeIterable<Node> usages() { - assert recordsUsages() : this; return new NodeUsageIterable(this); } /** - * Determines if this node records its usages (i.e. the nodes for which it is an input). All - * methods in {@link Node} that pertain to querying or updating usage information must not be - * called for a {@link Node} instance that returns false for this method. - */ - public boolean recordsUsages() { - return true; - } - - /** * Finds the index of the last non-null entry in a node array. The search assumes that all * non-null entries precede the first null entry in the array. * @@ -291,7 +283,6 @@ * @param node the node to add */ private void addUsage(Node node) { - assert recordsUsages(); incUsageModCount(); if (usage0 == null) { usage0 = node; @@ -398,7 +389,6 @@ * @return whether or not {@code usage} was in the usage list */ private boolean removeUsage(Node node) { - assert recordsUsages(); assert node != null; // It is critical that this method maintains the invariant that // the usage list has no null element preceding a non-null element @@ -449,7 +439,6 @@ } private void clearUsages() { - assert recordsUsages(); incUsageModCount(); usage0 = null; usage1 = null; @@ -502,18 +491,14 @@ assert isAlive() && (newInput == null || newInput.isAlive()) : "adding " + newInput + " to " + this + " instead of " + oldInput; if (oldInput != newInput) { if (oldInput != null) { - if (oldInput.recordsUsages()) { - boolean result = removeThisFromUsages(oldInput); - assert assertTrue(result, "not found in usages, old input: %s", oldInput); - } + boolean result = removeThisFromUsages(oldInput); + assert assertTrue(result, "not found in usages, old input: %s", oldInput); } maybeNotifyInputChanged(this); if (newInput != null) { - if (newInput.recordsUsages()) { - newInput.addUsage(this); - } + newInput.addUsage(this); } - if (oldInput != null && oldInput.recordsUsages() && oldInput.usages().isEmpty()) { + if (oldInput != null && oldInput.usages().isEmpty()) { maybeNotifyZeroUsages(oldInput); } } @@ -578,9 +563,7 @@ assert assertTrue(result, "not found in inputs, usage: %s", usage); if (other != null) { maybeNotifyInputChanged(usage); - if (other.recordsUsages()) { - other.addUsage(usage); - } + other.addUsage(usage); } } clearUsages(); @@ -600,9 +583,7 @@ assert assertTrue(result, "not found in inputs, usage: %s", usage); if (other != null) { maybeNotifyInputChanged(usage); - if (other.recordsUsages()) { - other.addUsage(usage); - } + other.addUsage(usage); } } else { if (removeStart >= 0) { @@ -686,11 +667,9 @@ private void unregisterInputs() { for (Node input : inputs()) { - if (input.recordsUsages()) { - removeThisFromUsages(input); - if (input.usages().isEmpty()) { - maybeNotifyZeroUsages(input); - } + removeThisFromUsages(input); + if (input.usages().isEmpty()) { + maybeNotifyZeroUsages(input); } } } @@ -721,9 +700,7 @@ } private boolean checkDeletion() { - if (recordsUsages()) { - assertTrue(usages().isEmpty(), "cannot delete node %s because of usages: %s", this, usages()); - } + assertTrue(usages().isEmpty(), "cannot delete node %s because of usages: %s", this, usages()); assertTrue(predecessor == null, "cannot delete node %s because of predecessor: %s", this, predecessor); return true; } @@ -751,9 +728,7 @@ clazz.copyInputs(this, newNode); if (addToGraph) { for (Node input : inputs()) { - if (input.recordsUsages()) { - input.addUsage(newNode); - } + input.addUsage(newNode); } } return newNode; @@ -825,23 +800,20 @@ assertTrue(isAlive(), "cannot verify inactive nodes (id=%d)", id); assertTrue(graph() != null, "null graph"); for (Node input : inputs()) { - assertTrue(!input.recordsUsages() || input.usages().contains(this), "missing usage in input %s", input); + assertTrue(input.usages().contains(this), "missing usage in input %s", input); } for (Node successor : successors()) { assertTrue(successor.predecessor() == this, "missing predecessor in %s (actual: %s)", successor, successor.predecessor()); assertTrue(successor.graph() == graph(), "mismatching graph in successor %s", successor); } - if (recordsUsages()) { - for (Node usage : usages()) { - assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage); - assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage); - NodePosIterator iterator = usage.inputs().iterator(); - while (iterator.hasNext()) { - Position pos = iterator.nextPosition(); - if (pos.get(usage) == this && pos.getInputType(usage) != InputType.Unchecked) { - assert isAllowedUsageType(pos.getInputType(usage)) : "invalid input of type " + pos.getInputType(usage) + " from " + usage + " to " + this + " (" + pos.getInputName(usage) + - ")"; - } + for (Node usage : usages()) { + assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage); + assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage); + NodePosIterator iterator = usage.inputs().iterator(); + while (iterator.hasNext()) { + Position pos = iterator.nextPosition(); + if (pos.get(usage) == this && pos.getInputType(usage) != InputType.Unchecked) { + assert isAllowedUsageType(pos.getInputType(usage)) : "invalid input of type " + pos.getInputType(usage) + " from " + usage + " to " + this + " (" + pos.getInputName(usage) + ")"; } } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Mon Sep 08 21:00:12 2014 +0200 @@ -45,10 +45,8 @@ @Override protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ConstantNode node : getConstantNodes(graph)) { - if (node.recordsUsages()) { - if (isObject(node) && !isNullReference(node) && !isInternedString(node) && !isDirectMethodHandle(node) && !isBoundMethodHandle(node)) { - throw new VerificationError("illegal object constant: " + node); - } + if (isObject(node) && !isNullReference(node) && !isInternedString(node) && !isDirectMethodHandle(node) && !isBoundMethodHandle(node)) { + throw new VerificationError("illegal object constant: " + node); } } return true;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Mon Sep 08 21:00:12 2014 +0200 @@ -100,7 +100,7 @@ } ValueNode removedValue = phi.valueAt(predIndex); phi.removeInput(predIndex); - if (removedValue != null && removedValue.isAlive() && removedValue.recordsUsages() && removedValue.usages().isEmpty() && GraphUtil.isFloatingNode().apply(removedValue)) { + if (removedValue != null && removedValue.isAlive() && removedValue.usages().isEmpty() && GraphUtil.isFloatingNode().apply(removedValue)) { GraphUtil.killWithUnusedFloatingInputs(removedValue); } }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Mon Sep 08 21:00:12 2014 +0200 @@ -135,17 +135,13 @@ } public static void killWithUnusedFloatingInputs(Node node) { - if (node.recordsUsages()) { - List<Node> floatingInputs = node.inputs().filter(isFloatingNode()).snapshot(); - node.safeDelete(); + List<Node> floatingInputs = node.inputs().filter(isFloatingNode()).snapshot(); + node.safeDelete(); - for (Node in : floatingInputs) { - if (in.isAlive() && (!in.recordsUsages() || in.usages().isEmpty())) { - killWithUnusedFloatingInputs(in); - } + for (Node in : floatingInputs) { + if (in.isAlive() && in.usages().isEmpty()) { + killWithUnusedFloatingInputs(in); } - } else { - assert node.inputs().isEmpty(); } } @@ -358,7 +354,7 @@ } public static boolean tryKillUnused(Node node) { - if (node.isAlive() && isFloatingNode().apply(node) && node.recordsUsages() && node.usages().isEmpty()) { + if (node.isAlive() && isFloatingNode().apply(node) && node.usages().isEmpty()) { killWithUnusedFloatingInputs(node); return true; }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Mon Sep 08 21:00:12 2014 +0200 @@ -832,9 +832,6 @@ } private GuardingNode searchAnchor(ValueNode value, ResolvedJavaType type) { - if (!value.recordsUsages()) { - return null; - } for (Node n : value.usages()) { if (n instanceof InstanceOfNode) { InstanceOfNode instanceOfNode = (InstanceOfNode) n;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowUtil.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowUtil.java Mon Sep 08 21:00:12 2014 +0200 @@ -37,7 +37,7 @@ } public static boolean lacksUsages(Node n) { - return n.recordsUsages() && n.usages().isEmpty(); + return n.usages().isEmpty(); } public static ResolvedJavaType widen(ResolvedJavaType a, ResolvedJavaType b) { @@ -95,11 +95,11 @@ } else { /* * Not comparable, two cases: - * + * * Example 1: 'a' standing for j.l.Number and 'b' for j.l.String We return null for lack * of a value representing NullType, the right answer. Same goes when both arguments are * non-comparable interfaces. - * + * * Example 2: 'a' standing for sun/nio/ch/DirectBuffer (an interface) and b for * java/nio/Buffer (an abstract class). The class always takes precedence. */
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Sep 08 21:00:12 2014 +0200 @@ -625,10 +625,8 @@ cdbc.apply(cfg.getNodeToBlock().get(succ)); } ensureScheduledUsages(node, strategy); - if (node.recordsUsages()) { - for (Node usage : node.usages()) { - blocksForUsage(node, usage, cdbc, strategy); - } + for (Node usage : node.usages()) { + blocksForUsage(node, usage, cdbc, strategy); } if (assertionEnabled()) { @@ -820,10 +818,8 @@ } private void ensureScheduledUsages(Node node, SchedulingStrategy strategy) { - if (node.recordsUsages()) { - for (Node usage : node.usages().filter(ScheduledNode.class)) { - assignBlockToNode((ScheduledNode) usage, strategy); - } + for (Node usage : node.usages().filter(ScheduledNode.class)) { + assignBlockToNode((ScheduledNode) usage, strategy); } // now true usages are ready } @@ -1149,16 +1145,14 @@ } visited.mark(instruction); - if (instruction.recordsUsages()) { - for (Node usage : instruction.usages()) { - if (usage instanceof VirtualState) { - // only fixed nodes can have VirtualState -> no need to schedule them + for (Node usage : instruction.usages()) { + if (usage instanceof VirtualState) { + // only fixed nodes can have VirtualState -> no need to schedule them + } else { + if (instruction instanceof LoopExitNode && usage instanceof ProxyNode) { + // value proxies should be scheduled before the loopexit, not after } else { - if (instruction instanceof LoopExitNode && usage instanceof ProxyNode) { - // value proxies should be scheduled before the loopexit, not after - } else { - addToEarliestSorting(b, (ScheduledNode) usage, sortedInstructions, visited); - } + addToEarliestSorting(b, (ScheduledNode) usage, sortedInstructions, visited); } } }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Sep 08 21:00:12 2014 +0200 @@ -343,7 +343,7 @@ out.println("=== Succesors ==="); printNamedNodes(node, node.successors().iterator(), "", "\n", null); out.println("=== Usages ==="); - if (node.recordsUsages() && !node.usages().isEmpty()) { + if (!node.usages().isEmpty()) { for (Node usage : node.usages()) { out.print(nodeToString(usage)).print(" "); }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Mon Sep 08 21:00:12 2014 +0200 @@ -343,8 +343,7 @@ } public void cleanUpReturnCheckCast(Node newInstance) { - if (newInstance.recordsUsages() && newInstance instanceof ValueNode && - (((ValueNode) newInstance).getKind() != Kind.Object || ((ValueNode) newInstance).stamp() == StampFactory.forNodeIntrinsic())) { + if (newInstance instanceof ValueNode && (((ValueNode) newInstance).getKind() != Kind.Object || ((ValueNode) newInstance).stamp() == StampFactory.forNodeIntrinsic())) { StructuredGraph graph = (StructuredGraph) newInstance.graph(); for (CheckCastNode checkCastNode : newInstance.usages().filter(CheckCastNode.class).snapshot()) { for (Node checkCastUsage : checkCastNode.usages().snapshot()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Mon Sep 08 21:00:12 2014 +0200 @@ -243,7 +243,7 @@ Mark beforeInvokeMark = graph.getMark(); expandInvoke(methodCallTarget); for (Node arg : argumentSnapshot) { - if (arg != null && arg.recordsUsages()) { + if (arg != null) { for (Node argUsage : arg.usages()) { if (graph.isNew(beforeInvokeMark, argUsage) && argUsage instanceof Canonicalizable) { canonicalizerUsages.add(argUsage);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java Mon Sep 08 19:04:32 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java Mon Sep 08 21:00:12 2014 +0200 @@ -62,9 +62,6 @@ InferStamps.inferStamps(graph); for (ValueNode node : graph.getNodes().filter(ValueNode.class)) { - if (!node.recordsUsages()) { - continue; - } for (Node usage : node.usages()) { if (usage instanceof AccessMonitorNode) { verify(!isWord(node), node, usage, "word value has no monitor");