# HG changeset patch # User twisti # Date 1375640161 25200 # Node ID e2c63a0b799c863b41ab43c91a809cf390719a7b # Parent c6e004578eb4c62f8b497eef4ce8cf7d54e1a3fc moved move logic into architecture specific FrameMap diff -r c6e004578eb4 -r e2c63a0b799c graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Thu Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Sun Aug 04 11:16:01 2013 -0700 @@ -81,16 +81,4 @@ this.implicitNullCheckLimit = implicitNullCheckLimit; this.inlineObjects = inlineObjects; } - - /** - * Aligns the given frame size (without return instruction pointer) to the stack alignment size - * and return the aligned size (without return instruction pointer). - * - * @param frameSize the initial frame size to be aligned - * @return the aligned frame size - */ - public int alignFrameSize(int frameSize) { - int x = frameSize + arch.getReturnAddressSize() + (stackAlignment - 1); - return (x / stackAlignment) * stackAlignment - arch.getReturnAddressSize(); - } } diff -r c6e004578eb4 -r e2c63a0b799c 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 Thu Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Sun Aug 04 11:16:01 2013 -0700 @@ -71,6 +71,25 @@ public AMD64FrameMap(CodeCacheProvider runtime, TargetDescription target, RegisterConfig registerConfig) { super(runtime, target, registerConfig); + // (negative) offset relative to sp + total frame size + initialSpillSize = returnAddressSize() + calleeSaveAreaSize(); + spillSize = initialSpillSize; + } + + @Override + public int totalFrameSize() { + return frameSize() + returnAddressSize(); + } + + @Override + public int currentFrameSize() { + return alignFrameSize(outgoingSize + spillSize - returnAddressSize()); + } + + @Override + protected int alignFrameSize(int size) { + int x = size + returnAddressSize() + (target.stackAlignment - 1); + return (x / target.stackAlignment) * target.stackAlignment - returnAddressSize(); } @Override diff -r c6e004578eb4 -r e2c63a0b799c graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Thu Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Sun Aug 04 11:16:01 2013 -0700 @@ -24,6 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; /** @@ -42,6 +43,21 @@ } @Override + public int totalFrameSize() { + throw GraalInternalError.unimplemented(); + } + + @Override + public int currentFrameSize() { + throw GraalInternalError.unimplemented(); + } + + @Override + protected int alignFrameSize(int size) { + throw GraalInternalError.unimplemented(); + } + + @Override public int offsetToCalleeSaveArea() { return frameSize() - calleeSaveAreaSize(); } diff -r c6e004578eb4 -r e2c63a0b799c graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Thu Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Sun Aug 04 11:16:01 2013 -0700 @@ -24,6 +24,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; /** @@ -42,6 +43,21 @@ } @Override + public int totalFrameSize() { + throw GraalInternalError.unimplemented(); + } + + @Override + public int currentFrameSize() { + throw GraalInternalError.unimplemented(); + } + + @Override + protected int alignFrameSize(int size) { + throw GraalInternalError.unimplemented(); + } + + @Override public int offsetToCalleeSaveArea() { return frameSize() - calleeSaveAreaSize(); } diff -r c6e004578eb4 -r e2c63a0b799c graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Thu Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Sun Aug 04 11:16:01 2013 -0700 @@ -38,22 +38,22 @@ * caller | incoming overflow argument n | ^ * frame : ... : | positive * | incoming overflow argument 0 | | offsets - * ---------+--------------------------------+--------------------- - * | spill slot 0 | | negative ^ | + * ---------+--------------------------------+--------------------------- + * | spill slot 0 | | negative ^ ^ * : ... : v offsets | | - * | spill slot n | ----- total frame - * +--------------------------------+ frame size + * | spill slot n | ----- total | + * +--------------------------------+ frame | * current | alignment padding | size | * frame +--------------------------------+ ----- | | - * | outgoing overflow argument n | ^ | | - * : ... : | positive | | - * | outgoing overflow argument 0 | | offsets | v - * +--------------------------------+ | | - * | return address | | | - * +--------------------------------+ | | ----- - * | | | | ^ + * | outgoing overflow argument n | ^ | frame + * : ... : | positive | size + * | outgoing overflow argument 0 | | offsets | | + * +--------------------------------+ | | | + * | return address | | | | + * +--------------------------------+ | | | + * | | | | | * : callee save area : | | | - * | | | v | + * | | | v v * %sp--> +--------------------------------+--------------------------- * * @@ -71,6 +71,25 @@ public SPARCFrameMap(CodeCacheProvider runtime, TargetDescription target, RegisterConfig registerConfig) { super(runtime, target, registerConfig); + // offset relative to sp + total frame size + initialSpillSize = 0; + spillSize = initialSpillSize; + } + + @Override + public int totalFrameSize() { + return frameSize(); + } + + @Override + public int currentFrameSize() { + return alignFrameSize(calleeSaveAreaSize() + returnAddressSize() + outgoingSize + spillSize); + } + + @Override + protected int alignFrameSize(int size) { + int x = size + (target.stackAlignment - 1); + return (x / target.stackAlignment) * target.stackAlignment; } @Override @@ -80,6 +99,6 @@ @Override protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { - return StackSlot.get(kind, spillSize + additionalOffset, false); + return StackSlot.get(kind, -spillSize + additionalOffset, true); } } diff -r c6e004578eb4 -r e2c63a0b799c 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 Aug 01 15:23:05 2013 -0700 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Sun Aug 04 11:16:01 2013 -0700 @@ -52,6 +52,11 @@ private int frameSize; /** + * Initial size of the area occupied by spill slots and other stack-allocated memory blocks. + */ + protected int initialSpillSize; + + /** * Size of the area occupied by spill slots and other stack-allocated memory blocks. */ protected int spillSize; @@ -61,7 +66,7 @@ * conventions for outgoing calls are retrieved. On some platforms, there is a minimum outgoing * size even if no overflow arguments are on the stack. */ - private int outgoingSize; + protected int outgoingSize; /** * Determines if this frame has values on the stack for outgoing calls. @@ -87,12 +92,11 @@ this.target = target; this.registerConfig = registerConfig; this.frameSize = -1; - this.spillSize = returnAddressSize() + calleeSaveAreaSize(); this.outgoingSize = runtime.getMinimumOutgoingSize(); this.objectStackBlocks = new ArrayList<>(); } - private int returnAddressSize() { + protected int returnAddressSize() { return target.arch.getReturnAddressSize(); } @@ -135,17 +139,21 @@ * * @return The total size of the frame (in bytes). */ - public int totalFrameSize() { - return frameSize() + returnAddressSize(); - } + public abstract int totalFrameSize(); /** * Gets the current size of this frame. This is the size that would be returned by * {@link #frameSize()} if {@link #finish()} were called now. */ - public int currentFrameSize() { - return target.alignFrameSize(outgoingSize + spillSize - returnAddressSize()); - } + public abstract int currentFrameSize(); + + /** + * Aligns the given frame size to the stack alignment size and return the aligned size. + * + * @param size the initial frame size to be aligned + * @return the aligned frame size + */ + protected abstract int alignFrameSize(int size); /** * Computes the final size of this frame. After this method has been called, methods that change @@ -162,7 +170,6 @@ for (StackSlot s : freedSlots) { total += target.arch.getSizeInBytes(s.getKind()); } - int initialSpillSize = returnAddressSize() + calleeSaveAreaSize(); if (total == spillSize - initialSpillSize) { // reset spill area size spillSize = initialSpillSize;