diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2014-05-29 12:16:04 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2014-05-29 12:37:49 -0700 |
commit | 196851b634a5bfdd8ab3fb59a320e550b21b0f4d (patch) | |
tree | f9fca2858b6213163d358c2eb2b2f88aa88a027b /runtime/indirect_reference_table.h | |
parent | ea0b6e284cab12eed88eebf6aa19e6292af57389 (diff) | |
download | art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.tar.gz art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.tar.bz2 art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.zip |
Add read barriers for the weak roots in the JNI weak globals.
Bug: 12687968
Change-Id: Ic265a0e162e8cc9edc4ab7fa34f8afd5ce968d08
Diffstat (limited to 'runtime/indirect_reference_table.h')
-rw-r--r-- | runtime/indirect_reference_table.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h index 5015410874..5b3ed685c7 100644 --- a/runtime/indirect_reference_table.h +++ b/runtime/indirect_reference_table.h @@ -263,14 +263,16 @@ class IndirectReferenceTable { * * Returns kInvalidIndirectRefObject if iref is invalid. */ + template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> mirror::Object* Get(IndirectRef iref) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE; // Synchronized get which reads a reference, acquiring a lock if necessary. + template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> mirror::Object* SynchronizedGet(Thread* /*self*/, ReaderWriterMutex* /*mutex*/, IndirectRef iref) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return Get(iref); + return Get<kReadBarrierOption>(iref); } /* @@ -366,7 +368,9 @@ class IndirectReferenceTable { std::unique_ptr<MemMap> table_mem_map_; // Mem map where we store the extended debugging info. std::unique_ptr<MemMap> slot_mem_map_; - /* bottom of the stack */ + // bottom of the stack. If a JNI weak global table, do not directly + // access the object references in this as they are weak roots. Use + // Get() that has a read barrier. mirror::Object** table_; /* bit mask, ORed into all irefs */ IndirectRefKind kind_; |