edu.umd.cs.findbugs.ba
Class LockCountAnalysis

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
      extended by edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis<LockCount>
          extended by edu.umd.cs.findbugs.ba.LockCountAnalysis
All Implemented Interfaces:
DataflowAnalysis<LockCount>
Direct Known Subclasses:
AnyLockCountAnalysis, OtherLockCountAnalysis

public abstract class LockCountAnalysis
extends ForwardDataflowAnalysis<LockCount>

Family of dataflow analyses for counting the number of locks held at points in a method. Subclasses just need to override the initEntryFact() and getDelta() methods.

Author:
David Hovemeyer
See Also:
Dataflow, DataflowAnalysis, LockCount

Field Summary
private static boolean DEBUG
           
protected  org.apache.bcel.generic.MethodGen methodGen
           
protected  ValueNumberDataflow vnaDataflow
           
 
Constructor Summary
LockCountAnalysis(org.apache.bcel.generic.MethodGen methodGen, ValueNumberDataflow vnaDataflow, DepthFirstSearch dfs)
          Constructor.
 
Method Summary
 void copy(LockCount source, LockCount dest)
          Copy dataflow facts.
 LockCount createFact()
          Create empty (uninitialized) dataflow facts for one program point.
abstract  int getDelta(org.apache.bcel.generic.Instruction ins, ValueNumberFrame frame)
          Get the lock count delta resulting from the execution of the given instruction.
private  ValueNumberFrame getFrame(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock)
           
 void initResultFact(LockCount result)
          Initialize result fact for block.
 boolean isFactValid(LockCount fact)
          Determine whether the given fact is valid (neither top nor bottom).
 boolean isThisValue(ValueNumber valNum)
           
 void makeFactTop(LockCount fact)
          Make given fact the top value.
 void meetInto(LockCount fact, Edge edge, LockCount result)
          Meet a dataflow fact associated with an incoming edge into another fact.
 boolean same(LockCount fact1, LockCount fact2)
          Are given dataflow facts the same?
 void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, LockCount fact)
          Transfer function for a single instruction.
 
Methods inherited from class edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis
getBlockOrder, getDepthFirstSearch, isForwards
 
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis
endTransfer, factToString, getFactAfterLocation, getFactAtLocation, getResultFact, getStartFact, resultFactIterator, startTransfer, transfer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.umd.cs.findbugs.ba.DataflowAnalysis
initEntryFact
 

Field Detail

DEBUG

private static final boolean DEBUG

methodGen

protected final org.apache.bcel.generic.MethodGen methodGen

vnaDataflow

protected final ValueNumberDataflow vnaDataflow
Constructor Detail

LockCountAnalysis

public LockCountAnalysis(org.apache.bcel.generic.MethodGen methodGen,
                         ValueNumberDataflow vnaDataflow,
                         DepthFirstSearch dfs)
Constructor.

Parameters:
methodGen - method being analyzed
vnaDataflow - the Dataflow object used to execute ValueNumberAnalysis on the method
dfs - DepthFirstSearch on the method
Method Detail

isThisValue

public boolean isThisValue(ValueNumber valNum)

createFact

public LockCount createFact()
Description copied from interface: DataflowAnalysis
Create empty (uninitialized) dataflow facts for one program point. A valid value will be copied into it before it is used.


copy

public void copy(LockCount source,
                 LockCount dest)
Description copied from interface: DataflowAnalysis
Copy dataflow facts.


initResultFact

public void initResultFact(LockCount result)
Description copied from interface: DataflowAnalysis
Initialize result fact for block. The start facts for a block are initialized as the meet of the "logical" predecessor's result facts. Note that a "logical predecessor" is actually a CFG successor if the analysis is backwards.


makeFactTop

public void makeFactTop(LockCount fact)
Description copied from interface: DataflowAnalysis
Make given fact the top value.


isFactValid

public boolean isFactValid(LockCount fact)
Description copied from class: AbstractDataflowAnalysis
Determine whether the given fact is valid (neither top nor bottom).

Specified by:
isFactValid in class AbstractDataflowAnalysis<LockCount>

same

public boolean same(LockCount fact1,
                    LockCount fact2)
Description copied from interface: DataflowAnalysis
Are given dataflow facts the same?


transferInstruction

public void transferInstruction(org.apache.bcel.generic.InstructionHandle handle,
                                BasicBlock basicBlock,
                                LockCount fact)
                         throws DataflowAnalysisException
Description copied from class: AbstractDataflowAnalysis
Transfer function for a single instruction.

Specified by:
transferInstruction in class AbstractDataflowAnalysis<LockCount>
Parameters:
handle - the instruction
basicBlock - the BasicBlock containing the instruction; needed to disambiguate instructions in inlined JSR subroutines
fact - which should be modified based on the instruction
Throws:
DataflowAnalysisException

getFrame

private ValueNumberFrame getFrame(org.apache.bcel.generic.InstructionHandle handle,
                                  BasicBlock basicBlock)

meetInto

public void meetInto(LockCount fact,
                     Edge edge,
                     LockCount result)
              throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Meet a dataflow fact associated with an incoming edge into another fact. This is used to determine the start fact for a basic block.

Parameters:
fact - the predecessor fact (incoming edge)
edge - the edge from the predecessor
result - the result fact
Throws:
DataflowAnalysisException

getDelta

public abstract int getDelta(org.apache.bcel.generic.Instruction ins,
                             ValueNumberFrame frame)
                      throws DataflowAnalysisException
Get the lock count delta resulting from the execution of the given instruction.

Parameters:
ins - the instruction
frame - the ValueNumberFrame representing the values in the Java stack frame at the point in the control-flow graph before the instruction
Throws:
DataflowAnalysisException