/**
* Gets the name of the given opcode.
*
- * @param opcode {@code >= 0, <= 255;} the opcode
+ * @param opcode the opcode
* @return {@code non-null;} its name
*/
public static String opName(int opcode) {
Method** inlinedMethods;
/*
- * Dalvik instruction counts (256 entries).
+ * Dalvik instruction counts (kNumDalvikInstructions entries).
*/
int* executedInstrCounts;
int instructionCountEnableCount;
} LIR;
enum ExtendedMIROpcode {
- kMirOpFirst = 256,
+ kMirOpFirst = kNumDalvikInstructions,
kMirOpPhi = kMirOpFirst,
kMirOpNullNRangeUpCheck,
kMirOpNullNRangeDownCheck,
#include "libdex/OpCodeNames.h"
/*
- * Main table containing data flow attributes for each bytecode. The first
- * 256 entries are for Dalvik bytecode instructions, where extended opcode at
- * the MIR level are appended afterwards.
+ * Main table containing data flow attributes for each bytecode. The
+ * first kNumDalvikInstructions entries are for Dalvik bytecode
+ * instructions, where extended opcode at the MIR level are appended
+ * afterwards.
*
* TODO - many optimization flags are incomplete - they will only limit the
* scope of optimizations but will not cause mis-optimizations.
dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode];
/* Skip extended MIR instructions */
- if (dInsn->opCode > 255) continue;
+ if (dInsn->opCode >= kNumDalvikInstructions) continue;
int instrFlags = dexGetInstrFlags(dInsn->opCode);
static intptr_t templateEntryOffsets[TEMPLATE_LAST_MARK];
/* Track exercised opcodes */
-static int opcodeCoverage[256];
+static int opcodeCoverage[kNumDalvikInstructions];
static void setMemRefType(ArmLIR *lir, bool isLoad, int memType)
{
streak = i = 0;
buf[0] = 0;
- while (opcodeCoverage[i] == 0 && i < 256) {
+ while (opcodeCoverage[i] == 0 && i < kNumDalvikInstructions) {
i++;
}
- if (i == 256) {
+ if (i == kNumDalvikInstructions) {
return;
}
- for (start = i++, streak = 1; i < 256; i++) {
+ for (start = i++, streak = 1; i < kNumDalvikInstructions; i++) {
if (opcodeCoverage[i]) {
streak++;
} else {
sprintf(buf+strlen(buf), "%x-%x,", start, start + streak - 1);
}
streak = 0;
- while (opcodeCoverage[i] == 0 && i < 256) {
+ while (opcodeCoverage[i] == 0 && i < kNumDalvikInstructions) {
i++;
}
- if (i < 256) {
+ if (i < kNumDalvikInstructions) {
streak = 1;
start = i;
}
* applicable directory below this one.
*/
-static int opcodeCoverage[256];
+static int opcodeCoverage[kNumDalvikInstructions];
static intptr_t templateEntryOffsets[TEMPLATE_LAST_MARK];
/*
streak = i = 0;
buf[0] = 0;
- while (opcodeCoverage[i] == 0 && i < 256) {
+ while (opcodeCoverage[i] == 0 && i < kNumDalvikInstructions) {
i++;
}
- if (i == 256) {
+ if (i == kNumDalvikInstructions) {
return;
}
- for (start = i++, streak = 1; i < 256; i++) {
+ for (start = i++, streak = 1; i < kNumDalvikInstructions; i++) {
if (opcodeCoverage[i]) {
streak++;
} else {
sprintf(buf+strlen(buf), "%x-%x,", start, start + streak - 1);
}
streak = 0;
- while (opcodeCoverage[i] == 0 && i < 256) {
+ while (opcodeCoverage[i] == 0 && i < kNumDalvikInstructions) {
i++;
}
- if (i < 256) {
+ if (i < kNumDalvikInstructions) {
streak = 1;
start = i;
}
#
# Extract an ordered list of instructions from the VM sources. We use the
-# "goto table" definition macro, which has exactly 256 entries.
+# "goto table" definition macro, which has exactly kNumDalvikInstructions
+# entries.
#
def getOpcodeList():
opcodes = []
#
-# Load and emit opcodes for all 256 instructions.
+# Load and emit opcodes for all kNumDalvikInstructions instructions.
#
def loadAndEmitOpcodes():
sister_list = []
*/
const int width = 64;
int interpSize = dvmAsmInstructionEnd - dvmAsmInstructionStart;
- if (interpSize != 0 && interpSize != 256*width) {
+ if (interpSize != 0 && interpSize != kNumDalvikInstructions*width) {
LOGE("ERROR: unexpected asm interp size %d\n", interpSize);
LOGE("(did an instruction handler exceed %d bytes?)\n", width);
dvmAbort();
op-end
- Indicates the end of the opcode list. All 256 opcodes are emitted
- when this is seen, followed by any code that didn't fit inside the
- fixed-size instruction handler space.
+ Indicates the end of the opcode list. All kNumDalvikInstructions
+ opcodes are emitted when this is seen, followed by any code that
+ didn't fit inside the fixed-size instruction handler space.
The order of "op" directives is not significant; the generation tool will
is special in two ways: (1) the sources are assumed to be C code, and
will be inserted into the generated C file; (2) when a C implementation
is emitted, a "glue stub" is emitted in the assembly source file.
-(The generator script always emits 256 assembly instructions, unless
-"asm-stub" was left blank, in which case it only emits some labels.)
+(The generator script always emits kNumDalvikInstructions assembly
+instructions, unless "asm-stub" was left blank, in which case it only
+emits some labels.)
==== Instruction file format ====
from string import Template
interp_defs_file = "../../libdex/OpCode.h" # need opcode list
+kNumDalvikInstructions = 256 # TODO: Derive this from OpCode.h.
verbose = False
handler_size_bits = -1000
#
# Extract an ordered list of instructions from the VM sources. We use the
-# "goto table" definition macro, which has exactly 256 entries.
+# "goto table" definition macro, which has exactly kNumDalvikInstructions
+# entries.
#
def getOpcodeList():
opcodes = []
opcodes.append("OP_" + match.group(1))
opcode_fp.close()
- if len(opcodes) != 256:
- print "ERROR: found %d opcodes in Interp.h (expected 256)" \
- % len(opcodes)
+ if len(opcodes) != kNumDalvikInstructions:
+ print "ERROR: found %d opcodes in Interp.h (expected %d)" \
+ % (len(opcodes), kNumDalvikInstructions)
raise SyntaxError, "bad opcode count"
return opcodes
#
-# Load and emit opcodes for all 256 instructions.
+# Load and emit opcodes for all kNumDalvikInstructions instructions.
#
def loadAndEmitOpcodes():
sister_list = []
- assert len(opcodes) == 256
+ assert len(opcodes) == kNumDalvikInstructions
need_dummy_start = False
# point dvmAsmInstructionStart at the first handler or stub
asm_fp.write("dvmAsmInstructionStart = " + label_prefix + "_OP_NOP\n")
asm_fp.write(" .text\n\n")
- for i in xrange(256):
+ for i in xrange(kNumDalvikInstructions):
op = opcodes[i]
if opcode_locations.has_key(op):