summaryrefslogtreecommitdiffstats
path: root/runtime/intern_table.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-05-23 19:58:15 -0700
committerHiroshi Yamauchi <yamauchi@google.com>2014-05-28 11:46:57 -0700
commit1bd4872773184fb9f5f152c7bbf9856a8235d2af (patch)
treef00044ea6edf93e130dd89a30f88fb6c7c60b0ce /runtime/intern_table.h
parent0130ba045e1397594f2c6a0dd48730349fe3cbed (diff)
downloadart-1bd4872773184fb9f5f152c7bbf9856a8235d2af.zip
art-1bd4872773184fb9f5f152c7bbf9856a8235d2af.tar.gz
art-1bd4872773184fb9f5f152c7bbf9856a8235d2af.tar.bz2
Add read barriers to the weak roots in the intern table.
Bug: 12687968 Change-Id: I424f1df76a7e3d7154fb9f3c951c973d19bd640f
Diffstat (limited to 'runtime/intern_table.h')
-rw-r--r--runtime/intern_table.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/runtime/intern_table.h b/runtime/intern_table.h
index 47d5e09..3df2aeb 100644
--- a/runtime/intern_table.h
+++ b/runtime/intern_table.h
@@ -79,15 +79,26 @@ class InternTable {
LOCKS_EXCLUDED(Locks::intern_table_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::String* Lookup(Table& table, mirror::String* s, int32_t hash_code)
+ mirror::String* LookupStrong(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ mirror::String* LookupWeak(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
+ mirror::String* Lookup(Table* table, mirror::String* s, int32_t hash_code)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::String* InsertStrong(mirror::String* s, int32_t hash_code)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
mirror::String* InsertWeak(mirror::String* s, int32_t hash_code)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
+ void RemoveStrong(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
void RemoveWeak(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
- void Remove(Table& table, mirror::String* s, int32_t hash_code)
+ template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
+ void Remove(Table* table, mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
// Transaction rollback access.
@@ -96,8 +107,10 @@ class InternTable {
mirror::String* InsertWeakFromTransaction(mirror::String* s, int32_t hash_code)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
void RemoveStrongFromTransaction(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
void RemoveWeakFromTransaction(mirror::String* s, int32_t hash_code)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
friend class Transaction;
@@ -107,6 +120,9 @@ class InternTable {
Table strong_interns_ GUARDED_BY(Locks::intern_table_lock_);
std::vector<std::pair<int32_t, mirror::String*>> new_strong_intern_roots_
GUARDED_BY(Locks::intern_table_lock_);
+ // Since weak_interns_ contain weak roots, they need a read
+ // barrier. Do not directly access the strings in it. Use functions
+ // that contain read barriers.
Table weak_interns_ GUARDED_BY(Locks::intern_table_lock_);
};