summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2018-10-31 11:50:26 -0700
committer Mathieu Chartier <mathieuc@google.com> 2018-10-31 12:50:20 -0700
commit41c080891ca9d8834c9b50c3ac18dd01c20de9e9 (patch)
treeabdf11b6e000884004c0c82f784a90595f63da05 /runtime/class_linker.cc
parent41271dd3dfc2ff75702ae3b709eb8afa9464a49f (diff)
Hold intern table lock for AddImageStringsToTable
Fixes a correctness issue where another thread adding an intern string after the visitor could cause duplicate strings. Reduces how often the intern table lock is acquired, probably improving performance. Bug: 116059983 Test: test-art-host Change-Id: I5ba6ca3ba7535de6d4ad5cb46750bd23a6e9aadc
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f43791ab06..e3dfdb3256 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1486,7 +1486,6 @@ void AppImageLoadingHelper::HandleAppImageStrings(gc::space::ImageSpace* space)
// the strings they point to.
ScopedTrace timing("AppImage:InternString");
- Thread* const self = Thread::Current();
InternTable* const intern_table = Runtime::Current()->GetInternTable();
// Add the intern table, removing any conflicts. For conflicts, store the new address in a map
@@ -1494,13 +1493,14 @@ void AppImageLoadingHelper::HandleAppImageStrings(gc::space::ImageSpace* space)
// TODO: Optimize with a bitmap or bloom filter
SafeMap<mirror::String*, mirror::String*> intern_remap;
intern_table->AddImageStringsToTable(space, [&](InternTable::UnorderedSet& interns)
- REQUIRES_SHARED(Locks::mutator_lock_) {
+ REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(Locks::intern_table_lock_) {
VLOG(image) << "AppImage:stringsInInternTableSize = " << interns.size();
for (auto it = interns.begin(); it != interns.end(); ) {
ObjPtr<mirror::String> string = it->Read();
- ObjPtr<mirror::String> existing = intern_table->LookupWeak(self, string);
+ ObjPtr<mirror::String> existing = intern_table->LookupWeakLocked(string);
if (existing == nullptr) {
- existing = intern_table->LookupStrong(self, string);
+ existing = intern_table->LookupStrongLocked(string);
}
if (existing != nullptr) {
intern_remap.Put(string.Ptr(), existing.Ptr());