Implement EnsureCapacity, PushLocalFrame, and PopLocalFrame.

These are as good as the old implementations, except that unbalanced usages
won't be cleaned up completely (you'll slowly grow the vector in your JNIEnv).

This patch also renames IndirectReferenceTable::Contains to the less misleading
ContainsDirectPointer, and fixes JNI::GetObjectRefType to not claim that
invalid local references are locals indefinitely.

We also now include detail messages in OOMEs where possible. (Test 061 still
passes.) We still log regardless, since OOME should be a rare thing.

Change-Id: I77b2f44ea066e92c517e5c96700ec533727b9c78
diff --git a/src/indirect_reference_table.cc b/src/indirect_reference_table.cc
index 716c214..5f5541e 100644
--- a/src/indirect_reference_table.cc
+++ b/src/indirect_reference_table.cc
@@ -204,17 +204,17 @@
   return true;
 }
 
-static int LinearScan(IndirectRef iref, int bottomIndex, int topIndex, const Object** table) {
+static int Find(Object* direct_pointer, int bottomIndex, int topIndex, const Object** table) {
   for (int i = bottomIndex; i < topIndex; ++i) {
-    if (table[i] == reinterpret_cast<const Object*>(iref)) {
+    if (table[i] == direct_pointer) {
       return i;
     }
   }
   return -1;
 }
 
-bool IndirectReferenceTable::Contains(IndirectRef iref) const {
-  return LinearScan(iref, 0, segment_state_.parts.topIndex, table_) != -1;
+bool IndirectReferenceTable::ContainsDirectPointer(Object* direct_pointer) const {
+  return Find(direct_pointer, 0, segment_state_.parts.topIndex, table_) != -1;
 }
 
 /*
@@ -249,7 +249,8 @@
     return true;
   }
   if (GetIndirectRefKind(iref) == kSirtOrInvalid || vm->work_around_app_jni_bugs) {
-    idx = LinearScan(iref, bottomIndex, topIndex, table_);
+    Object* direct_pointer = reinterpret_cast<Object*>(iref);
+    idx = Find(direct_pointer, bottomIndex, topIndex, table_);
     if (idx == -1) {
       LOG(WARNING) << "trying to work around app JNI bugs, but didn't find " << iref << " in table!";
       return false;