tweak comments and deprecate some old code

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3671 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2009-06-12 15:20:44 +00:00
parent 80a636f601
commit 6e93304be5
32 changed files with 100 additions and 166 deletions

View File

@ -407,10 +407,12 @@ public class AnalysisOptions {
/**
* @return true iff we should solve with the sub-transitive solver
*/
@Deprecated
public boolean usePreTransitiveSolver() {
return usePreTransitiveSolver;
}
@Deprecated
public void setUsePreTransitiveSolver(boolean b) {
usePreTransitiveSolver = b;
}

View File

@ -15,76 +15,62 @@ import java.util.Iterator;
import com.ibm.wala.util.graph.Graph;
/**
* This interface encapsulates the result of a proagation-based
* bit-vector dataflow analysis done over a set of PointerKey objects
* related by dataflow. There are several aspects of the analysis
* summarized by this interface:
* This interface encapsulates the result of a propagation-based bit-vector dataflow analysis done over a set of PointerKey objects
* related by dataflow. There are several aspects of the analysis summarized by this interface:
*
* 1) The graph embedded in an AbstractAnalysis corresponds to the dataflow induces over the keys, so one PointerKey is a graph
* successor of another one if there is dataflow from the first to second.
*
* 2) Each key maps to an IntSet denoting which bits are set for that PointerKey. These bits correspond to whatever analysis
* property has been analyzed.
*
* 3) The bits each have some interpretation, and the AbstractAnalysis provides a mapping from each bit index to an object
* representing its interpretation.
*
* 4) The assumption is that each bit starts at some set of PointerKeys and flows to others via dataflow. The AbstractAnalysis
* provides an iterator over the sources of each bit.
*
* 5) In object-oriented programs, there is non-local data flow induced by field accesses. The set of constraints at a field access
* depend upon the container object. Thus, for each constraint induced by a field access, there is a corresponding PointerKey that
* is the container object; AbstractAnalysis provides an explicit accessor of that relationship.
*
* 1) The graph embedded in an AbstractAnalysis corresponds to the
* dataflow induces over the keys, so one PointerKey is a graph
* successor of another one if there is dataflow from the first to
* second.
*
* 2) Each key maps to an IntSet denoting which bits are set for that
* PointerKey. These bits correspond to whatever analysis property
* has been analyzed.
*
* 3) The bits each have some interpretation, and the AbstractAnalysis
* provides a mapping from each bit index to an object representing
* its interpretation.
*
* 4) The assumption is that each bit starts at some set of
* PointerKeys and flows to others via dataflow. The
* AbstractAnalysis provides an iterator over the sources of each
* bit.
*
* 5) In object-oriented programs, there is non-local data flow
* induced by field accesses. The set of constraints at a field
* access depend upon the container object. Thus, for each
* constraint induced by a field access, there is a corresponding
* PointerKey that is the container object; AbstractAnalysis
* provides an explicit accessor of that relationship.
*
* @author Julian Dolby
* @deprecated because no one in my workspace uses this. Is this dead? -- JSF
*/
@Deprecated
public interface AbstractAnalysis extends Graph {
/**
* Get the set of bits that are set for the given key. Do not
* mutate the set returned, since it can be internal solver state.
* (It is not an Iterator for efficiency reasons.)
*
* Get the set of bits that are set for the given key. Do not mutate the set returned, since it can be internal solver state. (It
* is not an Iterator for efficiency reasons.)
*
* @param key The PointerKey or other object of interest
* @return The set of bits enabled for that key.
*/
Object getValue(Object key);
/**
* Get the interpretation of the given bit. The AbstractAnalysis
* provides no particular semantics for this method, since it
* Get the interpretation of the given bit. The AbstractAnalysis provides no particular semantics for this method, since it
* depends upon the analysis being done.
*
*
* @param index The bit index of interest
* @return The meaning of the given bit.
*/
*/
Object getInterpretation(int index);
int getEncoding(Object thing);
/**
* Get the PointerKeys that represent sources of the dataflow
* property represented by the given bit.
*
* Get the PointerKeys that represent sources of the dataflow property represented by the given bit.
*
* @param index The bit index of interest
* @return The PointerKeys that are sources for the given bit.
*/
Iterator getSources(int index);
/**
* Get the PointerKey representing the container object that
* induced dataflow between the given field and local value. Can
* return null if no such container exists.
*
* Get the PointerKey representing the container object that induced dataflow between the given field and local value. Can return
* null if no such container exists.
*
* @param xval An lval or rval of a field or array access
* @param field The field involved
* @return The container object, if any
@ -94,10 +80,9 @@ public interface AbstractAnalysis extends Graph {
Iterator getContainerWriteLink(Object xval, Object field);
/**
* Get the concrete type (i.e. InstanceKey) that contains the
* given pointer key, which must be a pointer key of a field of
* some kind.
*
* Get the concrete type (i.e. InstanceKey) that contains the given pointer key, which must be a pointer key of a field of some
* kind.
*
* @return The containing instance key
*/
Object getContainer(Object fieldKey);

View File

@ -10,7 +10,10 @@
*******************************************************************************/
package com.ibm.wala.ipa.callgraph.propagation;
/**
* Common implementation for {@link InstanceFieldPointerKey} implementations.
*
*/
public abstract class AbstractFieldPointerKey extends AbstractPointerKey implements InstanceFieldPointerKey {
final protected InstanceKey instance;

View File

@ -12,9 +12,12 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* A {@link PointerKey} representing a local variable must carry at least a {@link CGNode}.
*
*/
public abstract class AbstractLocalPointerKey extends AbstractPointerKey {
abstract public CGNode getNode();
}

View File

@ -20,8 +20,7 @@ import com.ibm.wala.util.intset.MutableMapping;
import com.ibm.wala.util.intset.OrdinalSetMapping;
/**
* @author sfink
*
* Abstract superclass for {@link PointerAnalysis} implementations.
*/
public abstract class AbstractPointerAnalysis implements PointerAnalysis {
@ -51,9 +50,6 @@ public abstract class AbstractPointerAnalysis implements PointerAnalysis {
return heapGraph;
}
/**
* @return Returns the callgraph.
*/
protected CallGraph getCallGraph() {
return cg;
}
@ -65,5 +61,4 @@ public abstract class AbstractPointerAnalysis implements PointerAnalysis {
public OrdinalSetMapping<InstanceKey> getInstanceKeyMapping() {
return instanceKeys;
}
}

View File

@ -10,6 +10,10 @@
*******************************************************************************/
package com.ibm.wala.ipa.callgraph.propagation;
/**
* This class exists to force {@link PointerKey} implementations to implement equals() and hashCode()s.
*
*/
public abstract class AbstractPointerKey implements PointerKey {
@Override
public abstract boolean equals(Object obj);

View File

@ -15,12 +15,13 @@ import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.NewSiteReference;
/**
* An {@link InstanceKey} which represents a {@link NewSiteReference} in some
* {@link IMethod}.
* An {@link InstanceKey} which represents a {@link NewSiteReference} in some {@link IMethod}.
*/
public class AllocationSite implements InstanceKey {
private final NewSiteReference site;
private final IMethod method;
private final IClass concreteType;
public AllocationSite(IMethod method, NewSiteReference allocation, IClass type) {
@ -31,7 +32,7 @@ public class AllocationSite implements InstanceKey {
@Override
public String toString() {
return "SITE{" + getMethod() + ":" + site + "}";
return "SITE{" + getMethod() + ":" + site + "}";
}
public NewSiteReference getSite() {
@ -77,4 +78,3 @@ public class AllocationSite implements InstanceKey {
return true;
}
}

View File

@ -15,14 +15,13 @@ import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* An {@link InstanceKey} which represents a {@link NewSiteReference} in some
* {@link CGNode}.
* An {@link InstanceKey} which represents a {@link NewSiteReference} in some {@link CGNode}.
*/
public abstract class AllocationSiteInNode extends AbstractTypeInNode {
private final NewSiteReference site;
public AllocationSiteInNode(CGNode node, NewSiteReference allocation, IClass type) {
super(node,type);
super(node, type);
this.site = allocation;
}
@ -44,4 +43,3 @@ public abstract class AllocationSiteInNode extends AbstractTypeInNode {
return site;
}
}

View File

@ -23,19 +23,16 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.TypeReference;
/**
* A factory which tries by default to create {@link InstanceKey}s which are
* {@link AllocationSiteInNode}s.
* A factory which tries by default to create {@link InstanceKey}s which are {@link AllocationSiteInNode}s.
*
* Notes:
* <ul>
* <li> This class checks to avoid creating recursive contexts when {@link CGNode}s
* are based on {@link ReceiverInstanceContext}, as in object-sensitivity.
* <li> Up till recursion, this class will happily create unlimited object sensitivity, so be careful.
* <li> This class resorts to {@link ClassBasedInstanceKeys} for exceptions from PEIs and class objects.
* <li> This class consults the {@link AnalysisOptions} to determine whether to disambiguate individual constants.
* <li>This class checks to avoid creating recursive contexts when {@link CGNode}s are based on {@link ReceiverInstanceContext}, as
* in object-sensitivity.
* <li>Up till recursion, this class will happily create unlimited object sensitivity, so be careful.
* <li>This class resorts to {@link ClassBasedInstanceKeys} for exceptions from PEIs and class objects.
* <li>This class consults the {@link AnalysisOptions} to determine whether to disambiguate individual constants.
* </ul>
*
* @author sfink
*/
public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
@ -52,8 +49,7 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
private final ClassBasedInstanceKeys classBased;
/**
* @param options
* Governing call graph construction options
* @param options Governing call graph construction options
*/
public AllocationSiteInNodeFactory(AnalysisOptions options, IClassHierarchy cha) {
this.options = options;
@ -75,9 +71,9 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
return new NormalAllocationInNode(n, allocation, type);
}
}
InstanceKey key = new NormalAllocationInNode(node, allocation, type);
return key;
}
@ -99,7 +95,6 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
}
}
public InstanceKey getInstanceKeyForPEI(CGNode node, ProgramCounter pei, TypeReference type) {
return classBased.getInstanceKeyForPEI(node, pei, type);
}

View File

@ -13,7 +13,7 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.classLoader.ArrayClass;
/**
* A pointer key which represents the contents of an array instance.
* A {@link PointerKey} which represents the contents of an array instance.
*/
public final class ArrayContentsKey extends AbstractFieldPointerKey implements FilteredPointerKey {
public ArrayContentsKey(InstanceKey instance) {

View File

@ -15,8 +15,6 @@ import com.ibm.wala.fixedpoint.impl.UnaryStatement;
/**
* A specialized equation class introduced for efficiency
*
* @author sfink
*/
public final class AssignEquation extends UnaryStatement<PointsToSetVariable> {

View File

@ -18,9 +18,8 @@ import com.ibm.wala.fixedpoint.impl.UnaryStatement;
*
* Unary op: <lhs>:= Assign( <rhs>)
*
* (Technically, it's a binary op, since it includes lhs as an implicit input;
* this allows it to compose with other ops that define the same lhs, so long as
* they're all Assign ops)
* (Technically, it's a binary op, since it includes lhs as an implicit input; this allows it to compose with other ops that define
* the same lhs, so long as they're all Assign ops)
*/
class AssignOperator extends UnaryOperator<PointsToSetVariable> implements IPointerOperator {
@ -61,7 +60,7 @@ class AssignOperator extends UnaryOperator<PointsToSetVariable> implements IPoin
return (this == o);
}
/*
/*
* @see com.ibm.wala.ipa.callgraph.propagation.IPointerOperator#isComplex()
*/
public boolean isComplex() {

View File

@ -23,8 +23,6 @@ import com.ibm.wala.util.debug.Assertions;
/**
* This class provides Instance Key call backs where each instance is in the same equivalence class as all other instances of the
* same concrete type.
*
* @author sfink
*/
public class ClassBasedInstanceKeys implements InstanceKeyFactory {

View File

@ -18,11 +18,8 @@ import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextSelector;
/**
*
* This context selector selects a context based on the concrete type of
* the receiver to a call of java.lang.Object.clone
*
* @author sfink
*/
public class CloneContextSelector implements ContextSelector {

View File

@ -19,10 +19,7 @@ import com.ibm.wala.util.intset.IntSetUtil;
import com.ibm.wala.util.intset.MutableIntSet;
/**
*
* A PointerKey which carries a type filter, used during pointer analysis
*
* @author sfink
* A {@link PointerKey} which carries a type filter, used during pointer analysis
*/
public interface FilteredPointerKey extends PointerKey {
@ -200,8 +197,7 @@ public interface FilteredPointerKey extends PointerKey {
}
/**
* @return the class which should govern filtering of instances to which this
* pointer points, or null if no filtering needed
* @return the class which should govern filtering of instances to which this pointer points, or null if no filtering needed
*/
public TypeFilter getTypeFilter();
}

View File

@ -16,9 +16,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
/**
* Embodies how a pointer analysis abstracts heap locations.
*
* @author sfink
* A {@link HeapModel} embodies how a pointer analysis abstracts heap locations.
*/
public interface HeapModel extends InstanceKeyFactory, PointerKeyFactory {

View File

@ -16,9 +16,6 @@ import com.ibm.wala.eclipse.util.CancelException;
/**
* Basic interface for a pointer analysis solver.
*
* @author sfink
*
*/
public interface IPointsToSolver {

View File

@ -14,8 +14,7 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.classLoader.IField;
/**
* An pointer key which represents a unique set for a field associated with a
* set of instances.
* An pointer key which represents a unique set for a field associated with a set of instances.
*/
public class InstanceFieldKey extends AbstractFieldPointerKey {
private final IField field;

View File

@ -16,10 +16,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.TypeReference;
/**
*
* a instance field pointer key key that carries a type filter
*
* @author sfink
* an instance field pointer key key that carries a type filter
*/
public class InstanceFieldKeyWithFilter extends InstanceFieldKey implements FilteredPointerKey {

View File

@ -14,7 +14,6 @@ import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.callgraph.ContextItem;
/**
*
* An InstanceKey serves as the representative for an equivalence class of
* objects in the heap, that can be pointed to.
*
@ -23,8 +22,6 @@ import com.ibm.wala.ipa.callgraph.ContextItem;
*
* For 0-1-CFA, an InstanceKey could be <IMethod,statement #>, representing a
* particular allocation statement in a particular method.
*
* @author sfink
*/
public interface InstanceKey extends ContextItem {

View File

@ -17,8 +17,6 @@ import com.ibm.wala.types.TypeReference;
/**
* An object that abstracts how to model instances in the heap.
*
* @author sfink
*/
public interface InstanceKeyFactory {
/**

View File

@ -12,13 +12,12 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* A pointer key which provides a unique set for each local in
* each call graph node.
* A pointer key which provides a unique set for each local in each call graph node.
*/
public class LocalPointerKey extends AbstractLocalPointerKey {
private final CGNode node;
private final int valueNumber;
public LocalPointerKey(CGNode node, int valueNumber) {

View File

@ -17,15 +17,14 @@ import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* An {@link InstanceKey} which represents a multinewarray allocation
* site in a {@link CGNode}.
* An {@link InstanceKey} which represents a multinewarray allocation site in a {@link CGNode}.
*/
public final class MultiNewArrayInNode extends AllocationSiteInNode {
private final int dim;
/**
* @return null if the element type is a primitive
* @throws IllegalArgumentException if T == null
* @throws IllegalArgumentException if T == null
*/
private static IClass myElementType(ArrayClass T, int d) throws IllegalArgumentException, IllegalArgumentException {
if (T == null) {
@ -38,7 +37,7 @@ public final class MultiNewArrayInNode extends AllocationSiteInNode {
if (element == null) {
return null;
} else {
return myElementType(element, d-1);
return myElementType(element, d - 1);
}
}
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph.propagation;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* A key which represents a set corresponding to a call graph node.
*/

View File

@ -15,13 +15,13 @@ import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
* An {@link InstanceKey} which represents a "normal" (not multinewarray)
* {@link NewSiteReference} in a {@link CGNode}.
* An {@link InstanceKey} which represents a "normal" (not multinewarray) {@link NewSiteReference} in a {@link CGNode}.
*/
public final class NormalAllocationInNode extends AllocationSiteInNode {
public NormalAllocationInNode(CGNode node, NewSiteReference allocation, IClass type) {
super(node, allocation, type);
}
@Override
public boolean equals(Object obj) {
// instanceof is OK because this class is final
@ -32,6 +32,7 @@ public final class NormalAllocationInNode extends AllocationSiteInNode {
return false;
}
}
@Override
public int hashCode() {
return getNode().hashCode() * 8647 + getSite().hashCode();

View File

@ -17,12 +17,8 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.util.intset.OrdinalSet;
import com.ibm.wala.util.intset.OrdinalSetMapping;
/**
*
* Abstract definition of pointer analysis
*
* @author sfink
*/
public interface PointerAnalysis {

View File

@ -46,10 +46,7 @@ import com.ibm.wala.util.intset.MutableSparseIntSet;
import com.ibm.wala.util.intset.OrdinalSet;
/**
*
* General representation of the results of pointer analysis
*
* @author sfink
*/
public class PointerAnalysisImpl extends AbstractPointerAnalysis {

View File

@ -23,8 +23,6 @@ package com.ibm.wala.ipa.callgraph.propagation;
* A PointerKey for 0-1-CFA, with 1-level of InstanceVar context in the Grove et
* al. terminology, would instead of FieldReference, use a - <InstanceKey,
* FieldReference> pair
*
* @author sfink
*/
public interface PointerKey {

View File

@ -14,62 +14,49 @@ import com.ibm.wala.classLoader.IField;
import com.ibm.wala.ipa.callgraph.CGNode;
/**
*
* An object that abstracts how to model pointers in the heap.
*
* @author sfink
*/
public interface PointerKeyFactory {
/**
* @param node
* @param valueNumber
* @return the PointerKey that acts as a representative for the class of
* pointers that includes the local variable identified by the value
* number parameter.
* @return the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by
* the value number parameter.
*
*/
PointerKey getPointerKeyForLocal(CGNode node, int valueNumber);
/**
* @return the PointerKey that acts as a representative for the class of
* pointers that includes the local variable identified by the value
* number parameter.
* @return the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by
* the value number parameter.
*
*/
FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node, int valueNumber, FilteredPointerKey.TypeFilter filter);
/**
* @param node
* @return the PointerKey that acts as a representative for the class of
* pointers that includes the return value for a node
* @return the PointerKey that acts as a representative for the class of pointers that includes the return value for a node
*/
PointerKey getPointerKeyForReturnValue(CGNode node);
/**
* @return the PointerKey that acts as a representative for the class of
* pointers that includes the exceptional return value
* @return the PointerKey that acts as a representative for the class of pointers that includes the exceptional return value
*/
PointerKey getPointerKeyForExceptionalReturnValue(CGNode node);
/**
* @return the PointerKey that acts as a representative for the class of
* pointers that includes the contents of the static field
* @return the PointerKey that acts as a representative for the class of pointers that includes the contents of the static field
*/
PointerKey getPointerKeyForStaticField(IField f);
/**
* @return the PointerKey that acts as a representation for the class of
* pointers that includes the given instance field.
* @return the PointerKey that acts as a representation for the class of pointers that includes the given instance field.
*/
PointerKey getPointerKeyForInstanceField(InstanceKey I, IField field);
/**
* TODO: expand this API to differentiate between different array indices
*
* @param I
* an InstanceKey representing an abstract array
* @return the PointerKey that acts as a representation for the class of
* pointers that includes the given array contents.
* @param I an InstanceKey representing an abstract array
* @return the PointerKey that acts as a representation for the class of pointers that includes the given array contents.
*/
PointerKey getPointerKeyForArrayContents(InstanceKey I);
}

View File

@ -24,8 +24,7 @@ import com.ibm.wala.util.intset.MutableMapping;
import com.ibm.wala.util.intset.MutableSparseIntSet;
/**
* @author sfink
*
* Representation of a points-to set during an andersen-style analysis.
*/
public class PointsToSetVariable extends IntSetVariable<PointsToSetVariable> {
@ -49,9 +48,6 @@ public class PointsToSetVariable extends IntSetVariable<PointsToSetVariable> {
this.pointerKey = key;
}
/**
* @return Returns the pointerKey.
*/
public PointerKey getPointerKey() {
return pointerKey;
}

View File

@ -34,7 +34,6 @@ import com.ibm.wala.util.intset.MutableIntSet;
import com.ibm.wala.util.intset.MutableSparseIntSet;
/**
*
* pre-transitive solver incorporating concepts from Heintze and Tardieu, PLDI 2001
*
* In this implementation, there are two types of points-to-sets, "transitive roots", and "not-roots".
@ -46,8 +45,9 @@ import com.ibm.wala.util.intset.MutableSparseIntSet;
*
* TODO: fix points-to solution to use demand-driven
*
* @author sfink
* @deprecated this has never been finished and will probably go away soon.
*/
@Deprecated
public class PreTransitiveSolver extends AbstractPointsToSolver {
public PreTransitiveSolver(PropagationSystem system, PropagationCallGraphBuilder builder) {

View File

@ -152,12 +152,14 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
/**
* Should we use the pre-transitive solver?
*/
private final boolean usePreTransitiveSolver;
@SuppressWarnings("unused")
@Deprecated
private final boolean usePreTransitiveSolver = false;
protected SSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
PointerKeyFactory pointerKeyFactory) {
super(cha, options, cache, pointerKeyFactory);
this.usePreTransitiveSolver = options.usePreTransitiveSolver();
// this.usePreTransitiveSolver = options.usePreTransitiveSolver();
}
public SSAContextInterpreter getCFAContextInterpreter() {
@ -2059,7 +2061,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
*/
@Override
protected IPointsToSolver makeSolver() {
return usePreTransitiveSolver ? (IPointsToSolver) new PreTransitiveSolver(system, this) : new StandardSolver(system, this);
return new StandardSolver(system, this);
// return usePreTransitiveSolver ? (IPointsToSolver) new PreTransitiveSolver(system, this) : new StandardSolver(system, this);
// return true ? (IPointsToSolver)new PreTransitiveSolver(system,this) : new
// StandardSolver(system,this);
}