public final class StackManager extends GenericStackManager
GenericStackManager.ScratchRegister| Modifier and Type | Field and Description |
|---|---|
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.
|
allocFrame, CONDITION_VALUE, DEBUG, DOUBLE_VALUE, FLOAT_VALUE, frameSize, INT_VALUE, ir, nonVolatileFPRLocation, nonVolatileGPRLocation, pref, regAllocState, restrict, saveVolatileFPRLocation, saveVolatileGPRLocation, scratchInUse, scratchMap, spillPointer, VERBOSE, VERBOSE_DEBUG, WORDSIZE| Constructor and Description |
|---|
StackManager() |
| Modifier and Type | Method and Description |
|---|---|
int |
allocateNewSpillLocation(int type)
Allocates a new spill location and grows the
frame size to reflect the new layout.
|
private boolean |
canModifyEFLAGS(Instruction s) |
void |
cleanUpAndInsertEpilogue()
Cleans up some junk that's left in the IR after register allocation,
and adds epilogue code.
|
void |
computeNonVolatileArea()
Computes 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()
Returns the size of the fixed portion of the stack.
|
private static Operator |
getMoveOperator(byte type) |
private static byte |
getSizeOfType(byte type) |
private boolean |
hasSymbolicRegister(MemoryOperand M) |
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) |
boolean |
isSysCall(Instruction s) |
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)
Rewrites a move instruction if it has 2 memory operands.
|
private void |
rewriteStackLocations()
Walks 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.
|
align, allocateNonVolatileRegister, allocateOnStackFrame, allocateParameterSpace, allocateSpaceForCaughtException, allocateSpaceForConversion, allocateSpaceForSysCall, allocateVolatileRegister, computeRestrictions, forceFrameAllocation, frameIsRequired, getNonvolatileFPROffset, getNonvolatileGPROffset, getOffsetForSysCall, getValueType, hasPrologueYieldpoint, insertPrologueAndEpilogue, insertSpillAfter, insertSpillCode, insertSpillCode, insertUnspillAfter, isDeadBefore, isLegal, prepare, reloadScratchRegisterBefore, setFrameRequired, unloadScratchRegisterBeforeA, 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, offsetOperand, TG, usedIn, useDoublesAsDefprivate int fsaveLocation
private int ESPOffset
private static final boolean FLOAT_ESP
public StackManager()
public int getFrameFixedSize()
GenericStackManagergetFrameFixedSize in class GenericStackManagerprivate 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 int allocateNewSpillLocation(int type)
GenericStackManagerallocateNewSpillLocation in class GenericStackManagertype - the type to spillpublic void insertSpillBefore(Instruction s, Register r, byte type, int location)
GenericStackManagerinsertSpillBefore in class GenericStackManagers - 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 insertUnspillBefore(Instruction s, Register r, byte type, int location)
GenericStackManagerinsertUnspillBefore in class GenericStackManagers - 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()
GenericStackManagerframeSize field of this object
frameRequired field of this object
computeNonVolatileArea in class GenericStackManagerpublic void cleanUpAndInsertEpilogue()
GenericStackManagercleanUpAndInsertEpilogue in class GenericStackManagerprivate 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 GenericStackManagerprivate 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)
GenericStackManagerreplaceOperandWithSpillLocation in class GenericStackManagers - the instruction to mutate.symb - the symbolic register operand to replaceprivate boolean hasSymbolicRegister(MemoryOperand M)
private boolean isScratchFreeMove(Instruction s)
s - the instruction to checktrue if and only if the instruction is a MOVE instruction
that can be generated without resorting to scratch registerspublic boolean needScratch(Register r, Instruction s)
GenericStackManagerneedScratch in class GenericStackManagerr - the symbolic registers - the instruction that has an occurrence of the registertrue if the symbolic register needs to be a scratch
registerprivate void moveESPBefore(Instruction s, int desiredOffset)
s - the instruction before which ESP must have the desired offsetdesiredOffset - the desired offsetprivate boolean canModifyEFLAGS(Instruction s)
private boolean mutateMoveToNop(Instruction s)
s - the instruction to rewritetrue if and only if the transformation appliesprivate void rewriteMoveInstruction(Instruction s)
s - the instruction to rewriteprivate void rewriteStackLocations()
private int FPOffset2SPOffset(int fpOffset)
fpOffset - offset in bytes from the top of the stack framepublic void restoreScratchRegistersBefore(Instruction s)
GenericStackManagerFor 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 GenericStackManagers - the instruction to processpublic void initForArch(IR ir)
initForArch in class GenericStackManagerir - the IR that's being processedpublic boolean isSysCall(Instruction s)
isSysCall in class GenericStackManagers - the instruction to check