Java Code Examples for com.android.dx.rop.code.RegOps#MOVE_RESULT

The following examples show how to use com.android.dx.rop.code.RegOps#MOVE_RESULT . 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: EscapeAnalysis.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
Example 2
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * TODO: Increase the scope of this.
 */
@Override
public boolean hasSideEffect() {
    Rop opcode = getOpcode();

    if (opcode.getBranchingness() != Rop.BRANCH_NONE) {
        return true;
    }

    boolean hasLocalSideEffect
        = Optimizer.getPreserveLocals() && getLocalAssignment() != null;

    switch (opcode.getOpcode()) {
        case RegOps.MOVE_RESULT:
        case RegOps.MOVE:
        case RegOps.CONST:
            return hasLocalSideEffect;
        default:
            return true;
    }
}
 
Example 3
Source File: EscapeAnalysis.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
Example 4
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * TODO: Increase the scope of this.
 */
@Override
public boolean hasSideEffect() {
    Rop opcode = getOpcode();

    if (opcode.getBranchingness() != Rop.BRANCH_NONE) {
        return true;
    }

    boolean hasLocalSideEffect
        = Optimizer.getPreserveLocals() && getLocalAssignment() != null;

    switch (opcode.getOpcode()) {
        case RegOps.MOVE_RESULT:
        case RegOps.MOVE:
        case RegOps.CONST:
            return hasLocalSideEffect;
        default:
            return true;
    }
}
 
Example 5
Source File: EscapeAnalysis.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
Example 6
Source File: NormalSsaInsn.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * TODO: Increase the scope of this.
 */
@Override
public boolean hasSideEffect() {
    Rop opcode = getOpcode();

    if (opcode.getBranchingness() != Rop.BRANCH_NONE) {
        return true;
    }

    boolean hasLocalSideEffect
        = Optimizer.getPreserveLocals() && getLocalAssignment() != null;

    switch (opcode.getOpcode()) {
        case RegOps.MOVE_RESULT:
        case RegOps.MOVE:
        case RegOps.CONST:
            return hasLocalSideEffect;
        default:
            return true;
    }
}
 
Example 7
Source File: EscapeAnalysis.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
Example 8
Source File: NormalSsaInsn.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * TODO: Increase the scope of this.
 */
@Override
public boolean hasSideEffect() {
    Rop opcode = getOpcode();

    if (opcode.getBranchingness() != Rop.BRANCH_NONE) {
        return true;
    }

    boolean hasLocalSideEffect
        = Optimizer.getPreserveLocals() && getLocalAssignment() != null;

    switch (opcode.getOpcode()) {
        case RegOps.MOVE_RESULT:
        case RegOps.MOVE:
        case RegOps.CONST:
            return hasLocalSideEffect;
        default:
            return true;
    }
}
 
Example 9
Source File: IdenticalBlockCombiner.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Runs algorithm. TODO: This is n^2, and could be made linear-ish with
 * a hash. In particular, hash the contents of each block and only
 * compare blocks with the same hash.
 *
 * @return {@code non-null;} new method that has been processed
 */
public RopMethod process() {
    int szBlocks = blocks.size();
    // indexed by label
    BitSet toDelete = new BitSet(blocks.getMaxLabel());

    // For each non-deleted block...
    for (int bindex = 0; bindex < szBlocks; bindex++) {
        BasicBlock b = blocks.get(bindex);

        if (toDelete.get(b.getLabel())) {
            // doomed block
            continue;
        }

        IntList preds = ropMethod.labelToPredecessors(b.getLabel());

        // ...look at all of it's predecessors that have only one succ...
        int szPreds = preds.size();
        for (int i = 0; i < szPreds; i++) {
            int iLabel = preds.get(i);

            BasicBlock iBlock = blocks.labelToBlock(iLabel);

            if (toDelete.get(iLabel)
                    || iBlock.getSuccessors().size() > 1
                    || iBlock.getFirstInsn().getOpcode().getOpcode() ==
                        RegOps.MOVE_RESULT) {
                continue;
            }

            IntList toCombine = new IntList();

            // ...and see if they can be combined with any other preds...
            for (int j = i + 1; j < szPreds; j++) {
                int jLabel = preds.get(j);
                BasicBlock jBlock = blocks.labelToBlock(jLabel);

                if (jBlock.getSuccessors().size() == 1
                        && compareInsns(iBlock, jBlock)) {

                    toCombine.add(jLabel);
                    toDelete.set(jLabel);
                }
            }

            combineBlocks(iLabel, toCombine);
        }
    }

    for (int i = szBlocks - 1; i >= 0; i--) {
        if (toDelete.get(newBlocks.get(i).getLabel())) {
            newBlocks.set(i, null);
        }
    }

    newBlocks.shrinkToFit();
    newBlocks.setImmutable();

    return new RopMethod(newBlocks, ropMethod.getFirstLabel());
}
 
Example 10
Source File: IdenticalBlockCombiner.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Runs algorithm. TODO: This is n^2, and could be made linear-ish with
 * a hash. In particular, hash the contents of each block and only
 * compare blocks with the same hash.
 *
 * @return {@code non-null;} new method that has been processed
 */
