diff options
| author | Dan Bornstein <danfuzz@android.com> | 2010-12-01 12:30:21 -0800 |
|---|---|---|
| committer | Dan Bornstein <danfuzz@android.com> | 2010-12-01 12:47:45 -0800 |
| commit | 111221644c5b7b1d4f426d02786aeebf1addc8f6 (patch) | |
| tree | 31115dc6d484bd9b4877ed41e5ad3c5eb380605b /libdex/InstrUtils.c | |
| parent | fe9382b46660cb240a99efb7ac772db7b2f4ab21 (diff) | |
| download | android_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.tar.gz android_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.tar.bz2 android_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.zip | |
Add more "extended opcode" structure to libdex.
Although we don't yet generate any of the extended opcodes, this
change makes it a bit easier to add them.
In particular, we now differentiate between the raw opcode in a code
unit and an associated "packed opcode number." The packed opcode space
is densely populated in the range 0x000-0x1ff (though there will still
be a few unused slots), whereas the raw opcode values are sparse
throughout the range 0x0000-0xffff.
The OpCode enum is redefined/clarified to have packed, not sparse,
opcode values.
Change-Id: Ie3208a258648fbf044d344646f66c49ad24c31b2
Diffstat (limited to 'libdex/InstrUtils.c')
| -rw-r--r-- | libdex/InstrUtils.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libdex/InstrUtils.c b/libdex/InstrUtils.c index c194bc3b4..d0dea5f61 100644 --- a/libdex/InstrUtils.c +++ b/libdex/InstrUtils.c @@ -472,7 +472,6 @@ InstructionInfoTables gDexOpcodeInfo = { */ #define FETCH(_offset) (insns[(_offset)]) #define FETCH_u4(_offset) (fetch_u4_impl((_offset), insns)) -#define INST_INST(_inst) ((_inst) & 0xff) #define INST_A(_inst) (((u2)(_inst) >> 8) & 0x0f) #define INST_B(_inst) ((u2)(_inst) >> 12) #define INST_AA(_inst) ((_inst) >> 8) @@ -491,7 +490,7 @@ static inline u4 fetch_u4_impl(u4 offset, const u2* insns) { void dexDecodeInstruction(const u2* insns, DecodedInstruction* pDec) { u2 inst = *insns; - OpCode opCode = (OpCode) INST_INST(inst); + OpCode opCode = dexOpCodeFromCodeUnit(inst); InstructionFormat format = dexGetInstrFormat(opCode); pDec->opCode = opCode; @@ -705,9 +704,10 @@ size_t dexGetInstrOrTableWidth(const u2* insns) } else if (*insns == kArrayDataSignature) { u2 elemWidth = insns[1]; u4 len = insns[2] | (((u4)insns[3]) << 16); + // The plus 1 is to round up for odd size and width. width = 4 + (elemWidth * len + 1) / 2; } else { - width = dexGetInstrWidth(INST_INST(insns[0])); + width = dexGetInstrWidth(dexOpCodeFromCodeUnit(insns[0])); } return width; } |
