Mercurial > hg > graal-compiler
changeset 11956:8a6d0cd7971b
Label: allocate ArrayList lazily
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Thu, 10 Oct 2013 13:03:26 +0200 |
parents | 8bc017616cb7 |
children | ee3b959c81b8 |
files | graal/com.oracle.graal.asm/src/com/oracle/graal/asm/Label.java |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/Label.java Thu Oct 10 12:06:33 2013 +0200 +++ b/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/Label.java Thu Oct 10 13:03:26 2013 +0200 @@ -37,7 +37,7 @@ * patched when the label is bound using the {@link #patchInstructions(AbstractAssembler)} * method. */ - private ArrayList<Integer> patchPositions = new ArrayList<>(4); + private ArrayList<Integer> patchPositions = null; /** * Returns the position of this label in the code buffer. @@ -76,15 +76,20 @@ public void addPatchAt(int branchLocation) { assert !isBound() : "Label is already bound " + this + " " + branchLocation + " at position " + position; + if (patchPositions == null) { + patchPositions = new ArrayList<>(2); + } patchPositions.add(branchLocation); } protected void patchInstructions(AbstractAssembler masm) { assert isBound() : "Label should be bound"; - int target = position; - for (int i = 0; i < patchPositions.size(); ++i) { - int pos = patchPositions.get(i); - masm.patchJumpTarget(pos, target); + if (patchPositions != null) { + int target = position; + for (int i = 0; i < patchPositions.size(); ++i) { + int pos = patchPositions.get(i); + masm.patchJumpTarget(pos, target); + } } }