# HG changeset patch # User Josef Eisl # Date 1415644996 -3600 # Node ID 06624c98ed8b4911871e55b0c75c414d03159cdd # Parent a0cd3a1e7d7d5a78dbf1db8fe5bc5260f550f57a Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder. diff -r a0cd3a1e7d7d -r 06624c98ed8b graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Nov 10 18:40:52 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Nov 10 19:43:16 2014 +0100 @@ -88,7 +88,7 @@ /** * The slot reserved for saving RBP. */ - final VirtualStackSlot reservedSlot; + final StackSlot reservedSlot; public SaveRbp(NoOp placeholder) { this.placeholder = placeholder; @@ -106,7 +106,7 @@ if (useStack) { dst = reservedSlot; } else { - getResult().getFrameMapBuilder().freeSpillSlot(reservedSlot); + ((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).freeRBPSpillSlot(); dst = newVariable(LIRKind.value(Kind.Long)); } @@ -417,7 +417,7 @@ boolean hasDebugInfo = getResult().getLIR().hasDebugInfo(); AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo); if (hasDebugInfo) { - ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(Kind.Long))); + ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot()); } for (AMD64HotSpotEpilogueOp op : epilogueOps) { diff -r a0cd3a1e7d7d -r 06624c98ed8b graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Mon Nov 10 18:40:52 2014 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Mon Nov 10 19:43:16 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.lir.amd64; +import static com.oracle.graal.api.code.ValueUtil.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; @@ -70,6 +72,8 @@ */ public class AMD64FrameMap extends FrameMap { + private StackSlot rbpSpillSlot; + public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) { super(codeCache, registerConfig); // (negative) offset relative to sp + total frame size @@ -101,4 +105,29 @@ protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } + + /** + * For non-leaf methods, RBP is preserved in the special stack slot required by the HotSpot + * runtime for walking/inspecting frames of such methods. + */ + StackSlot allocateRBPSpillSlot() { + assert spillSize == initialSpillSize : "RBP spill slot can only be allocated before getting other stack slots"; + int size = spillSlotSize(LIRKind.value(Kind.Long)); + spillSize = NumUtil.roundUp(spillSize + size, size); + rbpSpillSlot = allocateNewSpillSlot(LIRKind.value(Kind.Long), 0); + assert asStackSlot(rbpSpillSlot).getRawOffset() == -16 : asStackSlot(rbpSpillSlot).getRawOffset(); + return rbpSpillSlot; + } + + void freeRBPSpillSlot() { + int size = spillSlotSize(LIRKind.value(Kind.Long)); + assert spillSize == NumUtil.roundUp(initialSpillSize + size, size) : "RBP spill slot can not be freed after allocation other stack slots"; + spillSize = initialSpillSize; + } + + public StackSlot allocateDeoptimizationRescueSlot() { + int size = spillSlotSize(LIRKind.value(Kind.Long)); + spillSize = NumUtil.roundUp(spillSize + size, size); + return allocateNewSpillSlot(LIRKind.value(Kind.Long), 0); + } } diff -r a0cd3a1e7d7d -r 06624c98ed8b graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java Mon Nov 10 18:40:52 2014 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMapBuilder.java Mon Nov 10 19:43:16 2014 +0100 @@ -22,18 +22,11 @@ */ package com.oracle.graal.lir.amd64; -import static com.oracle.graal.api.code.ValueUtil.*; - -import java.util.*; - import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.*; public class AMD64FrameMapBuilder extends DelayedFrameMapBuilder { - private TrackedVirtualStackSlot rbpSpillSlot; - public AMD64FrameMapBuilder(FrameMapFactory factory, CodeCacheProvider codeCache, RegisterConfig registerConfig) { super(factory, codeCache, registerConfig); } @@ -42,28 +35,15 @@ * For non-leaf methods, RBP is preserved in the special stack slot required by the HotSpot * runtime for walking/inspecting frames of such methods. */ - public VirtualStackSlot allocateRBPSpillSlot() { - rbpSpillSlot = (TrackedVirtualStackSlot) allocateSpillSlot(LIRKind.value(Kind.Long)); - return rbpSpillSlot; + public StackSlot allocateRBPSpillSlot() { + return ((AMD64FrameMap) frameMap).allocateRBPSpillSlot(); } - @Override - public void freeSpillSlot(VirtualStackSlot slot) { - assert slot != null; - if (slot.equals(rbpSpillSlot)) { - rbpSpillSlot = null; - } else { - super.freeSpillSlot(slot); - } + public void freeRBPSpillSlot() { + ((AMD64FrameMap) frameMap).freeRBPSpillSlot(); } - @Override - protected void mapStackSlots(HashMap mapping) { - if (rbpSpillSlot != null) { - StackSlot reservedSlot = rbpSpillSlot.transform(); - assert asStackSlot(reservedSlot).getRawOffset() == -16 : asStackSlot(reservedSlot).getRawOffset(); - mapping.put(rbpSpillSlot, reservedSlot); - } - super.mapStackSlots(mapping); + public StackSlot allocateDeoptimizationRescueSlot() { + return ((AMD64FrameMap) frameMap).allocateDeoptimizationRescueSlot(); } }