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/art_field.h b/runtime/mirror/art_field.h
index 741c6eb..f3dfa15 100644
--- a/runtime/mirror/art_field.h
+++ b/runtime/mirror/art_field.h
@@ -19,11 +19,12 @@
#include <jni.h>
+#include "gc_root.h"
#include "modifiers.h"
#include "object.h"
#include "object_callbacks.h"
#include "primitive.h"
-#include "read_barrier.h"
+#include "read_barrier_option.h"
namespace art {
@@ -135,9 +136,8 @@
template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
static Class* GetJavaLangReflectArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK(java_lang_reflect_ArtField_ != nullptr);
- return ReadBarrier::BarrierForRoot<mirror::Class, kReadBarrierOption>(
- &java_lang_reflect_ArtField_);
+ DCHECK(!java_lang_reflect_ArtField_.IsNull());
+ return java_lang_reflect_ArtField_.Read<kReadBarrierOption>();
}
static void SetClass(Class* java_lang_reflect_ArtField);
@@ -180,7 +180,7 @@
// Offset of field within an instance or in the Class' static fields
uint32_t offset_;
- static Class* java_lang_reflect_ArtField_;
+ static GcRoot<Class> java_lang_reflect_ArtField_;
friend struct art::ArtFieldOffsets; // for verifying offset information
DISALLOW_IMPLICIT_CONSTRUCTORS(ArtField);