com.android.dx.rop.code.LocalVariableInfo Java Examples
The following examples show how to use
com.android.dx.rop.code.LocalVariableInfo.
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 buck with Apache License 2.0 | 5 votes |
/** * 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); }
Example #2
Source File: CfTranslator.java From Box with Apache License 2.0 | 5 votes |
/** * 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 dexmaker with Apache License 2.0 | 5 votes |
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 #4
Source File: CfTranslator.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * 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: CfTranslator.java From Box with Apache License 2.0 | 5 votes |
/** * 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 #6
Source File: DexMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 #7
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** * Constructs an instance. This method is private. Use {@link #translate}. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output */ private RopTranslator(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { this.dexOptions = dexOptions; this.method = method; this.positionInfo = positionInfo; this.locals = locals; this.addresses = new BlockAddresses(method); this.paramSize = paramSize; this.order = null; this.paramsAreInOrder = calculateParamsAreInOrder(method, paramSize); BasicBlockList blocks = method.getBlocks(); int bsz = blocks.size(); /* * Max possible instructions includes three code address * objects per basic block (to the first and last instruction, * and just past the end of the block), and the possibility of * an extra goto at the end of each basic block. */ int maxInsns = (bsz * 3) + blocks.getInstructionCount(); if (locals != null) { /* * If we're tracking locals, then there's could be another * extra instruction per block (for the locals state at the * start of the block) as well as one for each interblock * local introduction. */ maxInsns += bsz + locals.getAssignmentCount(); } /* * If params are not in order, we will need register space * for them before this is all over... */ this.regCount = blocks.getRegCount() + (paramsAreInOrder ? 0 : this.paramSize); this.output = new OutputCollector(dexOptions, maxInsns, bsz * 3, regCount, paramSize); if (locals != null) { this.translationVisitor = new LocalVariableAwareTranslationVisitor(output, locals); } else { this.translationVisitor = new TranslationVisitor(output); } }
Example #8
Source File: RopTranslator.java From buck with Apache License 2.0 | 4 votes |
/** * Constructs an instance. This method is private. Use {@link #translate}. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output */ private RopTranslator(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { this.dexOptions = dexOptions; this.method = method; this.positionInfo = positionInfo; this.locals = locals; this.addresses = new BlockAddresses(method); this.paramSize = paramSize; this.order = null; this.paramsAreInOrder = calculateParamsAreInOrder(method, paramSize); BasicBlockList blocks = method.getBlocks(); int bsz = blocks.size(); /* * Max possible instructions includes three code address * objects per basic block (to the first and last instruction, * and just past the end of the block), and the possibility of * an extra goto at the end of each basic block. */ int maxInsns = (bsz * 3) + blocks.getInstructionCount(); if (locals != null) { /* * If we're tracking locals, then there's could be another * extra instruction per block (for the locals state at the * start of the block) as well as one for each interblock * local introduction. */ maxInsns += bsz + locals.getAssignmentCount(); } /* * If params are not in order, we will need register space * for them before this is all over... */ this.regCount = blocks.getRegCount() + (paramsAreInOrder ? 0 : this.paramSize); this.output = new OutputCollector(dexOptions, maxInsns, bsz * 3, regCount, paramSize); if (locals != null) { this.translationVisitor = new LocalVariableAwareTranslationVisitor(output, locals); } else { this.translationVisitor = new TranslationVisitor(output); } }
Example #9
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** * Constructs an instance. This method is private. Use {@link #translate}. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output */ private RopTranslator(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { this.method = method; this.positionInfo = positionInfo; this.locals = locals; this.addresses = new BlockAddresses(method); this.paramSize = paramSize; this.order = null; this.paramsAreInOrder = calculateParamsAreInOrder(method, paramSize); BasicBlockList blocks = method.getBlocks(); int bsz = blocks.size(); /* * Max possible instructions includes three code address * objects per basic block (to the first and last instruction, * and just past the end of the block), and the possibility of * an extra goto at the end of each basic block. */ int maxInsns = (bsz * 3) + blocks.getInstructionCount(); if (locals != null) { /* * If we're tracking locals, then there's could be another * extra instruction per block (for the locals state at the * start of the block) as well as one for each interblock * local introduction. */ maxInsns += bsz + locals.getAssignmentCount(); } /* * If params are not in order, we will need register space * for them before this is all over... */ this.regCount = blocks.getRegCount() + (paramsAreInOrder ? 0 : this.paramSize); this.output = new OutputCollector(dexOptions, maxInsns, bsz * 3, regCount, paramSize); if (locals != null) { this.translationVisitor = new LocalVariableAwareTranslationVisitor(output, locals); } else { this.translationVisitor = new TranslationVisitor(output); } }
Example #10
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** * Constructs an instance. This method is private. Use {@link #translate}. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output */ private RopTranslator(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { this.dexOptions = dexOptions; this.method = method; this.positionInfo = positionInfo; this.locals = locals; this.addresses = new BlockAddresses(method); this.paramSize = paramSize; this.order = null; this.paramsAreInOrder = calculateParamsAreInOrder(method, paramSize); BasicBlockList blocks = method.getBlocks(); int bsz = blocks.size(); /* * Max possible instructions includes three code address * objects per basic block (to the first and last instruction, * and just past the end of the block), and the possibility of * an extra goto at the end of each basic block. */ int maxInsns = (bsz * 3) + blocks.getInstructionCount(); if (locals != null) { /* * If we're tracking locals, then there's could be another * extra instruction per block (for the locals state at the * start of the block) as well as one for each interblock * local introduction. */ maxInsns += bsz + locals.getAssignmentCount(); } /* * If params are not in order, we will need register space * for them before this is all over... */ this.regCount = blocks.getRegCount() + (paramsAreInOrder ? 0 : this.paramSize); this.output = new OutputCollector(dexOptions, maxInsns, bsz * 3, regCount, paramSize); if (locals != null) { this.translationVisitor = new LocalVariableAwareTranslationVisitor(output, locals); } else { this.translationVisitor = new TranslationVisitor(output); } }
Example #11
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 3 votes |
/** * Translates a {@link RopMethod}. This may modify the given * input. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output * @return {@code non-null;} the translated version */ public static DalvCode translate(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { RopTranslator translator = new RopTranslator(method, positionInfo, locals, paramSize, dexOptions); return translator.translateAndGetResult(); }
Example #12
Source File: RopTranslator.java From Box with Apache License 2.0 | 3 votes |
/** * Translates a {@link RopMethod}. This may modify the given * input. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output * @return {@code non-null;} the translated version */ public static DalvCode translate(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { RopTranslator translator = new RopTranslator(method, positionInfo, locals, paramSize, dexOptions); return translator.translateAndGetResult(); }
Example #13
Source File: RopTranslator.java From buck with Apache License 2.0 | 3 votes |
/** * Translates a {@link RopMethod}. This may modify the given * input. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output * @return {@code non-null;} the translated version */ public static DalvCode translate(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { RopTranslator translator = new RopTranslator(method, positionInfo, locals, paramSize, dexOptions); return translator.translateAndGetResult(); }
Example #14
Source File: RopTranslator.java From Box with Apache License 2.0 | 3 votes |
/** * Translates a {@link RopMethod}. This may modify the given * input. * * @param method {@code non-null;} the original method * @param positionInfo how much position info to preserve; one of the * static constants in {@link PositionList} * @param locals {@code null-ok;} local variable information to use * @param paramSize size, in register units, of all the parameters to * this method * @param dexOptions {@code non-null;} options for dex output * @return {@code non-null;} the translated version */ public static DalvCode translate(RopMethod method, int positionInfo, LocalVariableInfo locals, int paramSize, DexOptions dexOptions) { RopTranslator translator = new RopTranslator(method, positionInfo, locals, paramSize, dexOptions); return translator.translateAndGetResult(); }
Example #15
Source File: RopTranslator.java From Box with Apache License 2.0 | 2 votes |
/** * Constructs an instance. * * @param output {@code non-null;} destination for instruction output * @param locals {@code non-null;} the local variable info */ public LocalVariableAwareTranslationVisitor(OutputCollector output, LocalVariableInfo locals) { super(output); this.locals = locals; }
Example #16
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 2 votes |
/** * Constructs an instance. * * @param output {@code non-null;} destination for instruction output * @param locals {@code non-null;} the local variable info */ public LocalVariableAwareTranslationVisitor(OutputCollector output, LocalVariableInfo locals) { super(output); this.locals = locals; }
Example #17
Source File: RopTranslator.java From Box with Apache License 2.0 | 2 votes |
/** * Constructs an instance. * * @param output {@code non-null;} destination for instruction output * @param locals {@code non-null;} the local variable info */ public LocalVariableAwareTranslationVisitor(OutputCollector output, LocalVariableInfo locals) { super(output); this.locals = locals; }
Example #18
Source File: RopTranslator.java From buck with Apache License 2.0 | 2 votes |
/** * Constructs an instance. * * @param output {@code non-null;} destination for instruction output * @param locals {@code non-null;} the local variable info */ public LocalVariableAwareTranslationVisitor(OutputCollector output, LocalVariableInfo locals) { super(output); this.locals = locals; }