本文整理汇总了Java中com.android.dx.rop.code.Insn.getOpcode方法的典型用法代码示例。如果您正苦于以下问题:Java Insn.getOpcode方法的具体用法?Java Insn.getOpcode怎么用?Java Insn.getOpcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.dx.rop.code.Insn
的用法示例。
在下文中一共展示了Insn.getOpcode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterMoveReturnAddressInsns
import com.android.dx.rop.code.Insn; //导入方法依赖的package包/类
/**
* Removes all {@code move-return-address} instructions, returning a new
* {@code InsnList} if necessary. The {@code move-return-address}
* insns are dead code after subroutines have been inlined.
*
* @param insns {@code InsnList} that may contain
* {@code move-return-address} insns
* @return {@code InsnList} with {@code move-return-address} removed
*/
private InsnList filterMoveReturnAddressInsns(InsnList insns) {
int sz;
int newSz = 0;
// First see if we need to filter, and if so what the new size will be
sz = insns.size();
for (int i = 0; i < sz; i++) {
if (insns.get(i).getOpcode() != Rops.MOVE_RETURN_ADDRESS) {
newSz++;
}
}
if (newSz == sz) {
return insns;
}
// Make a new list without the MOVE_RETURN_ADDRESS insns
InsnList newInsns = new InsnList(newSz);
int newIndex = 0;
for (int i = 0; i < sz; i++) {
Insn insn = insns.get(i);
if (insn.getOpcode() != Rops.MOVE_RETURN_ADDRESS) {
newInsns.set(newIndex++, insn);
}
}
newInsns.setImmutable();
return newInsns;
}
示例2: tryReplacingWithConstant
import com.android.dx.rop.code.Insn; //导入方法依赖的package包/类
/**
* Tries to replace an instruction with a const instruction. The given
* instruction must have a constant result for it to be replaced.
*
* @param insn {@code non-null;} instruction to try to replace
* @return true if the instruction was replaced
*/
private boolean tryReplacingWithConstant(NormalSsaInsn insn) {
Insn originalRopInsn = insn.getOriginalRopInsn();
Rop opcode = originalRopInsn.getOpcode();
RegisterSpec result = insn.getResult();
if (result != null && !ssaMeth.isRegALocal(result) &&
opcode.getOpcode() != RegOps.CONST) {
TypeBearer type = insn.getResult().getTypeBearer();
if (type.isConstant() && type.getBasicType() == Type.BT_INT) {
// Replace the instruction with a constant
replacePlainInsn(insn, RegisterSpecList.EMPTY,
RegOps.CONST, (Constant) type);
// Remove the source as well if this is a move-result-pseudo
if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
int pred = insn.getBlock().getPredecessors().nextSetBit(0);
ArrayList<SsaInsn> predInsns =
ssaMeth.getBlocks().get(pred).getInsns();
NormalSsaInsn sourceInsn =
(NormalSsaInsn) predInsns.get(predInsns.size()-1);
replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY,
RegOps.GOTO, null);
}
return true;
}
}
return false;
}
示例3: outputBlock
import com.android.dx.rop.code.Insn; //导入方法依赖的package包/类
/**
* Helper for {@link #outputInstructions}, which does the processing
* and output of one block.
*
* @param block {@code non-null;} the block to process and output
* @param nextLabel {@code >= -1;} the next block that will be processed, or
* {@code -1} if there is no next block
*/
private void outputBlock(BasicBlock block, int nextLabel) {
// Append the code address for this block.
CodeAddress startAddress = addresses.getStart(block);
output.add(startAddress);
// Append the local variable state for the block.
if (locals != null) {
RegisterSpecSet starts = locals.getStarts(block);
output.add(new LocalSnapshot(startAddress.getPosition(),
starts));
}
/*
* Choose and append an output instruction for each original
* instruction.
*/
translationVisitor.setBlock(block, addresses.getLast(block));
block.getInsns().forEach(translationVisitor);
// Insert the block end code address.
output.add(addresses.getEnd(block));
// Set up for end-of-block activities.
int succ = block.getPrimarySuccessor();
Insn lastInsn = block.getLastInsn();
/*
* Check for (and possibly correct for) a non-optimal choice of
* which block will get output next.
*/
if ((succ >= 0) && (succ != nextLabel)) {
/*
* The block has a "primary successor" and that primary
* successor isn't the next block to be output.
*/
Rop lastRop = lastInsn.getOpcode();
if ((lastRop.getBranchingness() == Rop.BRANCH_IF) &&
(block.getSecondarySuccessor() == nextLabel)) {
/*
* The block ends with an "if" of some sort, and its
* secondary successor (the "then") is in fact the
* next block to output. So, reverse the sense of
* the test, so that we can just emit the next block
* without an interstitial goto.
*/
output.reverseBranch(1, addresses.getStart(succ));
} else {
/*
* Our only recourse is to add a goto here to get the
* flow to be correct.
*/
TargetInsn insn =
new TargetInsn(Dops.GOTO, lastInsn.getPosition(),
RegisterSpecList.EMPTY,
addresses.getStart(succ));
output.add(insn);
}
}
}