changeset 11540:601755e6848b

Allow getting modCount fo deleted nodes
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 06 Sep 2013 15:28:53 +0200
parents edf875b3c091
children 6014bd8d52ce
files graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java
diffstat 1 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Fri Sep 06 12:15:44 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Fri Sep 06 15:28:53 2013 +0200
@@ -125,37 +125,49 @@
         }
     }
 
+    int extractOriginalNodeId(Node node) {
+        int id = node.id;
+        if (id <= Node.DELETED_ID_START) {
+            id = Node.DELETED_ID_START - id;
+        }
+        return id;
+    }
+
     int modCount(Node node) {
-        if (node.id >= 0 && node.id < nodeModCounts.length) {
-            return nodeModCounts[node.id];
+        int id = extractOriginalNodeId(node);
+        if (id >= 0 && id < nodeModCounts.length) {
+            return nodeModCounts[id];
         }
         return 0;
     }
 
     void incModCount(Node node) {
-        if (node.id >= 0) {
-            if (node.id >= nodeModCounts.length) {
-                nodeModCounts = Arrays.copyOf(nodeModCounts, node.id + 30);
+        int id = extractOriginalNodeId(node);
+        if (id >= 0) {
+            if (id >= nodeModCounts.length) {
+                nodeModCounts = Arrays.copyOf(nodeModCounts, id + 30);
             }
-            nodeModCounts[node.id]++;
+            nodeModCounts[id]++;
         } else {
             assert false;
         }
     }
 
     int usageModCount(Node node) {
-        if (node.id >= 0 && node.id < nodeUsageModCounts.length) {
+        int id = extractOriginalNodeId(node);
+        if (id >= 0 && id < nodeUsageModCounts.length) {
             return nodeUsageModCounts[node.id];
         }
         return 0;
     }
 
     void incUsageModCount(Node node) {
-        if (node.id >= 0) {
-            if (node.id >= nodeUsageModCounts.length) {
-                nodeUsageModCounts = Arrays.copyOf(nodeUsageModCounts, node.id + 30);
+        int id = extractOriginalNodeId(node);
+        if (id >= 0) {
+            if (id >= nodeUsageModCounts.length) {
+                nodeUsageModCounts = Arrays.copyOf(nodeUsageModCounts, id + 30);
             }
-            nodeUsageModCounts[node.id]++;
+            nodeUsageModCounts[id]++;
         } else {
             assert false;
         }