edu.umd.cs.findbugs.ba
Class LiveLocalStoreAnalysis

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
      extended by edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis<java.util.BitSet>
          extended by edu.umd.cs.findbugs.ba.LiveLocalStoreAnalysis
All Implemented Interfaces:
DataflowAnalysis<java.util.BitSet>, Debug

public class LiveLocalStoreAnalysis
extends BackwardDataflowAnalysis<java.util.BitSet>
implements Debug

Dataflow analysis to find live stores of locals. This is just a backward analysis to see which loads reach stores of the same local.

This analysis also computes which stores that were killed by a subsequent store on any subsequent reachable path. (The FindDeadLocalStores detector uses this information to reduce false positives.)

Author:
David Hovemeyer

Field Summary
 
Fields inherited from interface edu.umd.cs.findbugs.ba.Debug
CHECK_ASSERTIONS, VERIFY_INTEGRITY
 
Constructor Summary
LiveLocalStoreAnalysis(org.apache.bcel.generic.MethodGen methodGen, ReverseDepthFirstSearch rdfs)
           
 
Method Summary
 void copy(java.util.BitSet source, java.util.BitSet dest)
          Copy dataflow facts.
 java.util.BitSet createFact()
          Create empty (uninitialized) dataflow facts for one program point.
 java.lang.String factToString(java.util.BitSet fact)
          Call this to get a dataflow value as a String.
 void initEntryFact(java.util.BitSet result)
          Initialize the "entry" fact for the graph.
 void initResultFact(java.util.BitSet result)
          Initialize result fact for block.
 boolean isFactValid(java.util.BitSet fact)
          Determine whether the given fact is valid (neither top nor bottom).
 boolean isStoreAlive(java.util.BitSet fact, int local)
          Return whether or not a store of given local is alive.
 boolean isTop(java.util.BitSet fact)
          Return whether or not given fact is the special TOP value.
 boolean killedByStore(java.util.BitSet fact, int local)
          Return whether or not a store of given local was killed by a subsequent (dominated) store.
static void main(java.lang.String[] argv)
           
 void makeFactTop(java.util.BitSet fact)
          Make given fact the top value.
 void meetInto(java.util.BitSet fact, Edge edge, java.util.BitSet result)
          Meet a dataflow fact associated with an incoming edge into another fact.
 boolean same(java.util.BitSet fact1, java.util.BitSet fact2)
          Are given dataflow facts the same?
 void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, java.util.BitSet fact)
          Transfer function for a single instruction.
 
Methods inherited from class edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis
getBlockOrder, getReverseDepthFirstSearch, isForwards
 
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis
endTransfer, 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
 

Constructor Detail

LiveLocalStoreAnalysis

public LiveLocalStoreAnalysis(org.apache.bcel.generic.MethodGen methodGen,
                              ReverseDepthFirstSearch rdfs)
Method Detail

createFact

public java.util.BitSet 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.

Specified by:
createFact in interface DataflowAnalysis<java.util.BitSet>

copy

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

Specified by:
copy in interface DataflowAnalysis<java.util.BitSet>

initEntryFact

public void initEntryFact(java.util.BitSet result)
                   throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Initialize the "entry" fact for the graph.

Specified by:
initEntryFact in interface DataflowAnalysis<java.util.BitSet>
Throws:
DataflowAnalysisException

initResultFact

public void initResultFact(java.util.BitSet 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.

Specified by:
initResultFact in interface DataflowAnalysis<java.util.BitSet>

makeFactTop

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

Specified by:
makeFactTop in interface DataflowAnalysis<java.util.BitSet>

same

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

Specified by:
same in interface DataflowAnalysis<java.util.BitSet>

meetInto

public void meetInto(java.util.BitSet fact,
                     Edge edge,
                     java.util.BitSet 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.

Specified by:
meetInto in interface DataflowAnalysis<java.util.BitSet>
Parameters:
fact - the predecessor fact (incoming edge)
edge - the edge from the predecessor
result - the result fact
Throws:
DataflowAnalysisException

transferInstruction

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

Specified by:
transferInstruction in class AbstractDataflowAnalysis<java.util.BitSet>
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

isFactValid

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

Specified by:
isFactValid in class AbstractDataflowAnalysis<java.util.BitSet>

factToString

public java.lang.String factToString(java.util.BitSet fact)
Description copied from class: AbstractDataflowAnalysis
Call this to get a dataflow value as a String. By default, we just call toString(). Subclasses may override to get different behavior.

Overrides:
factToString in class AbstractDataflowAnalysis<java.util.BitSet>

isTop

public boolean isTop(java.util.BitSet fact)
Return whether or not given fact is the special TOP value.


isStoreAlive

public boolean isStoreAlive(java.util.BitSet fact,
                            int local)
Return whether or not a store of given local is alive.

Parameters:
fact - a dataflow fact created by this analysis
local - the local

killedByStore

public boolean killedByStore(java.util.BitSet fact,
                             int local)
Return whether or not a store of given local was killed by a subsequent (dominated) store.


main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception