Merge "testrunner: Forward --build-with-javac-dx to run-test"
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 805c5da..f77b3dd 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -78,8 +78,8 @@
 #include "vdex_file.h"
 #include "verifier/method_verifier.h"
 #include "verifier/method_verifier-inl.h"
-#include "verifier/verifier_log_mode.h"
 #include "verifier/verifier_deps.h"
+#include "verifier/verifier_enums.h"
 
 namespace art {
 
@@ -2132,7 +2132,7 @@
         hs.NewHandle(soa.Decode<mirror::ClassLoader>(jclass_loader)));
     Handle<mirror::Class> klass(
         hs.NewHandle(class_linker->FindClass(soa.Self(), descriptor, class_loader)));
-    verifier::MethodVerifier::FailureKind failure_kind;
+    verifier::FailureKind failure_kind;
     if (klass == nullptr) {
       CHECK(soa.Self()->IsExceptionPending());
       soa.Self()->ClearException();
@@ -2155,7 +2155,7 @@
                                                 true /* allow soft failures */,
                                                 log_level_,
                                                 &error_msg);
-      if (failure_kind == verifier::MethodVerifier::kHardFailure) {
+      if (failure_kind == verifier::FailureKind::kHardFailure) {
         LOG(ERROR) << "Verification failed on class " << PrettyDescriptor(descriptor)
                    << " because: " << error_msg;
         manager_->GetCompiler()->SetHadHardVerifierFailure();
@@ -2163,10 +2163,10 @@
         // Force a soft failure for the VerifierDeps. This is a sanity measure, as
         // the vdex file already records that the class hasn't been resolved. It avoids
         // trying to do future verification optimizations when processing the vdex file.
-        DCHECK(failure_kind == verifier::MethodVerifier::kSoftFailure ||
-               failure_kind == verifier::MethodVerifier::kNoFailure)
+        DCHECK(failure_kind == verifier::FailureKind::kSoftFailure ||
+               failure_kind == verifier::FailureKind::kNoFailure)
             << failure_kind;
-        failure_kind = verifier::MethodVerifier::kSoftFailure;
+        failure_kind = verifier::FailureKind::kSoftFailure;
       }
     } else if (!SkipClass(jclass_loader, dex_file, klass.Get())) {
       CHECK(klass->IsResolved()) << klass->PrettyClass();
@@ -2198,16 +2198,16 @@
               << " failed to fully verify: state= " << klass->GetStatus();
         }
         if (klass->IsVerified()) {
-          DCHECK_EQ(failure_kind, verifier::MethodVerifier::kNoFailure);
+          DCHECK_EQ(failure_kind, verifier::FailureKind::kNoFailure);
         } else if (klass->ShouldVerifyAtRuntime()) {
-          DCHECK_EQ(failure_kind, verifier::MethodVerifier::kSoftFailure);
+          DCHECK_EQ(failure_kind, verifier::FailureKind::kSoftFailure);
         } else {
-          DCHECK_EQ(failure_kind, verifier::MethodVerifier::kHardFailure);
+          DCHECK_EQ(failure_kind, verifier::FailureKind::kHardFailure);
         }
       }
     } else {
       // Make the skip a soft failure, essentially being considered as verify at runtime.
-      failure_kind = verifier::MethodVerifier::kSoftFailure;
+      failure_kind = verifier::FailureKind::kSoftFailure;
     }
     verifier::VerifierDeps::MaybeRecordVerificationStatus(
         dex_file, class_def.class_idx_, failure_kind);
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 1781643..af60def 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -55,7 +55,6 @@
 #include "type_lookup_table.h"
 #include "utils/dex_cache_arrays_layout-inl.h"
 #include "vdex_file.h"
-#include "verifier/method_verifier.h"
 #include "verifier/verifier_deps.h"
 #include "zip_archive.h"
 
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 8aad539..065c11e 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -98,7 +98,7 @@
 #include "ssa_liveness_analysis.h"
 #include "ssa_phi_elimination.h"
 #include "utils/assembler.h"
