com.android.dx.dex.code.RopTranslator Java Examples

The following examples show how to use com.android.dx.dex.code.RopTranslator. 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: CfTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper that updates the dex statistics.
 */
private static void updateDexStatistics(DxContext context, CfOptions cfOptions, DexOptions dexOptions,
        RopMethod optRmeth, RopMethod nonOptRmeth,
        LocalVariableInfo locals, int paramSize, int originalByteCount) {
    /*
     * Run rop->dex again on optimized vs. non-optimized method to
     * collect statistics. We have to totally convert both ways,
     * since converting the "real" method getting added to the
     * file would corrupt it (by messing with its constant pool
     * indices).
     */

    DalvCode optCode = RopTranslator.translate(optRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);
    DalvCode nonOptCode = RopTranslator.translate(nonOptRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);

    /*
     * Fake out the indices, so code.getInsns() can work well enough
     * for the current purpose.
     */

    DalvCode.AssignIndicesCallback callback =
        new DalvCode.AssignIndicesCallback() {
            @Override
            public int getIndex(Constant cst) {
                // Everything is at index 0!
                return 0;
            }
        };

    optCode.assignIndices(callback);
    nonOptCode.assignIndices(callback);

    context.codeStatistics.updateDexStatistics(nonOptCode, optCode);
    context.codeStatistics.updateOriginalByteCount(originalByteCount);
}
 
Example #2
Source File: CfTranslator.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper that updates the dex statistics.
 */
private static void updateDexStatistics(DxContext context, CfOptions cfOptions, DexOptions dexOptions,
        RopMethod optRmeth, RopMethod nonOptRmeth,
        LocalVariableInfo locals, int paramSize, int originalByteCount) {
    /*
     * Run rop->dex again on optimized vs. non-optimized method to
     * collect statistics. We have to totally convert both ways,
     * since converting the "real" method getting added to the
     * file would corrupt it (by messing with its constant pool
     * indices).
     */

    DalvCode optCode = RopTranslator.translate(optRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);
    DalvCode nonOptCode = RopTranslator.translate(nonOptRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);

    /*
     * Fake out the indices, so code.getInsns() can work well enough
     * for the current purpose.
     */

    DalvCode.AssignIndicesCallback callback =
        new DalvCode.AssignIndicesCallback() {
            @Override
            public int getIndex(Constant cst) {
                // Everything is at index 0!
                return 0;
            }
        };

    optCode.assignIndices(callback);
    nonOptCode.assignIndices(callback);

    context.codeStatistics.updateDexStatistics(nonOptCode, optCode);
    context.codeStatistics.updateOriginalByteCount(originalByteCount);
}
 
Example #3
Source File: DexMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
EncodedMethod toEncodedMethod(DexOptions dexOptions) {
    if (code != null) {
        RopMethod ropMethod = new RopMethod(code.toBasicBlocks(), 0);
        LocalVariableInfo locals = null;
        DalvCode dalvCode = RopTranslator.translate(
                ropMethod, PositionList.NONE, locals, code.paramSize(), dexOptions);
        return new EncodedMethod(method.constant, flags, dalvCode, StdTypeList.EMPTY);
    } else return new EncodedMethod(method.constant, flags, null, StdTypeList.EMPTY);

}
 
Example #4
Source File: CfTranslator.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper that updates the dex statistics.
 */
private static void updateDexStatistics(DxContext context, CfOptions cfOptions, DexOptions dexOptions,
        RopMethod optRmeth, RopMethod nonOptRmeth,
        LocalVariableInfo locals, int paramSize, int originalByteCount) {
    /*
     * Run rop->dex again on optimized vs. non-optimized method to
     * collect statistics. We have to totally convert both ways,
     * since converting the "real" method getting added to the
     * file would corrupt it (by messing with its constant pool
     * indices).
     */

    DalvCode optCode = RopTranslator.translate(optRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);
    DalvCode nonOptCode = RopTranslator.translate(nonOptRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);

    /*
     * Fake out the indices, so code.getInsns() can work well enough
     * for the current purpose.
     */

    DalvCode.AssignIndicesCallback callback =
        new DalvCode.AssignIndicesCallback() {
            @Override
public int getIndex(Constant cst) {
                // Everything is at index 0!
                return 0;
            }
        };

    optCode.assignIndices(callback);
    nonOptCode.assignIndices(callback);

    context.codeStatistics.updateDexStatistics(nonOptCode, optCode);
    context.codeStatistics.updateOriginalByteCount(originalByteCount);
}
 
Example #5
Source File: DexMaker.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
EncodedMethod toEncodedMethod(DexOptions dexOptions) {
    if((flags & ABSTRACT) != 0 || (flags & NATIVE) != 0){
        return new EncodedMethod(method.constant, flags, null, StdTypeList.EMPTY);
    }

    RopMethod ropMethod = new RopMethod(code.toBasicBlocks(), 0);
    LocalVariableInfo locals = null;
    DalvCode dalvCode = RopTranslator.translate(
            ropMethod, PositionList.NONE, locals, code.paramSize(), dexOptions);
    return new EncodedMethod(method.constant, flags, dalvCode, StdTypeList.EMPTY);
}
 
Example #6
Source File: CfTranslator.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Helper that updates the dex statistics.
 */
private static void updateDexStatistics(DxContext context, CfOptions cfOptions, DexOptions dexOptions,
                                        RopMethod optRmeth, RopMethod nonOptRmeth,
                                        LocalVariableInfo locals, int paramSize, int originalByteCount) {
    /*
     * Run rop->dex again on optimized vs. non-optimized method to
     * collect statistics. We have to totally convert both ways,
     * since converting the "real" method getting added to the
     * file would corrupt it (by messing with its constant pool
     * indices).
     */

    DalvCode optCode = RopTranslator.translate(optRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);
    DalvCode nonOptCode = RopTranslator.translate(nonOptRmeth,
            cfOptions.positionInfo, locals, paramSize, dexOptions);

    /*
     * Fake out the indices, so code.getInsns() can work well enough
     * for the current purpose.
     */

    DalvCode.AssignIndicesCallback callback =
        new DalvCode.AssignIndicesCallback() {
            public int getIndex(Constant cst) {
                // Everything is at index 0!
                return 0;
            }
        };

    optCode.assignIndices(callback);
    nonOptCode.assignIndices(callback);

    context.codeStatistics.updateDexStatistics(nonOptCode, optCode);
    context.codeStatistics.updateOriginalByteCount(originalByteCount);
}