Java Code Examples for com.android.dx.rop.code.Rop#BRANCH_THROW

The following examples show how to use com.android.dx.rop.code.Rop#BRANCH_THROW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RopTranslator.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitInvokePolymorphicInsn(InvokePolymorphicInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("Expected BRANCH_THROW got " + rop.getBranchingness());
    } else if (!rop.isCallLike()) {
        throw new RuntimeException("Expected call-like operation");
    }

    addOutput(lastAddress);

    RegisterSpecList regs = insn.getSources();
    Constant[] constants = new Constant[] {
        insn.getPolymorphicMethod(),
        insn.getCallSiteProto()
        };
    DalvInsn di = new MultiCstInsn(opcode, pos, regs, constants);

    addOutput(di);
}
 
Example 2
Source File: RopTranslator.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitThrowingInsn(ThrowingInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();
    RegisterSpec realResult;

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("shouldn't happen");
    }

    realResult = getNextMoveResultPseudo();

    if (opcode.hasResult() != (realResult != null)) {
        throw new RuntimeException(
                "Insn with result/move-result-pseudo mismatch" + insn);
    }

    addOutput(lastAddress);

    DalvInsn di = new SimpleInsn(opcode, pos,
            getRegs(insn, realResult));

    addOutput(di);
}
 
Example 3
Source File: RopTranslator.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitInvokePolymorphicInsn(InvokePolymorphicInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("Expected BRANCH_THROW got " + rop.getBranchingness());
    } else if (!rop.isCallLike()) {
        throw new RuntimeException("Expected call-like operation");
    }

    addOutput(lastAddress);

    RegisterSpecList regs = insn.getSources();
    Constant[] constants = new Constant[] {
        insn.getPolymorphicMethod(),
        insn.getCallSiteProto()
        };
    DalvInsn di = new MultiCstInsn(opcode, pos, regs, constants);

    addOutput(di);
}
 
Example 4
Source File: RopTranslator.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitThrowingInsn(ThrowingInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();
    RegisterSpec realResult;

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("shouldn't happen");
    }

    realResult = getNextMoveResultPseudo();

    if (opcode.hasResult() != (realResult != null)) {
        throw new RuntimeException(
                "Insn with result/move-result-pseudo mismatch" + insn);
    }

    addOutput(lastAddress);

    DalvInsn di = new SimpleInsn(opcode, pos,
            getRegs(insn, realResult));

    addOutput(di);
}
 
Example 5
Source File: RopTranslator.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitInvokePolymorphicInsn(InvokePolymorphicInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("Expected BRANCH_THROW got " + rop.getBranchingness());
    } else if (!rop.isCallLike()) {
        throw new RuntimeException("Expected call-like operation");
    }

    addOutput(lastAddress);

    RegisterSpecList regs = insn.getSources();
    Constant[] constants = new Constant[] {
        insn.getInvokeMethod(),
        insn.getCallSiteProto()
        };
    DalvInsn di = new MultiCstInsn(opcode, pos, regs, constants);

    addOutput(di);
}
 
Example 6
Source File: RopTranslator.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitThrowingInsn(ThrowingInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();
    RegisterSpec realResult;

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("shouldn't happen");
    }

    realResult = getNextMoveResultPseudo();

    if (opcode.hasResult() != (realResult != null)) {
        throw new RuntimeException(
                "Insn with result/move-result-pseudo mismatch" + insn);
    }

    addOutput(lastAddress);

    DalvInsn di = new SimpleInsn(opcode, pos,
            getRegs(insn, realResult));

    addOutput(di);
}
 
Example 7
Source File: RopTranslator.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void visitThrowingInsn(ThrowingInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();
    RegisterSpec realResult;

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("shouldn't happen");
    }

    realResult = getNextMoveResultPseudo();

    if (opcode.hasResult() != (realResult != null)) {
        throw new RuntimeException(
                "Insn with result/move-result-pseudo mismatch" + insn);
    }

    addOutput(lastAddress);

    DalvInsn di = new SimpleInsn(opcode, pos,
            getRegs(insn, realResult));

    addOutput(di);
}
 
