diff options
author | 2023-03-17 00:24:00 +0000 | |
---|---|---|
committer | 2023-03-17 15:42:16 +0000 | |
commit | 8e564db61d5326c710f1840d83a71d51bf94a754 (patch) | |
tree | 24fa1ab8036dc2dedd158b3e5b05a43958f1bfb0 | |
parent | 947b322d2c38dea414e9578d25dcf6f1d3963102 (diff) |
Clear interpreter cache with atomic stores
std::fill* function can potentially cause partial clearing which doesn't
work well with IsMarked() functions.
Also added more info in the nullptr CHECK while sweeping interpreter
caches.
Bug: 273235602
Test: manual
Change-Id: I47993504c18ed0c088a73b8eb77d1eaae9fef729
-rw-r--r-- | runtime/interpreter/interpreter_cache.cc | 8 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 2 | ||||
-rw-r--r-- | runtime/thread.cc | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/runtime/interpreter/interpreter_cache.cc b/runtime/interpreter/interpreter_cache.cc index 450edbaa4e..7e7b294c17 100644 --- a/runtime/interpreter/interpreter_cache.cc +++ b/runtime/interpreter/interpreter_cache.cc @@ -22,7 +22,13 @@ namespace art { void InterpreterCache::Clear(Thread* owning_thread) { DCHECK(owning_thread->GetInterpreterCache() == this); DCHECK(owning_thread == Thread::Current() || owning_thread->IsSuspended()); - data_.fill(Entry{}); + // Avoid using std::fill (or its variant) as there could be a concurrent sweep + // happening by the GC thread and these functions may clear partially. + for (Entry& entry : data_) { + std::atomic<const void*>* atomic_key_addr = + reinterpret_cast<std::atomic<const void*>*>(&entry.first); + atomic_key_addr->store(nullptr, std::memory_order_relaxed); + } } } // namespace art diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 4124354467..34f9045a33 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -430,7 +430,7 @@ void JitCodeCache::SweepRootTables(IsMarkedVisitor* visitor) { // is always alive. // TODO: Do not use IsMarked for j.l.Class, and adjust once we move this method // out of the weak access/creation pause. b/32167580 - DCHECK_NE(new_object, nullptr); + DCHECK_NE(new_object, nullptr) << "old-string:" << object; if (new_object != object) { roots[i] = GcRoot<mirror::Object>(new_object); } diff --git a/runtime/thread.cc b/runtime/thread.cc index d7299bcb26..77f53cff79 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -4488,7 +4488,7 @@ static void SweepCacheEntry(IsMarkedVisitor* visitor, const Instruction* inst, s mirror::Object* new_object = visitor->IsMarked(object); // We know the string is marked because it's a strongly-interned string that // is always alive (see b/117621117 for trying to make those strings weak). - DCHECK_NE(new_object, nullptr); + CHECK_NE(new_object, nullptr) << "old-string:" << object; if (new_object != object) { *value = reinterpret_cast<size_t>(new_object); } |