Methods Summary |
---|
public boolean | catchesEqual(BasicBlock block1, BasicBlock block2)Compares the catches of two blocks for equality. This includes
both the catch types and target labels.
TypeList catches1 = block1.getExceptionHandlerTypes();
TypeList catches2 = block2.getExceptionHandlerTypes();
if (!StdTypeList.equalContents(catches1, catches2)) {
return false;
}
IntList succ1 = block1.getSuccessors();
IntList succ2 = block2.getSuccessors();
int size = succ1.size(); // Both are guaranteed to be the same size.
int primary1 = block1.getPrimarySuccessor();
int primary2 = block2.getPrimarySuccessor();
if (((primary1 == -1) || (primary2 == -1))
&& (primary1 != primary2)) {
/*
* For the current purpose, both blocks in question must
* either both have a primary or both not have a primary to
* be considered equal, and it turns out here that that's not
* the case.
*/
return false;
}
for (int i = 0; i < size; i++) {
int label1 = succ1.get(i);
int label2 = succ2.get(i);
if (label1 == primary1) {
/*
* It should be the case that block2's primary is at the
* same index. If not, we consider the blocks unequal for
* the current purpose.
*/
if (label2 != primary2) {
return false;
}
continue;
}
if (label1 != label2) {
return false;
}
}
return true;
|
public void | forEachInsn(Insn.Visitor visitor)Visits each instruction of each block in the list, in order.
int sz = size();
for (int i = 0; i < sz; i++) {
BasicBlock one = get(i);
InsnList insns = one.getInsns();
insns.forEach(visitor);
}
|
public BasicBlock | get(int n)Gets the element at the given index. It is an error to call
this with the index for an element which was never set; if you
do that, this will throw {@code NullPointerException}.
return (BasicBlock) get0(n);
|
public int | getEffectiveInstructionCount()Gets the total instruction count for this instance, ignoring
mark-local instructions which are not actually emitted.
int sz = size();
int result = 0;
for (int i = 0; i < sz; i++) {
BasicBlock one = (BasicBlock) getOrNull0(i);
if (one != null) {
InsnList insns = one.getInsns();
int insnsSz = insns.size();
for (int j = 0; j < insnsSz; j++) {
Insn insn = insns.get(j);
if (insn.getOpcode().getOpcode() != RegOps.MARK_LOCAL) {
result++;
}
}
}
}
return result;
|
public int | getInstructionCount()Gets the total instruction count for this instance. This is the
sum of the instruction counts of each block.
int sz = size();
int result = 0;
for (int i = 0; i < sz; i++) {
BasicBlock one = (BasicBlock) getOrNull0(i);
if (one != null) {
result += one.getInsns().size();
}
}
return result;
|
public com.android.dx.rop.code.BasicBlockList | getMutableCopy()Returns a mutable copy of this list.
return new BasicBlockList(this);
|
public int | getRegCount()Returns how many registers this method requires. This is simply
the maximum of register-number-plus-category referred to by this
instance's instructions (indirectly through {@link BasicBlock}
instances).
if (regCount == -1) {
RegCountVisitor visitor = new RegCountVisitor();
forEachInsn(visitor);
regCount = visitor.getRegCount();
}
return regCount;
|
public BasicBlock | labelToBlock(int label)Gets the first block in the list with the given label, if any.
int idx = indexOfLabel(label);
if (idx < 0) {
throw new IllegalArgumentException("no such label: "
+ Hex.u2(label));
}
return get(idx);
|
public BasicBlock | preferredSuccessorOf(BasicBlock block)Gets the preferred successor for the given block. If the block
only has one successor, then that is the preferred successor.
Otherwise, if the block has a primay successor, then that is
the preferred successor. If the block has no successors, then
this returns {@code null}.
int primarySuccessor = block.getPrimarySuccessor();
IntList successors = block.getSuccessors();
int succSize = successors.size();
switch (succSize) {
case 0: {
return null;
}
case 1: {
return labelToBlock(successors.get(0));
}
}
if (primarySuccessor != -1) {
return labelToBlock(primarySuccessor);
} else {
return labelToBlock(successors.get(0));
}
|
public void | set(int n, BasicBlock bb)Sets the basic block at the given index.
super.set(n, bb);
// Reset regCount, since it will need to be recalculated.
regCount = -1;
|
public com.android.dx.rop.code.BasicBlockList | withRegisterOffset(int delta)Returns an instance that is identical to this one, except that
the registers in each instruction are offset by the given
amount. Mutability of the result is inherited from the
original.
int sz = size();
BasicBlockList result = new BasicBlockList(sz);
for (int i = 0; i < sz; i++) {
BasicBlock one = (BasicBlock) get0(i);
if (one != null) {
result.set(i, one.withRegisterOffset(delta));
}
}
if (isImmutable()) {
result.setImmutable();
}
return result;
|