OSDN Git Service

Say kNumDalvikInstructions when appropriate.
authorDan Bornstein <danfuzz@android.com>
Sat, 20 Nov 2010 00:01:25 +0000 (16:01 -0800)
committerDan Bornstein <danfuzz@android.com>
Sat, 20 Nov 2010 00:01:25 +0000 (16:01 -0800)
In particular, use it instead of just saying 256, and similarly for
255. The number of opcodes will be changing soon.

Change-Id: Icc77120c2673968dddd6b4003f717245d46e4159

12 files changed:
dx/src/com/android/dx/rop/code/RegOps.java
vm/Globals.h
vm/compiler/CompilerIR.h
vm/compiler/Dataflow.c
vm/compiler/Loop.c
vm/compiler/codegen/arm/CodegenCommon.c
vm/compiler/codegen/arm/CodegenDriver.c
vm/compiler/codegen/x86/CodegenDriver.c
vm/compiler/template/gen-template.py
vm/mterp/Mterp.c
vm/mterp/README.txt
vm/mterp/gen-mterp.py

index bdf9342..c81398d 100644 (file)
@@ -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) {
index b96a1ab..f7d69c3 100644 (file)
@@ -616,7 +616,7 @@ struct DvmGlobals {
     Method**    inlinedMethods;
 
     /*
-     * Dalvik instruction counts (256 entries).
+     * Dalvik instruction counts (kNumDalvikInstructions entries).
      */
     int*        executedInstrCounts;
     int         instructionCountEnableCount;
index 82b97e5..c83c0ba 100644 (file)
@@ -78,7 +78,7 @@ typedef struct LIR {
 } LIR;
 
 enum ExtendedMIROpcode {
-    kMirOpFirst = 256,
+    kMirOpFirst = kNumDalvikInstructions,
     kMirOpPhi = kMirOpFirst,
     kMirOpNullNRangeUpCheck,
     kMirOpNullNRangeDownCheck,
index cd1761c..9c31f61 100644 (file)
 #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.
index 6492187..f309450 100644 (file)
@@ -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);
 
index ee5d9f5..d14dd06 100644 (file)
@@ -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)
 {
index 8e1d9a2..b52420f 100644 (file)
@@ -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;
             }
index 026a0b5..60f003b 100644 (file)
@@ -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;
             }
index 8a1ba0c..2474ee2 100755 (executable)
@@ -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 = []
index 4a3fc34..2b2e0d1 100644 (file)
@@ -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();
index 80596ea..058312e 100644 (file)
@@ -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 <directory> 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 ====
index e0d854d..0f45eca 100755 (executable)
@@ -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):