-#include "verifier/method_verifier.h"
+#include "verifier/verifier_compiler_binding.h"
 
 namespace art {
 
@@ -1041,7 +1041,7 @@
   const VerifiedMethod* verified_method = compiler_driver->GetVerifiedMethod(&dex_file, method_idx);
   DCHECK(!verified_method->HasRuntimeThrow());
   if (compiler_driver->IsMethodVerifiedWithoutFailures(method_idx, class_def_idx, dex_file)
-      || verifier::MethodVerifier::CanCompilerHandleVerificationFailure(
+      || verifier::CanCompilerHandleVerificationFailure(
             verified_method->GetEncounteredVerificationFailures())) {
     ArenaAllocator arena(Runtime::Current()->GetArenaPool());
     CodeVectorAllocator code_allocator(&arena);
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index 0b1ab75..4d55eb0 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -28,12 +28,13 @@
 #include "driver/compiler_options.h"
 #include "driver/compiler_driver.h"
 #include "handle_scope-inl.h"
-#include "verifier/method_verifier-inl.h"
+#include "indenter.h"
 #include "mirror/class_loader.h"
 #include "runtime.h"
-#include "thread.h"
 #include "scoped_thread_state_change-inl.h"
+#include "thread.h"
 #include "utils/atomic_method_ref_map-inl.h"
+#include "verifier/method_verifier-inl.h"
 
 namespace art {
 namespace verifier {
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 344d735..204af22 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -24,6 +24,7 @@
 
 #include <inttypes.h>
 #include <stdio.h>
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 
 #include <iostream>
 #include <memory>
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 0860b2e..cff2cbc 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -457,7 +457,7 @@
         "thread.h",
         "thread_state.h",
         "ti/agent.h",
-        "verifier/method_verifier.h",
+        "verifier/verifier_enums.h",
     ],
     output_extension: "operator_out.cc",
 }
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index ee33fc4..3ecf595 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3981,7 +3981,7 @@
   }
 }
 
-verifier::MethodVerifier::FailureKind ClassLinker::VerifyClass(
+verifier::FailureKind ClassLinker::VerifyClass(
     Thread* self, Handle<mirror::Class> klass, verifier::HardFailLogMode log_level) {
   {
     // TODO: assert that the monitor on the Class is held
@@ -4003,19 +4003,19 @@
     // this class as a parent to another.
     if (klass->IsErroneous()) {
       ThrowEarlierClassFailure(klass.Get());
-      return verifier::MethodVerifier::kHardFailure;
+      return verifier::FailureKind::kHardFailure;
     }
 
     // Don't attempt to re-verify if already verified.
     if (klass->IsVerified()) {
       EnsureSkipAccessChecksMethods(klass, image_pointer_size_);
-      return verifier::MethodVerifier::kNoFailure;
+      return verifier::FailureKind::kNoFailure;
     }
 
     // For AOT, don't attempt to re-verify if we have already found we should
     // verify at runtime.
     if (Runtime::Current()->IsAotCompiler() && klass->ShouldVerifyAtRuntime()) {
-      return verifier::MethodVerifier::kSoftFailure;
+      return verifier::FailureKind::kSoftFailure;
     }
 
     if (klass->GetStatus() == mirror::Class::kStatusResolved) {
@@ -4031,7 +4031,7 @@
     if (!Runtime::Current()->IsVerificationEnabled()) {
       mirror::Class::SetStatus(klass, mirror::Class::kStatusVerified, self);
       EnsureSkipAccessChecksMethods(klass, image_pointer_size_);
-      return verifier::MethodVerifier::kNoFailure;
+      return verifier::FailureKind::kNoFailure;
     }
   }
 
@@ -4041,7 +4041,7 @@
   // If we have a superclass and we get a hard verification failure we can return immediately.
   if (supertype != nullptr && !AttemptSupertypeVerification(self, klass, supertype)) {
     CHECK(self->IsExceptionPending()) << "Verification error should be pending.";
-    return verifier::MethodVerifier::kHardFailure;
+    return verifier::FailureKind::kHardFailure;
   }
 
   // Verify all default super-interfaces.
@@ -4068,7 +4068,7 @@
       } else if (UNLIKELY(!AttemptSupertypeVerification(self, klass, iface))) {
         // We had a hard failure while verifying this interface. Just return immediately.
         CHECK(self->IsExceptionPending()) << "Verification error should be pending.";
-        return verifier::MethodVerifier::kHardFailure;
+        return verifier::FailureKind::kHardFailure;
       } else if (UNLIKELY(!iface->IsVerified())) {
         // We softly failed to verify the iface. Stop checking and clean up.
         // Put the iface into the supertype handle so we know what caused us to fail.
@@ -4095,7 +4095,7 @@
   DCHECK(!mirror::Class::IsErroneous(oat_file_class_status) || !preverified);
 
   std::string error_msg;
-  verifier::MethodVerifier::FailureKind verifier_failure = verifier::MethodVerifier::kNoFailure;
+  verifier::FailureKind verifier_failure = verifier::FailureKind::kNoFailure;
   if (!preverified) {
     Runtime* runtime = Runtime::Current();
     verifier_failure = verifier::MethodVerifier::VerifyClass(self,
@@ -4109,8 +4109,8 @@
   // Verification is done, grab the lock again.
   ObjectLock<mirror::Class> lock(self, klass);
 
-  if (preverified || verifier_failure != verifier::MethodVerifier::kHardFailure) {
-    if (!preverified && verifier_failure != verifier::MethodVerifier::kNoFailure) {
+  if (preverified || verifier_failure != verifier::FailureKind::kHardFailure) {
+    if (!preverified && verifier_failure != verifier::FailureKind::kNoFailure) {
       VLOG(class_linker) << "Soft verification failure in class "
                          << klass->PrettyDescriptor()
                          << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
@@ -4119,7 +4119,7 @@
     self->AssertNoPendingException();
     // Make sure all classes referenced by catch blocks are resolved.
     ResolveClassExceptionHandlerTypes(klass);
-    if (verifier_failure == verifier::MethodVerifier::kNoFailure) {
+    if (verifier_failure == verifier::FailureKind::kNoFailure) {
       // Even though there were no verifier failures we need to respect whether the super-class and
       // super-default-interfaces were verified or requiring runtime reverification.
       if (supertype == nullptr || supertype->IsVerified()) {
@@ -4128,10 +4128,10 @@
         CHECK_EQ(supertype->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
         mirror::Class::SetStatus(klass, mirror::Class::kStatusRetryVerificationAtRuntime, self);
         // Pretend a soft failure occurred so that we don't consider the class verified below.
-        verifier_failure = verifier::MethodVerifier::kSoftFailure;
+        verifier_failure = verifier::FailureKind::kSoftFailure;
       }
     } else {
-      CHECK_EQ(verifier_failure, verifier::MethodVerifier::kSoftFailure);
+      CHECK_EQ(verifier_failure, verifier::FailureKind::kSoftFailure);
       // Soft failures at compile time should be retried at runtime. Soft
       // failures at runtime will be handled by slow paths in the generated
       // code. Set status accordingly.
@@ -4152,7 +4152,7 @@
     ThrowVerifyError(klass.Get(), "%s", error_msg.c_str());
     mirror::Class::SetStatus(klass, mirror::Class::kStatusErrorResolved, self);
   }
-  if (preverified || verifier_failure == verifier::MethodVerifier::kNoFailure) {
+  if (preverified || verifier_failure == verifier::FailureKind::kNoFailure) {
     // Class is verified so we don't need to do any access check on its methods.
     // Let the interpreter know it by setting the kAccSkipAccessChecks flag onto each
     // method.
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 1c280a4..7f652ec 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -24,9 +24,7 @@
 #include <utility>
 #include <vector>
 
-#include "base/allocator.h"
 #include "base/enums.h"
-#include "base/hash_set.h"
 #include "base/macros.h"
 #include "base/mutex.h"
 #include "class_table.h"
@@ -38,8 +36,7 @@
 #include "jni.h"
 #include "mirror/class.h"
 #include "object_callbacks.h"
-#include "verifier/method_verifier.h"
-#include "verifier/verifier_log_mode.h"
+#include "verifier/verifier_enums.h"
 
 namespace art {
 
@@ -453,7 +450,7 @@
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Roles::uninterruptible_);
 
-  verifier::MethodVerifier::FailureKind VerifyClass(
+  verifier::FailureKind VerifyClass(
       Thread* self,
       Handle<mirror::Class> klass,
       verifier::HardFailLogMode log_level = verifier::HardFailLogMode::kLogNone)
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index bfa273d..56e8aa3 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -243,6 +243,12 @@
     return; \
   }
 
+#define TEST_DISABLED_FOR_MEMORY_TOOL() \
+  if (RUNNING_ON_MEMORY_TOOL > 0) { \
+    printf("WARNING: TEST DISABLED FOR MEMORY TOOL\n"); \
+    return; \
+  }
+
 }  // namespace art
 
 namespace std {
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index 688f95b..625794e 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/file.h>
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 #include <sys/stat.h>
 #include <zlib.h>
 
diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc
index 59b734f..5fbdc46 100644
--- a/runtime/elf_file.cc
+++ b/runtime/elf_file.cc
@@ -17,6 +17,7 @@
 #include "elf_file.h"
 
 #include <inttypes.h>
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 #include <sys/types.h>
 #include <unistd.h>
 
diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h
index db9568a..351798e 100644
--- a/runtime/gc/accounting/atomic_stack.h
+++ b/runtime/gc/accounting/atomic_stack.h
@@ -17,6 +17,8 @@
 #ifndef ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_
 #define ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_
 
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
+
 #include <algorithm>
 #include <memory>
 #include <string>
@@ -25,7 +27,7 @@
 #include "base/logging.h"
 #include "base/macros.h"
 #include "mem_map.h"
-#include "stack.h"
+#include "stack_reference.h"
 
 namespace art {
 namespace gc {
diff --git a/runtime/gc/accounting/bitmap.cc b/runtime/gc/accounting/bitmap.cc
index 380cb8e..e535380 100644
--- a/runtime/gc/accounting/bitmap.cc
+++ b/runtime/gc/accounting/bitmap.cc
@@ -16,6 +16,8 @@
 
 #include "bitmap-inl.h"
 
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
+
 #include "base/bit_utils.h"
 #include "card_table.h"
 #include "jit/jit_code_cache.h"
diff --git a/runtime/gc/accounting/read_barrier_table.h b/runtime/gc/accounting/read_barrier_table.h
index e77a5b8..775746f 100644
--- a/runtime/gc/accounting/read_barrier_table.h
+++ b/runtime/gc/accounting/read_barrier_table.h
@@ -17,6 +17,8 @@
 #ifndef ART_RUNTIME_GC_ACCOUNTING_READ_BARRIER_TABLE_H_
 #define ART_RUNTIME_GC_ACCOUNTING_READ_BARRIER_TABLE_H_
 
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
+
 #include "base/bit_utils.h"
 #include "base/mutex.h"
 #include "gc/space/space.h"
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index d5af29e..4192f34 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -22,8 +22,10 @@
 #include "base/stl_util.h"
 #include "base/systrace.h"
 #include "debugger.h"
+#include "gc/accounting/atomic_stack.h"
 #include "gc/accounting/heap_bitmap-inl.h"
 #include "gc/accounting/mod_union_table-inl.h"
+#include "gc/accounting/read_barrier_table.h"
 #include "gc/accounting/space_bitmap-inl.h"
 #include "gc/gc_pause_listener.h"
 #include "gc/reference_processor.h"
diff --git a/runtime/gc/collector/concurrent_copying.h b/runtime/gc/collector/concurrent_copying.h
index c21520d..f877314 100644
--- a/runtime/gc/collector/concurrent_copying.h
+++ b/runtime/gc/collector/concurrent_copying.h
@@ -23,8 +23,6 @@
 #include "jni.h"
 #include "object_callbacks.h"
 #include "offsets.h"
-#include "gc/accounting/atomic_stack.h"
-#include "gc/accounting/read_barrier_table.h"
 #include "gc/accounting/space_bitmap.h"
 #include "mirror/object.h"
 #include "mirror/object_reference.h"
@@ -40,8 +38,11 @@
 namespace gc {
 
 namespace accounting {
+  template<typename T> class AtomicStack;
+  typedef AtomicStack<mirror::Object> ObjectStack;
   typedef SpaceBitmap<kObjectAlignment> ContinuousSpaceBitmap;
   class HeapBitmap;
+  class ReadBarrierTable;
 }  // namespace accounting
 
 namespace space {
diff --git a/runtime/gc/heap_verification_test.cc b/runtime/gc/heap_verification_test.cc
index c8233e3..2cdfc16 100644
--- a/runtime/gc/heap_verification_test.cc
+++ b/runtime/gc/heap_verification_test.cc
@@ -16,6 +16,7 @@
 
 #include "common_runtime_test.h"
 
+#include "base/memory_tool.h"
 #include "class_linker.h"
 #include "handle_scope-inl.h"
 #include "mirror/object-inl.h"
@@ -63,7 +64,7 @@
       reinterpret_cast<const void*>(&uint_klass)));
 }
 
-TEST_F(VerificationTest, IsValidClass) {
+TEST_F(VerificationTest, IsValidClassOrNotInHeap) {
   ScopedObjectAccess soa(Thread::Current());
   VariableSizedHandleScope hs(soa.Self());
   Handle<mirror::String> string(
@@ -72,14 +73,35 @@
   EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(1)));
   EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(4)));
   EXPECT_FALSE(v->IsValidClass(nullptr));
-  EXPECT_FALSE(v->IsValidClass(string.Get()));
   EXPECT_TRUE(v->IsValidClass(string->GetClass()));
+  EXPECT_FALSE(v->IsValidClass(string.Get()));
+}
+
+TEST_F(VerificationTest, IsValidClassInHeap) {
+  TEST_DISABLED_FOR_MEMORY_TOOL();
+  ScopedObjectAccess soa(Thread::Current());
+  VariableSizedHandleScope hs(soa.Self());
+  Handle<mirror::String> string(
+      hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "test")));
+  const Verification* const v = Runtime::Current()->GetHeap()->GetVerification();
   const uintptr_t uint_klass = reinterpret_cast<uintptr_t>(string->GetClass());
   EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(uint_klass - kObjectAlignment)));
   EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(&uint_klass)));
 }
 
-TEST_F(VerificationTest, DumpObjectInfo) {
+TEST_F(VerificationTest, DumpInvalidObjectInfo) {
+  ScopedLogSeverity sls(LogSeverity::INFO);
+  ScopedObjectAccess soa(Thread::Current());
+  Runtime* const runtime = Runtime::Current();
+  VariableSizedHandleScope hs(soa.Self());
+  const Verification* const v = runtime->GetHeap()->GetVerification();
+  LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(1), "obj");
+  LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(4), "obj");
+  LOG(INFO) << v->DumpObjectInfo(nullptr, "obj");
+}
+
+TEST_F(VerificationTest, DumpValidObjectInfo) {
+  TEST_DISABLED_FOR_MEMORY_TOOL();
   ScopedLogSeverity sls(LogSeverity::INFO);
   ScopedObjectAccess soa(Thread::Current());
   Runtime* const runtime = Runtime::Current();
@@ -89,9 +111,6 @@
   Handle<mirror::ObjectArray<mirror::Object>> arr(
       hs.NewHandle(AllocObjectArray<mirror::Object>(soa.Self(), 256)));
   const Verification* const v = runtime->GetHeap()->GetVerification();
-  LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(1), "obj");
-  LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(4), "obj");
-  LOG(INFO) << v->DumpObjectInfo(nullptr, "obj");
   LOG(INFO) << v->DumpObjectInfo(string.Get(), "test");
   LOG(INFO) << v->DumpObjectInfo(string->GetClass(), "obj");
   const uintptr_t uint_klass = reinterpret_cast<uintptr_t>(string->GetClass());
@@ -102,6 +121,7 @@
 }
 
 TEST_F(VerificationTest, LogHeapCorruption) {
+  TEST_DISABLED_FOR_MEMORY_TOOL();
   ScopedLogSeverity sls(LogSeverity::INFO);
   ScopedObjectAccess soa(Thread::Current());
   Runtime* const runtime = Runtime::Current();
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 326f5c9..ef0ddb3 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -32,7 +32,6 @@
 #include "reflection.h"
 #include "reflection-inl.h"
 #include "stack.h"
-#include "verifier/method_verifier.h"
 #include "well_known_classes.h"
 
 namespace art {
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index 40309b9..6c39361 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -16,26 +16,26 @@
 
 #include "mem_map.h"
 
-#include "base/memory_tool.h"
-#include <backtrace/BacktraceMap.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
+#ifndef ANDROID_OS
+#include <sys/resource.h>
+#endif
 
 #include <memory>
 #include <sstream>
 
 #include "android-base/stringprintf.h"
+#include "android-base/unique_fd.h"
+#include "backtrace/BacktraceMap.h"
+#include "cutils/ashmem.h"
 
-#include "base/unix_file/fd_file.h"
-#include "os.h"
-#include "thread-inl.h"
+#include "base/allocator.h"
+#include "base/memory_tool.h"
+#include "globals.h"
 #include "utils.h"
 
-#include <cutils/ashmem.h>
-
-#ifndef ANDROID_OS
-#include <sys/resource.h>
-#endif
 
 #ifndef MAP_ANONYMOUS
 #define MAP_ANONYMOUS MAP_ANON
@@ -44,6 +44,12 @@
 namespace art {
 
 using android::base::StringPrintf;
+using android::base::unique_fd;
+
+using Maps = AllocationTrackingMultiMap<void*, MemMap*, kAllocatorTagMaps>;
+
+// All the non-empty MemMaps. Use a multimap as we do a reserve-and-divide (eg ElfMap::Load()).
+static Maps* gMaps GUARDED_BY(MemMap::GetMemMapsLock()) = nullptr;
 
 static std::ostream& operator<<(
     std::ostream& os,
@@ -59,7 +65,7 @@
   return os;
 }
 
-std::ostream& operator<<(std::ostream& os, const MemMap::Maps& mem_maps) {
+std::ostream& operator<<(std::ostream& os, const Maps& mem_maps) {
   os << "MemMap:" << std::endl;
   for (auto it = mem_maps.begin(); it != mem_maps.end(); ++it) {
     void* base = it->first;
@@ -71,7 +77,6 @@
 }
 
 std::mutex* MemMap::mem_maps_lock_ = nullptr;
-MemMap::Maps* MemMap::maps_ = nullptr;
 
 #if USE_ART_LOW_4G_ALLOCATOR
 // Handling mem_map in 32b address range for 64b architectures that do not support MAP_32BIT.
@@ -132,7 +137,7 @@
 #endif
 
 // Return true if the address range is contained in a single memory map by either reading
-// the maps_ variable or the /proc/self/map entry.
+// the gMaps variable or the /proc/self/map entry.
 bool MemMap::ContainedWithinExistingMap(uint8_t* ptr, size_t size, std::string* error_msg) {
   uintptr_t begin = reinterpret_cast<uintptr_t>(ptr);
   uintptr_t end = begin + size;
@@ -141,7 +146,7 @@
   // further.
   {
     std::lock_guard<std::mutex> mu(*mem_maps_lock_);
-    for (auto& pair : *maps_) {
+    for (auto& pair : *gMaps) {
       MemMap* const map = pair.second;
       if (begin >= reinterpret_cast<uintptr_t>(map->Begin()) &&
           end <= reinterpret_cast<uintptr_t>(map->End())) {
@@ -302,8 +307,6 @@
     flags |= MAP_FIXED;
   }
 
-  File fd;
-
   if (use_ashmem) {
     if (!kIsTargetBuild) {
       // When not on Android (either host or assuming a linux target) ashmem is faked using
@@ -316,15 +319,17 @@
     }
   }
 
+  unique_fd fd;
+
+
   if (use_ashmem) {
     // android_os_Debug.cpp read_mapinfo assumes all ashmem regions associated with the VM are
     // prefixed "dalvik-".
     std::string debug_friendly_name("dalvik-");
     debug_friendly_name += name;
-    fd.Reset(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count),
-             /* check_usage */ false);
+    fd.reset(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count));
 
-    if (fd.Fd() == -1) {
+    if (fd.get() == -1) {
       // We failed to create the ashmem region. Print a warning, but continue
       // anyway by creating a true anonymous mmap with an fd of -1. It is
       // better to use an unlabelled anonymous map than to fail to create a
@@ -344,7 +349,7 @@
                              page_aligned_byte_count,
                              prot,
                              flags,
-                             fd.Fd(),
+                             fd.get(),
                              0,
                              low_4gb);
   saved_errno = errno;
@@ -361,7 +366,7 @@
                                 page_aligned_byte_count,
                                 prot,
                                 flags,
-                                fd.Fd(),
+                                fd.get(),
                                 strerror(saved_errno));
     }
     return nullptr;
@@ -490,15 +495,15 @@
     }
   }
 
-  // Remove it from maps_.
+  // Remove it from gMaps.
   std::lock_guard<std::mutex> mu(*mem_maps_lock_);
   bool found = false;
-  DCHECK(maps_ != nullptr);
-  for (auto it = maps_->lower_bound(base_begin_), end = maps_->end();
+  DCHECK(gMaps != nullptr);
+  for (auto it = gMaps->lower_bound(base_begin_), end = gMaps->end();
        it != end && it->first == base_begin_; ++it) {
     if (it->second == this) {
       found = true;
-      maps_->erase(it);
+      gMaps->erase(it);
       break;
     }
   }
@@ -518,10 +523,10 @@
     CHECK(base_begin_ != nullptr);
     CHECK_NE(base_size_, 0U);
 
-    // Add it to maps_.
+    // Add it to gMaps.
     std::lock_guard<std::mutex> mu(*mem_maps_lock_);
-    DCHECK(maps_ != nullptr);
-    maps_->insert(std::make_pair(base_begin_, this));
+    DCHECK(gMaps != nullptr);
+    gMaps->insert(std::make_pair(base_begin_, this));
   }
 }
 
@@ -551,22 +556,21 @@
   DCHECK_EQ(tail_base_begin + tail_base_size, old_base_end);
   DCHECK_ALIGNED(tail_base_size, kPageSize);
 
-  int int_fd = -1;
+  unique_fd fd;
   int flags = MAP_PRIVATE | MAP_ANONYMOUS;
   if (use_ashmem) {
     // android_os_Debug.cpp read_mapinfo assumes all ashmem regions associated with the VM are
     // prefixed "dalvik-".
     std::string debug_friendly_name("dalvik-");
     debug_friendly_name += tail_name;
-    int_fd = ashmem_create_region(debug_friendly_name.c_str(), tail_base_size);
+    fd.reset(ashmem_create_region(debug_friendly_name.c_str(), tail_base_size));
     flags = MAP_PRIVATE | MAP_FIXED;
-    if (int_fd == -1) {
+    if (fd.get() == -1) {
       *error_msg = StringPrintf("ashmem_create_region failed for '%s': %s",
                                 tail_name, strerror(errno));
       return nullptr;
     }
   }
-  File fd(int_fd, /* check_usage */ false);
 
   MEMORY_TOOL_MAKE_UNDEFINED(tail_base_begin, tail_base_size);
   // Unmap/map the tail region.
@@ -581,13 +585,17 @@
   // calls. Otherwise, libc (or something else) might take this memory
   // region. Note this isn't perfect as there's no way to prevent
   // other threads to try to take this memory region here.
-  uint8_t* actual = reinterpret_cast<uint8_t*>(mmap(tail_base_begin, tail_base_size, tail_prot,
-                                              flags, fd.Fd(), 0));
+  uint8_t* actual = reinterpret_cast<uint8_t*>(mmap(tail_base_begin,
+                                                    tail_base_size,
+                                                    tail_prot,
+                                                    flags,
+                                                    fd.get(),
+                                                    0));
   if (actual == MAP_FAILED) {
     PrintFileToLog("/proc/self/maps", LogSeverity::WARNING);
     *error_msg = StringPrintf("anonymous mmap(%p, %zd, 0x%x, 0x%x, %d, 0) failed. See process "
                               "maps in the log.", tail_base_begin, tail_base_size, tail_prot, flags,
-                              fd.Fd());
+                              fd.get());
     return nullptr;
   }
   return new MemMap(tail_name, actual, tail_size, actual, tail_base_size, tail_prot, false);
@@ -662,7 +670,7 @@
 }
 
 void MemMap::DumpMapsLocked(std::ostream& os, bool terse) {
-  const auto& mem_maps = *maps_;
+  const auto& mem_maps = *gMaps;
   if (!terse) {
     os << mem_maps;
     return;
@@ -722,7 +730,7 @@
 
 bool MemMap::HasMemMap(MemMap* map) {
   void* base_begin = map->BaseBegin();
-  for (auto it = maps_->lower_bound(base_begin), end = maps_->end();
+  for (auto it = gMaps->lower_bound(base_begin), end = gMaps->end();
        it != end && it->first == base_begin; ++it) {
     if (it->second == map) {
       return true;
@@ -734,8 +742,8 @@
 MemMap* MemMap::GetLargestMemMapAt(void* address) {
   size_t largest_size = 0;
   MemMap* largest_map = nullptr;
-  DCHECK(maps_ != nullptr);
-  for (auto it = maps_->lower_bound(address), end = maps_->end();
+  DCHECK(gMaps != nullptr);
+  for (auto it = gMaps->lower_bound(address), end = gMaps->end();
        it != end && it->first == address; ++it) {
     MemMap* map = it->second;
     CHECK(map != nullptr);
@@ -753,10 +761,10 @@
     return;
   }
   mem_maps_lock_ = new std::mutex();
-  // Not for thread safety, but for the annotation that maps_ is GUARDED_BY(mem_maps_lock_).
+  // Not for thread safety, but for the annotation that gMaps is GUARDED_BY(mem_maps_lock_).
   std::lock_guard<std::mutex> mu(*mem_maps_lock_);
-  DCHECK(maps_ == nullptr);
-  maps_ = new Maps;
+  DCHECK(gMaps == nullptr);
+  gMaps = new Maps;
 }
 
 void MemMap::Shutdown() {
@@ -765,11 +773,11 @@
     return;
   }
   {
-    // Not for thread safety, but for the annotation that maps_ is GUARDED_BY(mem_maps_lock_).
+    // Not for thread safety, but for the annotation that gMaps is GUARDED_BY(mem_maps_lock_).
     std::lock_guard<std::mutex> mu(*mem_maps_lock_);
-    DCHECK(maps_ != nullptr);
-    delete maps_;
-    maps_ = nullptr;
+    DCHECK(gMaps != nullptr);
+    delete gMaps;
+    gMaps = nullptr;
   }
   delete mem_maps_lock_;
   mem_maps_lock_ = nullptr;
@@ -830,17 +838,17 @@
 
     std::lock_guard<std::mutex> mu(*mem_maps_lock_);
     for (uintptr_t ptr = next_mem_pos_; ptr < 4 * GB; ptr += kPageSize) {
-      // Use maps_ as an optimization to skip over large maps.
+      // Use gMaps as an optimization to skip over large maps.
       // Find the first map which is address > ptr.
-      auto it = maps_->upper_bound(reinterpret_cast<void*>(ptr));
-      if (it != maps_->begin()) {
+      auto it = gMaps->upper_bound(reinterpret_cast<void*>(ptr));
+      if (it != gMaps->begin()) {
         auto before_it = it;
         --before_it;
         // Start at the end of the map before the upper bound.
         ptr = std::max(ptr, reinterpret_cast<uintptr_t>(before_it->second->BaseEnd()));
         CHECK_ALIGNED(ptr, kPageSize);
       }
-      while (it != maps_->end()) {
+      while (it != gMaps->end()) {
         // How much space do we have until the next map?
         size_t delta = reinterpret_cast<uintptr_t>(it->first) - ptr;
         // If the space may be sufficient, break out of the loop.
@@ -1001,12 +1009,12 @@
   base_size_ = aligned_base_size;
   begin_ = aligned_base_begin;
   size_ = aligned_base_size;
-  DCHECK(maps_ != nullptr);
+  DCHECK(gMaps != nullptr);
   if (base_begin < aligned_base_begin) {
-    auto it = maps_->find(base_begin);
-    CHECK(it != maps_->end()) << "MemMap not found";
-    maps_->erase(it);
-    maps_->insert(std::make_pair(base_begin_, this));
+    auto it = gMaps->find(base_begin);
+    CHECK(it != gMaps->end()) << "MemMap not found";
+    gMaps->erase(it);
+    gMaps->insert(std::make_pair(base_begin_, this));
   }
 }
 
diff --git a/runtime/mem_map.h b/runtime/mem_map.h
index ceb4c33..140877e 100644
--- a/runtime/mem_map.h
+++ b/runtime/mem_map.h
@@ -17,18 +17,14 @@
 #ifndef ART_RUNTIME_MEM_MAP_H_
 #define ART_RUNTIME_MEM_MAP_H_
 
-#include "base/mutex.h"
-
-#include <string>
-#include <map>
-#include <mutex>
-
 #include <stddef.h>
-#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 #include <sys/types.h>
 
-#include "base/allocator.h"
-#include "globals.h"
+#include <map>
+#include <mutex>
+#include <string>
+
+#include "android-base/thread_annotations.h"
 
 namespace art {
 
@@ -180,8 +176,6 @@
   static void DumpMaps(std::ostream& os, bool terse = false)
       REQUIRES(!MemMap::mem_maps_lock_);
 
-  typedef AllocationTrackingMultiMap<void*, MemMap*, kAllocatorTagMaps> Maps;
-
   // Init and Shutdown are NOT thread safe.
   // Both may be called multiple times and MemMap objects may be created any
   // time after the first call to Init and before the first call to Shutodwn.
@@ -196,6 +190,11 @@
   // Align the map by unmapping the unaligned parts at the lower and the higher ends.
   void AlignBy(size_t size);
 
+  // For annotation reasons.
+  static std::mutex* GetMemMapsLock() RETURN_CAPABILITY(mem_maps_lock_) {
+    return nullptr;
+  }
+
  private:
   MemMap(const std::string& name,
          uint8_t* begin,
@@ -245,14 +244,10 @@
 
   static std::mutex* mem_maps_lock_;
 
-  // All the non-empty MemMaps. Use a multimap as we do a reserve-and-divide (eg ElfMap::Load()).
-  static Maps* maps_ GUARDED_BY(MemMap::mem_maps_lock_);
-
   friend class MemMapTest;  // To allow access to base_begin_ and base_size_.
 };
 
 std::ostream& operator<<(std::ostream& os, const MemMap& mem_map);
-std::ostream& operator<<(std::ostream& os, const MemMap::Maps& mem_maps);
 
 // Zero and release pages if possible, no requirements on alignments.
 void ZeroAndReleasePages(void* address, size_t length);
diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc
index 41ed862..cca1486 100644
--- a/runtime/openjdkjvmti/ti_redefine.cc
+++ b/runtime/openjdkjvmti/ti_redefine.cc
@@ -66,7 +66,7 @@
 #include "ti_class_loader.h"
 #include "transform.h"
 #include "verifier/method_verifier.h"
-#include "verifier/verifier_log_mode.h"
+#include "verifier/verifier_enums.h"
 
 namespace openjdkjvmti {
 
@@ -1063,7 +1063,7 @@
   art::StackHandleScope<2> hs(driver_->self_);
   std::string error;
   // TODO Make verification log level lower
-  art::verifier::MethodVerifier::FailureKind failure =
+  art::verifier::FailureKind failure =
       art::verifier::MethodVerifier::VerifyClass(driver_->self_,
                                                  dex_file_.get(),
                                                  hs.NewHandle(iter.GetNewDexCache()),
@@ -1074,7 +1074,7 @@
                                                  /*log_level*/
                                                  art::verifier::HardFailLogMode::kLogWarning,
                                                  &error);
-  bool passes = failure == art::verifier::MethodVerifier::kNoFailure;
+  bool passes = failure == art::verifier::FailureKind::kNoFailure;
   if (!passes) {
     RecordFailure(ERR(FAILS_VERIFICATION), "Failed to verify class. Error was: " + error);
   }
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 72e0500..b866941 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -32,7 +32,6 @@
 #include "oat_quick_method_header.h"
 #include "stack.h"
 #include "stack_map.h"
-#include "verifier/method_verifier.h"
 
 namespace art {
 
diff --git a/runtime/runtime_options.h b/runtime/runtime_options.h
index 5fcb86e..c509992 100644
--- a/runtime/runtime_options.h
+++ b/runtime/runtime_options.h
@@ -17,13 +17,15 @@
 #ifndef ART_RUNTIME_RUNTIME_OPTIONS_H_
 #define ART_RUNTIME_RUNTIME_OPTIONS_H_
 
-#include "base/variant_map.h"
-#include "cmdline_types.h"  // TODO: don't need to include this file here
-
-// Map keys
 #include <vector>
 #include <string>
+
+#include <stdio.h>
+#include <stdarg.h>
+
 #include "base/logging.h"
+#include "base/variant_map.h"
+#include "cmdline_types.h"  // TODO: don't need to include this file here
 #include "jdwp/jdwp.h"
 #include "jit/jit.h"
 #include "jit/jit_code_cache.h"
@@ -31,9 +33,7 @@
 #include "gc/space/large_object_space.h"
 #include "arch/instruction_set.h"
 #include "jit/profile_saver_options.h"
-#include "verifier/verify_mode.h"
-#include <stdio.h>
-#include <stdarg.h>
+#include "verifier/verifier_enums.h"
 
 namespace art {
 
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index 9ff104b..945f08b 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -16,6 +16,8 @@
 
 #include "vdex_file.h"
 
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
+
 #include <memory>
 
 #include "base/logging.h"
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index e1c6af4..2b0c612 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -36,6 +36,7 @@
 #include "dex_instruction_visitor.h"
 #include "experimental_flags.h"
 #include "gc/accounting/card_table-inl.h"
+#include "handle_scope-inl.h"
 #include "indenter.h"
 #include "intern_table.h"
 #include "leb128.h"
@@ -52,7 +53,7 @@
 #include "scoped_thread_state_change-inl.h"
 #include "utils.h"
 #include "verifier_deps.h"
-#include "handle_scope-inl.h"
+#include "verifier_compiler_binding.h"
 
 namespace art {
 namespace verifier {
@@ -136,14 +137,14 @@
   reg_line->MarkAllRegistersAsConflicts(verifier);
 }
 
-MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self,
-                                                        mirror::Class* klass,
-                                                        CompilerCallbacks* callbacks,
-                                                        bool allow_soft_failures,
-                                                        HardFailLogMode log_level,
-                                                        std::string* error) {
+FailureKind MethodVerifier::VerifyClass(Thread* self,
+                                        mirror::Class* klass,
+                                        CompilerCallbacks* callbacks,
+                                        bool allow_soft_failures,
+                                        HardFailLogMode log_level,
+                                        std::string* error) {
   if (klass->IsVerified()) {
-    return kNoFailure;
+    return FailureKind::kNoFailure;
   }
   bool early_failure = false;
   std::string failure_message;
@@ -167,7 +168,7 @@
       ClassReference ref(&dex_file, klass->GetDexClassDefIndex());
       callbacks->ClassRejected(ref);
     }
-    return kHardFailure;
+    return FailureKind::kHardFailure;
   }
   StackHandleScope<2> hs(self);
   Handle<mirror::DexCache> dex_cache(hs.NewHandle(klass->GetDexCache()));
@@ -188,12 +189,9 @@
   return kDirect ? it->HasNextDirectMethod() : it->HasNextVirtualMethod();
 }
 
-static MethodVerifier::FailureKind FailureKindMax(MethodVerifier::FailureKind fk1,
-                                                  MethodVerifier::FailureKind fk2) {
-  static_assert(MethodVerifier::FailureKind::kNoFailure <
-                    MethodVerifier::FailureKind::kSoftFailure
-                && MethodVerifier::FailureKind::kSoftFailure <
-                       MethodVerifier::FailureKind::kHardFailure,
+static FailureKind FailureKindMax(FailureKind fk1, FailureKind fk2) {
+  static_assert(FailureKind::kNoFailure < FailureKind::kSoftFailure
+                    && FailureKind::kSoftFailure < FailureKind::kHardFailure,
                 "Unexpected FailureKind order");
   return std::max(fk1, fk2);
 }
@@ -257,8 +255,8 @@
                                                       log_level,
                                                       need_precise_constants,
                                                       &hard_failure_msg);
-    if (result.kind == kHardFailure) {
-      if (failure_data.kind == kHardFailure) {
+    if (result.kind == FailureKind::kHardFailure) {
+      if (failure_data.kind == FailureKind::kHardFailure) {
         // If we logged an error before, we need a newline.
         *error_string += "\n";
       } else {
@@ -277,15 +275,15 @@
   return failure_data;
 }
 
-MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self,
-                                                        const DexFile* dex_file,
-                                                        Handle<mirror::DexCache> dex_cache,
-                                                        Handle<mirror::ClassLoader> class_loader,
-                                                        const DexFile::ClassDef& class_def,
-                                                        CompilerCallbacks* callbacks,
-                                                        bool allow_soft_failures,
-                                                        HardFailLogMode log_level,
-                                                        std::string* error) {
+FailureKind MethodVerifier::VerifyClass(Thread* self,
+                                        const DexFile* dex_file,
+                                        Handle<mirror::DexCache> dex_cache,
+                                        Handle<mirror::ClassLoader> class_loader,
+                                        const DexFile::ClassDef& class_def,
+                                        CompilerCallbacks* callbacks,
+                                        bool allow_soft_failures,
+                                        HardFailLogMode log_level,
+                                        std::string* error) {
   ScopedTrace trace(__FUNCTION__);
 
   // A class must not be abstract and final.
@@ -293,13 +291,13 @@
     *error = "Verifier rejected class ";
     *error += PrettyDescriptor(dex_file->GetClassDescriptor(class_def));
     *error += ": class is abstract and final.";
-    return kHardFailure;
+    return FailureKind::kHardFailure;
   }
 
   const uint8_t* class_data = dex_file->GetClassData(class_def);
   if (class_data == nullptr) {
     // empty class, probably a marker interface
-    return kNoFailure;
+    return FailureKind::kNoFailure;
   }
   ClassDataItemIterator it(*dex_file, class_data);
   while (it.HasNextStaticField() || it.HasNextInstanceField()) {
@@ -335,8 +333,8 @@
 
   data1.Merge(data2);
 
-  if (data1.kind == kNoFailure) {
-    return kNoFailure;
+  if (data1.kind == FailureKind::kNoFailure) {
+    return FailureKind::kNoFailure;
   } else {
     if ((data1.types & VERIFY_ERROR_LOCKING) != 0) {
       // Print a warning about expected slow-down. Use a string temporary to print one contiguous
@@ -412,7 +410,7 @@
         verifier.DumpFailures(VLOG_STREAM(verifier) << "Soft verification failures in "
                                                     << dex_file->PrettyMethod(method_idx) << "\n");
       }
-      result.kind = kSoftFailure;
+      result.kind = FailureKind::kSoftFailure;
       if (method != nullptr &&
           !CanCompilerHandleVerificationFailure(verifier.encountered_failure_types_)) {
         method->SetDontCompile();
@@ -432,7 +430,7 @@
           // code is valid (even the dead and unverified one). As such this is done only for apps.
           // (CompilerDriver DCHECKs in VerifyClassVisitor that methods from boot image are
           // fully verified).
-          result.kind = kSoftFailure;
+          result.kind = FailureKind::kSoftFailure;
         }
       }
       if ((verifier.encountered_failure_types_ & VerifyError::VERIFY_ERROR_LOCKING) != 0) {
@@ -446,7 +444,7 @@
     if (UNLIKELY(verifier.have_pending_experimental_failure_)) {
       // Failed due to being forced into interpreter. This is ok because
       // we just want to skip verification.
-      result.kind = kSoftFailure;
+      result.kind = FailureKind::kSoftFailure;
     } else {
       CHECK(verifier.have_pending_hard_failure_);
       if (VLOG_IS_ON(verifier)) {
@@ -477,7 +475,7 @@
         *hard_failure_msg =
             verifier.failure_messages_[verifier.failure_messages_.size() - 1]->str();
       }
-      result.kind = kHardFailure;
+      result.kind = FailureKind::kHardFailure;
 
       if (callbacks != nullptr) {
         // Let the interested party know that we failed the class.
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index 7b67967..26dc15e 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -33,7 +33,7 @@
 #include "method_reference.h"
 #include "register_line.h"
 #include "reg_type_cache.h"
-#include "verifier_log_mode.h"
+#include "verifier_enums.h"
 
 namespace art {
 
@@ -50,57 +50,6 @@
 using RegisterLineArenaUniquePtr = std::unique_ptr<RegisterLine, RegisterLineArenaDelete>;
 class RegType;
 
-/*
- * "Direct" and "virtual" methods are stored independently. The type of call used to invoke the
- * method determines which list we search, and whether we travel up into superclasses.
- *
- * (<clinit>, <init>, and methods declared "private" or "static" are stored in the "direct" list.
- * All others are stored in the "virtual" list.)
- */
-enum MethodType {
-  METHOD_UNKNOWN  = 0,
-  METHOD_DIRECT,      // <init>, private
-  METHOD_STATIC,      // static
-  METHOD_VIRTUAL,     // virtual
-  METHOD_SUPER,       // super
-  METHOD_INTERFACE,   // interface
-  METHOD_POLYMORPHIC  // polymorphic
-};
-std::ostream& operator<<(std::ostream& os, const MethodType& rhs);
-
-/*
- * An enumeration of problems that can turn up during verification.
- * Both VERIFY_ERROR_BAD_CLASS_SOFT and VERIFY_ERROR_BAD_CLASS_HARD denote failures that cause
- * the entire class to be rejected. However, VERIFY_ERROR_BAD_CLASS_SOFT denotes a soft failure
- * that can potentially be corrected, and the verifier will try again at runtime.
- * VERIFY_ERROR_BAD_CLASS_HARD denotes a hard failure that can't be corrected, and will cause
- * the class to remain uncompiled. Other errors denote verification errors that cause bytecode
- * to be rewritten to fail at runtime.
- */
-enum VerifyError {
-  VERIFY_ERROR_BAD_CLASS_HARD = 1,        // VerifyError; hard error that skips compilation.
-  VERIFY_ERROR_BAD_CLASS_SOFT = 2,        // VerifyError; soft error that verifies again at runtime.
-
-  VERIFY_ERROR_NO_CLASS = 4,              // NoClassDefFoundError.
-  VERIFY_ERROR_NO_FIELD = 8,              // NoSuchFieldError.
-  VERIFY_ERROR_NO_METHOD = 16,            // NoSuchMethodError.
-  VERIFY_ERROR_ACCESS_CLASS = 32,         // IllegalAccessError.
-  VERIFY_ERROR_ACCESS_FIELD = 64,         // IllegalAccessError.
-  VERIFY_ERROR_ACCESS_METHOD = 128,       // IllegalAccessError.
-  VERIFY_ERROR_CLASS_CHANGE = 256,        // IncompatibleClassChangeError.
-  VERIFY_ERROR_INSTANTIATION = 512,       // InstantiationError.
-  // For opcodes that don't have complete verifier support,  we need a way to continue
-  // execution at runtime without attempting to re-verify (since we know it will fail no
-  // matter what). Instead, run as the interpreter in a special "do access checks" mode
-  // which will perform verifier-like checking on the fly.
-  VERIFY_ERROR_FORCE_INTERPRETER = 1024,  // Skip the verification phase at runtime;
-                                          // force the interpreter to do access checks.
-                                          // (sets a soft fail at compile time).
-  VERIFY_ERROR_LOCKING = 2048,            // Could not guarantee balanced locking. This should be
-                                          // punted to the interpreter with access checks.
-};
-std::ostream& operator<<(std::ostream& os, const VerifyError& rhs);
-
 // We don't need to store the register data for many instructions, because we either only need
 // it at branch points (for verification) or GC points and branches (for verification +
 // type-precise register analysis).
@@ -136,20 +85,6 @@
 // The verifier
 class MethodVerifier {
  public:
-  enum FailureKind {
-    kNoFailure,
-    kSoftFailure,
-    kHardFailure,
-  };
-
-  static bool CanCompilerHandleVerificationFailure(uint32_t encountered_failure_types) {
-    constexpr uint32_t unresolved_mask = verifier::VerifyError::VERIFY_ERROR_NO_CLASS
-        | verifier::VerifyError::VERIFY_ERROR_ACCESS_CLASS
-        | verifier::VerifyError::VERIFY_ERROR_ACCESS_FIELD
-        | verifier::VerifyError::VERIFY_ERROR_ACCESS_METHOD;
-    return (encountered_failure_types & (~unresolved_mask)) == 0;
-  }
-
   // Verify a class. Returns "kNoFailure" on success.
   static FailureKind VerifyClass(Thread* self,
                                  mirror::Class* klass,
@@ -325,7 +260,7 @@
   // Verification result for method(s). Includes a (maximum) failure kind, and (the union of)
   // all failure types.
   struct FailureData : ValueObject {
-    FailureKind kind = kNoFailure;
+    FailureKind kind = FailureKind::kNoFailure;
     uint32_t types = 0U;
 
     // Merge src into this. Uses the most severe failure kind, and the union of types.
@@ -869,7 +804,6 @@
 
   DISALLOW_COPY_AND_ASSIGN(MethodVerifier);
 };
-std::ostream& operator<<(std::ostream& os, const MethodVerifier::FailureKind& rhs);
 
 }  // namespace verifier
 }  // namespace art
diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc
index bdb6b68..d987467 100644
--- a/runtime/verifier/method_verifier_test.cc
+++ b/runtime/verifier/method_verifier_test.cc
@@ -26,7 +26,7 @@
 #include "dex_file-inl.h"
 #include "scoped_thread_state_change-inl.h"
 #include "utils.h"
-#include "verifier_log_mode.h"
+#include "verifier_enums.h"
 
 namespace art {
 namespace verifier {
@@ -41,15 +41,15 @@
 
     // Verify the class
     std::string error_msg;
-    MethodVerifier::FailureKind failure = MethodVerifier::VerifyClass(
+    FailureKind failure = MethodVerifier::VerifyClass(
         self, klass, nullptr, true, HardFailLogMode::kLogWarning, &error_msg);
 
     if (android::base::StartsWith(descriptor, "Ljava/lang/invoke")) {
-      ASSERT_TRUE(failure == MethodVerifier::kSoftFailure ||
-                  failure == MethodVerifier::kNoFailure) << error_msg;
+      ASSERT_TRUE(failure == FailureKind::kSoftFailure ||
+                  failure == FailureKind::kNoFailure) << error_msg;
 
     } else {
-      ASSERT_TRUE(failure == MethodVerifier::kNoFailure) << error_msg;
+      ASSERT_TRUE(failure == FailureKind::kNoFailure) << error_msg;
     }
   }
 
diff --git a/runtime/verifier/verifier_compiler_binding.h b/runtime/verifier/verifier_compiler_binding.h
new file mode 100644
index 0000000..4f9a13f
--- /dev/null
+++ b/runtime/verifier/verifier_compiler_binding.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_VERIFIER_VERIFIER_COMPILER_BINDING_H_
+#define ART_RUNTIME_VERIFIER_VERIFIER_COMPILER_BINDING_H_
+
+#include <inttypes.h>
+
+#include "base/macros.h"
+#include "verifier_enums.h"
+
+namespace art {
+namespace verifier {
+
+ALWAYS_INLINE
+static inline bool CanCompilerHandleVerificationFailure(uint32_t encountered_failure_types) {
+  constexpr uint32_t unresolved_mask = verifier::VerifyError::VERIFY_ERROR_NO_CLASS
+      | verifier::VerifyError::VERIFY_ERROR_ACCESS_CLASS
+      | verifier::VerifyError::VERIFY_ERROR_ACCESS_FIELD
+      | verifier::VerifyError::VERIFY_ERROR_ACCESS_METHOD;
+  return (encountered_failure_types & (~unresolved_mask)) == 0;
+}
+
+}  // namespace verifier
+}  // namespace art
+
+#endif  // ART_RUNTIME_VERIFIER_VERIFIER_COMPILER_BINDING_H_
diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index 0497a6d..122e05f 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -23,8 +23,10 @@
 #include "base/stl_util.h"
 #include "compiler_callbacks.h"
 #include "dex_file-inl.h"
+#include "indenter.h"
 #include "leb128.h"
 #include "mirror/class-inl.h"
+#include "mirror/class_loader.h"
 #include "obj_ptr-inl.h"
 #include "runtime.h"
 
@@ -502,8 +504,8 @@
 
 void VerifierDeps::MaybeRecordVerificationStatus(const DexFile& dex_file,
                                                  dex::TypeIndex type_idx,
-                                                 MethodVerifier::FailureKind failure_kind) {
-  if (failure_kind == MethodVerifier::kNoFailure) {
+                                                 FailureKind failure_kind) {
+  if (failure_kind == FailureKind::kNoFailure) {
     // We only record classes that did not fully verify at compile time.
     return;
   }
diff --git a/runtime/verifier/verifier_deps.h b/runtime/verifier/verifier_deps.h
index 11750fd..d69e4dc 100644
--- a/runtime/verifier/verifier_deps.h
+++ b/runtime/verifier/verifier_deps.h
@@ -21,17 +21,26 @@
 #include <set>
 #include <vector>
 
-#include "art_field.h"
-#include "art_method.h"
 #include "base/array_ref.h"
 #include "base/mutex.h"
-#include "indenter.h"
+#include "handle.h"
 #include "method_resolution_kind.h"
-#include "method_verifier.h"  // For MethodVerifier::FailureKind.
 #include "obj_ptr.h"
-#include "os.h"
+#include "thread.h"
+#include "verifier_enums.h"  // For MethodVerifier::FailureKind.
 
 namespace art {
+
+class ArtField;
+class ArtMethod;
+class DexFile;
+class VariableIndentationOutputStream;
+
+namespace mirror {
+class Class;
+class ClassLoader;
+}
+
 namespace verifier {
 
 // Verification dependencies collector class used by the MethodVerifier to record
@@ -59,7 +68,7 @@
   // Record the verification status of the class at `type_idx`.
   static void MaybeRecordVerificationStatus(const DexFile& dex_file,
                                             dex::TypeIndex type_idx,
-                                            MethodVerifier::FailureKind failure_kind)
+                                            FailureKind failure_kind)
       REQUIRES(!Locks::verifier_deps_lock_);
 
   // Record the outcome `klass` of resolving type `type_idx` from `dex_file`.
diff --git a/runtime/verifier/verifier_enums.h b/runtime/verifier/verifier_enums.h
new file mode 100644
index 0000000..bbdd45d
--- /dev/null
+++ b/runtime/verifier/verifier_enums.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_
+#define ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_
+
+#include <stdint.h>
+
+namespace art {
+namespace verifier {
+
+// The mode that the verifier should run as.
+enum class VerifyMode : int8_t {
+  kNone,      // Everything is assumed verified.
+  kEnable,    // Standard verification, try pre-verifying at compile-time.
+  kSoftFail,  // Force a soft fail, punting to the interpreter with access checks.
+};
+
+// The outcome of verification.
+enum class FailureKind {
+  kNoFailure,
+  kSoftFailure,
+  kHardFailure,
+};
+std::ostream& operator<<(std::ostream& os, const FailureKind& rhs);
+
+// How to log hard failures during verification.
+enum class HardFailLogMode {
+  kLogNone,                               // Don't log hard failures at all.
+  kLogVerbose,                            // Log with severity VERBOSE.
+  kLogWarning,                            // Log with severity WARNING.
+  kLogInternalFatal,                      // Log with severity FATAL_WITHOUT_ABORT
+};
+
+/*
+ * "Direct" and "virtual" methods are stored independently. The type of call used to invoke the
+ * method determines which list we search, and whether we travel up into superclasses.
+ *
+ * (<clinit>, <init>, and methods declared "private" or "static" are stored in the "direct" list.
+ * All others are stored in the "virtual" list.)
+ */
+enum MethodType {
+  METHOD_UNKNOWN  = 0,
+  METHOD_DIRECT,      // <init>, private
+  METHOD_STATIC,      // static
+  METHOD_VIRTUAL,     // virtual
+  METHOD_SUPER,       // super
+  METHOD_INTERFACE,   // interface
+  METHOD_POLYMORPHIC  // polymorphic
+};
+std::ostream& operator<<(std::ostream& os, const MethodType& rhs);
+
+/*
+ * An enumeration of problems that can turn up during verification.
+ * Both VERIFY_ERROR_BAD_CLASS_SOFT and VERIFY_ERROR_BAD_CLASS_HARD denote failures that cause
+ * the entire class to be rejected. However, VERIFY_ERROR_BAD_CLASS_SOFT denotes a soft failure
+ * that can potentially be corrected, and the verifier will try again at runtime.
+ * VERIFY_ERROR_BAD_CLASS_HARD denotes a hard failure that can't be corrected, and will cause
+ * the class to remain uncompiled. Other errors denote verification errors that cause bytecode
+ * to be rewritten to fail at runtime.
+ */
+enum VerifyError {
+  VERIFY_ERROR_BAD_CLASS_HARD = 1,        // VerifyError; hard error that skips compilation.
+  VERIFY_ERROR_BAD_CLASS_SOFT = 2,        // VerifyError; soft error that verifies again at runtime.
+
+  VERIFY_ERROR_NO_CLASS = 4,              // NoClassDefFoundError.
+  VERIFY_ERROR_NO_FIELD = 8,              // NoSuchFieldError.
+  VERIFY_ERROR_NO_METHOD = 16,            // NoSuchMethodError.
+  VERIFY_ERROR_ACCESS_CLASS = 32,         // IllegalAccessError.
+  VERIFY_ERROR_ACCESS_FIELD = 64,         // IllegalAccessError.
+  VERIFY_ERROR_ACCESS_METHOD = 128,       // IllegalAccessError.
+  VERIFY_ERROR_CLASS_CHANGE = 256,        // IncompatibleClassChangeError.
+  VERIFY_ERROR_INSTANTIATION = 512,       // InstantiationError.
+  // For opcodes that don't have complete verifier support,  we need a way to continue
+  // execution at runtime without attempting to re-verify (since we know it will fail no
+  // matter what). Instead, run as the interpreter in a special "do access checks" mode
+  // which will perform verifier-like checking on the fly.
+  VERIFY_ERROR_FORCE_INTERPRETER = 1024,  // Skip the verification phase at runtime;
+                                          // force the interpreter to do access checks.
+                                          // (sets a soft fail at compile time).
+  VERIFY_ERROR_LOCKING = 2048,            // Could not guarantee balanced locking. This should be
+                                          // punted to the interpreter with access checks.
+};
+std::ostream& operator<<(std::ostream& os, const VerifyError& rhs);
+
+}  // namespace verifier
+}  // namespace art
+
+#endif  // ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_
diff --git a/runtime/verifier/verifier_log_mode.h b/runtime/verifier/verifier_log_mode.h
deleted file mode 100644
index e83d174..0000000
--- a/runtime/verifier/verifier_log_mode.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_
-#define ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_
-
-namespace art {
-namespace verifier {
-
-enum class HardFailLogMode {
-  kLogNone,                               // Don't log hard failures at all.
-  kLogVerbose,                            // Log with severity VERBOSE.
-  kLogWarning,                            // Log with severity WARNING.
-  kLogInternalFatal,                      // Log with severity FATAL_WITHOUT_ABORT
-};
-
-}  // namespace verifier
-}  // namespace art
-
-#endif  // ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_
diff --git a/runtime/verifier/verify_mode.h b/runtime/verifier/verify_mode.h
deleted file mode 100644
index bea4378..0000000
--- a/runtime/verifier/verify_mode.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_RUNTIME_VERIFIER_VERIFY_MODE_H_
-#define ART_RUNTIME_VERIFIER_VERIFY_MODE_H_
-
-#include <stdint.h>
-
-namespace art {
-namespace verifier {
-
-// The mode that the verifier should run as.
-enum class VerifyMode : int8_t {
-  kNone,      // Everything is assumed verified.
-  kEnable,    // Standard verification, try pre-verifying at compile-time.
-  kSoftFail,  // Force a soft fail, punting to the interpreter with access checks.
-};
-
-}  // namespace verifier
-}  // namespace art
-
-#endif  // ART_RUNTIME_VERIFIER_VERIFY_MODE_H_
diff --git a/runtime/zip_archive.cc b/runtime/zip_archive.cc
index 416873f..0d0d5c7 100644
--- a/runtime/zip_archive.cc
+++ b/runtime/zip_archive.cc
@@ -18,6 +18,7 @@
 
 #include <fcntl.h>
 #include <stdio.h>
+#include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/test/Android.run-test-jvmti-java-library.mk b/test/Android.run-test-jvmti-java-library.mk
index 70ee693..c480be5 100644
--- a/test/Android.run-test-jvmti-java-library.mk
+++ b/test/Android.run-test-jvmti-java-library.mk
@@ -74,6 +74,8 @@
   981-dedup-original-dex/src/art/Test981.java \
   982-ok-no-retransform/src/art/Test982.java \
   984-obsolete-invoke/src/art/Test984.java \
+  985-re-obsolete/src/art/Test985.java \
+  986-native-method-bind/src/art/Test986.java \
 
 JVMTI_RUN_TEST_GENERATED_NUMBERS := \
   901 \
@@ -114,6 +116,8 @@
   981 \
   982 \
   984 \
+  985 \
+  986 \
 
 # Try to enforce that the directories correspond to the Java files we pull in.
 JVMTI_RUN_TEST_DIR_CHECK := $(sort $(foreach DIR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS), \