Clear interpreter cache with atomic stores am: 8e564db61d am: 980e3cfce0

Original change: https://android-review.googlesource.com/c/platform/art/+/2494049

Change-Id: Ia28cffac3bdcbeb60c52be0674894aaf5fbfe67d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/runtime/interpreter/interpreter_cache.cc b/runtime/interpreter/interpreter_cache.cc
index 450edba..7e7b294 100644
--- a/runtime/interpreter/interpreter_cache.cc
+++ b/runtime/interpreter/interpreter_cache.cc
@@ -22,7 +22,13 @@
 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 4124354..34f9045 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -430,7 +430,7 @@
         // 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 d7299bc..77f53cf 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -4488,7 +4488,7 @@
       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);
       }