com.android.dx.rop.code.BasicBlock类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.android.dx.rop.code.BasicBlock类的一些代码示例,展示了BasicBlock类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BasicBlock类的具体详情如下:
包路径:com.android.dx.rop.code.BasicBlock
类名称:BasicBlock

BasicBlock介绍

[英]Basic block of register-based instructions.
[中]基于寄存器的指令的基本块。

代码示例

代码示例来源:origin: linkedin/dexmaker

BasicBlock toBasicBlock() {
    InsnList result = new InsnList(instructions.size());
    for (int i = 0; i < instructions.size(); i++) {
      result.set(i, instructions.get(i));
    }
    result.setImmutable();

    int primarySuccessorIndex = -1;
    IntList successors = new IntList();
    for (Label catchLabel : catchLabels) {
      successors.add(catchLabel.id);
    }
    if (primarySuccessor != null) {
      primarySuccessorIndex = primarySuccessor.id;
      successors.add(primarySuccessorIndex);
    }
    if (alternateSuccessor != null) {
      successors.add(alternateSuccessor.id);
    }
    successors.setImmutable();

    return new BasicBlock(id, result, successors, primarySuccessorIndex);
  }
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Helper method to compare the contents of two blocks.
 *
 * @param a {@code non-null;} a block to compare
 * @param b {@code non-null;} another block to compare
 * @return {@code true} iff the two blocks' instructions are the same
 */
