summaryrefslogtreecommitdiff
path: root/runtime/mirror/reference.h
diff options
context:
space:
mode:
author Hiroshi Yamauchi <yamauchi@google.com> 2014-07-22 18:08:23 -0700
committer Hiroshi Yamauchi <yamauchi@google.com> 2014-07-29 13:30:46 -0700
commit94f7b49578b6aaa80de8ffed230648d601393905 (patch)
treecfc69e453faefee38178ceb85378e1f0f1e17812 /runtime/mirror/reference.h
parent8df73882c60451e7f789bf9b1f3db2d7dc228640 (diff)
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
Diffstat (limited to 'runtime/mirror/reference.h')
-rw-r--r--runtime/mirror/reference.h10
1 files changed, 5 insertions, 5 deletions
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<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
static Class* GetJavaLangRefReference() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK(java_lang_ref_Reference_ != nullptr);
- return ReadBarrier::BarrierForRoot<mirror::Class, kReadBarrierOption>(
- &java_lang_ref_Reference_);
+ DCHECK(!java_lang_ref_Reference_.IsNull());
+ return java_lang_ref_Reference_.Read<kReadBarrierOption>();
}
static void SetClass(Class* klass);
static void ResetClass(void);
@@ -114,7 +114,7 @@ class MANAGED Reference : public Object {
HeapReference<Reference> queue_next_; // Note this is Java volatile:
HeapReference<Object> referent_; // Note this is Java volatile:
- static Class* java_lang_ref_Reference_;
+ static GcRoot<Class> java_lang_ref_Reference_;
friend struct art::ReferenceOffsets; // for verifying offset information
friend class gc::ReferenceProcessor;