FileDocCategorySizeDatePackage
SsaDumper.javaAPI DocAndroid 1.5 API5598Wed May 06 22:41:02 BST 2009com.android.dx.command.dump

SsaDumper

public class SsaDumper extends BlockDumper

Fields Summary
Constructors Summary
SsaDumper(byte[] bytes, PrintStream out, String filePath, Args args)


        super(bytes, out, filePath, true, args);

    
Methods Summary
public static voiddump(byte[] bytes, java.io.PrintStream out, java.lang.String filePath, Args args)


        SsaDumper sd =
            new SsaDumper(bytes, out, filePath, args);
        sd.dump();
    
public voidendParsingMember(com.android.dx.util.ByteArray bytes, int offset, java.lang.String name, java.lang.String descriptor, com.android.dx.cf.iface.Member member)
{@inheritDoc}

        if (!(member instanceof Method)) {
            return;
        }

        if (!shouldDumpMethod(name)) {
            return;
        }

        ConcreteMethod meth = new ConcreteMethod((Method) member, classFile,
                                                 true, true);

        TranslationAdvice advice = DexTranslationAdvice.THE_ONE;

        RopMethod rmeth = Ropper.convert(meth, advice);

        SsaMethod ssaMeth = null;

        boolean isStatic = AccessFlags.isStatic(meth.getAccessFlags());
        int paramWidth = computeParamWidth(meth, isStatic);
        if (args.ssaStep == null) {
            ssaMeth = Optimizer.debugNoRegisterAllocation(rmeth,
                    paramWidth, isStatic, true, advice,
                    EnumSet.allOf(Optimizer.OptionalStep.class));
        } else if ("edge-split".equals(args.ssaStep)) {
            ssaMeth = Optimizer.debugEdgeSplit(rmeth, paramWidth,
                    isStatic, true, advice);
        } else if ("phi-placement".equals(args.ssaStep)) {
            ssaMeth = Optimizer.debugPhiPlacement(
                    rmeth, paramWidth, isStatic, true, advice);
        } else if ("renaming".equals(args.ssaStep)) {
            ssaMeth = Optimizer.debugRenaming(
                    rmeth, paramWidth, isStatic, true, advice);
        } else if ("dead-code".equals(args.ssaStep)) {
            ssaMeth = Optimizer.debugDeadCodeRemover(
                    rmeth, paramWidth, isStatic,true, advice);
        }

        StringBuffer sb = new StringBuffer(2000);

        sb.append("first ");
        sb.append(Hex.u2(
                ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())));
        sb.append('\n");
        
        for (SsaBasicBlock block : ssaMeth.getBlocks()) {
            sb.append("block ")
                    .append(Hex.u2(block.getRopLabel())).append('\n");

            BitSet preds = block.getPredecessors();

            for(int i=preds.nextSetBit(0); i>=0; i=preds.nextSetBit(i+1)) {
                sb.append ("  pred ");
                sb.append (Hex.u2(ssaMeth.blockIndexToRopLabel(i)));
                sb.append('\n");
            }

            sb.append ("  live in:" + block.getLiveInRegs());
            sb.append ("\n");

            for (SsaInsn insn: block.getInsns()) {
                sb.append("  ");
                sb.append(insn.toHuman());
                sb.append('\n");
            }

            if (block.getSuccessors().cardinality() == 0) {
                sb.append ("  returns\n");
            } else {
                int primary = block.getPrimarySuccessorRopLabel();

                IntList succLabelList = block.getRopLabelSuccessorList();

                int szSuccLabels = succLabelList.size();

                for (int i = 0; i < szSuccLabels; i++) {
                    sb.append ("  next ");
                    sb.append (Hex.u2(succLabelList.get(i)));

                    if (szSuccLabels != 1 && primary == succLabelList.get(i)) {
                        sb.append (" *");                        
                    }
                    sb.append('\n");
                }
            }

            sb.append ("  live out:" + block.getLiveOutRegs());
            sb.append ("\n");
        }

        suppressDump = false;
        setAt(bytes, 0);
        parsed(bytes, 0, bytes.size(), sb.toString());
        suppressDump = true;