Example 8
Source File: RopTranslator.java    From Box with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitPlainInsn(PlainInsn insn) {
    Rop rop = insn.getOpcode();
    if (rop.getOpcode() == RegOps.MARK_LOCAL) {
        /*
         * Ignore these. They're dealt with by
         * the LocalVariableAwareTranslationVisitor
         */
        return;
    }
    if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
        // These get skipped
        return;
    }

    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    DalvInsn di;

    switch (rop.getBranchingness()) {
        case Rop.BRANCH_NONE:
        case Rop.BRANCH_RETURN:
        case Rop.BRANCH_THROW: {
            di = new SimpleInsn(opcode, pos, getRegs(insn));
            break;
        }
        case Rop.BRANCH_GOTO: {
            /*
             * Code in the main translation loop will emit a
             * goto if necessary (if the branch isn't to the
             * immediately subsequent block).
             */
            return;
        }
        case Rop.BRANCH_IF: {
            int target = block.getSuccessors().get(1);
            di = new TargetInsn(opcode, pos, getRegs(insn),
                                addresses.getStart(target));
            break;
        }
        default: {
            throw new RuntimeException("shouldn't happen");
        }
    }

    addOutput(di);
}
 
Example 9
Source File: RopTranslator.java    From Box with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitPlainInsn(PlainInsn insn) {
    Rop rop = insn.getOpcode();
    if (rop.getOpcode() == RegOps.MARK_LOCAL) {
        /*
         * Ignore these. They're dealt with by
         * the LocalVariableAwareTranslationVisitor
         */
        return;
    }
    if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
        // These get skipped
        return;
    }

    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    DalvInsn di;

    switch (rop.getBranchingness()) {
        case Rop.BRANCH_NONE:
        case Rop.BRANCH_RETURN:
        case Rop.BRANCH_THROW: {
            di = new SimpleInsn(opcode, pos, getRegs(insn));
            break;
        }
        case Rop.BRANCH_GOTO: {
            /*
             * Code in the main translation loop will emit a
             * goto if necessary (if the branch isn't to the
             * immediately subsequent block).
             */
            return;
        }
        case Rop.BRANCH_IF: {
            int target = block.getSuccessors().get(1);
            di = new TargetInsn(opcode, pos, getRegs(insn),
                                addresses.getStart(target));
            break;
        }
        default: {
            throw new RuntimeException("shouldn't happen");
        }
    }

    addOutput(di);
}
 
Example 10
Source File: Code.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @param branch the branches to follow; interpretation depends on the
 *               instruction's branchingness.
 */
private void addInstruction(Insn insn, Label branch) {
    if (currentLabel == null || !currentLabel.marked) {
        throw new IllegalStateException("no current label");
    }
    currentLabel.instructions.add(insn);

    switch (insn.getOpcode().getBranchingness()) {
        case BRANCH_NONE:
            if (branch != null) {
                throw new IllegalArgumentException("unexpected branch: " + branch);
            }
            return;

        case BRANCH_RETURN:
            if (branch != null) {
                throw new IllegalArgumentException("unexpected branch: " + branch);
            }
            currentLabel = null;
            break;

        case BRANCH_GOTO:
            if (branch == null) {
                throw new IllegalArgumentException("branch == null");
            }
            currentLabel.primarySuccessor = branch;
            currentLabel = null;
            break;

        case Rop.BRANCH_IF:
            if (branch == null) {
                throw new IllegalArgumentException("branch == null");
            }
            splitCurrentLabel(branch, Collections.<Label>emptyList());
            break;

        case Rop.BRANCH_THROW:
            if (branch != null) {
                throw new IllegalArgumentException("unexpected branch: " + branch);
            }
            splitCurrentLabel(null, new ArrayList<Label>(catchLabels));
            break;

        default:
            throw new IllegalArgumentException();
    }
}
 
