Package proguard.evaluation
Class LivenessAnalyzer
- java.lang.Object
-
- proguard.evaluation.LivenessAnalyzer
-
- All Implemented Interfaces:
AttributeVisitor
,ExceptionInfoVisitor
,InstructionVisitor
public class LivenessAnalyzer extends java.lang.Object implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor
ThisAttributeVisitor
analyzes the liveness of the variables in the code attributes that it visits, based on partial evaluation.
-
-
Constructor Summary
Constructors Constructor Description LivenessAnalyzer()
Creates a new LivenessAnalyzer.LivenessAnalyzer(PartialEvaluator partialEvaluator, boolean runPartialEvaluator, InitializationFinder initializationFinder, boolean runInitializationFinder)
Creates a new LivenessAnalyzer that will use the given partial evaluator and initialization finder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isAliveAfter(int instructionOffset, int variableIndex)
Returns whether the specified variable is alive after the instruction at the given offset.boolean
isAliveBefore(int instructionOffset, int variableIndex)
Returns whether the specified variable is alive before the instruction at the given offset.boolean
isCategory2(int instructionOffset, int variableIndex)
Returns whether the specified variable takes up two entries after the instruction at the given offset.boolean
isTraced(int instructionOffset)
Returns whether the instruction at the given offset has ever been executed during the partial evaluation.void
setAliveAfter(int instructionOffset, int variableIndex, boolean alive)
Sets whether the specified variable is alive after the instruction at the given offset.void
setAliveBefore(int instructionOffset, int variableIndex, boolean alive)
Sets whether the specified variable is alive before the instruction at the given offset.void
setCategory2(int instructionOffset, int variableIndex, boolean category2)
Sets whether the specified variable takes up two entries after the instruction at the given offset.void
visitAnyAttribute(Clazz clazz, Attribute attribute)
Visits any Attribute instance.void
visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
Visits any Instruction instance.void
visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
void
visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
void
visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
void
visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.classfile.attribute.visitor.AttributeVisitor
visitAnnotationDefaultAttribute, visitAnyAnnotationsAttribute, visitAnyParameterAnnotationsAttribute, visitAnyTypeAnnotationsAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitMethodParametersAttribute, visitModuleAttribute, visitModuleMainClassAttribute, visitModulePackagesAttribute, visitNestHostAttribute, visitNestMembersAttribute, visitPermittedSubclassesAttribute, visitRecordAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDebugExtensionAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
-
Methods inherited from interface proguard.classfile.instruction.visitor.InstructionVisitor
visitAnySwitchInstruction, visitBranchInstruction, visitLookUpSwitchInstruction, visitSimpleInstruction, visitTableSwitchInstruction
-
-
-
-
Constructor Detail
-
LivenessAnalyzer
public LivenessAnalyzer()
Creates a new LivenessAnalyzer.
-
LivenessAnalyzer
public LivenessAnalyzer(PartialEvaluator partialEvaluator, boolean runPartialEvaluator, InitializationFinder initializationFinder, boolean runInitializationFinder)
Creates a new LivenessAnalyzer that will use the given partial evaluator and initialization finder.- Parameters:
partialEvaluator
- the evaluator to be used for the analysis.runPartialEvaluator
- specifies whether to run this evaluator on every code attribute that is visited.initializationFinder
- the initialization finder to be used for the analysis.runInitializationFinder
- specifies whether to run this initialization finder on every code attribute that is visited.
-
-
Method Detail
-
isTraced
public boolean isTraced(int instructionOffset)
Returns whether the instruction at the given offset has ever been executed during the partial evaluation.
-
isAliveBefore
public boolean isAliveBefore(int instructionOffset, int variableIndex)
Returns whether the specified variable is alive before the instruction at the given offset.
-
setAliveBefore
public void setAliveBefore(int instructionOffset, int variableIndex, boolean alive)
Sets whether the specified variable is alive before the instruction at the given offset.
-
isAliveAfter
public boolean isAliveAfter(int instructionOffset, int variableIndex)
Returns whether the specified variable is alive after the instruction at the given offset.
-
setAliveAfter
public void setAliveAfter(int instructionOffset, int variableIndex, boolean alive)
Sets whether the specified variable is alive after the instruction at the given offset.
-
isCategory2
public boolean isCategory2(int instructionOffset, int variableIndex)
Returns whether the specified variable takes up two entries after the instruction at the given offset.
-
setCategory2
public void setCategory2(int instructionOffset, int variableIndex, boolean category2)
Sets whether the specified variable takes up two entries after the instruction at the given offset.
-
visitAnyAttribute
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
Description copied from interface:AttributeVisitor
Visits any Attribute instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyAttribute
in interfaceAttributeVisitor
-
visitCodeAttribute
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
- Specified by:
visitCodeAttribute
in interfaceAttributeVisitor
-
visitAnyInstruction
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
Description copied from interface:InstructionVisitor
Visits any Instruction instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyInstruction
in interfaceInstructionVisitor
-
visitVariableInstruction
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
- Specified by:
visitVariableInstruction
in interfaceInstructionVisitor
-
visitConstantInstruction
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
- Specified by:
visitConstantInstruction
in interfaceInstructionVisitor
-
visitExceptionInfo
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
- Specified by:
visitExceptionInfo
in interfaceExceptionInfoVisitor
-
-