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/monitor.cc b/runtime/monitor.cc
index 371a9d9..433c1b2 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -84,7 +84,7 @@
       num_waiters_(0),
       owner_(owner),
       lock_count_(0),
-      obj_(obj),
+      obj_(GcRoot<mirror::Object>(obj)),
       wait_set_(NULL),
       hash_code_(hash_code),
       locking_method_(NULL),
@@ -107,7 +107,7 @@
       num_waiters_(0),
       owner_(owner),
       lock_count_(0),
-      obj_(obj),
+      obj_(GcRoot<mirror::Object>(obj)),
       wait_set_(NULL),
       hash_code_(hash_code),
       locking_method_(NULL),
@@ -225,7 +225,7 @@
 }
 
 void Monitor::SetObject(mirror::Object* object) {
-  obj_ = object;
+  obj_ = GcRoot<mirror::Object>(object);
 }
 
 void Monitor::Lock(Thread* self) {
@@ -636,7 +636,7 @@
     }
     // The monitor is deflated, mark the object as nullptr so that we know to delete it during the
     // next GC.
-    monitor->obj_ = nullptr;
+    monitor->obj_ = GcRoot<mirror::Object>(nullptr);
   }
   return true;
 }