Class ValueNumberAnalysis
java.lang.Object
edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis<ValueNumberFrame>
edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<ValueNumberFrame>
edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis<ValueNumberFrame>
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanprivate final ValueNumber[]private final IdentityHashMap<BasicBlock, ValueNumber> private final HashMap<Location, ValueNumberFrame> private final HashMap<Location, ValueNumberFrame> private final ValueNumberFactoryprivate MergeTreeprivate final org.apache.bcel.generic.MethodGenprivate ValueNumberprivate static final booleanprivate final ValueNumberFrameModelingVisitor -
Constructor Summary
ConstructorsConstructorDescriptionValueNumberAnalysis(org.apache.bcel.generic.MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback) -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.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.private ValueNumbergetExceptionValueNumber(BasicBlock handlerBlock) Mark value numbers in a value number frame for compaction.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.intvoidinitEntryFact(ValueNumberFrame result) Initialize the "entry" fact for the graph.booleanisThisValue(ValueNumber value) voidmeetInto(ValueNumberFrame fact, Edge edge, ValueNumberFrame result) Meet a dataflow fact associated with an incoming edge into another fact.protected voidmergeInto(ValueNumberFrame frame, ValueNumberFrame result) Merge one frame into another.private ValueNumbermergeValues(ValueNumberFrame frame, int slot, ValueNumber mine, ValueNumber other) protected voidmergeValues(ValueNumberFrame otherFrame, ValueNumberFrame resultFrame, int slot) Merge the values contained in a given slot of two Frames.voidsetMergeTree(MergeTree mergeTree) voidtransfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ValueNumberFrame start, ValueNumberFrame result) Transfer function for the analysis.voidtransferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, ValueNumberFrame fact) Transfer function for a single instruction.Methods inherited from class FrameDataflowAnalysis
copy, getFactAtPC, getFactBeforeExceptionCheck, getLastUpdateTimestamp, isFactValid, isTop, makeFactTop, modifyFrame, same, setLastUpdateTimestampMethods inherited from class ForwardDataflowAnalysis
getBlockOrder, getDepthFirstSearch, isForwardsMethods inherited from class BasicAbstractDataflowAnalysis
edgeTransfer, factToString, finishIteration, getFactOnEdge, getResultFact, getStartFact, resultFactIterator, startIteration
-
Field Details
-
TRACE
private static final boolean TRACE -
DEBUG
public static final boolean DEBUG -
methodGen
private final org.apache.bcel.generic.MethodGen methodGen -
factory
-
visitor
-
entryLocalValueList
-
exceptionHandlerValueNumberMap
-
thisValue
-
factAtLocationMap
-
factAfterLocationMap
-
mergeTree
-
-
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:DataflowAnalysisCreate 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:DataflowAnalysisInitialize 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:DataflowAnalysisTransfer 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:
transferin interfaceDataflowAnalysis<ValueNumberFrame>- Overrides:
transferin 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:AbstractDataflowAnalysisTransfer function for a single instruction.- Specified by:
transferInstructionin 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:DataflowAnalysisMeet 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:FrameDataflowAnalysisMerge one frame into another.- Overrides:
mergeIntoin 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:FrameDataflowAnalysisMerge the values contained in a given slot of two Frames.- Specified by:
mergeValuesin classFrameDataflowAnalysis<ValueNumber, ValueNumberFrame>- Parameters:
otherFrame- a FrameresultFrame- a Frame which will contain the resulting merged valueslot- a slot in both frames- Throws:
DataflowAnalysisException
-
mergeValues
private ValueNumber mergeValues(ValueNumberFrame frame, int slot, ValueNumber mine, ValueNumber other) -
getFactAtLocation
Description copied from class:AbstractDataflowAnalysisGet 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:
getFactAtLocationin interfaceDataflowAnalysis<ValueNumberFrame>- Overrides:
getFactAtLocationin classAbstractDataflowAnalysis<ValueNumberFrame>- Parameters:
location- the location- Returns:
- the fact at the point just before the location
-
getFactAfterLocation
Description copied from class:AbstractDataflowAnalysisGet 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:
getFactAfterLocationin interfaceDataflowAnalysis<ValueNumberFrame>- Overrides:
getFactAfterLocationin 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)
-
getExceptionValueNumber
Mark value numbers in a value number frame for compaction. private static void markFrameValues(ValueNumberFrame frame, ValueCompacter compacter) { // We don't need to do anything for top and bottom frames. if (!frame.isValid()) { return; } for (int j = 0; j invalid input: '<' frame.getNumSlots(); ++j) { ValueNumber value = frame.getValue(j); int number = value.getNumber(); if (!compacter.isUsed(number)) { compacter.discovered[number] = compacter.allocateValue(); compacter.setUsed(number); } } } -
getClassName
-