当前位置: 首页>>代码示例>>Java>>正文


Java TranslationAdvice类代码示例

本文整理汇总了Java中com.android.dx.rop.code.TranslationAdvice的典型用法代码示例。如果您正苦于以下问题:Java TranslationAdvice类的具体用法?Java TranslationAdvice怎么用?Java TranslationAdvice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TranslationAdvice类属于com.android.dx.rop.code包,在下文中一共展示了TranslationAdvice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: optimize

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Runs optimization algorthims over this method, and returns a new
 * instance of RopMethod with the changes.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param inPreserveLocals true if local variable info should be preserved,
 * at the cost of some registers and insns
 * @param inAdvice {@code non-null;} translation advice
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
public static RopMethod optimize(RopMethod rmeth, int paramWidth,
        boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice, EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth = null;

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    ssaMeth = SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
    runSsaFormSteps(ssaMeth, steps);

    RopMethod resultMeth = SsaToRop.convertToRopMethod(ssaMeth, false);

    if (resultMeth.getBlocks().getRegCount()
            > advice.getMaxOptimalRegisterCount()) {
        // Try to see if we can squeeze it under the register count bar
        resultMeth = optimizeMinimizeRegisters(rmeth, paramWidth, isStatic,
                steps);
    }
    return resultMeth;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:36,代码来源:Optimizer.java

示例2: getCode

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Extracts the code block from the given method of the given class, or
 * <code>null</code>, if method is native or abstract.
 */
private static DalvCode getCode(Method method, DirectClassFile classFile) {
    boolean isNative = AccessFlags.isNative(method.getAccessFlags());
    boolean isStatic = AccessFlags.isStatic(method.getAccessFlags());
    boolean isAbstract = AccessFlags.isAbstract(method.getAccessFlags());

    if (isNative || isAbstract) {
        return null;
    }

    ConcreteMethod concrete = new ConcreteMethod(method, classFile, false, false);
    TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
    RopMethod rmeth = Ropper.convert(concrete, advice);
    CstMethodRef meth = new CstMethodRef(method.getDefiningClass(), method.getNat());
    int paramSize = meth.getParameterWordCount(isStatic);
    DalvCode code = RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize);
    DalvCode.AssignIndicesCallback callback = new DalvCode.AssignIndicesCallback() {
        public int getIndex(Constant cst) {
            // Everything is at index 0!
            return 0;
        }
    };
    code.assignIndices(callback);
    return code;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:JDKAnalyzer.java

示例3: optimize

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Runs optimization algorthims over this method, and returns a new
 * instance of RopMethod with the changes.
 *
 * @param rmeth method to process
 * @param paramWidth the total width, in register-units, of this method's
 * parameters
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param inPreserveLocals true if local variable info should be preserved,
 * at the cost of some registers and insns
 * @param inAdvice {@code non-null;} translation advice
 * @param steps set of optional optimization steps to run
 * @return optimized method
 */
public RopMethod optimize(RopMethod rmeth, int paramWidth,
        boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice, EnumSet<OptionalStep> steps) {
    SsaMethod ssaMeth = null;

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    ssaMeth = SsaConverter.convertToSsaMethod(this, rmeth, paramWidth, isStatic);
    runSsaFormSteps(ssaMeth, steps);

    RopMethod resultMeth = SsaToRop.convertToRopMethod(this, ssaMeth, false);

    if (resultMeth.getBlocks().getRegCount()
            > advice.getMaxOptimalRegisterCount()) {
        // Try to see if we can squeeze it under the register count bar
        resultMeth = optimizeMinimizeRegisters(rmeth, paramWidth, isStatic,
                steps);
    }
    return resultMeth;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:36,代码来源:Optimizer.java

示例4: compareOptimizerStep

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Compares the output of the optimizer run normally with a run skipping
 * some optional steps. Results are printed to stderr.
 *
 * @param nonOptRmeth {@code non-null;} origional rop method
 * @param paramSize {@code >= 0;} parameter size of method
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param args {@code non-null;} translator arguments
 * @param advice {@code non-null;} translation advice
 * @param rmeth {@code non-null;} method with all optimization steps run.
 */
public static void compareOptimizerStep(RopMethod nonOptRmeth,
        int paramSize, boolean isStatic, CfOptions args,
        TranslationAdvice advice, RopMethod rmeth) {
    EnumSet<Optimizer.OptionalStep> steps;

    steps = EnumSet.allOf(Optimizer.OptionalStep.class);

    // This is the step to skip.
    steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);

    RopMethod skipRopMethod
            = Optimizer.optimize(nonOptRmeth,
                    paramSize, isStatic, args.localInfo, advice, steps);

    int normalInsns
            = rmeth.getBlocks().getEffectiveInstructionCount();
    int skipInsns
            = skipRopMethod.getBlocks().getEffectiveInstructionCount();

    System.err.printf(
            "optimize step regs:(%d/%d/%.2f%%)"
            + " insns:(%d/%d/%.2f%%)\n",
            rmeth.getBlocks().getRegCount(),
            skipRopMethod.getBlocks().getRegCount(),
            100.0 * ((skipRopMethod.getBlocks().getRegCount()
                    - rmeth.getBlocks().getRegCount())
                    / (float) skipRopMethod.getBlocks().getRegCount()),
            normalInsns, skipInsns,
            100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:42,代码来源:OptimizerOptions.java

示例5: convert

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Converts a {@link ConcreteMethod} to a {@link RopMethod}.
 *
 * @param method {@code non-null;} method to convert
 * @param advice {@code non-null;} translation advice to use
 * @param methods {@code non-null;} list of methods defined by the class
 *     that defines {@code method}.
 * @return {@code non-null;} the converted instance
 */
public static RopMethod convert(ConcreteMethod method,
        TranslationAdvice advice, MethodList methods) {
    try {
        Ropper r = new Ropper(method, advice, methods);
        r.doit();
        return r.getRopMethod();
    } catch (SimException ex) {
        ex.addContext("...while working on method " +
                      method.getNat().toHuman());
        throw ex;
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:Ropper.java

示例6: Ropper

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #convert}.
 *
 * @param method {@code non-null;} method to convert
 * @param advice {@code non-null;} translation advice to use
 * @param methods {@code non-null;} list of methods defined by the class
 *     that defines {@code method}.
 */
private Ropper(ConcreteMethod method, TranslationAdvice advice, MethodList methods) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.method = method;
    this.blocks = BasicBlocker.identifyBlocks(method);
    this.maxLabel = blocks.getMaxLabel();
    this.maxLocals = method.getMaxLocals();
    this.machine = new RopperMachine(this, method, advice, methods);
    this.sim = new Simulator(machine, method);
    this.startFrames = new Frame[maxLabel];
    this.subroutines = new Subroutine[maxLabel];

    /*
     * The "* 2 + 10" below is to conservatively believe that every
     * block is an exception handler target and should also
     * take care of enough other possible extra overhead such that
     * the underlying array is unlikely to need resizing.
     */
    this.result = new ArrayList<BasicBlock>(blocks.size() * 2 + 10);
    this.resultSubroutines =
        new ArrayList<IntList>(blocks.size() * 2 + 10);

    this.catchInfos = new CatchInfo[maxLabel];
    this.synchNeedsExceptionHandler = false;

    /*
     * Set up the first stack frame with the right limits, but leave it
     * empty here (to be filled in outside of the constructor).
     */
    startFrames[0] = new Frame(maxLocals, method.getMaxStack());
    exceptionSetupLabelAllocator = new ExceptionSetupLabelAllocator();
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:48,代码来源:Ropper.java

示例7: RopperMachine

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param ropper {@code non-null;} ropper controlling this instance
 * @param method {@code non-null;} method being converted
 * @param advice {@code non-null;} translation advice to use
 * @param methods {@code non-null;} list of methods defined by the class
 *     that defines {@code method}.
 */
public RopperMachine(Ropper ropper, ConcreteMethod method,
        TranslationAdvice advice, MethodList methods) {
    super(method.getEffectiveDescriptor());

    if (methods == null) {
        throw new NullPointerException("methods == null");
    }

    if (ropper == null) {
        throw new NullPointerException("ropper == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.ropper = ropper;
    this.method = method;
    this.methods = methods;
    this.advice = advice;
    this.maxLocals = method.getMaxLocals();
    this.insns = new ArrayList<Insn>(25);
    this.catches = null;
    this.catchesUsed = false;
    this.returns = false;
    this.primarySuccessorIndex = -1;
    this.extraBlockCount = 0;
    this.blockCanThrow = false;
    this.returnOp = null;
    this.returnPosition = null;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:41,代码来源:RopperMachine.java

示例8: debugEdgeSplit

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
public static SsaMethod debugEdgeSplit(RopMethod rmeth, int paramWidth,
        boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice) {

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    return SsaConverter.testEdgeSplit(rmeth, paramWidth, isStatic);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:10,代码来源:Optimizer.java

示例9: debugPhiPlacement

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
public static SsaMethod debugPhiPlacement(RopMethod rmeth, int paramWidth,
        boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice) {

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    return SsaConverter.testPhiPlacement(rmeth, paramWidth, isStatic);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:10,代码来源:Optimizer.java

示例10: debugRenaming

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
public static SsaMethod debugRenaming(RopMethod rmeth, int paramWidth,
        boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice) {

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    return SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:10,代码来源:Optimizer.java

示例11: debugDeadCodeRemover

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
public static SsaMethod debugDeadCodeRemover(RopMethod rmeth,
        int paramWidth, boolean isStatic, boolean inPreserveLocals,
        TranslationAdvice inAdvice) {

    SsaMethod ssaMeth;

    preserveLocals = inPreserveLocals;
    advice = inAdvice;

    ssaMeth = SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
    DeadCodeRemover.process(ssaMeth);

    return ssaMeth;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:15,代码来源:Optimizer.java

示例12: RopperMachine

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param ropper {@code non-null;} ropper controlling this instance
 * @param method {@code non-null;} method being converted
 * @param advice {@code non-null;} translation advice to use
 */
public RopperMachine(Ropper ropper, ConcreteMethod method,
        TranslationAdvice advice) {
    super(method.getEffectiveDescriptor());

    if (ropper == null) {
        throw new NullPointerException("ropper == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.ropper = ropper;
    this.method = method;
    this.advice = advice;
    this.maxLocals = method.getMaxLocals();
    this.insns = new ArrayList<Insn>(25);
    this.catches = null;
    this.catchesUsed = false;
    this.returns = false;
    this.primarySuccessorIndex = -1;
    this.extraBlockCount = 0;
    this.blockCanThrow = false;
    this.returnOp = null;
    this.returnPosition = null;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:34,代码来源:RopperMachine.java

示例13: compareOptimizerStep

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Compares the output of the optimizer run normally with a run skipping
 * some optional steps. Results are printed to stderr.
 *
 * @param nonOptRmeth {@code non-null;} origional rop method
 * @param paramSize {@code >= 0;} parameter size of method
 * @param isStatic true if this method has no 'this' pointer argument.
 * @param args {@code non-null;} translator arguments
 * @param advice {@code non-null;} translation advice
 * @param rmeth {@code non-null;} method with all optimization steps run.
 */
public static void compareOptimizerStep(RopMethod nonOptRmeth,
        int paramSize, boolean isStatic, CfOptions args,
        TranslationAdvice advice, RopMethod rmeth) {
    EnumSet<Optimizer.OptionalStep> steps;

    steps = EnumSet.allOf(Optimizer.OptionalStep.class);

    // This is the step to skip.
    steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);

    RopMethod skipRopMethod
            = new Optimizer().optimize(nonOptRmeth,
                    paramSize, isStatic, args.localInfo, advice, steps);

    int normalInsns
            = rmeth.getBlocks().getEffectiveInstructionCount();
    int skipInsns
            = skipRopMethod.getBlocks().getEffectiveInstructionCount();

    System.err.printf(
            "optimize step regs:(%d/%d/%.2f%%)"
            + " insns:(%d/%d/%.2f%%)\n",
            rmeth.getBlocks().getRegCount(),
            skipRopMethod.getBlocks().getRegCount(),
            100.0 * ((skipRopMethod.getBlocks().getRegCount()
                    - rmeth.getBlocks().getRegCount())
                    / (float) skipRopMethod.getBlocks().getRegCount()),
            normalInsns, skipInsns,
            100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:42,代码来源:OptimizerOptions.java

示例14: convert

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Converts a {@link ConcreteMethod} to a {@link RopMethod}.
 *
 * @param method {@code non-null;} method to convert
 * @param advice {@code non-null;} translation advice to use
 * @return {@code non-null;} the converted instance
 */
public static RopMethod convert(ConcreteMethod method,
        TranslationAdvice advice) {
    try {
        Ropper r = new Ropper(method, advice);
        r.doit();
        return r.getRopMethod();
    } catch (SimException ex) {
        ex.addContext("...while working on method " +
                      method.getNat().toHuman());
        throw ex;
    }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:20,代码来源:Ropper.java

示例15: Ropper

import com.android.dx.rop.code.TranslationAdvice; //导入依赖的package包/类
/**
 * Constructs an instance. This class is not publicly instantiable; use
 * {@link #convert}.
 *
 * @param method {@code non-null;} method to convert
 * @param advice {@code non-null;} translation advice to use
 */
private Ropper(ConcreteMethod method, TranslationAdvice advice) {
    if (method == null) {
        throw new NullPointerException("method == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.method = method;
    this.blocks = BasicBlocker.identifyBlocks(method);
    this.maxLabel = blocks.getMaxLabel();
    this.maxLocals = method.getMaxLocals();
    this.machine = new RopperMachine(this, method, advice);
    this.sim = new Simulator(machine, method);
    this.startFrames = new Frame[maxLabel];
    this.subroutines = new Subroutine[maxLabel];

    /*
     * The "* 2 + 10" below is to conservatively believe that every
     * block is an exception handler target and should also
     * take care of enough other possible extra overhead such that
     * the underlying array is unlikely to need resizing.
     */
    this.result = new ArrayList<BasicBlock>(blocks.size() * 2 + 10);
    this.resultSubroutines =
        new ArrayList<IntList>(blocks.size() * 2 + 10);

    this.catchTypes = new Type[maxLabel];
    this.synchNeedsExceptionHandler = false;

    /*
     * Set up the first stack frame with the right limits, but leave it
     * empty here (to be filled in outside of the constructor).
     */
    startFrames[0] = new Frame(maxLocals, method.getMaxStack());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:45,代码来源:Ropper.java


注:本文中的com.android.dx.rop.code.TranslationAdvice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。