OSDN Git Service

ART: Note CC configuration down into oat files
authorAndreas Gampe <agampe@google.com>
Thu, 19 Jan 2017 00:05:01 +0000 (16:05 -0800)
committerHiroshi Yamauchi <yamauchi@google.com>
Thu, 19 Jan 2017 00:34:50 +0000 (16:34 -0800)
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

dex2oat/dex2oat.cc
runtime/oat.cc
runtime/oat.h
runtime/oat_file_assistant.cc

index 21b03eb..3fbdb89 100644 (file)
@@ -1095,6 +1095,8 @@ class Dex2Oat FINAL {
         compiler_options_->GetNativeDebuggable() ? OatHeader::kTrueValue : OatHeader::kFalseValue);
     key_value_store_->Put(OatHeader::kCompilerFilter,
         CompilerFilter::NameOfFilter(compiler_options_->GetCompilerFilter()));
+    key_value_store_->Put(OatHeader::kConcurrentCopying,
+                          kUseReadBarrier ? OatHeader::kTrueValue : OatHeader::kFalseValue);
   }
 
   // Parse the arguments from the command line. In case of an unrecognized option or impossible
index 1a07cdc..d14b399 100644 (file)
@@ -473,6 +473,10 @@ bool OatHeader::IsDebuggable() const {
   return IsKeyEnabled(OatHeader::kDebuggableKey);
 }
 
+bool OatHeader::IsConcurrentCopying() const {
+  return IsKeyEnabled(OatHeader::kConcurrentCopying);
+}
+
 bool OatHeader::IsNativeDebuggable() const {
   return IsKeyEnabled(OatHeader::kNativeDebuggableKey);
 }
index 5a4bc1c..88fa232 100644 (file)
@@ -43,6 +43,7 @@ class PACKED(4) OatHeader {
   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 @@ class PACKED(4) OatHeader {
   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;
index f12a5e7..8554fa2 100644 (file)
@@ -304,6 +304,13 @@ OatFileAssistant::OatStatus OatFileAssistant::OatFileStatus() {
 }
 
 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 @@ std::unique_ptr<OatFile> OatFileAssistant::OatFileInfo::ReleaseFileForUse() {
   return std::unique_ptr<OatFile>();
 }
 }  // namespace art
-