public RopMethod process() {
    int szBlocks = blocks.size();
    // indexed by label
    BitSet toDelete = new BitSet(blocks.getMaxLabel());

    // For each non-deleted block...
    for (int bindex = 0; bindex < szBlocks; bindex++) {
        BasicBlock b = blocks.get(bindex);

        if (toDelete.get(b.getLabel())) {
            // doomed block
            continue;
        }

        IntList preds = ropMethod.labelToPredecessors(b.getLabel());

        // ...look at all of it's predecessors that have only one succ...
        int szPreds = preds.size();
        for (int i = 0; i < szPreds; i++) {
            int iLabel = preds.get(i);

            BasicBlock iBlock = blocks.labelToBlock(iLabel);

            if (toDelete.get(iLabel)
                    || iBlock.getSuccessors().size() > 1
                    || iBlock.getFirstInsn().getOpcode().getOpcode() ==
                        RegOps.MOVE_RESULT) {
                continue;
            }

            IntList toCombine = new IntList();

            // ...and see if they can be combined with any other preds...
            for (int j = i + 1; j < szPreds; j++) {
                int jLabel = preds.get(j);
                BasicBlock jBlock = blocks.labelToBlock(jLabel);

                if (jBlock.getSuccessors().size() == 1
                        && compareInsns(iBlock, jBlock)) {

                    toCombine.add(jLabel);
                    toDelete.set(jLabel);
                }
            }

            combineBlocks(iLabel, toCombine);
        }
    }

    for (int i = szBlocks - 1; i >= 0; i--) {
        if (toDelete.get(newBlocks.get(i).getLabel())) {
            newBlocks.set(i, null);
        }
    }

    newBlocks.shrinkToFit();
    newBlocks.setImmutable();

    return new RopMethod(newBlocks, ropMethod.getFirstLabel());
}
 
Example 11
Source File: IdenticalBlockCombiner.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Runs algorithm. TODO: This is n^2, and could be made linear-ish with
 * a hash. In particular, hash the contents of each block and only
 * compare blocks with the same hash.
 *
 * @return {@code non-null;} new method that has been processed
 */
public RopMethod process() {
    int szBlocks = blocks.size();
    // indexed by label
    BitSet toDelete = new BitSet(blocks.getMaxLabel());

    // For each non-deleted block...
    for (int bindex = 0; bindex < szBlocks; bindex++) {
        BasicBlock b = blocks.get(bindex);

        if (toDelete.get(b.getLabel())) {
            // doomed block
            continue;
        }

        IntList preds = ropMethod.labelToPredecessors(b.getLabel());

        // ...look at all of it's predecessors that have only one succ...
        int szPreds = preds.size();
        for (int i = 0; i < szPreds; i++) {
            int iLabel = preds.get(i);

            BasicBlock iBlock = blocks.labelToBlock(iLabel);

            if (toDelete.get(iLabel)
                    || iBlock.getSuccessors().size() > 1
                    || iBlock.getFirstInsn().getOpcode().getOpcode() ==
                        RegOps.MOVE_RESULT) {
                continue;
            }

            IntList toCombine = new IntList();

            // ...and see if they can be combined with any other preds...
            for (int j = i + 1; j < szPreds; j++) {
                int jLabel = preds.get(j);
                BasicBlock jBlock = blocks.labelToBlock(jLabel);

                if (jBlock.getSuccessors().size() == 1
                        && compareInsns(iBlock, jBlock)) {

                    toCombine.add(jLabel);
                    toDelete.set(jLabel);
                }
            }

            combineBlocks(iLabel, toCombine);
        }
    }

    for (int i = szBlocks - 1; i >= 0; i--) {
        if (toDelete.get(newBlocks.get(i).getLabel())) {
            newBlocks.set(i, null);
        }
    }

    newBlocks.shrinkToFit();
    newBlocks.setImmutable();

    return new RopMethod(newBlocks, ropMethod.getFirstLabel());
}
 
Example 12
Source File: IdenticalBlockCombiner.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Runs algorithm. TODO: This is n^2, and could be made linear-ish with
 * a hash. In particular, hash the contents of each block and only
 * compare blocks with the same hash.
 *
 * @return {@code non-null;} new method that has been processed
 */
public RopMethod process() {
    int szBlocks = blocks.size();
    // indexed by label
    BitSet toDelete = new BitSet(blocks.getMaxLabel());

    // For each non-deleted block...
    for (int bindex = 0; bindex < szBlocks; bindex++) {
        BasicBlock b = blocks.get(bindex);

        if (toDelete.get(b.getLabel())) {
            // doomed block
            continue;
        }

        IntList preds = ropMethod.labelToPredecessors(b.getLabel());

        // ...look at all of it's predecessors that have only one succ...
        int szPreds = preds.size();
        for (int i = 0; i < szPreds; i++) {
            int iLabel = preds.get(i);

            BasicBlock iBlock = blocks.labelToBlock(iLabel);

            if (toDelete.get(iLabel)
                    || iBlock.getSuccessors().size() > 1
                    || iBlock.getFirstInsn().getOpcode().getOpcode() ==
                        RegOps.MOVE_RESULT) {
                continue;
            }

            IntList toCombine = new IntList();

            // ...and see if they can be combined with any other preds...
            for (int j = i + 1; j < szPreds; j++) {
                int jLabel = preds.get(j);
                BasicBlock jBlock = blocks.labelToBlock(jLabel);

                if (jBlock.getSuccessors().size() == 1
                        && compareInsns(iBlock, jBlock)) {

                    toCombine.add(jLabel);
                    toDelete.set(jLabel);
                }
            }

            combineBlocks(iLabel, toCombine);
        }
    }

    for (int i = szBlocks - 1; i >= 0; i--) {
        if (toDelete.get(newBlocks.get(i).getLabel())) {
            newBlocks.set(i, null);
        }
    }

    newBlocks.shrinkToFit();
    newBlocks.setImmutable();

    return new RopMethod(newBlocks, ropMethod.getFirstLabel());
}