public class DominatorCalculator extends java.lang.Object implements AttributeVisitor
This is useful for applications like the CallResolver
that 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 implementation here is based on an algorithm that solves the underlying dataflow equation
using optimized BitSet
objects instead of normal sets.
Modifier and Type | Field and Description |
---|---|
static int |
ENTRY_NODE_OFFSET
Virtual instruction offset modelling the method entry.
|
static int |
EXIT_NODE_OFFSET
Virtual instruction offset modelling the method exit, i.e.
|
Constructor and Description |
---|
DominatorCalculator()
Creates a new DominatorCalculator.
|
DominatorCalculator(boolean ignoreExceptions)
Creates a new DominatorCalculator.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dominates(int dominator,
int inferior)
Check if one instruction dominates another one.
|
void |
visitAnyAttribute(Clazz clazz,
Attribute attribute)
Visits any Attribute instance.
|
void |
visitCodeAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
public static final int EXIT_NODE_OFFSET
public static final int ENTRY_NODE_OFFSET
public DominatorCalculator()
public DominatorCalculator(boolean ignoreExceptions)
ignoreExceptions
- If false, exceptions will be taken into account in the analysis.public boolean dominates(int dominator, int inferior)
EXIT_NODE_OFFSET
as a collection for all return instructions.dominator
- The potentially dominating instruction's offsetinferior
- The potentially dominated instruction's offsetpublic void visitAnyAttribute(Clazz clazz, Attribute attribute)
AttributeVisitor
visitAnyAttribute
in interface AttributeVisitor
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
visitCodeAttribute
in interface AttributeVisitor