Relocate OpCodeNames.[ch].

The JIT was pulling it out of the dexdump directory, which is Just
Plain Wrong[tm].  Now it's part of libdex, for all to enjoy.

Change-Id: Ic1e4c981eb2d70ccc3c841ceb5a54f4f77af2008
diff --git a/dexdump/Android.mk b/dexdump/Android.mk
index 077339f..026067b 100644
--- a/dexdump/Android.mk
+++ b/dexdump/Android.mk
@@ -18,8 +18,7 @@
 LOCAL_PATH:= $(call my-dir)
 
 dexdump_src_files := \
-		DexDump.c \
-		OpCodeNames.c
+		DexDump.c
 
 dexdump_c_includes := \
 		dalvik \
diff --git a/dexdump/DexDump.c b/dexdump/DexDump.c
index 9582c98..33646bb 100644
--- a/dexdump/DexDump.c
+++ b/dexdump/DexDump.c
@@ -34,11 +34,10 @@
 #include "libdex/DexClass.h"
 #include "libdex/DexProto.h"
 #include "libdex/InstrUtils.h"
+#include "libdex/OpCodeNames.h"
 #include "libdex/SysUtil.h"
 #include "libdex/CmdUtils.h"
 
-#include "dexdump/OpCodeNames.h"
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -740,7 +739,7 @@
             printf("|%04x: nop // spacer", insnIdx);
         }
     } else {
-        printf("|%04x: %s", insnIdx, getOpcodeName(pDecInsn->opCode));
+        printf("|%04x: %s", insnIdx, dexGetOpcodeName(pDecInsn->opCode));
     }
 
     switch (dexGetInstrFormat(gInstrFormat, pDecInsn->opCode)) {
diff --git a/libdex/Android.mk b/libdex/Android.mk
index df45f04..dfd9802 100644
--- a/libdex/Android.mk
+++ b/libdex/Android.mk
@@ -25,6 +25,7 @@
 	DexSwapVerify.c \
 	InstrUtils.c \
 	Leb128.c \
+	OpCodeNames.c \
 	OptInvocation.c \
 	sha1.c \
 	SysUtil.c \
diff --git a/dexdump/OpCodeNames.c b/libdex/OpCodeNames.c
similarity index 97%
rename from dexdump/OpCodeNames.c
rename to libdex/OpCodeNames.c
index 1901f15..c182d4e 100644
--- a/dexdump/OpCodeNames.c
+++ b/libdex/OpCodeNames.c
@@ -13,11 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /*
  * Table of Dalvik opcode names.
  */
 #include "OpCodeNames.h"
 
+#include <assert.h>
+
 /*
  * The following two lines work, but slashes and dashes both turn into
  * underscores, and the strings are all upper case.  The output is easier
@@ -323,7 +326,8 @@
 /*
  * Return the name of an opcode.
  */
-const char* getOpcodeName(OpCode op)
+const char* dexGetOpcodeName(OpCode op)
 {
+    assert(op >= 0 && op < kNumDalvikInstructions);
     return gOpNames[op];
 }
diff --git a/dexdump/OpCodeNames.h b/libdex/OpCodeNames.h
similarity index 80%
rename from dexdump/OpCodeNames.h
rename to libdex/OpCodeNames.h
index 3965c6d..f81368d 100644
--- a/dexdump/OpCodeNames.h
+++ b/libdex/OpCodeNames.h
@@ -13,14 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /*
  * Dalvik opcode names.
  */
-#ifndef _DEXDUMP_OPCODENAMES
-#define _DEXDUMP_OPCODENAMES
+#ifndef _LIBDEX_OPCODENAMES
+#define _LIBDEX_OPCODENAMES
 
-#include "libdex/OpCode.h"
+#include "OpCode.h"
 
-const char* getOpcodeName(OpCode op);
+const char* dexGetOpcodeName(OpCode op);
 
-#endif /*_DEXDUMP_OPCODENAMES*/
+#endif /*_LIBDEX_OPCODENAMES*/
diff --git a/vm/Dvm.mk b/vm/Dvm.mk
index 451ed8e..3214e31 100644
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
@@ -216,7 +216,6 @@
 ifeq ($(WITH_JIT),true)
   LOCAL_CFLAGS += -DWITH_JIT
   LOCAL_SRC_FILES += \
-	../dexdump/OpCodeNames.c \
 	compiler/Compiler.c \
 	compiler/Frontend.c \
 	compiler/Utility.c \
diff --git a/vm/compiler/Dataflow.c b/vm/compiler/Dataflow.c
index 1084201..c5ec123 100644
--- a/vm/compiler/Dataflow.c
+++ b/vm/compiler/Dataflow.c
@@ -17,7 +17,7 @@
 #include "Dalvik.h"
 #include "Dataflow.h"
 #include "Loop.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 
 /*
  * Main table containing data flow attributes for each bytecode. The first
@@ -826,7 +826,7 @@
     char *ret;
 
     buffer[0] = 0;
-    strcpy(buffer, getOpcodeName(opcode));
+    strcpy(buffer, dexGetOpcodeName(opcode));
 
     if (dfAttributes & DF_FORMAT_35C) {
         unsigned int i;
diff --git a/vm/compiler/codegen/arm/ArchUtility.c b/vm/compiler/codegen/arm/ArchUtility.c
index 31e7c0b..4e0df28 100644
--- a/vm/compiler/codegen/arm/ArchUtility.c
+++ b/vm/compiler/codegen/arm/ArchUtility.c
@@ -15,7 +15,7 @@
  */
 
 #include "../../CompilerInternals.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include "ArmLIR.h"
 
 /* Decode and print a ARM register name */
diff --git a/vm/compiler/codegen/arm/Assemble.c b/vm/compiler/codegen/arm/Assemble.c
index 3dc4b29..b64a083 100644
--- a/vm/compiler/codegen/arm/Assemble.c
+++ b/vm/compiler/codegen/arm/Assemble.c
@@ -16,7 +16,7 @@
 
 #include "Dalvik.h"
 #include "libdex/OpCode.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 
 #include "../../CompilerInternals.h"
 #include "ArmLIR.h"
diff --git a/vm/compiler/codegen/arm/CodegenDriver.c b/vm/compiler/codegen/arm/CodegenDriver.c
index 7f60157..3e5126a 100644
--- a/vm/compiler/codegen/arm/CodegenDriver.c
+++ b/vm/compiler/codegen/arm/CodegenDriver.c
@@ -3892,7 +3892,7 @@
             if (notHandled) {
                 LOGE("%#06x: Opcode 0x%x (%s) / Fmt %d not handled\n",
                      mir->offset,
-                     dalvikOpCode, getOpcodeName(dalvikOpCode),
+                     dalvikOpCode, dexGetOpcodeName(dalvikOpCode),
                      dalvikFormat);
                 dvmCompilerAbort(cUnit);
                 break;
diff --git a/vm/compiler/codegen/arm/armv5te-vfp/Codegen.c b/vm/compiler/codegen/arm/armv5te-vfp/Codegen.c
index 3b03901..eda243f 100644
--- a/vm/compiler/codegen/arm/armv5te-vfp/Codegen.c
+++ b/vm/compiler/codegen/arm/armv5te-vfp/Codegen.c
@@ -19,7 +19,7 @@
 #include "Dalvik.h"
 #include "interp/InterpDefs.h"
 #include "libdex/OpCode.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include "compiler/CompilerInternals.h"
 #include "compiler/codegen/arm/ArmLIR.h"
 #include "mterp/common/FindInterface.h"
diff --git a/vm/compiler/codegen/arm/armv5te/Codegen.c b/vm/compiler/codegen/arm/armv5te/Codegen.c
index 1d9ee6d..f953390 100644
--- a/vm/compiler/codegen/arm/armv5te/Codegen.c
+++ b/vm/compiler/codegen/arm/armv5te/Codegen.c
@@ -19,7 +19,7 @@
 #include "Dalvik.h"
 #include "interp/InterpDefs.h"
 #include "libdex/OpCode.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include "compiler/CompilerInternals.h"
 #include "compiler/codegen/arm/ArmLIR.h"
 #include "mterp/common/FindInterface.h"
diff --git a/vm/compiler/codegen/arm/armv7-a-neon/Codegen.c b/vm/compiler/codegen/arm/armv7-a-neon/Codegen.c
index 305d103..1edc25b 100644
--- a/vm/compiler/codegen/arm/armv7-a-neon/Codegen.c
+++ b/vm/compiler/codegen/arm/armv7-a-neon/Codegen.c
@@ -19,7 +19,7 @@
 #include "Dalvik.h"
 #include "interp/InterpDefs.h"
 #include "libdex/OpCode.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include "compiler/CompilerInternals.h"
 #include "compiler/codegen/arm/ArmLIR.h"
 #include "mterp/common/FindInterface.h"
diff --git a/vm/compiler/codegen/arm/armv7-a/Codegen.c b/vm/compiler/codegen/arm/armv7-a/Codegen.c
index 0f64694..1514d55 100644
--- a/vm/compiler/codegen/arm/armv7-a/Codegen.c
+++ b/vm/compiler/codegen/arm/armv7-a/Codegen.c
@@ -19,7 +19,7 @@
 #include "Dalvik.h"
 #include "interp/InterpDefs.h"
 #include "libdex/OpCode.h"
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include "compiler/CompilerInternals.h"
 #include "compiler/codegen/arm/ArmLIR.h"
 #include "mterp/common/FindInterface.h"
diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c
index ebf308e..e920cfc 100644
--- a/vm/interp/Jit.c
+++ b/vm/interp/Jit.c
@@ -23,7 +23,7 @@
 #include "Jit.h"
 
 
-#include "dexdump/OpCodeNames.h"
+#include "libdex/OpCodeNames.h"
 #include <unistd.h>
 #include <pthread.h>
 #include <sys/time.h>
@@ -235,7 +235,8 @@
         offset =  (int)((u2*)addr - stackSave->method->insns);
         decInsn = &(shadowSpace->trace[i].decInsn);
         /* Not properly decoding instruction, some registers may be garbage */
-        LOGD("0x%x: (0x%04x) %s", addr, offset, getOpcodeName(decInsn->opCode));
+        LOGD("0x%x: (0x%04x) %s",
+            addr, offset, dexGetOpcodeName(decInsn->opCode));
     }
 }
 
