com.android.dx.dex.code.DalvCode Java Examples
The following examples show how to use
com.android.dx.dex.code.DalvCode.
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: CodeStatistics.java From Box with Apache License 2.0 | 6 votes |
/** * Updates the dex statistics. * * @param nonOptCode non-optimized code block * @param code optimized code block */ public void updateDexStatistics(DalvCode nonOptCode, DalvCode code) { if (DEBUG) { System.err.println("dex insns (old/new) " + nonOptCode.getInsns().codeSize() + "/" + code.getInsns().codeSize() + " regs (o/n) " + nonOptCode.getInsns().getRegistersSize() + "/" + code.getInsns().getRegistersSize() ); } dexRunningDeltaInsns += (code.getInsns().codeSize() - nonOptCode.getInsns().codeSize()); dexRunningDeltaRegisters += (code.getInsns().getRegistersSize() - nonOptCode.getInsns().getRegistersSize()); dexRunningTotalInsns += code.getInsns().codeSize(); }
Example #2
Source File: CodeItem.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param ref {@code non-null;} method that this code implements * @param code {@code non-null;} the underlying code * @param isStatic whether this instance is for a {@code static} * method * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public CodeItem(CstMethodRef ref, DalvCode code, boolean isStatic, TypeList throwsList) { super(ALIGNMENT, -1); if (ref == null) { throw new NullPointerException("ref == null"); } if (code == null) { throw new NullPointerException("code == null"); } if (throwsList == null) { throw new NullPointerException("throwsList == null"); } this.ref = ref; this.code = code; this.isStatic = isStatic; this.throwsList = throwsList; this.catches = null; this.debugInfo = null; }
Example #3
Source File: EncodedMethod.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param method {@code non-null;} constant for the method * @param accessFlags access flags * @param code {@code null-ok;} code for the method, if it is neither * {@code abstract} nor {@code native} * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public EncodedMethod(CstMethodRef method, int accessFlags, DalvCode code, TypeList throwsList) { super(accessFlags); if (method == null) { throw new NullPointerException("method == null"); } this.method = method; if (code == null) { this.code = null; } else { boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0; this.code = new CodeItem(method, code, isStatic, throwsList); } }
Example #4
Source File: DebugInfoDecoder.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Validates an encoded debug info stream against data used to encode it, * throwing an exception if they do not match. Used to validate the * encoder. * * @param info encoded debug info * @param file {@code non-null;} file to refer to during decoding * @param ref {@code non-null;} method whose info is being decoded * @param code {@code non-null;} original code object that was encoded * @param isStatic whether the method is static */ public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) { PositionList pl = code.getPositions(); LocalList ll = code.getLocals(); DalvInsnList insns = code.getInsns(); int codeSize = insns.codeSize(); int countRegisters = insns.getRegistersSize(); try { validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll); } catch (RuntimeException ex) { System.err.println("instructions:"); insns.debugPrint(System.err, " ", true); System.err.println("local list:"); ll.debugPrint(System.err, " "); throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman()); } }
Example #5
Source File: CodeStatistics.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Updates the dex statistics. * * @param nonOptCode non-optimized code block * @param code optimized code block */ public void updateDexStatistics(DalvCode nonOptCode, DalvCode code) { if (DEBUG) { System.err.println("dex insns (old/new) " + nonOptCode.getInsns().codeSize() + "/" + code.getInsns().codeSize() + " regs (o/n) " + nonOptCode.getInsns().getRegistersSize() + "/" + code.getInsns().getRegistersSize() ); } dexRunningDeltaInsns += (code.getInsns().codeSize() - nonOptCode.getInsns().codeSize()); dexRunningDeltaRegisters += (code.getInsns().getRegistersSize() - nonOptCode.getInsns().getRegistersSize()); dexRunningTotalInsns += code.getInsns().codeSize(); }
Example #6
Source File: CodeStatistics.java From buck with Apache License 2.0 | 6 votes |
/** * Updates the dex statistics. * * @param nonOptCode non-optimized code block * @param code optimized code block */ public void updateDexStatistics(DalvCode nonOptCode, DalvCode code) { if (DEBUG) { System.err.println("dex insns (old/new) " + nonOptCode.getInsns().codeSize() + "/" + code.getInsns().codeSize() + " regs (o/n) " + nonOptCode.getInsns().getRegistersSize() + "/" + code.getInsns().getRegistersSize() ); } dexRunningDeltaInsns += (code.getInsns().codeSize() - nonOptCode.getInsns().codeSize()); dexRunningDeltaRegisters += (code.getInsns().getRegistersSize() - nonOptCode.getInsns().getRegistersSize()); dexRunningTotalInsns += code.getInsns().codeSize(); }
Example #7
Source File: DebugInfoDecoder.java From buck with Apache License 2.0 | 6 votes |
/** * Validates an encoded debug info stream against data used to encode it, * throwing an exception if they do not match. Used to validate the * encoder. * * @param info encoded debug info * @param file {@code non-null;} file to refer to during decoding * @param ref {@code non-null;} method whose info is being decoded * @param code {@code non-null;} original code object that was encoded * @param isStatic whether the method is static */ public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) { PositionList pl = code.getPositions(); LocalList ll = code.getLocals(); DalvInsnList insns = code.getInsns(); int codeSize = insns.codeSize(); int countRegisters = insns.getRegistersSize(); try { validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll); } catch (RuntimeException ex) { System.err.println("instructions:"); insns.debugPrint(System.err, " ", true); System.err.println("local list:"); ll.debugPrint(System.err, " "); throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman()); } }
Example #8
Source File: CodeItem.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param ref {@code non-null;} method that this code implements * @param code {@code non-null;} the underlying code * @param isStatic whether this instance is for a {@code static} * method * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public CodeItem(CstMethodRef ref, DalvCode code, boolean isStatic, TypeList throwsList) { super(ALIGNMENT, -1); if (ref == null) { throw new NullPointerException("ref == null"); } if (code == null) { throw new NullPointerException("code == null"); } if (throwsList == null) { throw new NullPointerException("throwsList == null"); } this.ref = ref; this.code = code; this.isStatic = isStatic; this.throwsList = throwsList; this.catches = null; this.debugInfo = null; }
Example #9
Source File: EncodedMethod.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param method {@code non-null;} constant for the method * @param accessFlags access flags * @param code {@code null-ok;} code for the method, if it is neither * {@code abstract} nor {@code native} * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public EncodedMethod(CstMethodRef method, int accessFlags, DalvCode code, TypeList throwsList) { super(accessFlags); if (method == null) { throw new NullPointerException("method == null"); } this.method = method; if (code == null) { this.code = null; } else { boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0; this.code = new CodeItem(method, code, isStatic, throwsList); } }
Example #10
Source File: DebugInfoDecoder.java From Box with Apache License 2.0 | 6 votes |
/** * Validates an encoded debug info stream against data used to encode it, * throwing an exception if they do not match. Used to validate the * encoder. * * @param info encoded debug info * @param file {@code non-null;} file to refer to during decoding * @param ref {@code non-null;} method whose info is being decoded * @param code {@code non-null;} original code object that was encoded * @param isStatic whether the method is static */ public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) { PositionList pl = code.getPositions(); LocalList ll = code.getLocals(); DalvInsnList insns = code.getInsns(); int codeSize = insns.codeSize(); int countRegisters = insns.getRegistersSize(); try { validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll); } catch (RuntimeException ex) { System.err.println("instructions:"); insns.debugPrint(System.err, " ", true); System.err.println("local list:"); ll.debugPrint(System.err, " "); throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman()); } }
Example #11
Source File: EncodedMethod.java From buck with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param method {@code non-null;} constant for the method * @param accessFlags access flags * @param code {@code null-ok;} code for the method, if it is neither * {@code abstract} nor {@code native} * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public EncodedMethod(CstMethodRef method, int accessFlags, DalvCode code, TypeList throwsList) { super(accessFlags); if (method == null) { throw new NullPointerException("method == null"); } this.method = method; if (code == null) { this.code = null; } else { boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0; this.code = new CodeItem(method, code, isStatic, throwsList); } }
Example #12
Source File: CodeStatistics.java From Box with Apache License 2.0 | 6 votes |
/** * Updates the dex statistics. * * @param nonOptCode non-optimized code block * @param code optimized code block */ public void updateDexStatistics(DalvCode nonOptCode, DalvCode code) { if (DEBUG) { System.err.println("dex insns (old/new) " + nonOptCode.getInsns().codeSize() + "/" + code.getInsns().codeSize() + " regs (o/n) " + nonOptCode.getInsns().getRegistersSize() + "/" + code.getInsns().getRegistersSize() ); } dexRunningDeltaInsns += (code.getInsns().codeSize() - nonOptCode.getInsns().codeSize()); dexRunningDeltaRegisters += (code.getInsns().getRegistersSize() - nonOptCode.getInsns().getRegistersSize()); dexRunningTotalInsns += code.getInsns().codeSize(); }
Example #13
Source File: CodeItem.java From buck with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param ref {@code non-null;} method that this code implements * @param code {@code non-null;} the underlying code * @param isStatic whether this instance is for a {@code static} * method * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public CodeItem(CstMethodRef ref, DalvCode code, boolean isStatic, TypeList throwsList) { super(ALIGNMENT, -1); if (ref == null) { throw new NullPointerException("ref == null"); } if (code == null) { throw new NullPointerException("code == null"); } if (throwsList == null) { throw new NullPointerException("throwsList == null"); } this.ref = ref; this.code = code; this.isStatic = isStatic; this.throwsList = throwsList; this.catches = null; this.debugInfo = null; }
Example #14
Source File: CodeItem.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param ref {@code non-null;} method that this code implements * @param code {@code non-null;} the underlying code * @param isStatic whether this instance is for a {@code static} * method * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public CodeItem(CstMethodRef ref, DalvCode code, boolean isStatic, TypeList throwsList) { super(ALIGNMENT, -1); if (ref == null) { throw new NullPointerException("ref == null"); } if (code == null) { throw new NullPointerException("code == null"); } if (throwsList == null) { throw new NullPointerException("throwsList == null"); } this.ref = ref; this.code = code; this.isStatic = isStatic; this.throwsList = throwsList; this.catches = null; this.debugInfo = null; }
Example #15
Source File: EncodedMethod.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param method {@code non-null;} constant for the method * @param accessFlags access flags * @param code {@code null-ok;} code for the method, if it is neither * {@code abstract} nor {@code native} * @param throwsList {@code non-null;} list of possibly-thrown exceptions, * just used in generating debugging output (listings) */ public EncodedMethod(CstMethodRef method, int accessFlags, DalvCode code, TypeList throwsList) { super(accessFlags); if (method == null) { throw new NullPointerException("method == null"); } this.method = method; if (code == null) { this.code = null; } else { boolean isStatic = (accessFlags & AccessFlags.ACC_STATIC) != 0; this.code = new CodeItem(method, code, isStatic, throwsList); } }
Example #16
Source File: DebugInfoDecoder.java From Box with Apache License 2.0 | 6 votes |
/** * Validates an encoded debug info stream against data used to encode it, * throwing an exception if they do not match. Used to validate the * encoder. * * @param info encoded debug info * @param file {@code non-null;} file to refer to during decoding * @param ref {@code non-null;} method whose info is being decoded * @param code {@code non-null;} original code object that was encoded * @param isStatic whether the method is static */ public static void validateEncode(byte[] info, DexFile file, CstMethodRef ref, DalvCode code, boolean isStatic) { PositionList pl = code.getPositions(); LocalList ll = code.getLocals(); DalvInsnList insns = code.getInsns(); int codeSize = insns.codeSize(); int countRegisters = insns.getRegistersSize(); try { validateEncode0(info, codeSize, countRegisters, isStatic, ref, file, pl, ll); } catch (RuntimeException ex) { System.err.println("instructions:"); insns.debugPrint(System.err, " ", true); System.err.println("local list:"); ll.debugPrint(System.err, " "); throw ExceptionWithContext.withContext(ex, "while processing " + ref.toHuman()); } }
Example #17
Source File: CodeItem.java From buck with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { final DexFile file = addedTo.getFile(); int catchesSize; /* * In order to get the catches and insns, all the code's * constants need to be assigned indices. */ code.assignIndices(new DalvCode.AssignIndicesCallback() { public int getIndex(Constant cst) { IndexedItem item = file.findItemOrNull(cst); if (item == null) { return -1; } return item.getIndex(); } }); if (catches != null) { catches.encode(file); catchesSize = catches.writeSize(); } else { catchesSize = 0; } /* * The write size includes the header, two bytes per code * unit, post-code padding if necessary, and however much * space the catches need. */ int insnsSize = code.getInsns().codeSize(); if ((insnsSize & 1) != 0) { insnsSize++; } setWriteSize(HEADER_SIZE + (insnsSize * 2) + catchesSize); }
Example #18
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 #19
Source File: CatchStructs.java From buck with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param code {@code non-null;} code that contains the catches */ public CatchStructs(DalvCode code) { this.code = code; this.table = null; this.encodedHandlers = null; this.encodedHandlerHeaderSize = 0; this.handlerOffsets = null; }
Example #20
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 #21
Source File: DebugInfoItem.java From J2ME-Loader with Apache License 2.0 | 5 votes |
public DebugInfoItem(DalvCode code, boolean isStatic, CstMethodRef ref) { // We don't know the write size yet. super (ALIGNMENT, -1); if (code == null) { throw new NullPointerException("code == null"); } this.code = code; this.isStatic = isStatic; this.ref = ref; }
Example #22
Source File: DebugInfoItem.java From buck with Apache License 2.0 | 5 votes |
public DebugInfoItem(DalvCode code, boolean isStatic, CstMethodRef ref) { // We don't know the write size yet. super (ALIGNMENT, -1); if (code == null) { throw new NullPointerException("code == null"); } this.code = code; this.isStatic = isStatic; this.ref = ref; }
Example #23
Source File: CatchStructs.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param code {@code non-null;} code that contains the catches */ public CatchStructs(DalvCode code) { this.code = code; this.table = null; this.encodedHandlers = null; this.encodedHandlerHeaderSize = 0; this.handlerOffsets = null; }
Example #24
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 #25
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 #26
Source File: DebugInfoItem.java From Box with Apache License 2.0 | 5 votes |
public DebugInfoItem(DalvCode code, boolean isStatic, CstMethodRef ref) { // We don't know the write size yet. super (ALIGNMENT, -1); if (code == null) { throw new NullPointerException("code == null"); } this.code = code; this.isStatic = isStatic; this.ref = ref; }
Example #27
Source File: CatchStructs.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param code {@code non-null;} code that contains the catches */ public CatchStructs(DalvCode code) { this.code = code; this.table = null; this.encodedHandlers = null; this.encodedHandlerHeaderSize = 0; this.handlerOffsets = null; }
Example #28
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 #29
Source File: DebugInfoItem.java From Box with Apache License 2.0 | 5 votes |
public DebugInfoItem(DalvCode code, boolean isStatic, CstMethodRef ref) { // We don't know the write size yet. super (ALIGNMENT, -1); if (code == null) { throw new NullPointerException("code == null"); } this.code = code; this.isStatic = isStatic; this.ref = ref; }
Example #30
Source File: CatchStructs.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param code {@code non-null;} code that contains the catches */ public CatchStructs(DalvCode code) { this.code = code; this.table = null; this.encodedHandlers = null; this.encodedHandlerHeaderSize = 0; this.handlerOffsets = null; }