Search in sources :

Example 1 with PhiInsn

use of com.android.dx.ssa.PhiInsn in project buck by facebook.

the class LivenessAnalyzer method run.

/**
     * From Appel algorithm 19.17.
     */
public void run() {
    List<SsaInsn> useList = ssaMeth.getUseListForRegister(regV);
    for (SsaInsn insn : useList) {
        nextFunction = NextFunction.DONE;
        if (insn instanceof PhiInsn) {
            // If s is a phi-function with V as it's ith argument.
            PhiInsn phi = (PhiInsn) insn;
            for (SsaBasicBlock pred : phi.predBlocksForReg(regV, ssaMeth)) {
                blockN = pred;
                nextFunction = NextFunction.LIVE_OUT_AT_BLOCK;
                handleTailRecursion();
            }
        } else {
            blockN = insn.getBlock();
            statementIndex = blockN.getInsns().indexOf(insn);
            if (statementIndex < 0) {
                throw new RuntimeException("insn not found in it's own block");
            }
            nextFunction = NextFunction.LIVE_IN_AT_STATEMENT;
            handleTailRecursion();
        }
    }
    int nextLiveOutBlock;
    while ((nextLiveOutBlock = liveOutBlocks.nextSetBit(0)) >= 0) {
        blockN = ssaMeth.getBlocks().get(nextLiveOutBlock);
        liveOutBlocks.clear(nextLiveOutBlock);
        nextFunction = NextFunction.LIVE_OUT_AT_BLOCK;
        handleTailRecursion();
    }
}
Also used : PhiInsn(com.android.dx.ssa.PhiInsn) SsaBasicBlock(com.android.dx.ssa.SsaBasicBlock) SsaInsn(com.android.dx.ssa.SsaInsn)

Example 2 with PhiInsn

use of com.android.dx.ssa.PhiInsn in project J2ME-Loader by nikita36078.

the class LivenessAnalyzer method run.

/**
 * From Appel algorithm 19.17.
 */
public void run() {
    List<SsaInsn> useList = ssaMeth.getUseListForRegister(regV);
    for (SsaInsn insn : useList) {
        nextFunction = NextFunction.DONE;
        if (insn instanceof PhiInsn) {
            // If s is a phi-function with V as it's ith argument.
            PhiInsn phi = (PhiInsn) insn;
            for (SsaBasicBlock pred : phi.predBlocksForReg(regV, ssaMeth)) {
                blockN = pred;
                nextFunction = NextFunction.LIVE_OUT_AT_BLOCK;
                handleTailRecursion();
            }
        } else {
            blockN = insn.getBlock();
            statementIndex = blockN.getInsns().indexOf(insn);
            if (statementIndex < 0) {
                throw new RuntimeException("insn not found in it's own block");
            }
            nextFunction = NextFunction.LIVE_IN_AT_STATEMENT;
            handleTailRecursion();
        }
    }
    int nextLiveOutBlock;
    while ((nextLiveOutBlock = liveOutBlocks.nextSetBit(0)) >= 0) {
        blockN = ssaMeth.getBlocks().get(nextLiveOutBlock);
        liveOutBlocks.clear(nextLiveOutBlock);
        nextFunction = NextFunction.LIVE_OUT_AT_BLOCK;
        handleTailRecursion();
    }
}
Also used : PhiInsn(com.android.dx.ssa.PhiInsn) SsaBasicBlock(com.android.dx.ssa.SsaBasicBlock) SsaInsn(com.android.dx.ssa.SsaInsn)

Aggregations

PhiInsn (com.android.dx.ssa.PhiInsn)2 SsaBasicBlock (com.android.dx.ssa.SsaBasicBlock)2 SsaInsn (com.android.dx.ssa.SsaInsn)2