# HG changeset patch # User Doug Simon # Date 1409001725 -7200 # Node ID 87a40fe1ba0c4f23b6e59ee98dca0c22470a4c0c # Parent 29aa6f015c1665407bc8ab9ccdb5b4e2958e3ebb refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue diff -r 29aa6f015c16 -r 87a40fe1ba0c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Mon Aug 25 23:20:44 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Mon Aug 25 23:22:05 2014 +0200 @@ -709,15 +709,17 @@ return true; } - private class TypedNodeIterator implements Iterator { + private static class TypedNodeIterator implements Iterator { + private final Graph graph; private final int[] ids; private final Node[] current; private int currentIdIndex; private boolean needsForward; - public TypedNodeIterator(NodeClass clazz) { + public TypedNodeIterator(NodeClass clazz, Graph graph) { + this.graph = graph; ids = clazz.iterableIds(); currentIdIndex = 0; current = new Node[ids.length]; @@ -743,7 +745,7 @@ return current(); } - private Node skipDeleted(Node node) { + private static Node skipDeleted(Node node) { Node n = node; while (n != null && n.isDeleted()) { n = n.typeCacheNext; @@ -757,7 +759,7 @@ while (true) { Node next; if (current() == PLACE_HOLDER) { - next = getStartNode(ids[currentIdIndex]); + next = graph.getStartNode(ids[currentIdIndex]); } else { next = current().typeCacheNext; } @@ -821,7 +823,7 @@ @Override public Iterator iterator() { - return new TypedNodeIterator<>(nodeClass); + return new TypedNodeIterator<>(nodeClass, Graph.this); } }; } diff -r 29aa6f015c16 -r 87a40fe1ba0c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Aug 25 23:20:44 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Aug 25 23:22:05 2014 +0200 @@ -152,16 +152,16 @@ // therefore points to the next Node of the same type. Node typeCacheNext; - private static final int INLINE_USAGE_COUNT = 2; + static final int INLINE_USAGE_COUNT = 2; private static final Node[] NO_NODES = {}; /** * Head of usage list. The elements of the usage list in order are {@link #usage0}, * {@link #usage1} and {@link #extraUsages}. The first null entry terminates the list. */ - private Node usage0; - private Node usage1; - private Node[] extraUsages; + Node usage0; + Node usage1; + Node[] extraUsages; private Node predecessor; @@ -210,95 +210,6 @@ return getNodeClass().getSuccessorIterable(this); } - class NodeUsageIterator implements java.util.Iterator { - - int index = -1; - Node current; - - private void advance() { - current = null; - index++; - if (index == 0) { - current = usage0; - } else if (index == 1) { - current = usage1; - } else { - if (index - INLINE_USAGE_COUNT < extraUsages.length) { - current = extraUsages[index - INLINE_USAGE_COUNT]; - } - } - } - - public NodeUsageIterator() { - advance(); - } - - public boolean hasNext() { - return current != null; - } - - public Node next() { - Node result = current; - if (result == null) { - throw new NoSuchElementException(); - } - advance(); - return result; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - - class NodeUsageWithModCountIterator extends NodeUsageIterator { - - private final int expectedModCount = usageModCount(); - - @Override - public boolean hasNext() { - if (expectedModCount != usageModCount()) { - throw new ConcurrentModificationException(); - } - return super.hasNext(); - } - - @Override - public Node next() { - if (expectedModCount != usageModCount()) { - throw new ConcurrentModificationException(); - } - return super.next(); - } - } - - class NodeUsageIterable implements com.oracle.graal.graph.iterators.NodeIterable { - - public NodeUsageIterator iterator() { - if (MODIFICATION_COUNTS_ENABLED) { - return new NodeUsageWithModCountIterator(); - } else { - return new NodeUsageIterator(); - } - } - - @Override - public boolean isEmpty() { - return usage0 == null; - } - - @Override - public boolean isNotEmpty() { - return usage0 != null; - } - - @Override - public int count() { - return usageCount(); - } - } - int getUsageCountUpperBound() { assert recordsUsages(); if (usage0 == null) { @@ -315,7 +226,7 @@ */ public final NodeIterable usages() { assert recordsUsages() : this; - return new NodeUsageIterable(); + return new NodeUsageIterable(this); } /** @@ -392,7 +303,7 @@ } } - private int usageCount() { + int usageCount() { if (usage0 == null) { return 0; } diff -r 29aa6f015c16 -r 87a40fe1ba0c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterable.java Mon Aug 25 23:22:05 2014 +0200 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import static com.oracle.graal.graph.Graph.*; + +import com.oracle.graal.graph.iterators.*; + +class NodeUsageIterable implements NodeIterable { + + final Node node; + + NodeUsageIterable(Node node) { + this.node = node; + } + + public NodeUsageIterator iterator() { + if (MODIFICATION_COUNTS_ENABLED) { + return new NodeUsageWithModCountIterator(node); + } else { + return new NodeUsageIterator(node); + } + } + + @Override + public boolean isEmpty() { + return node.usage0 == null; + } + + @Override + public boolean isNotEmpty() { + return node.usage0 != null; + } + + @Override + public int count() { + return node.usageCount(); + } +} \ No newline at end of file diff -r 29aa6f015c16 -r 87a40fe1ba0c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterator.java Mon Aug 25 23:22:05 2014 +0200 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import java.util.*; + +class NodeUsageIterator implements Iterator { + + final Node node; + int index = -1; + Node current; + + void advance() { + current = null; + index++; + if (index == 0) { + current = node.usage0; + } else if (index == 1) { + current = node.usage1; + } else { + if (index - Node.INLINE_USAGE_COUNT < node.extraUsages.length) { + current = node.extraUsages[index - Node.INLINE_USAGE_COUNT]; + } + } + } + + public NodeUsageIterator(Node node) { + this.node = node; + advance(); + } + + public boolean hasNext() { + return current != null; + } + + public Node next() { + Node result = current; + if (result == null) { + throw new NoSuchElementException(); + } + advance(); + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff -r 29aa6f015c16 -r 87a40fe1ba0c graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageWithModCountIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageWithModCountIterator.java Mon Aug 25 23:22:05 2014 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import java.util.*; + +class NodeUsageWithModCountIterator extends NodeUsageIterator { + + public NodeUsageWithModCountIterator(Node n) { + super(n); + } + + private final int expectedModCount = node.usageModCount(); + + @Override + public boolean hasNext() { + if (expectedModCount != node.usageModCount()) { + throw new ConcurrentModificationException(); + } + return super.hasNext(); + } + + @Override + public Node next() { + if (expectedModCount != node.usageModCount()) { + throw new ConcurrentModificationException(); + } + return super.next(); + } +} \ No newline at end of file