ART: Note CC configuration down into oat files

To detect changes in configuration, write the runtime configuration
of ART_USE_READ_BARRIER into the oat file key-value store.

Bug: 34084559
Bug: 12687968
Test: m test-art-host
Test: m ART_USE_READ_BARRIER=true test-art-host
Change-Id: I0b2bd9aa5546538e2b4b669b0acc0a4bebfd7bf0
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index f12a5e7..8554fa2 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -304,6 +304,13 @@
 }
 
 OatFileAssistant::OatStatus OatFileAssistant::GivenOatFileStatus(const OatFile& file) {
+  // Verify the ART_USE_READ_BARRIER state.
+  const bool is_cc = file.GetOatHeader().IsConcurrentCopying();
+  constexpr bool kRuntimeIsCC = kUseReadBarrier;
+  if (is_cc != kRuntimeIsCC) {
+    return kOatCannotOpen;
+  }
+
   // Verify the dex checksum.
   // Note: GetOatDexFile will return null if the dex checksum doesn't match
   // what we provide, which verifies the primary dex checksum for us.
@@ -903,4 +910,3 @@
   return std::unique_ptr<OatFile>();
 }
 }  // namespace art
-