diff options
author | Andreas Gampe <agampe@google.com> | 2014-06-26 16:11:07 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-07-08 12:14:38 -0700 |
commit | c87d27b25994da8670d82a8f7bad6327b693bfff (patch) | |
tree | e8ad0fa224f050c5c3e3e30ccdc0912f28650f42 /compiler/oat_test.cc | |
parent | e8a30f37bf1530a80a7df17692dbe7a68764ac30 (diff) | |
download | art-c87d27b25994da8670d82a8f7bad6327b693bfff.zip art-c87d27b25994da8670d82a8f7bad6327b693bfff.tar.gz art-c87d27b25994da8670d82a8f7bad6327b693bfff.tar.bz2 |
ART: Key-Value Store in Oat header
Allows the storage of string-string pairs in the oat header. The
first significant use of this is storing the implicit-check flags,
so that an oat file can be rejected if it doesn't agree with the
current runtime.
Bump the oat version as the header structure changes.
Change-Id: I15a1c16886e6b8fa7b881c918c19c1efa5c7c00f
Diffstat (limited to 'compiler/oat_test.cc')
-rw-r--r-- | compiler/oat_test.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index 254faac..d2ee0ed 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -18,6 +18,7 @@ #include "compiler/compiler.h" #include "compiler/oat_writer.h" #include "entrypoints/quick/quick_entrypoints.h" +#include "implicit_check_options.h" #include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" @@ -111,12 +112,16 @@ TEST_F(OatTest, WriteRead) { ScopedObjectAccess soa(Thread::Current()); ScratchFile tmp; + SafeMap<std::string, std::string> key_value_store; + key_value_store.Put(OatHeader::kImageLocationKey, "lue.art"); + key_value_store.Put(ImplicitCheckOptions::kImplicitChecksOatHeaderKey, + ImplicitCheckOptions::Serialize(true, true, true)); OatWriter oat_writer(class_linker->GetBootClassPath(), 42U, 4096U, - "lue.art", compiler_driver_.get(), - &timings); + &timings, + &key_value_store); bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, class_linker->GetBootClassPath(), @@ -136,7 +141,7 @@ TEST_F(OatTest, WriteRead) { ASSERT_EQ(1U, oat_header.GetDexFileCount()); // core ASSERT_EQ(42U, oat_header.GetImageFileLocationOatChecksum()); ASSERT_EQ(4096U, oat_header.GetImageFileLocationOatDataBegin()); - ASSERT_EQ("lue.art", oat_header.GetImageFileLocation()); + ASSERT_EQ("lue.art", std::string(oat_header.GetStoreValueByKey(OatHeader::kImageLocationKey))); const DexFile* dex_file = java_lang_dex_file_; uint32_t dex_file_checksum = dex_file->GetLocationChecksum(); @@ -189,20 +194,20 @@ TEST_F(OatTest, OatHeaderIsValid) { std::vector<const DexFile*> dex_files; uint32_t image_file_location_oat_checksum = 0; uint32_t image_file_location_oat_begin = 0; - const std::string image_file_location; - OatHeader oat_header(instruction_set, - instruction_set_features, - &dex_files, - image_file_location_oat_checksum, - image_file_location_oat_begin, - image_file_location); - ASSERT_TRUE(oat_header.IsValid()); - - char* magic = const_cast<char*>(oat_header.GetMagic()); + OatHeader* oat_header = OatHeader::Create(instruction_set, + instruction_set_features, + &dex_files, + image_file_location_oat_checksum, + image_file_location_oat_begin, + nullptr); + ASSERT_NE(oat_header, nullptr); + ASSERT_TRUE(oat_header->IsValid()); + + char* magic = const_cast<char*>(oat_header->GetMagic()); strcpy(magic, ""); // bad magic - ASSERT_FALSE(oat_header.IsValid()); + ASSERT_FALSE(oat_header->IsValid()); strcpy(magic, "oat\n000"); // bad version - ASSERT_FALSE(oat_header.IsValid()); + ASSERT_FALSE(oat_header->IsValid()); } } // namespace art |