# HG changeset patch # User Thomas Wuerthinger # Date 1305880839 -7200 # Node ID 99c84a06bb64aec6e148b46c59c94cb91b1a7930 # Parent 03b80fb10ae936bc9d5d482fbda8bce483eb3df3 Added two new utilities to the Graph class: NodeBitMap and NodeMap. diff -r 03b80fb10ae9 -r 99c84a06bb64 graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java --- a/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Fri May 20 10:16:39 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Fri May 20 10:40:39 2011 +0200 @@ -36,7 +36,7 @@ * The {@code FrameState} class encapsulates the frame state (i.e. local variables and * operand stack) at a particular point in the abstract interpretation. */ -public class FrameState extends Value implements FrameStateAccess { +public final class FrameState extends Value implements FrameStateAccess { protected final int localsSize; diff -r 03b80fb10ae9 -r 99c84a06bb64 graal/GraalGraph/.classpath --- a/graal/GraalGraph/.classpath Fri May 20 10:16:39 2011 +0200 +++ b/graal/GraalGraph/.classpath Fri May 20 10:40:39 2011 +0200 @@ -1,8 +1,9 @@ - - - - - - - - + + + + + + + + + diff -r 03b80fb10ae9 -r 99c84a06bb64 graal/GraalGraph/src/com/oracle/graal/graph/Graph.java --- a/graal/GraalGraph/src/com/oracle/graal/graph/Graph.java Fri May 20 10:16:39 2011 +0200 +++ b/graal/GraalGraph/src/com/oracle/graal/graph/Graph.java Fri May 20 10:40:39 2011 +0200 @@ -26,6 +26,8 @@ import java.util.Collection; import java.util.Collections; +import com.sun.cri.ci.CiBitMap; + public class Graph { private final ArrayList nodes; @@ -54,4 +56,59 @@ public Root root() { return root; } + + public NodeBitMap createNodeBitMap() { + return new NodeBitMap(); + } + + public NodeMap createNodeMap() { + return new NodeMap(); + } + + public final class NodeBitMap { + + private final CiBitMap bitMap = new CiBitMap(nextId); + + private NodeBitMap() { + } + + public boolean isMarked(Node node) { + check(node); + return bitMap.get(node.id()); + } + + public void mark(Node node) { + check(node); + bitMap.set(node.id()); + } + + private void check(Node node) { + assert node.graph == Graph.this : "this node is not part of the graph"; + assert node.id() < bitMap.length() : "this node was added to the graph after creating the node bitmap"; + } + } + + public final class NodeMap { + + private final Object[] values = new Object[nextId]; + + private NodeMap() { + } + + @SuppressWarnings("unchecked") + public T get(Node node) { + check(node); + return (T) values[node.id()]; + } + + public void set(Node node, T value) { + check(node); + values[node.id()] = value; + } + + private void check(Node node) { + assert node.graph == Graph.this : "this node is not part of the graph"; + assert node.id() < values.length : "this node was added to the graph after creating the node map"; + } + } }