private static boolean compareInsns(BasicBlock a, BasicBlock b) {
  return a.getInsns().contentEquals(b.getInsns());
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Gets the instance for the start of the given block.
 *
 * @param block {@code non-null;} the block in question
 * @return {@code non-null;} the appropriate instance
 */
public CodeAddress getStart(BasicBlock block) {
  return starts[block.getLabel()];
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
   * Replaces one of a block's successors with a different label. Constructs
   * an updated BasicBlock instance and places it in {@code newBlocks}.
   *
   * @param block block to replace
   * @param oldLabel label of successor to replace
   * @param newLabel label of new successor
   */
  private void replaceSucc(BasicBlock block, int oldLabel, int newLabel) {
    IntList newSuccessors = block.getSuccessors().mutableCopy();
    int newPrimarySuccessor;

    newSuccessors.set(newSuccessors.indexOf(oldLabel), newLabel);
    newPrimarySuccessor = block.getPrimarySuccessor();

    if (newPrimarySuccessor == oldLabel) {
      newPrimarySuccessor = newLabel;
    }

    newSuccessors.setImmutable();

    BasicBlock newBB = new BasicBlock(block.getLabel(),
        block.getInsns(), newSuccessors, newPrimarySuccessor);

    newBlocks.set(newBlocks.indexOfLabel(block.getLabel()), newBB);
  }
}

代码示例来源:origin: nikita36078/J2ME-Loader

block.getInsns().forEach(translationVisitor);
int succ = block.getPrimarySuccessor();
Insn lastInsn = block.getLastInsn();
      (block.getSecondarySuccessor() == nextLabel)) {

代码示例来源:origin: nikita36078/J2ME-Loader

RegisterSpecSet primaryState = resultInfo.mutableCopyOfStarts(label);
BasicBlock block = blocks.labelToBlock(label);
InsnList insns = block.getInsns();
int insnSz = insns.size();
boolean canThrowDuringLastInsn = block.hasExceptionHandlers() &&
  (insns.getLast().getResult() != null);
int freezeSecondaryStateAt = insnSz - 1;
IntList successors = block.getSuccessors();
int succSz = successors.size();
int primarySuccessor = block.getPrimarySuccessor();

代码示例来源:origin: nikita36078/J2ME-Loader

BasicBlock b = blocks.get(bindex);
if (toDelete.get(b.getLabel())) {
IntList preds = ropMethod.labelToPredecessors(b.getLabel());
      || iBlock.getSuccessors().size() > 1
      || iBlock.getFirstInsn().getOpcode().getOpcode() ==
        RegOps.MOVE_RESULT) {
    continue;
    BasicBlock jBlock = blocks.labelToBlock(jLabel);
    if (jBlock.getSuccessors().size() == 1
        && compareInsns(iBlock, jBlock)) {
if (toDelete.get(newBlocks.get(i).getLabel())) {
  newBlocks.set(i, null);

代码示例来源:origin: com.google.android.tools/dx

Type one = catchTypes[i];
if (one != null) {
  Insn proto = labelToBlock(i).getFirstInsn();
  SourcePosition pos = proto.getPosition();
  InsnList il = new InsnList(2);
  il.setImmutable();
  BasicBlock bb = new BasicBlock(getExceptionSetupLabel(i),
                  il,
                  IntList.makeImmutable(i),

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Looks forward to the current block's primary successor, returning
 * the RegisterSpec of the result of the move-result-pseudo at the
 * top of that block or null if none.
 *
 * @return {@code null-ok;} result of move-result-pseudo at the beginning of
 * primary successor
 */
private RegisterSpec getNextMoveResultPseudo()
{
  int label = block.getPrimarySuccessor();
  if (label < 0) {
    return null;
  }
  Insn insn
      = method.getBlocks().labelToBlock(label).getInsns().get(0);
  if (insn.getOpcode().getOpcode() != RegOps.MOVE_RESULT_PSEUDO) {
    return null;
  } else {
    return insn.getResult();
  }
}

代码示例来源:origin: com.google.android.tools/dx

/** {@inheritDoc} */
public HashSet<Type> getCatchTypes() {
  HashSet<Type> result = new HashSet<Type>(20);
  BasicBlockList blocks = method.getBlocks();
  int size = blocks.size();
  for (int i = 0; i < size; i++) {
    BasicBlock block = blocks.get(i);
    TypeList catches = block.getLastInsn().getCatches();
    int catchSize = catches.size();
    for (int j = 0; j < catchSize; j++) {
      result.add(catches.getType(j));
    }
  }
  return result;
}

代码示例来源:origin: nikita36078/J2ME-Loader

BasicBlock block = blocks.labelToBlock(order[i]);
if (!block.canThrow()) {

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Checks to see if the basic block is a subroutine caller block.
 *
 * @param bb {@code non-null;} the basic block in question
 * @return true if this block calls a subroutine
 */
private boolean isSubroutineCaller(BasicBlock bb) {
  IntList successors = bb.getSuccessors();
  if (successors.size() < 2) return false;
  int subLabel = successors.get(1);
  return (subLabel < subroutines.length)
      && (subroutines[subLabel] != null);
}

代码示例来源:origin: com.android/dx

/**
   * Replaces one of a block's successors with a different label. Constructs
   * an updated BasicBlock instance and places it in {@code newBlocks}.
   *
   * @param block block to replace
   * @param oldLabel label of successor to replace
   * @param newLabel label of new successor
   */
  private void replaceSucc(BasicBlock block, int oldLabel, int newLabel) {
    IntList newSuccessors = block.getSuccessors().mutableCopy();
    int newPrimarySuccessor;

    newSuccessors.set(newSuccessors.indexOf(oldLabel), newLabel);
    newPrimarySuccessor = block.getPrimarySuccessor();

    if (newPrimarySuccessor == oldLabel) {
      newPrimarySuccessor = newLabel;
    }

    newSuccessors.setImmutable();

    BasicBlock newBB = new BasicBlock(block.getLabel(),
        block.getInsns(), newSuccessors, newPrimarySuccessor);

    newBlocks.set(newBlocks.indexOfLabel(block.getLabel()), newBB);
  }
}

代码示例来源:origin: com.google.android.tools/dx

block.getInsns().forEach(translationVisitor);
int succ = block.getPrimarySuccessor();
Insn lastInsn = block.getLastInsn();
      (block.getSecondarySuccessor() == nextLabel)) {

代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx

RegisterSpecSet primaryState = resultInfo.mutableCopyOfStarts(label);
BasicBlock block = blocks.labelToBlock(label);
InsnList insns = block.getInsns();
int insnSz = insns.size();
boolean canThrowDuringLastInsn = block.hasExceptionHandlers() &&
  (insns.getLast().getResult() != null);
int freezeSecondaryStateAt = insnSz - 1;
IntList successors = block.getSuccessors();
int succSz = successors.size();
int primarySuccessor = block.getPrimarySuccessor();

代码示例来源:origin: com.android/dx

BasicBlock b = blocks.get(bindex);
if (toDelete.get(b.getLabel())) {
IntList preds = ropMethod.labelToPredecessors(b.getLabel());
      || iBlock.getSuccessors().size() > 1
      || iBlock.getFirstInsn().getOpcode().getOpcode() ==
        RegOps.MOVE_RESULT) {
    continue;
    BasicBlock jBlock = blocks.labelToBlock(jLabel);
    if (jBlock.getSuccessors().size() == 1
        && compareInsns(iBlock, jBlock)) {
if (toDelete.get(newBlocks.get(i).getLabel())) {
  newBlocks.set(i, null);

代码示例来源:origin: dragome/dragome-sdk

Type one = catchTypes[i];
if (one != null) {
  Insn proto = labelToBlock(i).getFirstInsn();
  SourcePosition pos = proto.getPosition();
  InsnList il = new InsnList(2);
  il.setImmutable();
  BasicBlock bb = new BasicBlock(getExceptionSetupLabel(i),
                  il,
                  IntList.makeImmutable(i),

代码示例来源:origin: com.android.tools.build/builder

/**
 * Looks forward to the current block's primary successor, returning
 * the RegisterSpec of the result of the move-result-pseudo at the
 * top of that block or null if none.
 *
 * @return {@code null-ok;} result of move-result-pseudo at the beginning of
 * primary successor
 */
private RegisterSpec getNextMoveResultPseudo()
{
  int label = block.getPrimarySuccessor();
  if (label < 0) {
    return null;
  }
  Insn insn
      = method.getBlocks().labelToBlock(label).getInsns().get(0);
  if (insn.getOpcode().getOpcode() != RegOps.MOVE_RESULT_PSEUDO) {
    return null;
  } else {
    return insn.getResult();
  }
}

代码示例来源:origin: com.android/dx

/** {@inheritDoc} */
public HashSet<Type> getCatchTypes() {
  HashSet<Type> result = new HashSet<Type>(20);
  BasicBlockList blocks = method.getBlocks();
  int size = blocks.size();
  for (int i = 0; i < size; i++) {
    BasicBlock block = blocks.get(i);
    TypeList catches = block.getLastInsn().getCatches();
    int catchSize = catches.size();
    for (int j = 0; j < catchSize; j++) {
      result.add(catches.getType(j));
    }
  }
  return result;
}

代码示例来源:origin: com.google.dexmaker/dexmaker-dx

BasicBlock block = blocks.labelToBlock(order[i]);
if (!block.canThrow()) {

相关文章