org.jikesrvm.compilers.opt.regalloc
Class ScratchMap

java.lang.Object
  extended by org.jikesrvm.compilers.opt.regalloc.ScratchMap

public final class ScratchMap
extends Object

This class holds information on scratch register usage, needed to adjust GC Maps.


Nested Class Summary
private static class ScratchMap.Interval
          Super class of physical and symbolic intervals
(package private) static 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.
(package private) static class ScratchMap.SymbolicInterval
          An object that represents an interval where a symbolic register resides in a scratch register.
 
Field Summary
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.
 
Constructor Summary
ScratchMap()
           
 
Method Summary
(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)
          If a symbolic register resides in a scratch register at an instruction numbered n, then return the scratch register.
 boolean isDirty(Instruction s, Register r)
          At GC point s, is the value of register r cached in a dirty scratch register?
 boolean isEmpty()
          Is this map empty?
(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)
          Note that at GC point s, the real value of register symb is cached in a dirty scratch register.
 String toString()
          Return a String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

map

private final HashMap<Register,ArrayList<ScratchMap.Interval>> map
For each register, the set of intervals describing the register.


pending

private final HashMap<Register,ScratchMap.Interval> pending
For each register, a pending (incomplete) interval under construction.


dirtyMap

private final HashMap<Instruction,HashSet<Register>> dirtyMap
For each GC Point s, a set of symbolic registers that are cached in dirty scratch registers before s.

Constructor Detail

ScratchMap

public ScratchMap()
Method Detail

beginSymbolicInterval

void beginSymbolicInterval(Register r,
                           Register scratch,
                           Instruction begin)
Begin a new interval of scratch-ness for a symbolic register.

Parameters:
r - the symbolic register being moved into scratch
scratch - the physical register being used as a scratch
begin - the instruction before which the physical register is vacated.

endSymbolicInterval

public void endSymbolicInterval(Register r,
                                Instruction end)
End an interval of scratch-ness for a symbolic register.

Parameters:
r - the symbolic register being moved into scratch
end - the instruction before which the scratch interval ends

beginScratchInterval

void beginScratchInterval(Register r,
                          Instruction begin)
Begin a new interval of scratch-ness for a physical register.

Parameters:
r - the physical register being used as a scratch
begin - the instruction before which the physical register is vacated.

endScratchInterval

public void endScratchInterval(Register r,
                               Instruction end)
End an interval of scratch-ness for a physical register.

Parameters:
r - the physical register being used as a scratch
end - the instruction before which the physical register is vacated.

findOrCreateIntervalSet

private ArrayList<ScratchMap.Interval> findOrCreateIntervalSet(Register r)
Find or create the set of intervals corresponding to a register r.


isScratch

boolean isScratch(Register r,
                  int n)
Is the given physical register being used as a scratch register in the given instruction?

Parameters:
r - a physical register
n - the instruction's number
Returns:
true if the register is used as a scratch register in the instruction, false otherwise

getScratch

Register getScratch(Register r,
                    int n)
If a symbolic register resides in a scratch register at an instruction numbered n, then return the scratch register. Else, return null.


isEmpty

public boolean isEmpty()
Is this map empty?


markDirty

public void markDirty(Instruction s,
                      Register symb)
Note that at GC point s, the real value of register symb is cached in a dirty scratch register.


isDirty

public boolean isDirty(Instruction s,
                       Register r)
At GC point s, is the value of register r cached in a dirty scratch register?


toString

public String toString()
Return a String representation.

Overrides:
toString in class Object