# HG changeset patch # User Josef Eisl # Date 1414080451 -7200 # Node ID 9bf59aa9d8c6779b883ea1ba5f0d91d5a014b774 # Parent b2b37b36a25473f2411f76f74a8bc9080352335f Move allocateStackSlots logic from FrameMap to ForwardingFrameMapBuilder. diff -r b2b37b36a254 -r 9bf59aa9d8c6 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java Thu Oct 23 17:48:46 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ForwardingFrameMapBuilder.java Thu Oct 23 18:07:31 2014 +0200 @@ -71,7 +71,37 @@ } public StackSlot allocateStackSlots(int slots, BitSet objects, List outObjectStackSlots) { - return frameMap.allocateStackSlots(slots, objects, outObjectStackSlots); + if (slots == 0) { + return null; + } + frameMap.spillSize += (slots * frameMap.getTarget().wordSize); + + if (!objects.isEmpty()) { + assert objects.length() <= slots; + StackSlot result = null; + for (int slotIndex = 0; slotIndex < slots; slotIndex++) { + StackSlot objectSlot = null; + if (objects.get(slotIndex)) { + objectSlot = frameMap.allocateNewSpillSlot(LIRKind.reference(Kind.Object), slotIndex * frameMap.getTarget().wordSize); + frameMap.addObjectStackSlot(objectSlot); + if (outObjectStackSlots != null) { + outObjectStackSlots.add(objectSlot); + } + } + if (slotIndex == 0) { + if (objectSlot != null) { + result = objectSlot; + } else { + result = frameMap.allocateNewSpillSlot(LIRKind.value(frameMap.getTarget().wordKind), 0); + } + } + } + assert result != null; + return result; + + } else { + return frameMap.allocateNewSpillSlot(LIRKind.value(frameMap.getTarget().wordKind), 0); + } } public RegisterConfig getRegisterConfig() { diff -r b2b37b36a254 -r 9bf59aa9d8c6 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Thu Oct 23 17:48:46 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Thu Oct 23 18:07:31 2014 +0200 @@ -272,11 +272,9 @@ * for guaranteeing that each such object pointer slot is initialized before any * instruction that uses a reference map. Without this guarantee, the garbage * collector could see garbage object values. - * @param outObjectStackSlots if non-null, the object pointer slots allocated are added to this - * list * @return the first reserved stack slot (i.e., at the lowest address) */ - public StackSlot allocateStackSlots(int slots, BitSet objects, List outObjectStackSlots) { + protected StackSlot allocateStackSlots(int slots, BitSet objects) { assert frameSize == -1 : "frame size must not yet be fixed"; if (slots == 0) { return null; @@ -290,10 +288,7 @@ StackSlot objectSlot = null; if (objects.get(slotIndex)) { objectSlot = allocateNewSpillSlot(LIRKind.reference(Kind.Object), slotIndex * getTarget().wordSize); - objectStackSlots.add(objectSlot); - if (outObjectStackSlots != null) { - outObjectStackSlots.add(objectSlot); - } + addObjectStackSlot(objectSlot); } if (slotIndex == 0) { if (objectSlot != null) { @@ -311,6 +306,10 @@ } } + protected void addObjectStackSlot(StackSlot objectSlot) { + objectStackSlots.add(objectSlot); + } + public ReferenceMap initReferenceMap(boolean hasRegisters) { ReferenceMap refMap = getTarget().createReferenceMap(hasRegisters, frameSize() / getTarget().wordSize); for (StackSlot slot : objectStackSlots) {