diff options
| author | 2023-03-17 00:24:00 +0000 | |
|---|---|---|
| committer | 2023-03-17 15:42:16 +0000 | |
| commit | 8e564db61d5326c710f1840d83a71d51bf94a754 (patch) | |
| tree | 24fa1ab8036dc2dedd158b3e5b05a43958f1bfb0 /runtime/interpreter/interpreter_cache.cc | |
| 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
Diffstat (limited to 'runtime/interpreter/interpreter_cache.cc')
| -rw-r--r-- | runtime/interpreter/interpreter_cache.cc | 8 |
1 files changed, 7 insertions, 1 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 |