|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.ssa.SSADictionary
public final class SSADictionary
An SSADictionary
structure holds lookaside
information regarding Heap Array SSA form for an IR. The general idea
is that all Heap Array SSA form information resides in this lookaside
structure. Note that this is not the case for scalar SSA information.
See our SAS 2000 paper
Unified Analysis of Arrays and Object References in Strongly Typed
Languages for an overview of Array SSA form. More implementation
details are documented in
.
SSA.java
SSA
Nested Class Summary | |
---|---|
(package private) static class |
SSADictionary.AllInstructionEnumeration
This class implements an Enumeration over all
instructions for a basic block. |
private static class |
SSADictionary.HeapKey<T>
This class represents the name of a heap variable in the heap array SSA form. |
Field Summary | |
---|---|
private static boolean |
DEBUG
Flag to turn on debugging |
private HashMap<HeapVariable<Object>,HeapOperand<Object>> |
DefChain
A mapping from HeapVariable to HeapOperand . |
private HashMap<Instruction,HeapOperand<Object>[]> |
defs
A mapping from Instruction to the set of heap
operands (an HeapOperand[] ) that this instruction
defines. |
private static ArrayList<Instruction> |
emptyArrayList
An empty vector, used for utility. |
(package private) static String |
exceptionState
The object for the heap variable that is used for modelling explicit exception dependencies |
private HashSet<Instruction> |
exits
The set of instructions which have been registered to potentially exit the procedure |
private HashMap<BasicBlock,ArrayList<Instruction>> |
heapPhi
A mapping from BasicBlock to ArrayList
of Instruction . |
private Set<Object> |
heapTypes
The set of type to build heap array variables for |
private HashMap<SSADictionary.HeapKey<Object>,HeapVariable<Object>> |
heapVariables
A mapping from HeapKey to the set of heap
variables introduced for this IR |
private boolean |
insertPEIDeps
Should PEIs and stores to the heap be modelled via an explicit exception state heap variable? |
private IR |
ir
A pointer to the governing IR |
private HashMap<Object,Integer> |
nextNumber
A mapping from heap variable type to Integer
This structure holds the next number to assign when creating
a new heap variable name for a given type |
private HashMap<Object,HashSet<HeapOperand<Object>>> |
originalDefs
A mapping from a heap variable type to a HashSet
of Instruction . |
private HashMap<Object,HashSet<HeapOperand<Object>>> |
originalUses
A mapping from a heap variable type to a HashSet
of Instruction . |
private boolean |
uphi
Should the heap array SSA form constructed include uphi functions? |
private HashMap<HeapVariable<Object>,HashSet<HeapOperand<Object>>> |
UseChain
A mapping from HeapVariable to HashSet
of HeapOperand . |
private HashMap<Instruction,HeapOperand<Object>[]> |
uses
A mapping from Instruction to the set of heap
operands (an HeapOperand[] ) that this instruction
uses. |
Constructor Summary | |
---|---|
SSADictionary(Set<Object> heapTypes,
boolean uphi,
boolean insertPEIDeps,
IR ir)
Initialize a structure to hold Heap Array SSA information. |
Method Summary | |
---|---|
(package private) void |
addExceptionStateToDefs(Instruction s,
BasicBlock b)
Register that an instruction defines the exception state. |
(package private) void |
addExceptionStateToUses(Instruction s)
Register that an instruction defines the exception state. |
(package private) void |
addToUseChain(HeapOperand<Object> op)
Add an HeapOperand to the use chain of its heap variable |
private void |
aloadHelper(Instruction s,
BasicBlock b)
Record the effects of a aload instruction on the heap array SSA form. |
private void |
arraylengthHelper(Instruction s,
BasicBlock b)
Record the effects of an arraylength instruction on the heap array SSA form. |
private void |
astoreHelper(Instruction s,
BasicBlock b)
Record the effects of an astore instruction on the heap array SSA form. |
private void |
bbendHelper(Instruction s,
BasicBlock b)
Record the effects of a bbend instruction on the heap array SSA form. |
(package private) void |
createHeapPhiInstruction(BasicBlock bb,
HeapVariable<Object> H)
Create a heap control phi instruction, and store it at the beginning of a basic block. |
(package private) boolean |
defsHeapVariable(Instruction s)
Does a particular instruction define any heap variable? |
(package private) void |
deleteFromUseChain(HeapOperand<Object> op)
Delete an HeapOperand from the use chain of its heap variable |
(package private) Iterator<HeapVariable<Object>> |
enumerateExposedHeapVariables()
Return an enumeration of all heap variables that may be exposed on procedure exit. |
private static HeapOperand<Object>[] |
extendHArray(HeapOperand<Object>[] H)
Returns a copy of H with an additional free slot at position 0 |
private HeapVariable<Object> |
findOrCreateHeapVariable(Object type)
Return the heap variable for a given type or field with number 0. |
private HashSet<HeapOperand<Object>> |
findOrCreateOriginalDefs(Object type)
Return a set of all the original definitions of a heap variable. |
private HashSet<HeapOperand<Object>> |
findOrCreateOriginalUses(Object type)
Return a set of all the original uses of a heap variable. |
(package private) SSADictionary.AllInstructionEnumeration |
getAllInstructions(BasicBlock bb)
Return an enumeration of all instructions for a basic block, including the control-PHI functions for heap variables stored implicitly here. |
private void |
getFieldHelper(Instruction s,
BasicBlock b)
Record the effects of a getfield instruction on the heap array SSA form. |
HeapOperand<Object>[] |
getHeapDefs(Instruction s)
Return the heap operands defined by an instruction. |
Iterator<Instruction> |
getHeapPhiInstructions(BasicBlock bb)
Return an enumeration of the control-phi functions for Heap variables at the beginning of a basic block. |
HeapOperand<Object>[] |
getHeapUses(Instruction s)
Return the heap operands used by an instruction. |
(package private) Iterator<HeapVariable<Object>> |
getHeapVariables()
Return an enumeration of the heap variables in this IR. |
private int |
getNextHeapVariableNumber(Object type)
Get the next number to be assigned to a new heap variable for a given type or field. |
(package private) int |
getNumberOfHeapDefs(Instruction s)
Return the number of heap operands defined by an instruction |
(package private) int |
getNumberOfHeapVariables()
Return the total number of heap variables allocated for the IR |
(package private) int |
getNumberOfUses(HeapVariable<Object> A)
Return the number of uses of a heap variable. |
private void |
getStaticHelper(Instruction s,
BasicBlock b)
Record the effects of a getstatic instruction on the heap array SSA form. |
(package private) HeapOperand<Object> |
getUniqueDef(HeapVariable<Object> A)
Return the operand that represents a heap variable's unique def. |
(package private) boolean |
isExposedOnExit(HeapVariable<Object> H)
Is heap variable H exposed on procedure exit? |
(package private) Iterator<HeapOperand<Object>> |
iterateHeapUses(HeapVariable<Object> A)
Return an enumeration of all uses of a particular heap variable. |
private Iterator<HeapOperand<Object>> |
iterateOriginalHeapDefs(HeapVariable<Object> A)
Return an enumeration of all the original definitions of a heap variable. |
private Iterator<HeapOperand<Object>> |
iterateOriginalHeapUses(HeapVariable<Object> A)
Return an enumeration of all the original uses of a heap variable. |
private void |
labelHelper(Instruction s,
BasicBlock b)
Record the effects of a label instruction on the heap array SSA form. |
private static Instruction |
makePhiInstruction(HeapVariable<Object> H,
BasicBlock bb)
Create a phi-function instruction for a heap variable |
private void |
newArrayHelper(Instruction s,
BasicBlock b)
Update the heap array SSA form for an array allocation instruction |
private void |
newHelper(Instruction s,
BasicBlock b)
Update the heap array SSA form for an allocation instruction |
private void |
phiHelper(Instruction s,
BasicBlock b)
Record the effects of a phi instruction on the heap array SSA form. |
private void |
putFieldHelper(Instruction s,
BasicBlock b)
Record the effects of a putfield instruction on the heap array SSA form. |
private void |
putStaticHelper(Instruction s,
BasicBlock b)
Record the effects of a putstatic instruction on the heap array SSA form. |
(package private) void |
recomputeArrayDU()
Recompute the chain of uses for each heap variable. |
private void |
registerDef(Instruction s,
BasicBlock b,
FieldReference fr)
Register that instruction s writes a heap variable for
a given field. |
private void |
registerDef(Instruction s,
BasicBlock b,
String a)
Register that the instruction s writes a heap variable for
a given field. |
private void |
registerDef(Instruction s,
BasicBlock b,
TypeReference t)
Register that an instruction writes a heap variable for a given type. |
(package private) void |
registerExit(Instruction s,
BasicBlock b)
Register that an instruction s can potentially leave the procedure. |
(package private) void |
registerInstruction(Instruction s,
BasicBlock b)
Record the heap variables that instruction s defines and uses. |
(package private) void |
registerUnknown(Instruction s,
BasicBlock b)
Register that an instruction s has unknown side effects. |
private void |
registerUse(Instruction s,
FieldReference fr)
Register that an instruction uses a heap variable for a given field. |
private void |
registerUse(Instruction s,
String a)
Register that an instruction uses a heap variable for a given field. |
private void |
registerUse(Instruction s,
TypeReference t)
Register that an instruction uses a heap variable of a given type. |
(package private) HeapOperand<Object>[] |
replaceDefs(Instruction s,
BasicBlock b)
Replace all heap variables that an instruction defs with new heap variables. |
(package private) void |
replaceUses(Instruction s,
HeapOperand<Object>[] H)
Register that an instruction now uses the set of heap operands |
(package private) boolean |
usesHeapVariable(Instruction s)
Does a particular instruction use any heap variable? |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
static final String exceptionState
private final HashMap<Instruction,HeapOperand<Object>[]> uses
Instruction
to the set of heap
operands (an HeapOperand[]
) that this instruction
uses. Note that PHI instructions do not appear in
this mapping.
private final HashMap<Instruction,HeapOperand<Object>[]> defs
Instruction
to the set of heap
operands (an HeapOperand[]
) that this instruction
defines. Note that PHI instructions do not appear in
this mapping.
private final HashMap<SSADictionary.HeapKey<Object>,HeapVariable<Object>> heapVariables
HeapKey
to the set of heap
variables introduced for this IR
private HashMap<Object,Integer> nextNumber
Integer
This structure holds the next number to assign when creating
a new heap variable name for a given type
private final HashMap<BasicBlock,ArrayList<Instruction>> heapPhi
BasicBlock
to ArrayList
of Instruction
.
This map holds the list of heap phi instructions stored as
lookaside for each basic block.
private static final ArrayList<Instruction> emptyArrayList
private final HashMap<HeapVariable<Object>,HashSet<HeapOperand<Object>>> UseChain
HeapVariable
to HashSet
of HeapOperand
.
This map holds the set of heap operands which use each heap
variable.
private final HashMap<HeapVariable<Object>,HeapOperand<Object>> DefChain
HeapVariable
to HeapOperand
.
This map holds the set of heap operands which define each heap
variable.
private final HashSet<Instruction> exits
private final HashMap<Object,HashSet<HeapOperand<Object>>> originalUses
HashSet
of Instruction
.
The set of all uses of a heap variable type
before we performed renaming for SSA.
private final HashMap<Object,HashSet<HeapOperand<Object>>> originalDefs
HashSet
of Instruction
.
The set of all definitions of a heap variable type
before we performed renaming for SSA.
private final Set<Object> heapTypes
private final boolean uphi
private final boolean insertPEIDeps
private final IR ir
Constructor Detail |
---|
SSADictionary(Set<Object> heapTypes, boolean uphi, boolean insertPEIDeps, IR ir)
heapTypes
- only create heap arrays for these locations.
if null, create all heap arraysuphi
- Should we use uphi functions? (ie. loads create a new
name for heap arrays)Method Detail |
---|
boolean usesHeapVariable(Instruction s)
s
- the instruction in question
boolean defsHeapVariable(Instruction s)
s
- the instruction in question
public HeapOperand<Object>[] getHeapUses(Instruction s)
s
- the instruction in question
public HeapOperand<Object>[] getHeapDefs(Instruction s)
s
- the instruction in question
int getNumberOfHeapDefs(Instruction s)
s
- the instruction in question
HeapOperand<Object>[] replaceDefs(Instruction s, BasicBlock b)
s
- the instruction that writes to the new heap variablesb
- the basic block containing s
Iterator<HeapVariable<Object>> getHeapVariables()
public Iterator<Instruction> getHeapPhiInstructions(BasicBlock bb)
bb
- the basic block in question
SSADictionary.AllInstructionEnumeration getAllInstructions(BasicBlock bb)
bb
- the basic block in question
Iterator<HeapOperand<Object>> iterateHeapUses(HeapVariable<Object> A)
A
- the heap variable in question
HeapOperand<Object> getUniqueDef(HeapVariable<Object> A)
A
- the heap variable in question
private Iterator<HeapOperand<Object>> iterateOriginalHeapUses(HeapVariable<Object> A)
A
- the heap variable in question
private Iterator<HeapOperand<Object>> iterateOriginalHeapDefs(HeapVariable<Object> A)
A
- the heap variable in question
private HashSet<HeapOperand<Object>> findOrCreateOriginalUses(Object type)
type
- The heap variable in question
private HashSet<HeapOperand<Object>> findOrCreateOriginalDefs(Object type)
type
- the heap variable in question
int getNumberOfUses(HeapVariable<Object> A)
A
- the heap variable in question
Iterator<HeapVariable<Object>> enumerateExposedHeapVariables()
boolean isExposedOnExit(HeapVariable<Object> H)
void recomputeArrayDU()
void deleteFromUseChain(HeapOperand<Object> op)
op
- the heap operand to be deletedvoid addToUseChain(HeapOperand<Object> op)
op
- the heap operand to be addedvoid createHeapPhiInstruction(BasicBlock bb, HeapVariable<Object> H)
bb
- the basic blockH
- the heap variable to mergevoid replaceUses(Instruction s, HeapOperand<Object>[] H)
s
- the instruction in questionH
- the set of heap operands which s usesint getNumberOfHeapVariables()
void registerExit(Instruction s, BasicBlock b)
NOTE: This function should be called before renaming.
NOTE: Only need to use this for backwards analyses
s
- the instruction in questionb
- s's basic blockvoid registerUnknown(Instruction s, BasicBlock b)
NOTE: This function should be called before renaming.
s
- the instruction in questionb
- the basic block containing svoid registerInstruction(Instruction s, BasicBlock b)
s
- the instruction in questionb
- the basic block containing sprivate void getFieldHelper(Instruction s, BasicBlock b)
s
- the getfield instructionb
- the basic block containing sprivate void putFieldHelper(Instruction s, BasicBlock b)
s
- the getfield instructionb
- the basic block containing sprivate void getStaticHelper(Instruction s, BasicBlock b)
s
- the getstatic instructionb
- the basic block containing sprivate void putStaticHelper(Instruction s, BasicBlock b)
s
- the putstatic instructionb
- the basic block containing sprivate void newHelper(Instruction s, BasicBlock b)
s
- the allocation instructionb
- the basic block containing the allocationprivate void newArrayHelper(Instruction s, BasicBlock b)
s
- the allocation instructionb
- the basic block containing the allocationprivate void aloadHelper(Instruction s, BasicBlock b)
s
- the aload instructionb
- the basic block containing sprivate void astoreHelper(Instruction s, BasicBlock b)
s
- the astore instructionb
- the basic block containing sprivate void arraylengthHelper(Instruction s, BasicBlock b)
s
- the arraylength instructionb
- the basic block containing sprivate void phiHelper(Instruction s, BasicBlock b)
s
- the phi instructionb
- the basic block containing sprivate void labelHelper(Instruction s, BasicBlock b)
s
- the label instructionb
- the basic block containing sprivate void bbendHelper(Instruction s, BasicBlock b)
s
- the label instructionb
- the basic block containing sprivate void registerUse(Instruction s, TypeReference t)
s
- the instruction in questiont
- the type of the heap variable the instruction usesprivate void registerDef(Instruction s, BasicBlock b, TypeReference t)
s
- the instruction in questionb
- s's basic blockt
- the type of the heap variable the instruction modifiesprivate void registerUse(Instruction s, FieldReference fr)
s
- the instruction in questionfr
- the field heap variable the instruction usesprivate void registerDef(Instruction s, BasicBlock b, FieldReference fr)
s
writes a heap variable for
a given field.
s
- the instruction in questionb
- s
's basic blockfr
- the field heap variable the instruction modifiesprivate void registerUse(Instruction s, String a)
s
- the instruction in questiona
- the field heap variable the instruction usesprivate void registerDef(Instruction s, BasicBlock b, String a)
s
writes a heap variable for
a given field.
s
- the instruction in questionb
- s
's basic blocka
- XXX TODO Check this XXX The field in question.private static HeapOperand<Object>[] extendHArray(HeapOperand<Object>[] H)
H
- the array of HeapOperands to be extended.void addExceptionStateToDefs(Instruction s, BasicBlock b)
s
- the instruction in questionb
- s's basic blockvoid addExceptionStateToUses(Instruction s)
s
- the instruction in questionprivate HeapVariable<Object> findOrCreateHeapVariable(Object type)
type
- the TypeReference
or RVMField
identifying the desired heap variable
private int getNextHeapVariableNumber(Object type)
type
- the TypeReference
or RVMField
identifying the heap variable
private static Instruction makePhiInstruction(HeapVariable<Object> H, BasicBlock bb)
H
- a symbolic variable for a Heap variablebb
- the basic block holding the new phi function
instruction
H = phi H,H,..,H
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |