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.cc b/runtime/oat.cc
index 1a07cdc..d14b399 100644
--- a/runtime/oat.cc
+++ b/runtime/oat.cc
@@ -473,6 +473,10 @@
return IsKeyEnabled(OatHeader::kDebuggableKey);
}
+bool OatHeader::IsConcurrentCopying() const {
+ return IsKeyEnabled(OatHeader::kConcurrentCopying);
+}
+
bool OatHeader::IsNativeDebuggable() const {
return IsKeyEnabled(OatHeader::kNativeDebuggableKey);
}
diff --git a/runtime/oat.h b/runtime/oat.h
index 5a4bc1c..88fa232 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -43,6 +43,7 @@
static constexpr const char* kCompilerFilter = "compiler-filter";
static constexpr const char* kClassPathKey = "classpath";
static constexpr const char* kBootClassPathKey = "bootclasspath";
+ static constexpr const char* kConcurrentCopying = "concurrent-copying";
static constexpr const char kTrueValue[] = "true";
static constexpr const char kFalseValue[] = "false";
@@ -112,6 +113,7 @@
bool IsDebuggable() const;
bool IsNativeDebuggable() const;
CompilerFilter::Filter GetCompilerFilter() const;
+ bool IsConcurrentCopying() const;
private:
bool KeyHasValue(const char* key, const char* value, size_t value_size) const;
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
-