u4 width;
/* TODO: Make the index *always* be in field B, to simplify this code. */
- switch (dexGetInstrFormat(pDecInsn->opcode)) {
+ switch (dexGetFormatFromOpcode(pDecInsn->opcode)) {
case kFmt20bc:
case kFmt21c:
case kFmt35c:
indexBufChars, sizeof(indexBufChars));
}
- switch (dexGetInstrFormat(pDecInsn->opcode)) {
+ switch (dexGetFormatFromOpcode(pDecInsn->opcode)) {
case kFmt10x: // op
break;
case kFmt12x: // op vA, vB
/*
* Note: This code parallels the function
- * dexGetInstrOrTableWidth() in InstrUtils.c, but this version
+ * dexGetWidthFromInstruction() in InstrUtils.c, but this version
* can deal with data in either endianness.
*
* TODO: Figure out if this really matters, and possibly change
- * this to just use dexGetInstrOrTableWidth().
+ * this to just use dexGetWidthFromInstruction().
*/
instr = get2LE((const u1*)insns);
if (instr == kPackedSwitchSignature) {
insnWidth = 4 + ((size * width) + 1) / 2;
} else {
Opcode opcode = dexOpcodeFromCodeUnit(instr);
- insnWidth = dexGetInstrWidth(opcode);
+ insnWidth = dexGetWidthFromOpcode(opcode);
if (insnWidth == 0) {
fprintf(stderr,
"GLITCH: zero-width instruction at idx=0x%04x\n", insnIdx);
* 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,
* 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,
* 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,
* Global InstructionInfoTables struct.
*/
InstructionInfoTables gDexOpcodeInfo = {
- gOpcodeFormatTable,
- gOpcodeIndexTypeTable,
+ gInstructionFormatTable,
+ gInstructionIndexTypeTable,
gOpcodeFlagsTable,
- gOpcodeWidthTable
+ gInstructionWidthTable
};
/*
{
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
* 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;
// 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;
* 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
} 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
* 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;
} 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];
* 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];
/*
* 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;
}
/*
* 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];
/*
* 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];
* We can also return, in which case there is no successor instruction
* from this point.
*
- * The behavior can be determined from the InstructionFlags.
+ * The behavior can be determined from the OpcodeFlags.
*/
RegisterLine* workLine = ®Table->workLine;
#endif
dexDecodeInstruction(insns, &decInsn);
- int nextFlags = dexGetInstrFlags(decInsn.opcode);
+ int nextFlags = dexGetFlagsFromOpcode(decInsn.opcode);
/*
* Make a copy of the previous register state. If the instruction
int i;
for (i = 0; i < (int) insnCount; /**/) {
- size_t width = dexGetInstrOrTableWidth(insns);
+ size_t width = dexGetWidthFromInstruction(insns);
if (width == 0) {
LOG_VFY_METH(meth, "VFY: invalid instruction (0x%04x)\n", *insns);
goto bail;
const int kGcMask = kInstrCanBranch | kInstrCanSwitch |
kInstrCanThrow | kInstrCanReturn;
- InstructionFlags opFlags = dexGetInstrFlags(decInsn.opcode);
+ OpcodeFlags opFlags = dexGetFlagsFromOpcode(decInsn.opcode);
if ((opFlags & kGcMask) != 0) {
/*
* This instruction is probably a GC point. Branch instructions
}
}
- width = dexGetInstrOrTableWidth(insns);
+ width = dexGetWidthFromInstruction(insns);
assert(width > 0);
insns += width;
if (opcode == OP_NOP && instr != 0) {
return 0;
} else {
- insnWidth = dexGetInstrWidth(opcode);
+ insnWidth = dexGetWidthFromOpcode(opcode);
if (insnWidth < 0) {
insnWidth = -insnWidth;
}
static int analyzeInlineTarget(DecodedInstruction *dalvikInsn, int attributes,
int offset)
{
- int flags = dexGetInstrFlags(dalvikInsn->opcode);
+ int flags = dexGetFlagsFromOpcode(dalvikInsn->opcode);
int dalvikOpcode = dalvikInsn->opcode;
if (flags & kInstrInvoke) {
dvmCompilerAppendMIR(curBB, insn);
cUnit.numInsts++;
- int flags = dexGetInstrFlags(insn->dalvikInsn.opcode);
+ int flags = dexGetFlagsFromOpcode(insn->dalvikInsn.opcode);
if (flags & kInstrInvoke) {
assert(numInsts == 1);
/* Link the taken and fallthrough blocks */
BasicBlock *searchBB;
- int flags = dexGetInstrFlags(lastInsn->dalvikInsn.opcode);
+ int flags = dexGetFlagsFromOpcode(lastInsn->dalvikInsn.opcode);
if (flags & kInstrInvoke) {
cUnit.hasInvoke = true;
* aligned to 4-byte boundary (alignment instruction to be
* inserted later.
*/
- if (dexGetInstrFlags(curBB->lastMIRInsn->dalvikInsn.opcode)
+ if (dexGetFlagsFromOpcode(curBB->lastMIRInsn->dalvikInsn.opcode)
& kInstrInvoke) {
newBB->isFallThroughFromInvoke = true;
}
/* Now setup the Dalvik instruction with converted src/dst registers */
newGetterMIR->dalvikInsn = getterInsn;
- newGetterMIR->width = dexGetInstrWidth(getterInsn.opcode);
+ newGetterMIR->width = dexGetWidthFromOpcode(getterInsn.opcode);
newGetterMIR->OptimizationFlags |= MIR_CALLEE;
/* Now setup the Dalvik instruction with converted src/dst registers */
newSetterMIR->dalvikInsn = setterInsn;
- newSetterMIR->width = dexGetInstrWidth(setterInsn.opcode);
+ newSetterMIR->width = dexGetWidthFromOpcode(setterInsn.opcode);
newSetterMIR->OptimizationFlags |= MIR_CALLEE;
continue;
MIR *lastMIRInsn = bb->lastMIRInsn;
int opcode = lastMIRInsn->dalvikInsn.opcode;
- int flags = dexGetInstrFlags(opcode);
+ int flags = dexGetFlagsFromOpcode(opcode);
/* No invoke - continue */
if ((flags & kInstrInvoke) == 0)
/* Skip extended MIR instructions */
if (dInsn->opcode >= kNumDalvikInstructions) continue;
- int instrFlags = dexGetInstrFlags(dInsn->opcode);
+ int instrFlags = dexGetFlagsFromOpcode(dInsn->opcode);
/* Instruction is clean */
if ((instrFlags & kInstrCanThrow) == 0) continue;
*/
static void genInterpSingleStep(CompilationUnit *cUnit, MIR *mir)
{
- int flags = dexGetInstrFlags(mir->dalvikInsn.opcode);
+ int flags = dexGetFlagsFromOpcode(mir->dalvikInsn.opcode);
int flagsToCheck = kInstrCanBranch | kInstrCanSwitch | kInstrCanReturn |
kInstrCanThrow;
if (isEnter) {
/* Get dPC of next insn */
loadConstant(cUnit, r4PC, (int)(cUnit->method->insns + mir->offset +
- dexGetInstrWidth(OP_MONITOR_ENTER)));
+ dexGetWidthFromOpcode(OP_MONITOR_ENTER)));
#if defined(WITH_DEADLOCK_PREDICTION)
genDispatchToHandler(cUnit, TEMPLATE_MONITOR_ENTER_DEBUG);
#else
ArmLIR *branchOver = genCmpImmBranch(cUnit, kArmCondNe, r0, 0);
loadConstant(cUnit, r0,
(int) (cUnit->method->insns + mir->offset +
- dexGetInstrWidth(OP_MONITOR_EXIT)));
+ dexGetWidthFromOpcode(OP_MONITOR_EXIT)));
genDispatchToHandler(cUnit, TEMPLATE_THROW_EXCEPTION_COMMON);
ArmLIR *target = newLIR0(cUnit, kArmPseudoTargetLabel);
target->defMask = ENCODE_ALL;
Opcode dalvikOpcode = mir->dalvikInsn.opcode;
- InstructionFormat dalvikFormat = dexGetInstrFormat(dalvikOpcode);
+ InstructionFormat dalvikFormat = dexGetFormatFromOpcode(dalvikOpcode);
char *note;
if (mir->OptimizationFlags & MIR_INLINED) {
note = " (I)";
/* Get dPC of next insn */
loadConstant(cUnit, r4PC, (int)(cUnit->method->insns + mir->offset +
- dexGetInstrWidth(OP_MONITOR_ENTER)));
+ dexGetWidthFromOpcode(OP_MONITOR_ENTER)));
// Export PC (part 2)
newLIR3(cUnit, kThumb2StrRRI8Predec, r3, rFP,
sizeof(StackSaveArea) -
ArmLIR *branchOver = genCmpImmBranch(cUnit, kArmCondNe, r0, 0);
loadConstant(cUnit, r0,
(int) (cUnit->method->insns + mir->offset +
- dexGetInstrWidth(OP_MONITOR_EXIT)));
+ dexGetWidthFromOpcode(OP_MONITOR_EXIT)));
genDispatchToHandler(cUnit, TEMPLATE_THROW_EXCEPTION_COMMON);
// Resume here
interpState->trace[currTraceRun].frag.isCode = true;
interpState->totalTraceLen++;
- interpState->currRunLen = dexGetInstrOrTableWidth(moveResultPC);
+ interpState->currRunLen = dexGetWidthFromInstruction(moveResultPC);
}
/*
#if defined(SHOW_TRACE)
LOGD("TraceGen: adding %s", dexGetOpcodeName(decInsn.opcode));
#endif
- flags = dexGetInstrFlags(decInsn.opcode);
- len = dexGetInstrOrTableWidth(lastPC);
+ flags = dexGetFlagsFromOpcode(decInsn.opcode);
+ len = dexGetWidthFromInstruction(lastPC);
offset = lastPC - interpState->method->insns;
assert((unsigned) offset <
dvmGetMethodInsnsSize(interpState->method));
.long 0x80000000
.LintMax:
-.long 0x7FFFFFFF
\ No newline at end of file
+.long 0x7FFFFFFF
JValue* pResult)
{
jint opcode = (jint) args[0];
- int flags = dexGetInstrFlags(opcode);
+ int flags = dexGetFlagsFromOpcode(opcode);
bool result = (flags & kInstrInvoke) != 0;
RETURN_BOOLEAN(result);
}