From: Dan Bornstein Date: Sat, 20 Nov 2010 00:01:25 +0000 (-0800) Subject: Say kNumDalvikInstructions when appropriate. X-Git-Tag: android-x86-4.0-r1~250^2~16 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=675b642510ed79e8a7a3f23126dfac7679fd65b9;p=android-x86%2Fdalvik.git Say kNumDalvikInstructions when appropriate. In particular, use it instead of just saying 256, and similarly for 255. The number of opcodes will be changing soon. Change-Id: Icc77120c2673968dddd6b4003f717245d46e4159 --- diff --git a/dx/src/com/android/dx/rop/code/RegOps.java b/dx/src/com/android/dx/rop/code/RegOps.java index bdf93423a..c81398d28 100644 --- a/dx/src/com/android/dx/rop/code/RegOps.java +++ b/dx/src/com/android/dx/rop/code/RegOps.java @@ -306,7 +306,7 @@ public final class RegOps { /** * 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) { diff --git a/vm/Globals.h b/vm/Globals.h index b96a1abff..f7d69c30e 100644 --- a/vm/Globals.h +++ b/vm/Globals.h @@ -616,7 +616,7 @@ struct DvmGlobals { Method** inlinedMethods; /* - * Dalvik instruction counts (256 entries). + * Dalvik instruction counts (kNumDalvikInstructions entries). */ int* executedInstrCounts; int instructionCountEnableCount; diff --git a/vm/compiler/CompilerIR.h b/vm/compiler/CompilerIR.h index 82b97e5ba..c83c0bab2 100644 --- a/vm/compiler/CompilerIR.h +++ b/vm/compiler/CompilerIR.h @@ -78,7 +78,7 @@ typedef struct LIR { } LIR; enum ExtendedMIROpcode { - kMirOpFirst = 256, + kMirOpFirst = kNumDalvikInstructions, kMirOpPhi = kMirOpFirst, kMirOpNullNRangeUpCheck, kMirOpNullNRangeDownCheck, diff --git a/vm/compiler/Dataflow.c b/vm/compiler/Dataflow.c index cd1761c36..9c31f61f1 100644 --- a/vm/compiler/Dataflow.c +++ b/vm/compiler/Dataflow.c @@ -20,9 +20,10 @@ #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. diff --git a/vm/compiler/Loop.c b/vm/compiler/Loop.c index 649218726..f3094505f 100644 --- a/vm/compiler/Loop.c +++ b/vm/compiler/Loop.c @@ -309,7 +309,7 @@ static bool doLoopBodyCodeMotion(CompilationUnit *cUnit) dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode]; /* Skip extended MIR instructions */ - if (dInsn->opCode > 255) continue; + if (dInsn->opCode >= kNumDalvikInstructions) continue; int instrFlags = dexGetInstrFlags(dInsn->opCode); diff --git a/vm/compiler/codegen/arm/CodegenCommon.c b/vm/compiler/codegen/arm/CodegenCommon.c index ee5d9f5dd..d14dd0640 100644 --- a/vm/compiler/codegen/arm/CodegenCommon.c +++ b/vm/compiler/codegen/arm/CodegenCommon.c @@ -30,7 +30,7 @@ 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) { diff --git a/vm/compiler/codegen/arm/CodegenDriver.c b/vm/compiler/codegen/arm/CodegenDriver.c index 8e1d9a2d8..b52420fcc 100644 --- a/vm/compiler/codegen/arm/CodegenDriver.c +++ b/vm/compiler/codegen/arm/CodegenDriver.c @@ -4383,13 +4383,13 @@ void dvmCompilerArchDump(void) 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 { @@ -4399,10 +4399,10 @@ void dvmCompilerArchDump(void) 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; } diff --git a/vm/compiler/codegen/x86/CodegenDriver.c b/vm/compiler/codegen/x86/CodegenDriver.c index 026a0b54c..60f003bc7 100644 --- a/vm/compiler/codegen/x86/CodegenDriver.c +++ b/vm/compiler/codegen/x86/CodegenDriver.c @@ -24,7 +24,7 @@ * applicable directory below this one. */ -static int opcodeCoverage[256]; +static int opcodeCoverage[kNumDalvikInstructions]; static intptr_t templateEntryOffsets[TEMPLATE_LAST_MARK]; /* @@ -196,13 +196,13 @@ void dvmCompilerArchDump(void) 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 { @@ -212,10 +212,10 @@ void dvmCompilerArchDump(void) 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; } diff --git a/vm/compiler/template/gen-template.py b/vm/compiler/template/gen-template.py index 8a1ba0cb9..2474ee2e0 100755 --- a/vm/compiler/template/gen-template.py +++ b/vm/compiler/template/gen-template.py @@ -146,7 +146,8 @@ def opEnd(tokens): # # 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 = [] @@ -163,7 +164,7 @@ def getOpcodeList(): # -# Load and emit opcodes for all 256 instructions. +# Load and emit opcodes for all kNumDalvikInstructions instructions. # def loadAndEmitOpcodes(): sister_list = [] diff --git a/vm/mterp/Mterp.c b/vm/mterp/Mterp.c index 4a3fc3402..2b2e0d1e0 100644 --- a/vm/mterp/Mterp.c +++ b/vm/mterp/Mterp.c @@ -48,7 +48,7 @@ bool dvmCheckAsmConstants(void) */ 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(); diff --git a/vm/mterp/README.txt b/vm/mterp/README.txt index 80596ea4f..058312eb1 100644 --- a/vm/mterp/README.txt +++ b/vm/mterp/README.txt @@ -90,9 +90,9 @@ The commands are: 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 @@ -108,8 +108,9 @@ For the specified in the "op" command, the "c" directory 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 ==== diff --git a/vm/mterp/gen-mterp.py b/vm/mterp/gen-mterp.py index e0d854d68..0f45eca11 100755 --- a/vm/mterp/gen-mterp.py +++ b/vm/mterp/gen-mterp.py @@ -23,6 +23,7 @@ import sys, string, re, time 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 @@ -151,7 +152,8 @@ def opEnd(tokens): # # 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 = [] @@ -164,19 +166,19 @@ def getOpcodeList(): 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 @@ -185,7 +187,7 @@ def loadAndEmitOpcodes(): 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):