# HG changeset patch # User Thomas Wuerthinger # Date 1422748269 -3600 # Node ID 1ceffe3a92c762ea479aca69196dcc45ba721e9b # Parent e971180d16d9bbcc6be97284aef46c00d3972c09 Small improvement to LIRInsertionBuffer. diff -r e971180d16d9 -r 1ceffe3a92c7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInsertionBuffer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInsertionBuffer.java Sat Jan 31 23:43:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInsertionBuffer.java Sun Feb 01 00:51:09 2015 +0100 @@ -48,7 +48,8 @@ * index into lir list where "count" ops should be inserted indexAndCount[i * 2 + 1]: the number * of ops to be inserted at index */ - private final List indexAndCount; + private int[] indexAndCount; + private int indexAndCountSize; /** * The LIROps to be inserted. @@ -56,8 +57,8 @@ private final List ops; public LIRInsertionBuffer() { - indexAndCount = new ArrayList<>(8); - ops = new ArrayList<>(8); + indexAndCount = new int[8]; + ops = new ArrayList<>(4); } /** @@ -65,7 +66,7 @@ */ public void init(List newLir) { assert !initialized() : "already initialized"; - assert indexAndCount.size() == 0 && ops.size() == 0; + assert indexAndCountSize == 0 && ops.size() == 0; this.lir = newLir; } @@ -126,32 +127,38 @@ } ipIndex--; } - indexAndCount.clear(); + indexAndCountSize = 0; ops.clear(); } lir = null; } private void appendNew(int index, int count) { - indexAndCount.add(index); - indexAndCount.add(count); + int oldSize = indexAndCountSize; + int newSize = oldSize + 2; + if (newSize > this.indexAndCount.length) { + indexAndCount = Arrays.copyOf(indexAndCount, newSize * 2); + } + indexAndCount[oldSize] = index; + indexAndCount[oldSize + 1] = count; + this.indexAndCountSize = newSize; } private void setCountAt(int i, int value) { - indexAndCount.set((i << 1) + 1, value); + indexAndCount[(i << 1) + 1] = value; } private int numberOfInsertionPoints() { - assert indexAndCount.size() % 2 == 0 : "must have a count for each index"; - return indexAndCount.size() >> 1; + assert indexAndCount.length % 2 == 0 : "must have a count for each index"; + return indexAndCountSize >> 1; } private int indexAt(int i) { - return indexAndCount.get((i << 1)); + return indexAndCount[(i << 1)]; } private int countAt(int i) { - return indexAndCount.get((i << 1) + 1); + return indexAndCount[(i << 1) + 1]; } private boolean verify() {