Class TypeBasedHeapModel
- java.lang.Object
-
- com.ibm.wala.ipa.callgraph.propagation.rta.TypeBasedHeapModel
-
- All Implemented Interfaces:
HeapModel
,InstanceKeyFactory
,PointerKeyFactory
public class TypeBasedHeapModel extends 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.
-
-
Constructor Summary
Constructors Constructor Description TypeBasedHeapModel(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg)
-
Method Summary
-
-
-
Constructor Detail
-
TypeBasedHeapModel
public TypeBasedHeapModel(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg)
- Parameters:
klasses
- Collection- Throws:
IllegalArgumentException
- if cg is null
-
-
Method Detail
-
iteratePointerKeys
public Iterator<PointerKey> iteratePointerKeys()
- Specified by:
iteratePointerKeys
in interfaceHeapModel
- Returns:
- an Iterator of all PointerKeys that are modeled.
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchy
in interfaceHeapModel
- Returns:
- the governing class hierarchy for this heap model
-
getInstanceKeyForAllocation
public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) throws UnimplementedError
- Specified by:
getInstanceKeyForAllocation
in interfaceInstanceKeyFactory
- Returns:
- the instance key that represents a particular allocation
- Throws:
UnimplementedError
-
getInstanceKeyForMultiNewArray
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) throws UnimplementedError
- Specified by:
getInstanceKeyForMultiNewArray
in interfaceInstanceKeyFactory
- Returns:
- the instance key that represents the array allocated as the dim_th dimension at a particular allocation
- Throws:
UnimplementedError
-
getInstanceKeyForConstant
public InstanceKey getInstanceKeyForConstant(TypeReference type, Object S)
- Specified by:
getInstanceKeyForConstant
in interfaceInstanceKeyFactory
- Returns:
- the instance key that represents a constant with value S, when considered as a particular type
-
getStringConstantForInstanceKey
public String getStringConstantForInstanceKey(InstanceKey I) throws UnimplementedError
- Throws:
UnimplementedError
-
getInstanceKeyForPEI
public InstanceKey getInstanceKeyForPEI(CGNode node, ProgramCounter instr, TypeReference type) throws UnimplementedError
- Specified by:
getInstanceKeyForPEI
in interfaceInstanceKeyFactory
- Returns:
- the instance key that represents the exception of type _type_ thrown by a particular PEI.
- Throws:
UnimplementedError
-
getInstanceKeyForMetadataObject
public InstanceKey getInstanceKeyForMetadataObject(Object obj, TypeReference objType) throws UnimplementedError
- Specified by:
getInstanceKeyForMetadataObject
in interfaceInstanceKeyFactory
objType
- TODO- Returns:
- the instance key that represents the metadata object obj
- Throws:
UnimplementedError
-
getPointerKeyForLocal
public FilteredPointerKey getPointerKeyForLocal(CGNode node, int valueNumber)
Note that this always returns aFilteredPointerKey
, since theTypeBasedPointerAnalysis
relies on the type filter to compute points to sets.- Specified by:
getPointerKeyForLocal
in interfacePointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by the value number parameter.
- See Also:
PointerKeyFactory.getPointerKeyForLocal(com.ibm.wala.ipa.callgraph.CGNode, int)
-
getFilteredPointerKeyForLocal
public FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node, int valueNumber, FilteredPointerKey.TypeFilter filter) throws UnimplementedError
- Specified by:
getFilteredPointerKeyForLocal
in interfacePointerKeyFactory
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by the value number parameter.
- Throws:
UnimplementedError
-
getPointerKeyForReturnValue
public PointerKey getPointerKeyForReturnValue(CGNode node)
- Specified by:
getPointerKeyForReturnValue
in interfacePointerKeyFactory
- 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 interfacePointerKeyFactory
- 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 interfacePointerKeyFactory
- 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 interfacePointerKeyFactory
- 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 interfacePointerKeyFactory
- 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()
-
-