From 1bd4872773184fb9f5f152c7bbf9856a8235d2af Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Fri, 23 May 2014 19:58:15 -0700 Subject: Add read barriers to the weak roots in the intern table. Bug: 12687968 Change-Id: I424f1df76a7e3d7154fb9f3c951c973d19bd640f --- runtime/intern_table.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'runtime/intern_table.h') 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 + 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 + 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> 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_); }; -- cgit v1.1