Package edu.umd.cs.findbugs.ba
Class LockSet
java.lang.Object
edu.umd.cs.findbugs.ba.LockSet
Lock counts for values (as produced by ValueNumberAnalysis). A LockSet tells
us the lock counts for all values in a method, insofar as we can accurately
determine them.
- Author:
- David Hovemeyer
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all entries out of this LockSet.booleancontainsReturnValue(ValueNumberFactory factory) Determine whether or not this lock set contains any locked values which are method return values.voidMake this LockSet the same as the given one.intgetLockCount(int valueNumber) Get the lock count for given lock object.intGet the number of distinct lock values with positive lock counts.voidintersectWith(LockSet other) Destructively intersect this lock set with another.booleanisEmpty()Return whether or not this lock set is empty, meaning that no locks have a positive lock count.booleanisTop()voidMeet this LockSet with another LockSet, storing the result in this object.booleanReturn whether or not this LockSet is the same as the one given.voidsetDefaultLockCount(int defaultLockCount) Set the default lock count to return for nonexistent lock entries.voidsetLockCount(int valueNumber, int lockCount) Set the lock count for a lock object.toString()
-
Field Details
-
TOP
public static final int TOPAn uninitialized lock value.- See Also:
-
BOTTOM
public static final int BOTTOMAn invalid lock count resulting from the meet of two different (inconsistent) lock counts.- See Also:
-
-
Constructor Details
-
LockSet
public LockSet()Constructor. Creates an empty lock set which returns TOP for nonexistent lock entries.
-
-
Method Details
-
getLockCount
public int getLockCount(int valueNumber) Get the lock count for given lock object.- Parameters:
valueNumber- value number of the lock object- Returns:
- the lock count for the lock object
-
isTop
public boolean isTop() -
setLockCount
public void setLockCount(int valueNumber, int lockCount) Set the lock count for a lock object.- Parameters:
valueNumber- value number of the lock objectlockCount- the lock count for the lock
-
setDefaultLockCount
public void setDefaultLockCount(int defaultLockCount) Set the default lock count to return for nonexistent lock entries.- Parameters:
defaultLockCount- the default lock count value
-
getNumLockedObjects
public int getNumLockedObjects()Get the number of distinct lock values with positive lock counts. -
copyFrom
Make this LockSet the same as the given one.- Parameters:
other- the LockSet to copy
-
clear
public void clear()Clear all entries out of this LockSet. -
meetWith
Meet this LockSet with another LockSet, storing the result in this object.- Parameters:
other- the other LockSet
-
sameAs
Return whether or not this LockSet is the same as the one given.- Parameters:
other- the other LockSet
-
containsReturnValue
Determine whether or not this lock set contains any locked values which are method return values.- Parameters:
factory- the ValueNumberFactory that produced the lock values
-
intersectWith
Destructively intersect this lock set with another. Note that this is not a dataflow merge: we are interested in finding out which locks are held in both sets, not in the exact lock counts.- Parameters:
other- the other LockSet
-
isEmpty
public boolean isEmpty()Return whether or not this lock set is empty, meaning that no locks have a positive lock count.- Returns:
- true if no locks are held, false if at least one lock is held
-
toString
-
getLockedValueNumbers
- Parameters:
frame-- Returns:
- a set of the locked value numbers
-