public final class ScratchMap extends Object
Modifier and Type | Class and Description |
---|---|
private class |
ScratchMap.Interval
Super class of physical and symbolic intervals
|
private class |
ScratchMap.PhysicalInterval
An object that represents an interval where a physical register's
contents are evicted so that the physical register can be used as a
scratch.
|
private class |
ScratchMap.SymbolicInterval
An object that represents an interval where a symbolic register
resides in a scratch register.
|
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG |
private HashMap<Instruction,HashSet<Register>> |
dirtyMap
For each GC Point s, a set of symbolic registers that are cached in
dirty scratch registers before s.
|
private HashMap<Register,ArrayList<ScratchMap.Interval>> |
map
For each register, the set of intervals describing the register.
|
private HashMap<Register,ScratchMap.Interval> |
pending
For each register, a pending (incomplete) interval under
construction.
|
private RegisterAllocatorState |
regAllocState |
Constructor and Description |
---|
ScratchMap(RegisterAllocatorState regAllocState) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
beginScratchInterval(Register r,
Instruction begin)
Begin a new interval of scratch-ness for a physical register.
|
(package private) void |
beginSymbolicInterval(Register r,
Register scratch,
Instruction begin)
Begin a new interval of scratch-ness for a symbolic register.
|
void |
endScratchInterval(Register r,
Instruction end)
End an interval of scratch-ness for a physical register.
|
void |
endSymbolicInterval(Register r,
Instruction end)
End an interval of scratch-ness for a symbolic register.
|
private ArrayList<ScratchMap.Interval> |
findOrCreateIntervalSet(Register r)
Find or create the set of intervals corresponding to a register r.
|
(package private) Register |
getScratch(Register r,
int n)
Gets the scratch register if a matching one exists.
|
boolean |
isDirty(Instruction s,
Register r)
At GC point s, is the value of register r cached in a dirty scratch
register?
|
boolean |
isEmpty() |
(package private) boolean |
isScratch(Register r,
int n)
Is the given physical register being used as a scratch register
in the given instruction?
|
void |
markDirty(Instruction s,
Register symb)
Records that the real value of a symbolic register is cached in
a dirty scratch register at a given instruction that is a GC point.
|
String |
toString() |
private static final boolean DEBUG
private final HashMap<Register,ArrayList<ScratchMap.Interval>> map
private final HashMap<Register,ScratchMap.Interval> pending
private final HashMap<Instruction,HashSet<Register>> dirtyMap
private final RegisterAllocatorState regAllocState
public ScratchMap(RegisterAllocatorState regAllocState)
void beginSymbolicInterval(Register r, Register scratch, Instruction begin)
r
- the symbolic register being moved into scratchscratch
- the physical register being used as a scratchbegin
- the instruction before which the physical register is
vacated.public void endSymbolicInterval(Register r, Instruction end)
r
- the symbolic register being moved into scratchend
- the instruction before which the scratch interval endsvoid beginScratchInterval(Register r, Instruction begin)
r
- the physical register being used as a scratchbegin
- the instruction before which the physical register is
vacated.public void endScratchInterval(Register r, Instruction end)
r
- the physical register being used as a scratchend
- the instruction before which the physical register is
vacated.private ArrayList<ScratchMap.Interval> findOrCreateIntervalSet(Register r)
r
- the register to checkboolean isScratch(Register r, int n)
r
- a physical registern
- the instruction's numbertrue
if the register is used as a scratch register
in the instruction, false
otherwiseRegister getScratch(Register r, int n)
r
- a symbolic registern
- the instruction numbernull
.public boolean isEmpty()
public void markDirty(Instruction s, Register symb)
s
- an instruction that is a GC point. Note: it is the caller's
responsibility to check thissymb
- the symbolic registerpublic boolean isDirty(Instruction s, Register r)
s
- an instruction that is a GC pointr
- register to checktrue
if the register is in a scratch register and
the scratch register is dirty, false
otherwise