From 94f7b49578b6aaa80de8ffed230648d601393905 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Tue, 22 Jul 2014 18:08:23 -0700 Subject: 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 --- runtime/mirror/reference.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime/mirror/reference.h') diff --git a/runtime/mirror/reference.h b/runtime/mirror/reference.h index 07d47d31e7..7345448ed7 100644 --- a/runtime/mirror/reference.h +++ b/runtime/mirror/reference.h @@ -18,9 +18,10 @@ #define ART_RUNTIME_MIRROR_REFERENCE_H_ #include "class.h" +#include "gc_root.h" #include "object.h" #include "object_callbacks.h" -#include "read_barrier.h" +#include "read_barrier_option.h" #include "thread.h" namespace art { @@ -94,9 +95,8 @@ class MANAGED Reference : public Object { template static Class* GetJavaLangRefReference() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(java_lang_ref_Reference_ != nullptr); - return ReadBarrier::BarrierForRoot( - &java_lang_ref_Reference_); + DCHECK(!java_lang_ref_Reference_.IsNull()); + return java_lang_ref_Reference_.Read(); } static void SetClass(Class* klass); static void ResetClass(void); @@ -114,7 +114,7 @@ class MANAGED Reference : public Object { HeapReference queue_next_; // Note this is Java volatile: HeapReference referent_; // Note this is Java volatile: - static Class* java_lang_ref_Reference_; + static GcRoot java_lang_ref_Reference_; friend struct art::ReferenceOffsets; // for verifying offset information friend class gc::ReferenceProcessor; -- cgit v1.2.3-59-g8ed1b