Package edu.umd.cs.findbugs.ba.vna
Class ValueNumberAnalysis
java.lang.Object
edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis<Fact>
edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis<FrameType>
edu.umd.cs.findbugs.ba.FrameDataflowAnalysis<ValueNumber,ValueNumberFrame>
edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis
- All Implemented Interfaces:
DataflowAnalysis<ValueNumberFrame>
A dataflow analysis to track the production and flow of values in the Java
stack frame. See the ValueNumber
class for an explanation
of what the value numbers mean, and when they can be compared.
This class is still experimental.
- Author:
- David Hovemeyer
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionValueNumberAnalysis
(org.apache.bcel.generic.MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Create empty (uninitialized) dataflow facts for one program point.Get an Iterator over all dataflow facts that we've recorded for the Locations in the CFG.getClassObjectValue
(String className) getEntryValue
(int local) Get the value number assigned to the given local variable upon entry to the method.getEntryValueForParameter
(int param) Get the value number assigned to the given parameter upon entry to the method.getFactAfterLocation
(Location location) Get the dataflow fact representing the point just after given Location.getFactAtLocation
(Location location) Get the dataflow fact representing the point just before given Location.int
void
initEntryFact
(ValueNumberFrame result) Initialize the "entry" fact for the graph.boolean
isThisValue
(ValueNumber value) void
meetInto
(ValueNumberFrame fact, Edge edge, ValueNumberFrame result) Meet a dataflow fact associated with an incoming edge into another fact.protected void
mergeInto
(ValueNumberFrame frame, ValueNumberFrame result) Merge one frame into another.protected void
mergeValues
(ValueNumberFrame otherFrame, ValueNumberFrame resultFrame, int slot) Merge the values contained in a given slot of two Frames.void
setMergeTree
(MergeTree mergeTree) void
transfer
(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ValueNumberFrame start, ValueNumberFrame result) Transfer function for the analysis.void
transferInstruction
(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, ValueNumberFrame fact) Transfer function for a single instruction.Methods inherited from class edu.umd.cs.findbugs.ba.FrameDataflowAnalysis
copy, getFactAtPC, getFactBeforeExceptionCheck, getLastUpdateTimestamp, isFactValid, isTop, makeFactTop, modifyFrame, same, setLastUpdateTimestamp
Methods inherited from class edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis
getBlockOrder, getDepthFirstSearch, isForwards
Methods inherited from class edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis
edgeTransfer, factToString, finishIteration, getFactOnEdge, getResultFact, getStartFact, resultFactIterator, startIteration
-
Field Details
-
DEBUG
public static final boolean DEBUG
-
-
Constructor Details
-
ValueNumberAnalysis
public ValueNumberAnalysis(org.apache.bcel.generic.MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback)
-
-
Method Details
-
getClassObjectValue
-
setMergeTree
-
getMergeTree
-
getFactory
-
getNumValuesAllocated
public int getNumValuesAllocated() -
isThisValue
-
getThisValue
-
getEntryValue
Get the value number assigned to the given local variable upon entry to the method.- Parameters:
local
- local variable number- Returns:
- ValueNumber assigned to the local variable
-
getEntryValueForParameter
Get the value number assigned to the given parameter upon entry to the method.- Parameters:
param
- a parameter (0 == first parameter)- Returns:
- the ValueNumber assigned to that parameter
-
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. -
initEntryFact
Description copied from interface:DataflowAnalysis
Initialize the "entry" fact for the graph. -
transfer
public void transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ValueNumberFrame start, ValueNumberFrame result) throws DataflowAnalysisException Description copied from interface:DataflowAnalysis
Transfer function for the analysis. Taking dataflow facts at start (which might be either the entry or exit of the block, depending on whether the analysis is forwards or backwards), modify result to be the facts at the other end of the block.- Specified by:
transfer
in interfaceDataflowAnalysis<ValueNumberFrame>
- Overrides:
transfer
in classAbstractDataflowAnalysis<ValueNumberFrame>
- Parameters:
basicBlock
- the basic blockend
- if nonnull, stop before considering this instruction; otherwise, consider all of the instructions in the basic blockstart
- dataflow facts at beginning of block (if forward analysis) or end of block (if backwards analysis)result
- resulting dataflow facts at other end of block- Throws:
DataflowAnalysisException
-
transferInstruction
public void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, ValueNumberFrame fact) throws DataflowAnalysisException Description copied from class:AbstractDataflowAnalysis
Transfer function for a single instruction.- Specified by:
transferInstruction
in classAbstractDataflowAnalysis<ValueNumberFrame>
- Parameters:
handle
- the instructionbasicBlock
- the BasicBlock containing the instruction; needed to disambiguate instructions in inlined JSR subroutinesfact
- which should be modified based on the instruction- Throws:
DataflowAnalysisException
-
meetInto
public void meetInto(ValueNumberFrame fact, Edge edge, ValueNumberFrame 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 predecessorresult
- the result fact- Throws:
DataflowAnalysisException
-
mergeInto
protected void mergeInto(ValueNumberFrame frame, ValueNumberFrame result) throws DataflowAnalysisException Description copied from class:FrameDataflowAnalysis
Merge one frame into another.- Overrides:
mergeInto
in classFrameDataflowAnalysis<ValueNumber,
ValueNumberFrame> - Parameters:
frame
- the frame to merge with the resultresult
- the result frame, which is modified to be the merge of the two frames- Throws:
DataflowAnalysisException
-
mergeValues
protected void mergeValues(ValueNumberFrame otherFrame, ValueNumberFrame resultFrame, int slot) throws DataflowAnalysisException Description copied from class:FrameDataflowAnalysis
Merge the values contained in a given slot of two Frames.- Specified by:
mergeValues
in classFrameDataflowAnalysis<ValueNumber,
ValueNumberFrame> - Parameters:
otherFrame
- a FrameresultFrame
- a Frame which will contain the resulting merged valueslot
- a slot in both frames- Throws:
DataflowAnalysisException
-
getFactAtLocation
Description copied from class:AbstractDataflowAnalysis
Get the dataflow fact representing the point just before given Location. Note "before" is meant in the logical sense, so for backward analyses, before means after the location in the control flow sense.- Specified by:
getFactAtLocation
in interfaceDataflowAnalysis<ValueNumberFrame>
- Overrides:
getFactAtLocation
in classAbstractDataflowAnalysis<ValueNumberFrame>
- Parameters:
location
- the location- Returns:
- the fact at the point just before the location
-
getFactAfterLocation
Description copied from class:AbstractDataflowAnalysis
Get the dataflow fact representing the point just after given Location. Note "after" is meant in the logical sense, so for backward analyses, after means before the location in the control flow sense.- Specified by:
getFactAfterLocation
in interfaceDataflowAnalysis<ValueNumberFrame>
- Overrides:
getFactAfterLocation
in classAbstractDataflowAnalysis<ValueNumberFrame>
- Parameters:
location
- the location- Returns:
- the fact at the point just after the location
-
factIterator
Get an Iterator over all dataflow facts that we've recorded for the Locations in the CFG. Note that this does not include result facts (since there are no Locations corresponding to the end of basic blocks). -
compactValueNumbers
@Deprecated public void compactValueNumbers(Dataflow<ValueNumberFrame, ValueNumberAnalysis> dataflow) Deprecated.Compact the value numbers assigned. This should be done only after the dataflow algorithm has executed. This works by modifying the actual ValueNumber objects assigned. After this method is called, the getNumValuesAllocated() method of this object will return a value less than or equal to the value it would have returned before the call to this method.
This method should be called at most once.
- Parameters:
dataflow
- the Dataflow object which executed this analysis (and has all of the block result values)
-
getClassName
-