Mercurial > hg > graal-compiler
changeset 11524:dede53632f3e
removed Node.modCount field (GRAAL-452)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 04 Sep 2013 13:21:30 +0200 |
parents | d4537043ccc8 |
children | 75a7d4b79b29 |
files | graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java |
diffstat | 3 files changed, 50 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Wed Sep 04 10:40:56 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Wed Sep 04 13:21:30 2013 +0200 @@ -40,6 +40,11 @@ private final ArrayList<Node> nodes; + /** + * Records the modification count for nodes. This is only used in assertions. + */ + private int[] nodeModCounts; + // these two arrays contain one entry for each NodeClass, indexed by NodeClass.iterableId. // they contain the first and last pointer to a linked list of all nodes with this type. private final ArrayList<Node> nodeCacheFirst; @@ -87,6 +92,18 @@ this(null); } + static final boolean MODIFICATION_COUNTS_ENABLED = assertionsEnabled(); + + /** + * Determines if assertions are enabled for the {@link Graph} class. + */ + @SuppressWarnings("all") + private static boolean assertionsEnabled() { + boolean enabled = false; + assert enabled = true; + return enabled; + } + /** * Creates an empty Graph with a given name. * @@ -97,6 +114,27 @@ nodeCacheFirst = new ArrayList<>(NodeClass.cacheSize()); nodeCacheLast = new ArrayList<>(NodeClass.cacheSize()); this.name = name; + if (MODIFICATION_COUNTS_ENABLED) { + nodeModCounts = new int[nodes.size()]; + } + } + + int modCount(Node node) { + if (node.id >= 0 && node.id < nodeModCounts.length) { + return nodeModCounts[node.id]; + } + return 0; + } + + void incModCount(Node node) { + if (node.id >= 0) { + if (node.id >= nodeModCounts.length) { + nodeModCounts = Arrays.copyOf(nodeModCounts, node.id + 30); + } + nodeModCounts[node.id]++; + } else { + assert false; + } } /**
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Wed Sep 04 10:40:56 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Wed Sep 04 13:21:30 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.graph; +import static com.oracle.graal.graph.Graph.*; + import java.lang.annotation.*; import java.util.*; @@ -121,7 +123,6 @@ private NodeUsagesList usages; private Node predecessor; - private int modCount; public Node() { this.graph = null; @@ -165,11 +166,16 @@ } final int modCount() { - return modCount; + if (MODIFICATION_COUNTS_ENABLED && graph != null) { + return graph.modCount(this); + } + return 0; } final void incModCount() { - modCount++; + if (MODIFICATION_COUNTS_ENABLED && graph != null) { + graph.incModCount(this); + } } public boolean isDeleted() { @@ -375,7 +381,6 @@ into.register(newNode); newNode.usages = new NodeUsagesList(); newNode.predecessor = null; - newNode.modCount = 0; return newNode; }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Wed Sep 04 10:40:56 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Wed Sep 04 13:21:30 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.graph; +import static com.oracle.graal.graph.Graph.*; + import java.lang.reflect.*; import java.util.*; import java.util.Map.Entry; @@ -432,7 +434,7 @@ */ private NodeClassIterator(Node node, long[] offsets, int directCount) { this.node = node; - this.modCount = node.modCount(); + this.modCount = MODIFICATION_COUNTS_ENABLED ? node.modCount() : 0; this.offsets = offsets; this.directCount = directCount; index = NOT_ITERABLE;