|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.ir.IRTools org.jikesrvm.compilers.opt.regalloc.GenericStackManager org.jikesrvm.compilers.opt.regalloc.ia32.StackManager
public abstract class StackManager
Class to manage the allocation of the "compiler-specific" portion of the stackframe. This class holds only the architecture-specific functions.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.jikesrvm.compilers.opt.regalloc.GenericStackManager |
---|
GenericStackManager.ScratchRegister |
Field Summary | |
---|---|
private int |
ESPOffset
We allow the stack pointer to float from its normal position at the bottom of the frame. |
private static boolean |
FLOAT_ESP
Should we allow the stack pointer to float in order to avoid scratch registers in move instructions. |
private int |
fsaveLocation
A frame offset for 108 bytes of stack space to store the floating point state in the SaveVolatile protocol. |
Fields inherited from class org.jikesrvm.compilers.opt.regalloc.GenericStackManager |
---|
allocFrame, DEBUG, frameSize, ir, nonVolatileFPRLocation, nonVolatileGPRLocation, pref, restrict, saveVolatileFPRLocation, saveVolatileGPRLocation, scratchInUse, scratchMap, spillPointer, VERBOSE, VERBOSE_DEBUG, WORDSIZE |
Constructor Summary | |
---|---|
StackManager()
|
Method Summary | |
---|---|
int |
allocateNewSpillLocation(int type)
Allocate a new spill location and grow the frame size to reflect the new layout. |
private boolean |
canModifyEFLAGS(Instruction s)
|
void |
cleanUpAndInsertEpilogue()
Clean up some junk that's left in the IR after register allocation, and add epilogue code. |
void |
computeNonVolatileArea()
Compute the number of stack words needed to hold nonvolatile registers. |
private int |
FPOffset2SPOffset(int fpOffset)
PRECONDITION: The final frameSize is calculated before calling this routine. |
int |
getFrameFixedSize()
Return the size of the fixed portion of the stack. |
private static Operator |
getMoveOperator(byte type)
Return the move operator for a type of value. |
private static byte |
getSizeOfType(byte type)
Return the size of a type of value, in bytes. |
private boolean |
hasSymbolicRegister(MemoryOperand M)
Does a memory operand hold a symbolic register? |
void |
initForArch(IR ir)
Initialize some architecture-specific state needed for register allocation. |
private void |
insertBigFrameStackOverflowCheck(Instruction plg)
Insert an explicit stack overflow check in the prologue before buying the stack frame. |
private void |
insertEpilogue(Instruction ret)
Insert the epilogue before a particular return instruction. |
void |
insertNormalPrologue()
Insert the prologue for a normal method. |
private void |
insertNormalStackOverflowCheck(Instruction plg)
Insert an explicit stack overflow check in the prologue after buying the stack frame. |
void |
insertSpillBefore(Instruction s,
Register r,
byte type,
int location)
Insert a spill of a physical register before instruction s. |
void |
insertUnspillBefore(Instruction s,
Register r,
byte type,
int location)
Insert a load of a physical register from a spill location before instruction s. |
private boolean |
isScratchFreeMove(Instruction s)
Is s a MOVE instruction that can be generated without resorting to scratch registers? |
boolean |
isSysCall(Instruction s)
Is a particular instruction a system call? |
private void |
moveESPBefore(Instruction s,
int desiredOffset)
Before instruction s, insert code to adjust ESP so that it lies at a particular offset from its usual location. |
private boolean |
mutateMoveToNop(Instruction s)
Attempt to rewrite a move instruction to a NOP. |
boolean |
needScratch(Register r,
Instruction s)
Given symbolic register r in instruction s, do we need to ensure that r is in a scratch register is s (as opposed to a memory operand) |
void |
replaceOperandWithSpillLocation(Instruction s,
RegisterOperand symb)
In instruction s, replace all appearances of a symbolic register operand with uses of the appropriate spill location, as cached by the register allocator. |
private void |
restoreFloatingPointState(Instruction inst)
Insert code into the epilogue to restore the floating point state. |
private void |
restoreNonVolatiles(Instruction inst)
Insert code before a return instruction to restore the nonvolatile registers. |
void |
restoreScratchRegistersBefore(Instruction s)
Walk over the currently available scratch registers. |
private void |
restoreVolatileRegisters(Instruction inst)
Insert code before a return instruction to restore the volatile and volatile registers. |
private void |
rewriteMoveInstruction(Instruction s)
Rewrite a move instruction if it has 2 memory operands. |
private void |
rewriteStackLocations()
Walk through the IR. |
private void |
saveFloatingPointState(Instruction inst)
Insert code into the prologue to save the floating point state. |
private void |
saveNonVolatiles(Instruction inst)
Insert code into the prologue to save any used non-volatile registers. |
private void |
saveVolatiles(Instruction inst)
Insert code into the prologue to save all volatile registers. |
Methods inherited from class org.jikesrvm.compilers.opt.ir.IRTools |
---|
A, AC, AC, CPOS, CR, D, DC, defDoublesAsUse, definedIn, F, FC, getCondMoveOp, getDefaultOperand, getLoadOp, getLoadOp, getMoveOp, getStoreOp, getStoreOp, I, IC, insertInstructionsAfter, L, LC, makeBlockOnEdge, mayBeVolatileFieldLoad, moveInstruction, moveIntoRegister, moveIntoRegister, nonPEIGC, TG, usedIn, useDoublesAsDef |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int fsaveLocation
private int ESPOffset
private static boolean FLOAT_ESP
Constructor Detail |
---|
public StackManager()
Method Detail |
---|
public final int getFrameFixedSize()
GenericStackManager
getFrameFixedSize
in class GenericStackManager
private static byte getSizeOfType(byte type)
type
- one of INT_VALUE, FLOAT_VALUE, or DOUBLE_VALUEprivate static Operator getMoveOperator(byte type)
type
- one of INT_VALUE, FLOAT_VALUE, or DOUBLE_VALUEpublic final int allocateNewSpillLocation(int type)
GenericStackManager
allocateNewSpillLocation
in class GenericStackManager
type
- the type to spill
public final void insertSpillBefore(Instruction s, Register r, byte type, int location)
GenericStackManager
insertSpillBefore
in class GenericStackManager
s
- the instruction before which the spill should occurr
- the register (should be physical) to spilltype
- one of INT_VALUE, FLOAT_VALUE, DOUBLE_VALUE, or
CONDITION_VALUElocation
- the spill locationpublic final void insertUnspillBefore(Instruction s, Register r, byte type, int location)
GenericStackManager
insertUnspillBefore
in class GenericStackManager
s
- the instruction before which the spill should occurr
- the register (should be physical) to spilltype
- one of INT_VALUE, FLOAT_VALUE, DOUBLE_VALUE, or
CONDITION_VALUElocation
- the spill locationpublic void computeNonVolatileArea()
GenericStackManager
frameSize
field of this object
frameRequired
field of this object
computeNonVolatileArea
in class GenericStackManager
public void cleanUpAndInsertEpilogue()
GenericStackManager
cleanUpAndInsertEpilogue
in class GenericStackManager
private void insertNormalStackOverflowCheck(Instruction plg)
SIDE EFFECT: mutates the plg into a trap instruction. We need to mutate so that the trap instruction is in the GC map data structures.
plg
- the prologue instructionprivate void insertBigFrameStackOverflowCheck(Instruction plg)
plg
- the prologue instructionpublic void insertNormalPrologue()
insertNormalPrologue
in class GenericStackManager
private void saveNonVolatiles(Instruction inst)
inst
- the first instruction after the prologue.private void restoreNonVolatiles(Instruction inst)
inst
- the return instructionprivate void saveFloatingPointState(Instruction inst)
inst
- the first instruction after the prologue.private void restoreFloatingPointState(Instruction inst)
inst
- the return instruction after the epilogue.private void saveVolatiles(Instruction inst)
inst
- the first instruction after the prologue.private void restoreVolatileRegisters(Instruction inst)
inst
- the return instructionprivate void insertEpilogue(Instruction ret)
ret
- the return instruction.public void replaceOperandWithSpillLocation(Instruction s, RegisterOperand symb)
GenericStackManager
replaceOperandWithSpillLocation
in class GenericStackManager
s
- the instruction to mutate.symb
- the symbolic register operand to replaceprivate boolean hasSymbolicRegister(MemoryOperand M)
private boolean isScratchFreeMove(Instruction s)
public boolean needScratch(Register r, Instruction s)
GenericStackManager
needScratch
in class GenericStackManager
private void moveESPBefore(Instruction s, int desiredOffset)
private boolean canModifyEFLAGS(Instruction s)
private boolean mutateMoveToNop(Instruction s)
private void rewriteMoveInstruction(Instruction s)
private void rewriteStackLocations()
private int FPOffset2SPOffset(int fpOffset)
fpOffset
- offset in bytes from the top of the stack frame
public void restoreScratchRegistersBefore(Instruction s)
GenericStackManager
For any scratch register r which is def'ed by instruction s, spill r before s and remove r from the pool of available scratch registers.
For any scratch register r which is used by instruction s, restore r before s and remove r from the pool of available scratch registers.
For any scratch register r which has current contents symb, and symb is spilled to location M, and s defs M: the old value of symb is dead. Mark this.
Invalidate any scratch register assignments that are illegal in s.
restoreScratchRegistersBefore
in class GenericStackManager
public void initForArch(IR ir)
initForArch
in class GenericStackManager
public boolean isSysCall(Instruction s)
GenericStackManager
isSysCall
in class GenericStackManager
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |