Mercurial > hg > graal-compiler
changeset 11522:dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 04 Sep 2013 09:39:51 +0200 |
parents | f521a1db1378 |
children | d4537043ccc8 |
files | graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java |
diffstat | 1 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Tue Sep 03 18:19:30 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Wed Sep 04 09:39:51 2013 +0200 @@ -145,11 +145,11 @@ } } - protected static NodeBitMap computeNodes(Graph graph, Collection<AbstractBeginNode> blocks) { + protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks) { return computeNodes(graph, blocks, Collections.<AbstractBeginNode> emptyList()); } - protected static NodeBitMap computeNodes(Graph graph, Collection<AbstractBeginNode> blocks, Collection<AbstractBeginNode> earlyExits) { + protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks, Iterable<AbstractBeginNode> earlyExits) { final NodeBitMap nodes = graph.createNodeBitMap(true); for (AbstractBeginNode b : blocks) { for (Node n : b.getBlockNodes()) { @@ -229,12 +229,28 @@ return false; } - public static Collection<AbstractBeginNode> toHirBlocks(Collection<Block> blocks) { - List<AbstractBeginNode> hir = new ArrayList<>(blocks.size()); - for (Block b : blocks) { - hir.add(b.getBeginNode()); - } - return hir; + public static NodeIterable<AbstractBeginNode> toHirBlocks(final Iterable<Block> blocks) { + return new AbstractNodeIterable<AbstractBeginNode>() { + + public Iterator<AbstractBeginNode> iterator() { + final Iterator<Block> it = blocks.iterator(); + return new Iterator<AbstractBeginNode>() { + + public void remove() { + throw new UnsupportedOperationException(); + } + + public AbstractBeginNode next() { + return it.next().getBeginNode(); + } + + public boolean hasNext() { + return it.hasNext(); + } + }; + } + + }; } /**