Avoid sign extension in packed-switch.

This code (at least in the ARM version) is trying to assign to r0 and r1
from C by returning a 64-bit result. The mistaken use of signed integers
for pointers can lead to sign extension if the JIT code cache is at a
sufficiently high address.

Bug: 6799823
Bug: 6703991

(cherry picked from commit 2d0c1c2dbe44458ebb199c47ce1047f266db5349)

Conflicts:

	vm/compiler/codegen/mips/CalloutHelper.h
	vm/compiler/codegen/mips/CodegenDriver.cpp

Change-Id: Id4699fdd0b3d61abe9c92874832b8561df4fa797
diff --git a/vm/compiler/codegen/arm/CalloutHelper.h b/vm/compiler/codegen/arm/CalloutHelper.h
index cc4c0ae..079c5f6 100644
--- a/vm/compiler/codegen/arm/CalloutHelper.h
+++ b/vm/compiler/codegen/arm/CalloutHelper.h
@@ -87,13 +87,6 @@
                                           const ClassObject *clazz);
 
 /*
- * Switch dispatch offset calculation for OP_PACKED_SWITCH & OP_SPARSE_SWITCH
- * Used in CodegenDriver.c
- * static s8 findPackedSwitchIndex(const u2* switchData, int testVal, int pc);
- * static s8 findSparseSwitchIndex(const u2* switchData, int testVal, int pc);
- */
-
-/*
  * Resolve interface callsites - OP_INVOKE_INTERFACE & OP_INVOKE_INTERFACE_RANGE
  *
  * Originally declared in mterp/common/FindInterface.h and only comment it here
diff --git a/vm/compiler/codegen/arm/CodegenDriver.cpp b/vm/compiler/codegen/arm/CodegenDriver.cpp
index d7017b0..40fc964 100644
--- a/vm/compiler/codegen/arm/CodegenDriver.cpp
+++ b/vm/compiler/codegen/arm/CodegenDriver.cpp
@@ -2781,16 +2781,16 @@
  * chaining cell for case default [8 bytes]
  * noChain exit
  */
-static s8 findPackedSwitchIndex(const u2* switchData, int testVal, int pc)
+static u8 findPackedSwitchIndex(const u2* switchData, int testVal, uintptr_t pc)
 {
     int size;
     int firstKey;
     const int *entries;
     int index;
     int jumpIndex;
-    int caseDPCOffset = 0;
+    uintptr_t caseDPCOffset = 0;
     /* In Thumb mode pc is 4 ahead of the "mov r2, pc" instruction */
-    int chainingPC = (pc + 4) & ~3;
+    uintptr_t chainingPC = (pc + 4) & ~3;
 
     /*
      * Packed switch data format:
@@ -2829,16 +2829,16 @@
     }
 
     chainingPC += jumpIndex * CHAIN_CELL_NORMAL_SIZE;
-    return (((s8) caseDPCOffset) << 32) | (u8) chainingPC;
+    return (((u8) caseDPCOffset) << 32) | (u8) chainingPC;
 }
 
 /* See comments for findPackedSwitchIndex */
-static s8 findSparseSwitchIndex(const u2* switchData, int testVal, int pc)
+static u8 findSparseSwitchIndex(const u2* switchData, int testVal, uintptr_t pc)
 {
     int size;
     const int *keys;
     const int *entries;
-    int chainingPC = (pc + 4) & ~3;
+    uintptr_t chainingPC = (pc + 4) & ~3;
     int i;
 
     /*
@@ -2880,7 +2880,7 @@
             int jumpIndex = (i < MAX_CHAINED_SWITCH_CASES) ?
                            i : MAX_CHAINED_SWITCH_CASES + 1;
             chainingPC += jumpIndex * CHAIN_CELL_NORMAL_SIZE;
-            return (((s8) entries[i]) << 32) | (u8) chainingPC;
+            return (((u8) entries[i]) << 32) | (u8) chainingPC;
         } else if (k > testVal) {
             break;
         }
diff --git a/vm/oo/Resolve.cpp b/vm/oo/Resolve.cpp
index a4890a5..ab3de5b 100644
--- a/vm/oo/Resolve.cpp
+++ b/vm/oo/Resolve.cpp
@@ -219,7 +219,11 @@
     }
 
     if (resMethod == NULL) {
-        dvmThrowNoSuchMethodError(name);
+        std::string msg;
+        msg += resClass->descriptor;
+        msg += ".";
+        msg += name;
+        dvmThrowNoSuchMethodError(msg.c_str());
         return NULL;
     }
 
@@ -333,11 +337,14 @@
     DexProto proto;
     dexProtoSetFromMethodId(&proto, pDvmDex->pDexFile, pMethodId);
 
-    LOGVV("+++ looking for '%s' '%s' in resClass='%s'",
-        methodName, methodSig, resClass->descriptor);
+    LOGVV("+++ looking for '%s' in resClass='%s'", methodName, resClass->descriptor);
     resMethod = dvmFindInterfaceMethodHier(resClass, methodName, &proto);
     if (resMethod == NULL) {
-        dvmThrowNoSuchMethodError(methodName);
+        std::string msg;
+        msg += resClass->descriptor;
+        msg += ".";
+        msg += methodName;
+        dvmThrowNoSuchMethodError(msg.c_str());
         return NULL;
     }