com.ibm.wala.ipa.callgraph.propagation.rta
Class TypeBasedHeapModel
java.lang.Object
com.ibm.wala.ipa.callgraph.propagation.rta.TypeBasedHeapModel
- All Implemented Interfaces:
- HeapModel, InstanceKeyFactory, PointerKeyFactory
public class TypeBasedHeapModel
- extends java.lang.Object
- implements HeapModel
A trivial field-based heap model, which only uses the information of which
types (classes) are live.
Note that this heap model is based on ssa value numbers for locals, since we
will build a pointer flow graph based on this heap model when resolving
reflection.
This is an inefficient prototype.
|
Method Summary |
IClassHierarchy |
getClassHierarchy()
|
FilteredPointerKey |
getFilteredPointerKeyForLocal(CGNode node,
int valueNumber,
FilteredPointerKey.TypeFilter filter)
|
protected ClassBasedInstanceKeys |
getIKeyFactory()
|
InstanceKey |
getInstanceKeyForAllocation(CGNode node,
NewSiteReference allocation)
|
InstanceKey |
getInstanceKeyForClassObject(TypeReference type)
|
InstanceKey |
getInstanceKeyForConstant(TypeReference type,
java.lang.Object S)
|
InstanceKey |
getInstanceKeyForMultiNewArray(CGNode node,
NewSiteReference allocation,
int dim)
|
InstanceKey |
getInstanceKeyForPEI(CGNode node,
ProgramCounter instr,
TypeReference type)
|
PointerKey |
getPointerKeyForArrayContents(InstanceKey I)
TODO: expand this API to differentiate between different array indices |
PointerKey |
getPointerKeyForExceptionalReturnValue(CGNode node)
|
PointerKey |
getPointerKeyForInstanceField(InstanceKey I,
IField field)
|
PointerKey |
getPointerKeyForLocal(CGNode node,
int valueNumber)
|
PointerKey |
getPointerKeyForReturnValue(CGNode node)
|
PointerKey |
getPointerKeyForStaticField(IField f)
|
java.lang.String |
getStringConstantForInstanceKey(InstanceKey I)
|
java.util.Iterator<PointerKey> |
iteratePointerKeys()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TypeBasedHeapModel
public TypeBasedHeapModel(AnalysisOptions options,
java.util.Collection<IClass> klasses,
CallGraph cg)
- Parameters:
klasses - Collection
- Throws:
java.lang.IllegalArgumentException - if cg is null
iteratePointerKeys
public java.util.Iterator<PointerKey> iteratePointerKeys()
- Specified by:
iteratePointerKeys in interface HeapModel
- Returns:
- an Iterator of all PointerKeys that are modelled.
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchy in interface HeapModel
- Returns:
- the governing class hierarchy for this heap model
getInstanceKeyForAllocation
public InstanceKey getInstanceKeyForAllocation(CGNode node,
NewSiteReference allocation)
- Specified by:
getInstanceKeyForAllocation in interface InstanceKeyFactory
- Returns:
- the instance key that represents a particular allocation
getInstanceKeyForMultiNewArray
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node,
NewSiteReference allocation,
int dim)
- Specified by:
getInstanceKeyForMultiNewArray in interface InstanceKeyFactory
- Returns:
- the instance key that represents the array allocated as the dimth
dimension at a particular allocation
getInstanceKeyForConstant
public InstanceKey getInstanceKeyForConstant(TypeReference type,
java.lang.Object S)
- Specified by:
getInstanceKeyForConstant in interface InstanceKeyFactory
- Returns:
- the instance key that represents a constant with value S, when considered as a particular type
getStringConstantForInstanceKey
public java.lang.String getStringConstantForInstanceKey(InstanceKey I)
- Specified by:
getStringConstantForInstanceKey in interface InstanceKeyFactory
- Returns:
- if I was allocated by this for a specific string constant, return
that constant (return null otherwise).
getInstanceKeyForPEI
public InstanceKey getInstanceKeyForPEI(CGNode node,
ProgramCounter instr,
TypeReference type)
- Specified by:
getInstanceKeyForPEI in interface InstanceKeyFactory
- Returns:
- the instance key that represents the exception of type _type_
thrown by a particular PEI.
getInstanceKeyForClassObject
public InstanceKey getInstanceKeyForClassObject(TypeReference type)
- Specified by:
getInstanceKeyForClassObject in interface InstanceKeyFactory
- Returns:
- the instance key that represents the class object of type _type_.
getPointerKeyForLocal
public PointerKey getPointerKeyForLocal(CGNode node,
int valueNumber)
- Specified by:
getPointerKeyForLocal in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of
pointers that includes the local variable identified by the value
number parameter.
getFilteredPointerKeyForLocal
public FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node,
int valueNumber,
FilteredPointerKey.TypeFilter filter)
- Specified by:
getFilteredPointerKeyForLocal in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of
pointers that includes the local variable identified by the value
number parameter.
getPointerKeyForReturnValue
public PointerKey getPointerKeyForReturnValue(CGNode node)
- Specified by:
getPointerKeyForReturnValue in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of
pointers that includes the return value for a node
getPointerKeyForExceptionalReturnValue
public PointerKey getPointerKeyForExceptionalReturnValue(CGNode node)
- Specified by:
getPointerKeyForExceptionalReturnValue in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of
pointers that includes the exceptional return value
getPointerKeyForStaticField
public PointerKey getPointerKeyForStaticField(IField f)
- Specified by:
getPointerKeyForStaticField in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of
pointers that includes the contents of the static field
getPointerKeyForInstanceField
public PointerKey getPointerKeyForInstanceField(InstanceKey I,
IField field)
- Specified by:
getPointerKeyForInstanceField in interface PointerKeyFactory
- Returns:
- the PointerKey that acts as a representation for the class of
pointers that includes the given instance field.
getPointerKeyForArrayContents
public PointerKey getPointerKeyForArrayContents(InstanceKey I)
- Description copied from interface:
PointerKeyFactory
- TODO: expand this API to differentiate between different array indices
- Specified by:
getPointerKeyForArrayContents in interface PointerKeyFactory
- Parameters:
I - an InstanceKey representing an abstract array
- Returns:
- the PointerKey that acts as a representation for the class of
pointers that includes the given array contents.
getIKeyFactory
protected ClassBasedInstanceKeys getIKeyFactory()
- Returns:
- Returns the iKeyFactory.