diff options
author | 2015-09-18 22:58:22 +0000 | |
---|---|---|
committer | 2015-09-18 22:58:22 +0000 | |
commit | 9e30c0e177adabaaf94a66c91130a19a7632fc7c (patch) | |
tree | e3177c7686cb6203c5f4c91cb9a38b6e80fcbec0 /runtime/interpreter/interpreter_common.cc | |
parent | 8e7b964be2fab9b6bbb30cf8897617424d0fe85f (diff) | |
parent | 4686c52394c0221ee3236753ad6be48f18b79365 (diff) |
Merge "Fix locking on string init map."
Diffstat (limited to 'runtime/interpreter/interpreter_common.cc')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 02ec90c78f..68d56f5198 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -696,22 +696,20 @@ static inline bool DoCallCommon(ArtMethod* called_method, // new result of the StringFactory. Use the verifier to find this set of registers. ArtMethod* method = shadow_frame.GetMethod(); MethodReference method_ref = method->ToMethodReference(); - SafeMap<uint32_t, std::set<uint32_t>> string_init_map; - SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr; + SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr = nullptr; MethodRefToStringInitRegMap& method_to_string_init_map = Runtime::Current()->GetStringInitMap(); - 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)); - { - MutexLock mu(self, *Locks::interpreter_string_init_map_lock_); - method_to_string_init_map.Overwrite(method_ref, string_init_map); + auto it = method_to_string_init_map.find(method_ref); + if (it != method_to_string_init_map.end()) { + string_init_map_ptr = &it->second; } - string_init_map_ptr = &string_init_map; - } else { + } + if (string_init_map_ptr == nullptr) { + SafeMap<uint32_t, std::set<uint32_t>> string_init_map = + verifier::MethodVerifier::FindStringInitMap(method); + MutexLock mu(self, *Locks::interpreter_string_init_map_lock_); + auto it = method_to_string_init_map.Overwrite(method_ref, string_init_map); string_init_map_ptr = &it->second; } if (string_init_map_ptr->size() != 0) { |