ReaderWriterMutex* Locks::heap_bitmap_lock_ = nullptr;
Mutex* Locks::instrument_entrypoints_lock_ = nullptr;
Mutex* Locks::intern_table_lock_ = nullptr;
+Mutex* Locks::interpreter_string_init_map_lock_ = nullptr;
Mutex* Locks::jni_libraries_lock_ = nullptr;
Mutex* Locks::logging_lock_ = nullptr;
Mutex* Locks::mem_maps_lock_ = nullptr;
DCHECK(alloc_tracker_lock_ == nullptr);
alloc_tracker_lock_ = new Mutex("AllocTracker lock", current_lock_level);
+ UPDATE_CURRENT_LOCK_LEVEL(kInterpreterStringInitMapLock);
+ DCHECK(interpreter_string_init_map_lock_ == nullptr);
+ interpreter_string_init_map_lock_ = new Mutex("Interpreter String initializer reference map lock", current_lock_level);
+
UPDATE_CURRENT_LOCK_LEVEL(kThreadListLock);
DCHECK(thread_list_lock_ == nullptr);
thread_list_lock_ = new Mutex("thread list lock", current_lock_level);
kMonitorListLock,
kJniLoadLibraryLock,
kThreadListLock,
+ kInterpreterStringInitMapLock,
kAllocTrackerLock,
kDeoptimizationLock,
kProfilerLock,
// TODO: improve name, perhaps instrumentation_update_lock_.
static Mutex* deoptimization_lock_ ACQUIRED_AFTER(alloc_tracker_lock_);
+ // Guards String initializer register map in interpreter.
+ static Mutex* interpreter_string_init_map_lock_ ACQUIRED_AFTER(deoptimization_lock_);
+
// The thread_list_lock_ guards ThreadList::list_. It is also commonly held to stop threads
// attaching and detaching.
- static Mutex* thread_list_lock_ ACQUIRED_AFTER(deoptimization_lock_);
+ static Mutex* thread_list_lock_ ACQUIRED_AFTER(interpreter_string_init_map_lock_);
// Signaled when threads terminate. Used to determine when all non-daemons have terminated.
static ConditionVariable* thread_exit_cond_ GUARDED_BY(Locks::thread_list_lock_);
SafeMap<uint32_t, std::set<uint32_t>> string_init_map;
SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr;
MethodRefToStringInitRegMap& method_to_string_init_map = Runtime::Current()->GetStringInitMap();
- auto it = method_to_string_init_map.find(method_ref);
+ MethodRefToStringInitRegMap::iterator it;
+ {
+ MutexLock mu(self, *Locks::interpreter_string_init_map_lock_);
+ it = method_to_string_init_map.find(method_ref);
+ }
if (it == method_to_string_init_map.end()) {
string_init_map = std::move(verifier::MethodVerifier::FindStringInitMap(method));
- method_to_string_init_map.Overwrite(method_ref, string_init_map);
+ {
+ MutexLock mu(self, *Locks::interpreter_string_init_map_lock_);
+ method_to_string_init_map.Overwrite(method_ref, string_init_map);
+ }
string_init_map_ptr = &string_init_map;
} else {
string_init_map_ptr = &it->second;