Add GcRoot to clean up and enforce read barriers.

Introduce a value-type wrapper around Object* for GC roots so that 1)
we won't have to directly add the read barrier code in many places and
2) we can avoid accidentally bypassing/missing read barriers on GC
roots (the GcRoot interface ensures that the read barrier is executed
on a read).

The jdwp test passed.

Bug: 12687968
Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 0525abf..1e254fa 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -18,6 +18,7 @@
 #define ART_RUNTIME_MIRROR_CLASS_H_
 
 #include "dex_file.h"
+#include "gc_root.h"
 #include "gc/allocator_type.h"
 #include "invoke_type.h"
 #include "modifiers.h"
@@ -25,7 +26,7 @@
 #include "object_array.h"
 #include "object_callbacks.h"
 #include "primitive.h"
-#include "read_barrier.h"
+#include "read_barrier_option.h"
 
 /*
  * A magic value for refOffsets. Ignore the bits and walk the super
@@ -936,9 +937,8 @@
   }
 
   static Class* GetJavaLangClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-    DCHECK(java_lang_Class_ != NULL);
-    return ReadBarrier::BarrierForRoot<mirror::Class, kWithReadBarrier>(
-        &java_lang_Class_);
+    DCHECK(!java_lang_Class_.IsNull());
+    return java_lang_Class_.Read();
   }
 
   // Can't call this SetClass or else gets called instead of Object::SetClass in places.
@@ -1156,7 +1156,7 @@
   uint32_t fields_[0];
 
   // java.lang.Class
-  static Class* java_lang_Class_;
+  static GcRoot<Class> java_lang_Class_;
 
   friend struct art::ClassOffsets;  // for verifying offset information
   DISALLOW_IMPLICIT_CONSTRUCTORS(Class);