summaryrefslogtreecommitdiffstats
path: root/runtime/indirect_reference_table-inl.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-07-22 18:08:23 -0700
committerHiroshi Yamauchi <yamauchi@google.com>2014-07-29 13:30:46 -0700
commit94f7b49578b6aaa80de8ffed230648d601393905 (patch)
treecfc69e453faefee38178ceb85378e1f0f1e17812 /runtime/indirect_reference_table-inl.h
parent8df73882c60451e7f789bf9b1f3db2d7dc228640 (diff)
downloadart-94f7b49578b6aaa80de8ffed230648d601393905.tar.gz
art-94f7b49578b6aaa80de8ffed230648d601393905.tar.bz2
art-94f7b49578b6aaa80de8ffed230648d601393905.zip
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/indirect_reference_table-inl.h')
-rw-r--r--runtime/indirect_reference_table-inl.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/indirect_reference_table-inl.h b/runtime/indirect_reference_table-inl.h
index f561643399..c826716787 100644
--- a/runtime/indirect_reference_table-inl.h
+++ b/runtime/indirect_reference_table-inl.h
@@ -46,7 +46,7 @@ inline bool IndirectReferenceTable::GetChecked(IndirectRef iref) const {
AbortIfNoCheckJNI();
return false;
}
- if (UNLIKELY(table_[idx] == nullptr)) {
+ if (UNLIKELY(table_[idx].IsNull())) {
LOG(ERROR) << "JNI ERROR (app bug): accessed deleted " << kind_ << " " << iref;
AbortIfNoCheckJNI();
return false;
@@ -75,11 +75,11 @@ inline mirror::Object* IndirectReferenceTable::Get(IndirectRef iref) const {
if (!GetChecked(iref)) {
return kInvalidIndirectRefObject;
}
- mirror::Object** root = &table_[ExtractIndex(iref)];
- mirror::Object* obj = *root;
+ uint32_t idx = ExtractIndex(iref);
+ mirror::Object* obj = table_[idx].Read<kWithoutReadBarrier>();
if (LIKELY(obj != kClearedJniWeakGlobal)) {
// The read barrier or VerifyObject won't handle kClearedJniWeakGlobal.
- obj = ReadBarrier::BarrierForRoot<mirror::Object, kReadBarrierOption>(root);
+ obj = table_[idx].Read();
VerifyObject(obj);
}
return obj;