Change method verifiers to be thread local roots

Bug: 10921004

Change-Id: I3a1425d76cd380587ba67ef6d5ec1227564e55bf
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 8e98d53..affb6cd 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -70,6 +70,7 @@
 #include "thread-inl.h"
 #include "utils.h"
 #include "verifier/dex_gc_map.h"
+#include "verifier/method_verifier.h"
 #include "verify_object-inl.h"
 #include "vmap_table.h"
 #include "well_known_classes.h"
@@ -2296,6 +2297,9 @@
       mapper.VisitShadowFrame(shadow_frame);
     }
   }
+  if (tlsPtr_.method_verifier != nullptr) {
+    tlsPtr_.method_verifier->VisitRoots(visitor, arg, RootInfo(kRootNativeStack, thread_id));
+  }
   // Visit roots on this thread's stack
   Context* context = GetLongJumpContext();
   RootCallbackVisitor visitor_to_callback(visitor, arg, thread_id);
@@ -2417,4 +2421,14 @@
   tlsPtr_.debug_invoke_req = nullptr;
 }
 
+void Thread::SetVerifier(verifier::MethodVerifier* verifier) {
+  CHECK(tlsPtr_.method_verifier == nullptr);
+  tlsPtr_.method_verifier = verifier;
+}
+
+void Thread::ClearVerifier(verifier::MethodVerifier* verifier) {
+  CHECK_EQ(tlsPtr_.method_verifier, verifier);
+  tlsPtr_.method_verifier = nullptr;
+}
+
 }  // namespace art