# HG changeset patch # User Doug Simon # Date 1408805627 -7200 # Node ID 3ca8ba1bfc21257eaa143b1d3abac79df7c5d6e6 # Parent 0583d157992aca428a0f2757a471ad7a38753767 bind a generated Node class to the NodeClass instance of the generated-from Node class diff -r 0583d157992a -r 3ca8ba1bfc21 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Sat Aug 23 00:50:44 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Sat Aug 23 16:53:47 2014 +0200 @@ -54,7 +54,9 @@ */ @SuppressWarnings("unchecked") public static NodeClass get(Class c) { - Class key = (Class) c; + GeneratedNode gen = c.getAnnotation(GeneratedNode.class); + Class key = gen == null ? (Class) c : (Class) gen.value(); + NodeClass value = (NodeClass) allClasses.get(key); // The fact that {@link ConcurrentHashMap#put} and {@link ConcurrentHashMap#get} // are used makes the double-checked locking idiom work. @@ -162,6 +164,8 @@ if (!info.nameTemplate().isEmpty()) { newNameTemplate = info.nameTemplate(); } + } else { + System.out.println("No NodeInfo for " + clazz); } EnumSet newAllowedUsageTypes = EnumSet.noneOf(InputType.class); Class current = clazz; @@ -229,6 +233,12 @@ fieldTypes.putAll(scanner.fieldTypes); } + private boolean isNodeClassFor(Node n) { + GeneratedNode gen = n.getClass().getAnnotation(GeneratedNode.class); + assert gen != null; + return gen.value() == getClazz(); + } + public String shortName() { return shortName; } @@ -1199,7 +1209,7 @@ * @param newNode the node to which the inputs should be copied. */ public void copyInputs(Node node, Node newNode) { - assert node.getClass() == getClazz() && newNode.getClass() == getClazz(); + assert isNodeClassFor(node) && isNodeClassFor(newNode); int index = 0; while (index < directInputCount) { @@ -1221,7 +1231,7 @@ * @param newNode the node to which the successors should be copied. */ public void copySuccessors(Node node, Node newNode) { - assert node.getClass() == getClazz() && newNode.getClass() == getClazz(); + assert isNodeClassFor(node) && isNodeClassFor(newNode); int index = 0; while (index < directSuccessorCount) { @@ -1240,7 +1250,7 @@ } public boolean inputsEqual(Node node, Node other) { - assert node.getClass() == getClazz() && other.getClass() == getClazz(); + assert isNodeClassFor(node) && isNodeClassFor(other); int index = 0; while (index < directInputCount) { if (getNode(other, inputOffsets[index]) != getNode(node, inputOffsets[index])) { @@ -1259,7 +1269,7 @@ } public boolean successorsEqual(Node node, Node other) { - assert node.getClass() == getClazz() && other.getClass() == getClazz(); + assert isNodeClassFor(node) && isNodeClassFor(other); int index = 0; while (index < directSuccessorCount) { if (getNode(other, successorOffsets[index]) != getNode(node, successorOffsets[index])) { @@ -1278,7 +1288,7 @@ } public boolean inputContains(Node node, Node other) { - assert node.getClass() == getClazz(); + assert isNodeClassFor(node); int index = 0; while (index < directInputCount) { @@ -1298,7 +1308,7 @@ } public boolean successorContains(Node node, Node other) { - assert node.getClass() == getClazz(); + assert isNodeClassFor(node); int index = 0; while (index < directSuccessorCount) {