Fixes relating to 003-omnibus-opcodes

Fix computation of bits needed for a PC in GC map.
In the case that ClassLinker::FindClass fails with a class loader,
ignore the exception and raise a NoClassDefFoundError.
Elide callee-save methods from stack traces.

Change-Id: Ie0b7a544816e0c28d0f7df5821828aa84267cab7
diff --git a/src/class_linker.cc b/src/class_linker.cc
index ff8e179..e922d4c 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1042,7 +1042,12 @@
     }
     ScopedLocalRef<jobject> class_loader_object(env, AddLocalReference<jobject>(env, class_loader));
     ScopedLocalRef<jobject> result(env, env->CallObjectMethod(class_loader_object.get(), mid, class_name_object.get()));
-    return Decode<Class*>(env, result.get());
+    if (!env->ExceptionOccurred()) {
+      return Decode<Class*>(env, result.get());
+    } else {
+      env->ExceptionClear();  // Failed to find class fall-through to NCDFE
+      // TODO: initialize the cause of the NCDFE to this exception
+    }
   }
 
   ThrowNoClassDefFoundError("Class %s not found", PrintableString(descriptor).c_str());
diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc
index 7c3b4db..4f22448 100644
--- a/src/dex_verifier.cc
+++ b/src/dex_verifier.cc
@@ -3676,7 +3676,7 @@
   *gc_points = local_gc_points;
   *ref_bitmap_bits = max_ref_reg + 1;  // if max register is 0 we need 1 bit to encode (ie +1)
   size_t i = 0;
-  while ((1U << i) < max_insn) {
+  while ((1U << i) <= max_insn) {
     i++;
   }
   *log2_max_gc_pc = i;
@@ -3702,10 +3702,10 @@
   }
   size_t pc_bytes;
   RegisterMapFormat format;
-  if (pc_bits < 8) {
+  if (pc_bits <= 8) {
     format = kRegMapFormatCompact8;
     pc_bytes = 1;
-  } else if (pc_bits < 16) {
+  } else if (pc_bits <= 16) {
     format = kRegMapFormatCompact16;
     pc_bytes = 2;
   } else {
diff --git a/src/thread.cc b/src/thread.cc
index 7e38290..f6ce34d 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -989,7 +989,9 @@
       skipping_ = false;
     }
     if (!skipping_) {
-      ++depth_;
+      if (frame.HasMethod()) {  // ignore callee save frames
+        ++depth_;
+      }
     } else {
       ++skip_depth_;
     }
@@ -1043,6 +1045,9 @@
       skip_depth_--;
       return;
     }
+    if (!frame.HasMethod()) {
+      return;  // ignore callee save frames
+    }
     method_trace_->Set(count_, frame.GetMethod());
     pc_trace_->Set(count_, pc);
     ++count_;