diff options
| author | Dan Bornstein <danfuzz@android.com> | 2010-12-02 12:45:00 -0800 |
|---|---|---|
| committer | Dan Bornstein <danfuzz@android.com> | 2010-12-02 15:13:46 -0800 |
| commit | e485276c6ba778cafa373b3b5c867f84e91b0bfd (patch) | |
| tree | 9ac49d973c691964ff51f03e79a9d01f1e71d000 /libdex | |
| parent | 0c1af6d7e3176545b249338d782f886931948c86 (diff) | |
| download | android_dalvik-e485276c6ba778cafa373b3b5c867f84e91b0bfd.tar.gz android_dalvik-e485276c6ba778cafa373b3b5c867f84e91b0bfd.tar.bz2 android_dalvik-e485276c6ba778cafa373b3b5c867f84e91b0bfd.zip | |
Rename some instruction/opcode types and utilities.
A lot of this is more about properties of opcodes as opposed to
inspecting instructions per se, and the new naming attempts to
make it clear what is being queried and what sort of data is being
returned.
Change-Id: Ice6f9f2ebf4f1cfa8c99597419aa13d1134a33b2
Diffstat (limited to 'libdex')
| -rw-r--r-- | libdex/InstrUtils.c | 20 | ||||
| -rw-r--r-- | libdex/InstrUtils.h | 34 |
2 files changed, 27 insertions, 27 deletions
diff --git a/libdex/InstrUtils.c b/libdex/InstrUtils.c index 434c15123..055061779 100644 --- a/libdex/InstrUtils.c +++ b/libdex/InstrUtils.c @@ -30,7 +30,7 @@ * use that opcode, in (16-bit) code units. Unimplemented opcodes as * well as the "breakpoint" opcode have a width of zero. */ -static InstructionWidth gOpcodeWidthTable[kNumDalvikInstructions] = { +static InstructionWidth gInstructionWidthTable[kNumDalvikInstructions] = { // BEGIN(libdex-widths); GENERATED AUTOMATICALLY BY opcode-gen 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 3, 5, 2, 2, 3, 2, 1, 1, 2, @@ -320,7 +320,7 @@ static u1 gOpcodeFlagsTable[kNumDalvikInstructions] = { * Table that maps each opcode to the instruction format associated * that opcode. */ -static u1 gOpcodeFormatTable[kNumDalvikInstructions] = { +static u1 gInstructionFormatTable[kNumDalvikInstructions] = { // BEGIN(libdex-formats); GENERATED AUTOMATICALLY BY opcode-gen kFmt10x, kFmt12x, kFmt22x, kFmt32x, kFmt12x, kFmt22x, kFmt32x, kFmt12x, kFmt22x, kFmt32x, kFmt11x, kFmt11x, kFmt11x, kFmt11x, @@ -366,7 +366,7 @@ static u1 gOpcodeFormatTable[kNumDalvikInstructions] = { * Table that maps each opcode to the index type implied by that * opcode. */ -static u1 gOpcodeIndexTypeTable[kNumDalvikInstructions] = { +static u1 gInstructionIndexTypeTable[kNumDalvikInstructions] = { // BEGIN(libdex-index-types); GENERATED AUTOMATICALLY BY opcode-gen kIndexNone, kIndexNone, kIndexNone, kIndexNone, kIndexNone, kIndexNone, @@ -461,10 +461,10 @@ static u1 gOpcodeIndexTypeTable[kNumDalvikInstructions] = { * Global InstructionInfoTables struct. */ InstructionInfoTables gDexOpcodeInfo = { - gOpcodeFormatTable, - gOpcodeIndexTypeTable, + gInstructionFormatTable, + gInstructionIndexTypeTable, gOpcodeFlagsTable, - gOpcodeWidthTable + gInstructionWidthTable }; /* @@ -491,10 +491,10 @@ void dexDecodeInstruction(const u2* insns, DecodedInstruction* pDec) { u2 inst = *insns; Opcode opcode = dexOpcodeFromCodeUnit(inst); - InstructionFormat format = dexGetInstrFormat(opcode); + InstructionFormat format = dexGetFormatFromOpcode(opcode); pDec->opcode = opcode; - pDec->indexType = dexGetInstrIndexType(opcode); + pDec->indexType = dexGetIndexTypeFromOpcode(opcode); switch (format) { case kFmt10x: // op @@ -693,7 +693,7 @@ bail: * works for special OP_NOP entries, including switch statement data tables * and array data. */ -size_t dexGetInstrOrTableWidth(const u2* insns) +size_t dexGetWidthFromInstruction(const u2* insns) { size_t width; @@ -707,7 +707,7 @@ size_t dexGetInstrOrTableWidth(const u2* insns) // The plus 1 is to round up for odd size and width. width = 4 + (elemWidth * len + 1) / 2; } else { - width = dexGetInstrWidth(dexOpcodeFromCodeUnit(insns[0])); + width = dexGetWidthFromOpcode(dexOpcodeFromCodeUnit(insns[0])); } return width; diff --git a/libdex/InstrUtils.h b/libdex/InstrUtils.h index c6d81abf0..3cbc14623 100644 --- a/libdex/InstrUtils.h +++ b/libdex/InstrUtils.h @@ -72,7 +72,7 @@ typedef enum { * Types of indexed reference that are associated with opcodes whose * formats include such an indexed reference (e.g., 21c and 35c). */ -typedef enum InstructionIndexType { +typedef enum { kIndexUnknown = 0, kIndexNone, // has no index kIndexVaries, // "It depends." Used for throw-verification-error @@ -86,18 +86,18 @@ typedef enum InstructionIndexType { } InstructionIndexType; /* - * Instruction width implied by an opcode; a value in the range 0 to - * 5. Note that there are special "pseudo-instructions" which are used - * to encode switch and data tables, and these don't have a fixed width. - * See dexGetInstrOrTableWidth(), below. + * Instruction width implied by an opcode's format; a value in the + * range 0 to 5. Note that there are special "pseudo-instructions" + * which are used to encode switch and data tables, and these don't + * have a fixed width. See dexGetWidthFromInstruction(), below. */ typedef u1 InstructionWidth; /* * Opcode control flow flags, used by the verifier and JIT. */ -typedef u1 InstructionFlags; -enum InstructionFlagsBits { +typedef u1 OpcodeFlags; +enum OpcodeFlagsBits { kInstrCanBranch = 1, // conditional or unconditional branch kInstrCanContinue = 1 << 1, // flow can continue to next statement kInstrCanSwitch = 1 << 2, // switch statement @@ -117,9 +117,9 @@ enum InstructionFlagsBits { * suffice. */ typedef struct InstructionInfoTables { - u1* formats; /* InstructionFormat elements */ - u1* indexTypes; /* InstructionIndexType elements */ - InstructionFlags* flags; + u1* formats; /* InstructionFormat elements */ + u1* indexTypes; /* InstructionIndexType elements */ + OpcodeFlags* flags; InstructionWidth* widths; } InstructionInfoTables; @@ -142,9 +142,9 @@ typedef struct DecodedInstruction { } DecodedInstruction; /* - * Return the width of the specified instruction, or 0 if not defined. + * Return the instruction width of the specified opcode, or 0 if not defined. */ -DEX_INLINE size_t dexGetInstrWidth(Opcode opcode) +DEX_INLINE size_t dexGetWidthFromOpcode(Opcode opcode) { //assert(/*opcode >= 0 &&*/ opcode < kNumDalvikInstructions); return gDexOpcodeInfo.widths[opcode]; @@ -155,12 +155,12 @@ DEX_INLINE size_t dexGetInstrWidth(Opcode opcode) * works for special OP_NOP entries, including switch statement data tables * and array data. */ -size_t dexGetInstrOrTableWidth(const u2* insns); +size_t dexGetWidthFromInstruction(const u2* insns); /* * Returns the flags for the specified opcode. */ -DEX_INLINE InstructionFlags dexGetInstrFlags(Opcode opcode) +DEX_INLINE OpcodeFlags dexGetFlagsFromOpcode(Opcode opcode) { //assert(/*opcode >= 0 &&*/ opcode < kNumDalvikInstructions); return gDexOpcodeInfo.flags[opcode]; @@ -169,7 +169,7 @@ DEX_INLINE InstructionFlags dexGetInstrFlags(Opcode opcode) /* * Returns true if the given flags represent a goto (unconditional branch). */ -DEX_INLINE bool dexIsGoto(InstructionFlags flags) +DEX_INLINE bool dexIsGoto(OpcodeFlags flags) { return (flags & (kInstrCanBranch | kInstrCanContinue)) == kInstrCanBranch; } @@ -177,7 +177,7 @@ DEX_INLINE bool dexIsGoto(InstructionFlags flags) /* * Return the instruction format for the specified opcode. */ -DEX_INLINE InstructionFormat dexGetInstrFormat(Opcode opcode) +DEX_INLINE InstructionFormat dexGetFormatFromOpcode(Opcode opcode) { //assert(/*opcode >= 0 &&*/ opcode < kNumDalvikInstructions); return (InstructionFormat) gDexOpcodeInfo.formats[opcode]; @@ -186,7 +186,7 @@ DEX_INLINE InstructionFormat dexGetInstrFormat(Opcode opcode) /* * Return the instruction index type for the specified opcode. */ -DEX_INLINE InstructionIndexType dexGetInstrIndexType(Opcode opcode) +DEX_INLINE InstructionIndexType dexGetIndexTypeFromOpcode(Opcode opcode) { //assert(/*opcode >= 0 &&*/ opcode < kNumDalvikInstructions); return (InstructionIndexType) gDexOpcodeInfo.indexTypes[opcode]; |
