proguard.optimize.evaluation
Class LivenessAnalyzer

java.lang.Object
  extended by proguard.classfile.util.SimplifiedVisitor
      extended by proguard.optimize.evaluation.LivenessAnalyzer
All Implemented Interfaces:
AttributeVisitor, ExceptionInfoVisitor, InstructionVisitor

public class LivenessAnalyzer
extends SimplifiedVisitor
implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor

This AttributeVisitor analyzes the liveness of the variables in the code attributes that it visits, based on partial evaluation.


Constructor Summary
LivenessAnalyzer()
          Creates a new LivenessAnalyzer.
LivenessAnalyzer(PartialEvaluator partialEvaluator)
          Creates a new LivenessAnalyzer that will use the given partial evaluator.
 
Method Summary
 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.
 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)
          Visit any type of attribute.
 void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
          Visits any type of Instruction.
 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 proguard.classfile.util.SimplifiedVisitor
visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotationDefaultAttribute, visitAnnotationElementValue, visitAnyAnnotationsAttribute, visitAnyClass, visitAnyConstant, visitAnyElementValue, visitAnyMember, visitAnyMethodrefConstant, visitAnyParameterAnnotationsAttribute, visitAnyRefConstant, visitAnyStackMapFrame, visitAnySwitchInstruction, visitAnyVerificationType, visitArrayElementValue, visitBranchInstruction, visitClassConstant, visitClassElementValue, visitConstantElementValue, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDoubleConstant, visitDoubleType, visitEnclosingMethodAttribute, visitEnumConstantElementValue, visitExceptionsAttribute, visitFieldrefConstant, visitFloatConstant, visitFloatType, visitFullFrame, visitInnerClassesAttribute, visitIntegerConstant, visitIntegerType, visitInterfaceMethodrefConstant, visitLessZeroFrame, visitLibraryClass, visitLibraryField, visitLibraryMember, visitLibraryMethod, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitLongConstant, visitLongType, visitLookUpSwitchInstruction, visitMethodrefConstant, visitMoreZeroFrame, visitNameAndTypeConstant, visitNullType, visitObjectType, visitProgramClass, visitProgramField, visitProgramMember, visitProgramMethod, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitSameOneFrame, visitSameZeroFrame, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSimpleInstruction, visitSourceDirAttribute, visitSourceFileAttribute, visitStackDoubleType, visitStackFloatType, visitStackIntegerType, visitStackLongType, visitStackMapAttribute, visitStackMapTableAttribute, visitStackNullType, visitStackObjectType, visitStackTopType, visitStackUninitializedThisType, visitStackUninitializedType, visitStringConstant, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitTableSwitchInstruction, visitTopType, visitUninitializedThisType, visitUninitializedType, visitUnknownAttribute, visitUtf8Constant, visitVariablesDoubleType, visitVariablesFloatType, visitVariablesIntegerType, visitVariablesLongType, visitVariablesNullType, visitVariablesObjectType, visitVariablesTopType, visitVariablesUninitializedThisType, visitVariablesUninitializedType
 
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, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
 
Methods inherited from interface proguard.classfile.instruction.visitor.InstructionVisitor
visitBranchInstruction, visitLookUpSwitchInstruction, visitSimpleInstruction, visitTableSwitchInstruction
 

Constructor Detail

LivenessAnalyzer

public LivenessAnalyzer()
Creates a new LivenessAnalyzer.


LivenessAnalyzer

public LivenessAnalyzer(PartialEvaluator partialEvaluator)
Creates a new LivenessAnalyzer that will use the given partial evaluator. It will run this evaluator on every code attribute that it visits.

Method Detail

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 class: SimplifiedVisitor
Visit any type of attribute.

Overrides:
visitAnyAttribute in class SimplifiedVisitor

visitCodeAttribute

public void visitCodeAttribute(Clazz clazz,
                               Method method,
                               CodeAttribute codeAttribute)
Specified by:
visitCodeAttribute in interface AttributeVisitor
Overrides:
visitCodeAttribute in class SimplifiedVisitor

visitAnyInstruction

public void visitAnyInstruction(Clazz clazz,
                                Method method,
                                CodeAttribute codeAttribute,
                                int offset,
                                Instruction instruction)
Description copied from class: SimplifiedVisitor
Visits any type of Instruction.

Overrides:
visitAnyInstruction in class SimplifiedVisitor

visitVariableInstruction

public void visitVariableInstruction(Clazz clazz,
                                     Method method,
                                     CodeAttribute codeAttribute,
                                     int offset,
                                     VariableInstruction variableInstruction)
Specified by:
visitVariableInstruction in interface InstructionVisitor
Overrides:
visitVariableInstruction in class SimplifiedVisitor

visitConstantInstruction

public void visitConstantInstruction(Clazz clazz,
                                     Method method,
                                     CodeAttribute codeAttribute,
                                     int offset,
                                     ConstantInstruction constantInstruction)
Specified by:
visitConstantInstruction in interface InstructionVisitor
Overrides:
visitConstantInstruction in class SimplifiedVisitor

visitExceptionInfo

public void visitExceptionInfo(Clazz clazz,
                               Method method,
                               CodeAttribute codeAttribute,
                               ExceptionInfo exceptionInfo)
Specified by:
visitExceptionInfo in interface ExceptionInfoVisitor