ART: Register object tagging table

Actually register object tagging table with the runtime so it
gets swept properly.

Bug: 31385027
Test: m test-art-host
Test: m ART_USE_READ_BARRIER=true test-art-host
Change-Id: I4364458ece2893e6a85fe7518df39fb838199f20
diff --git a/runtime/openjdkjvmti/OpenjdkJvmTi.cc b/runtime/openjdkjvmti/OpenjdkJvmTi.cc
index bebc2fc..bea40c8 100644
--- a/runtime/openjdkjvmti/OpenjdkJvmTi.cc
+++ b/runtime/openjdkjvmti/OpenjdkJvmTi.cc
@@ -1035,7 +1035,9 @@
 
 // The plugin initialization function. This adds the jvmti environment.
 extern "C" bool ArtPlugin_Initialize() {
-  art::Runtime::Current()->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
+  art::Runtime* runtime = art::Runtime::Current();
+  runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
+  runtime->AddSystemWeakHolder(&gObjectTagTable);
   return true;
 }
 
diff --git a/runtime/openjdkjvmti/object_tagging.h b/runtime/openjdkjvmti/object_tagging.h
index e276c52..523e15f 100644
--- a/runtime/openjdkjvmti/object_tagging.h
+++ b/runtime/openjdkjvmti/object_tagging.h
@@ -102,7 +102,7 @@
 
     for (auto it = tagged_objects_.begin(); it != tagged_objects_.end(); ++it) {
       if (!it->first.IsNull()) {
-        art::mirror::Object* original_obj = it->first.Read();
+        art::mirror::Object* original_obj = it->first.Read<art::kWithoutReadBarrier>();
         art::mirror::Object* target_obj = visitor->IsMarked(original_obj);
         if (original_obj != target_obj) {
           it->first = art::GcRoot<art::mirror::Object>(target_obj);