@@ -267,7 +268,7 @@
 
     //LOGD("### DbgIntp(%d): PC: 0x%x endPC: 0x%x state: %d len: %d %s",
     //    self->threadId, (int)pc, (int)shadowSpace->endPC, state,
-    //    shadowSpace->traceLength, getOpcodeName(decInsn.opCode));
+    //    shadowSpace->traceLength, dexGetOpcodeName(decInsn.opCode));
 
     if (state == kSVSIdle || state == kSVSStart) {
         LOGD("~~~ DbgIntrp: INCORRECT PREVIOUS STATE(%d): %d",
@@ -685,7 +686,7 @@
 
 
 #if defined(SHOW_TRACE)
-            LOGD("TraceGen: adding %s",getOpcodeName(decInsn.opCode));
+            LOGD("TraceGen: adding %s", dexGetOpcodeName(decInsn.opCode));
 #endif
             flags = dexGetInstrFlags(gDvm.instrFlags, decInsn.opCode);
             len = dexGetInstrOrTableWidthAbs(gDvm.instrWidth, lastPC);
@@ -729,7 +730,7 @@
                     interpState->jitState = kJitTSelectEnd;
 #if defined(SHOW_TRACE)
                 LOGD("TraceGen: ending on %s, basic block end",
-                     getOpcodeName(decInsn.opCode));
+                     dexGetOpcodeName(decInsn.opCode));
 #endif
 
                 /*