Example 11
Source File: RopTranslator.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
      @Override
public void visitPlainInsn(PlainInsn insn) {
          Rop rop = insn.getOpcode();
          if (rop.getOpcode() == RegOps.MARK_LOCAL) {
              /*
               * Ignore these. They're dealt with by
               * the LocalVariableAwareTranslationVisitor
               */
              return;
          }
          if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
              // These get skipped
              return;
          }

          SourcePosition pos = insn.getPosition();
          Dop opcode = RopToDop.dopFor(insn);
          DalvInsn di;

          switch (rop.getBranchingness()) {
              case Rop.BRANCH_NONE:
              case Rop.BRANCH_RETURN:
              case Rop.BRANCH_THROW: {
                  di = new SimpleInsn(opcode, pos, getRegs(insn));
                  break;
              }
              case Rop.BRANCH_GOTO: {
                  /*
                   * Code in the main translation loop will emit a
                   * goto if necessary (if the branch isn't to the
                   * immediately subsequent block).
                   */
                  return;
              }
              case Rop.BRANCH_IF: {
                  int target = block.getSuccessors().get(1);
                  di = new TargetInsn(opcode, pos, getRegs(insn),
                                      addresses.getStart(target));
                  break;
              }
              default: {
                  throw new RuntimeException("shouldn't happen");
              }
          }

          addOutput(di);
      }
 
Example 12
Source File: Code.java    From dexmaker with Apache License 2.0 4 votes vote down vote up
/**
 * @param branch the branches to follow; interpretation depends on the
 *     instruction's branchingness.
 */
private void addInstruction(Insn insn, Label branch) {
    if (currentLabel == null || !currentLabel.marked) {
        throw new IllegalStateException("no current label");
    }
    currentLabel.instructions.add(insn);

    switch (insn.getOpcode().getBranchingness()) {
    case BRANCH_NONE:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        return;

    case BRANCH_RETURN:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        currentLabel = null;
        break;

    case BRANCH_GOTO:
        if (branch == null) {
            throw new IllegalArgumentException("branch == null");
        }
        currentLabel.primarySuccessor = branch;
        currentLabel = null;
        break;

    case Rop.BRANCH_IF:
        if (branch == null) {
            throw new IllegalArgumentException("branch == null");
        }
        splitCurrentLabel(branch, Collections.<Label>emptyList());
        break;

    case Rop.BRANCH_THROW:
        if (branch != null) {
            throw new IllegalArgumentException("unexpected branch: " + branch);
        }
        splitCurrentLabel(null, new ArrayList<Label>(catchLabels));
        break;

    default:
        throw new IllegalArgumentException();
    }
}
 
Example 13
Source File: RopTranslator.java    From buck with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public void visitPlainInsn(PlainInsn insn) {
    Rop rop = insn.getOpcode();
    if (rop.getOpcode() == RegOps.MARK_LOCAL) {
        /*
         * Ignore these. They're dealt with by
         * the LocalVariableAwareTranslationVisitor
         */
        return;
    }
    if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
        // These get skipped
        return;
    }

    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    DalvInsn di;

    switch (rop.getBranchingness()) {
        case Rop.BRANCH_NONE:
        case Rop.BRANCH_RETURN:
        case Rop.BRANCH_THROW: {
            di = new SimpleInsn(opcode, pos, getRegs(insn));
            break;
        }
        case Rop.BRANCH_GOTO: {
            /*
             * Code in the main translation loop will emit a
             * goto if necessary (if the branch isn't to the
             * immediately subsequent block).
             */
            return;
        }
        case Rop.BRANCH_IF: {
            int target = block.getSuccessors().get(1);
            di = new TargetInsn(opcode, pos, getRegs(insn),
                                addresses.getStart(target));
            break;
        }
        default: {
            throw new RuntimeException("shouldn't happen");
        }
    }

    addOutput(di);
}