Fix null dereference in SweepInterpreterCaches am: 6a05d70393

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

Change-Id: I9a881ebff6ee8b2696ca36a360a098147352c7e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 5492cc8..2c465c9 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -4455,6 +4455,9 @@
 
 static void SweepCacheEntry(IsMarkedVisitor* visitor, const Instruction* inst, size_t* value)
     REQUIRES_SHARED(Locks::mutator_lock_) {
+  // WARNING: The interpreter will not modify the cache while this method is running in GC.
+  //          However, ClearAllInterpreterCaches can still run if any dex file is closed.
+  //          Therefore the cache entry can be nulled at any point through this method.
   if (inst == nullptr) {
     return;
   }
@@ -4480,6 +4483,9 @@
     case Opcode::CONST_STRING:
     case Opcode::CONST_STRING_JUMBO: {
       mirror::Object* object = reinterpret_cast<mirror::Object*>(*value);
+      if (object == nullptr) {
+        return;
+      }
       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).