类 DominatorCalculator
- java.lang.Object
-
- proguard.analysis.DominatorCalculator
-
- 所有已实现的接口:
AttributeVisitor
public class DominatorCalculator extends java.lang.Object implements AttributeVisitor
Calculate the dominator tree of any method, making it possible to determine which instructions are guaranteed to be executed before others.This is useful for applications like the
CallResolverthat would like to know whether an instruction, e.g. a method call, is always guaranteed to be executed assuming the containing method is invoked, or if its execution requires specific branches in the method to be taken.In principle, dominator analysis is based on a simple equation:
- The entry node dominates only itself
- Any other node's dominator set is calculated by forming the intersection of the dominator sets of all its control flow predecessors. Afterwards, the node itself is also added to its dominator set.
The implementation here is based on an algorithm that solves the underlying dataflow equation using optimized
BitSetobjects instead of normal sets.
-
-
字段概要
字段 修饰符和类型 字段 说明 static intENTRY_NODE_OFFSETVirtual instruction offset modelling the method entry.static intEXIT_NODE_OFFSETVirtual instruction offset modelling the method exit, i.e. all return instructions.
-
构造器概要
构造器 构造器 说明 DominatorCalculator()Creates a new DominatorCalculator.DominatorCalculator(boolean ignoreExceptions)Creates a new DominatorCalculator.
-
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 booleandominates(int dominator, int inferior)已过时。Callers should usemaybeDominates(int, int)to handle an optional value instead of an exception.java.util.Optional<java.lang.Boolean>maybeDominates(int dominator, int inferior)Check if one instruction dominates another one.voidvisitAnyAttribute(Clazz clazz, Attribute attribute)Visits any Attribute instance.voidvisitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 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
-
-
-
-
字段详细资料
-
EXIT_NODE_OFFSET
public static final int EXIT_NODE_OFFSET
Virtual instruction offset modelling the method exit, i.e. all return instructions.- 另请参阅:
- 常量字段值
-
ENTRY_NODE_OFFSET
public static final int ENTRY_NODE_OFFSET
Virtual instruction offset modelling the method entry. This is needed such that the method entry is guaranteed to have no incoming control flow edges, as this would prevent the algorithm from converging properly without complicated alternative measures.- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
DominatorCalculator
public DominatorCalculator()
Creates a new DominatorCalculator. The default behavior is to ignore exceptions.
-
DominatorCalculator
public DominatorCalculator(boolean ignoreExceptions)
Creates a new DominatorCalculator.- 参数:
ignoreExceptions- If false, exceptions will be taken into account in the analysis.
-
-
方法详细资料
-
dominates
@Deprecated public boolean dominates(int dominator, int inferior)已过时。Callers should usemaybeDominates(int, int)to handle an optional value instead of an exception.Check if one instruction dominates another one. If this is the case, the dominating instruction is guaranteed to be executed before the inferior instruction. Should you wish to check whether an instruction is guaranteed to be executed once the containing method is invoked, you can use the virtual inferiorEXIT_NODE_OFFSETas a collection for all return instructions.- 参数:
dominator- The potentially dominating instruction's offsetinferior- The potentially dominated instruction's offset- 返回:
- true if the potential dominator is indeed guaranteed to be executed before the inferior
-
maybeDominates
public java.util.Optional<java.lang.Boolean> maybeDominates(int dominator, int inferior)Check if one instruction dominates another one. If this is the case, the dominating instruction is guaranteed to be executed before the inferior instruction. Should you wish to check whether an instruction is guaranteed to be executed once the containing method is invoked, you can use the virtual inferiorEXIT_NODE_OFFSETas a collection for all return instructions.- 参数:
dominator- The potentially dominating instruction's offsetinferior- The potentially dominated instruction's offset- 返回:
- Optional.true if the potential dominator is indeed guaranteed to be executed before the inferior, Optional.false if not and Optional.empty when no dominator information is known.
-
visitAnyAttribute
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
从接口复制的说明:AttributeVisitorVisits any Attribute instance. The more specific default implementations of this interface delegate to this method.- 指定者:
visitAnyAttribute在接口中AttributeVisitor
-
visitCodeAttribute
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
- 指定者:
visitCodeAttribute在接口中AttributeVisitor
-
-