Class TypeBasedHeapModel
java.lang.Object
com.ibm.wala.ipa.callgraph.propagation.rta.TypeBasedHeapModel
- All Implemented Interfaces:
HeapModel
,InstanceKeyFactory
,PointerKeyFactory
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
ConstructorDescriptionTypeBasedHeapModel
(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg) -
Method Summary
Modifier and TypeMethodDescriptiongetFilteredPointerKeyForLocal
(CGNode node, int valueNumber, FilteredPointerKey.TypeFilter filter) protected ClassBasedInstanceKeys
getInstanceKeyForAllocation
(CGNode node, NewSiteReference allocation) getInstanceKeyForConstant
(TypeReference type, Object S) getInstanceKeyForMetadataObject
(Object obj, TypeReference objType) getInstanceKeyForMultiNewArray
(CGNode node, NewSiteReference allocation, int dim) getInstanceKeyForPEI
(CGNode node, ProgramCounter instr, TypeReference type) TODO: expand this API to differentiate between different array indicesgetPointerKeyForInstanceField
(InstanceKey I, IField field) getPointerKeyForLocal
(CGNode node, int valueNumber) Note that this always returns aFilteredPointerKey
, since theTypeBasedPointerAnalysis
relies on the type filter to compute points to sets.
-
Constructor Details
-
TypeBasedHeapModel
- Parameters:
klasses
- Collection<IClass>- Throws:
IllegalArgumentException
- if cg is null
-
-
Method Details
-
iteratePointerKeys
- Specified by:
iteratePointerKeys
in interfaceHeapModel
- Returns:
- an Iterator of all PointerKeys that are modeled.
-
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
- Specified by:
getInstanceKeyForConstant
in interfaceInstanceKeyFactory
- Returns:
- the instance key that represents a constant with value S, when considered as a particular type
-
getStringConstantForInstanceKey
- 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
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.
-
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
- 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
- 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
- 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
- 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
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
-