diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/image_test.cc | 8 | ||||
| -rw-r--r-- | compiler/oat_test.cc | 35 | ||||
| -rw-r--r-- | compiler/oat_writer.cc | 45 | ||||
| -rw-r--r-- | compiler/oat_writer.h | 8 |
4 files changed, 45 insertions, 51 deletions
diff --git a/compiler/image_test.cc b/compiler/image_test.cc index 406d9d2696..d52ec0ad5a 100644 --- a/compiler/image_test.cc +++ b/compiler/image_test.cc @@ -25,7 +25,6 @@ #include "compiler/image_writer.h" #include "compiler/oat_writer.h" #include "gc/space/image_space.h" -#include "implicit_check_options.h" #include "lock_word.h" #include "mirror/object-inl.h" #include "signal_catcher.h" @@ -78,11 +77,8 @@ TEST_F(ImageTest, WriteRead) { t.NewTiming("WriteElf"); ScopedObjectAccess soa(Thread::Current()); - SafeMap<std::string, std::string> key_value_store; - key_value_store.Put(ImplicitCheckOptions::kImplicitChecksOatHeaderKey, - ImplicitCheckOptions::Serialize(true, true, true)); - OatWriter oat_writer(class_linker->GetBootClassPath(), 0, 0, compiler_driver_.get(), &timings, - &key_value_store); + OatWriter oat_writer(class_linker->GetBootClassPath(), + 0, 0, "", compiler_driver_.get(), &timings); bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, class_linker->GetBootClassPath(), diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index d2ee0ede80..254faac796 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -18,7 +18,6 @@ #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" @@ -112,16 +111,12 @@ 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, - &key_value_store); + &timings); bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(), !kIsTargetBuild, class_linker->GetBootClassPath(), @@ -141,7 +136,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", std::string(oat_header.GetStoreValueByKey(OatHeader::kImageLocationKey))); + ASSERT_EQ("lue.art", oat_header.GetImageFileLocation()); const DexFile* dex_file = java_lang_dex_file_; uint32_t dex_file_checksum = dex_file->GetLocationChecksum(); @@ -194,20 +189,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; - 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()); + 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()); 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 diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 92ed33c644..e1b6992c47 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -49,19 +49,19 @@ namespace art { OatWriter::OatWriter(const std::vector<const DexFile*>& dex_files, uint32_t image_file_location_oat_checksum, uintptr_t image_file_location_oat_begin, + const std::string& image_file_location, const CompilerDriver* compiler, - TimingLogger* timings, - SafeMap<std::string, std::string>* key_value_store) + TimingLogger* timings) : compiler_driver_(compiler), dex_files_(&dex_files), image_file_location_oat_checksum_(image_file_location_oat_checksum), image_file_location_oat_begin_(image_file_location_oat_begin), - key_value_store_(key_value_store), + image_file_location_(image_file_location), oat_header_(NULL), size_dex_file_alignment_(0), size_executable_offset_alignment_(0), size_oat_header_(0), - size_oat_header_key_value_store_(0), + size_oat_header_image_file_location_(0), size_dex_file_(0), size_interpreter_to_interpreter_bridge_(0), size_interpreter_to_compiled_code_bridge_(0), @@ -89,8 +89,6 @@ OatWriter::OatWriter(const std::vector<const DexFile*>& dex_files, size_oat_class_status_(0), size_oat_class_method_bitmaps_(0), size_oat_class_method_offsets_(0) { - CHECK(key_value_store != nullptr); - size_t offset; { TimingLogger::ScopedTiming split("InitOatHeader", timings); @@ -123,8 +121,7 @@ OatWriter::OatWriter(const std::vector<const DexFile*>& dex_files, size_ = offset; CHECK_EQ(dex_files_->size(), oat_dex_files_.size()); - CHECK_EQ(compiler->IsImage(), - key_value_store_->find(OatHeader::kImageLocationKey) == key_value_store_->end()); + CHECK(image_file_location.empty() == compiler->IsImage()); } OatWriter::~OatWriter() { @@ -719,14 +716,16 @@ bool OatWriter::VisitDexMethods(DexMethodVisitor* visitor) { } size_t OatWriter::InitOatHeader() { - oat_header_ = OatHeader::Create(compiler_driver_->GetInstructionSet(), - compiler_driver_->GetInstructionSetFeatures(), - dex_files_, - image_file_location_oat_checksum_, - image_file_location_oat_begin_, - key_value_store_); - - return oat_header_->GetHeaderSize(); + // create the OatHeader + oat_header_ = new OatHeader(compiler_driver_->GetInstructionSet(), + compiler_driver_->GetInstructionSetFeatures(), + dex_files_, + image_file_location_oat_checksum_, + image_file_location_oat_begin_, + image_file_location_); + size_t offset = sizeof(*oat_header_); + offset += image_file_location_.size(); + return offset; } size_t OatWriter::InitOatDexFiles(size_t offset) { @@ -865,13 +864,17 @@ size_t OatWriter::InitOatCodeDexFiles(size_t offset) { bool OatWriter::Write(OutputStream* out) { const size_t file_offset = out->Seek(0, kSeekCurrent); - size_t header_size = oat_header_->GetHeaderSize(); - if (!out->WriteFully(oat_header_, header_size)) { + if (!out->WriteFully(oat_header_, sizeof(*oat_header_))) { PLOG(ERROR) << "Failed to write oat header to " << out->GetLocation(); return false; } - size_oat_header_ += sizeof(OatHeader); - size_oat_header_key_value_store_ += oat_header_->GetHeaderSize() - sizeof(OatHeader); + size_oat_header_ += sizeof(*oat_header_); + + if (!out->WriteFully(image_file_location_.data(), image_file_location_.size())) { + PLOG(ERROR) << "Failed to write oat header image file location to " << out->GetLocation(); + return false; + } + size_oat_header_image_file_location_ += image_file_location_.size(); if (!WriteTables(out, file_offset)) { LOG(ERROR) << "Failed to write oat tables to " << out->GetLocation(); @@ -906,7 +909,7 @@ bool OatWriter::Write(OutputStream* out) { DO_STAT(size_dex_file_alignment_); DO_STAT(size_executable_offset_alignment_); DO_STAT(size_oat_header_); - DO_STAT(size_oat_header_key_value_store_); + DO_STAT(size_oat_header_image_file_location_); DO_STAT(size_dex_file_); DO_STAT(size_interpreter_to_interpreter_bridge_); DO_STAT(size_interpreter_to_compiled_code_bridge_); diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index 3d34956651..dbecb95362 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -79,9 +79,9 @@ class OatWriter { OatWriter(const std::vector<const DexFile*>& dex_files, uint32_t image_file_location_oat_checksum, uintptr_t image_file_location_oat_begin, + const std::string& image_file_location, const CompilerDriver* compiler, - TimingLogger* timings, - SafeMap<std::string, std::string>* key_value_store); + TimingLogger* timings); const OatHeader& GetOatHeader() const { return *oat_header_; @@ -253,9 +253,9 @@ class OatWriter { // dependencies on the image. uint32_t image_file_location_oat_checksum_; uintptr_t image_file_location_oat_begin_; + std::string image_file_location_; // data to write - SafeMap<std::string, std::string>* key_value_store_; OatHeader* oat_header_; std::vector<OatDexFile*> oat_dex_files_; std::vector<OatClass*> oat_classes_; @@ -274,7 +274,7 @@ class OatWriter { uint32_t size_dex_file_alignment_; uint32_t size_executable_offset_alignment_; uint32_t size_oat_header_; - uint32_t size_oat_header_key_value_store_; + uint32_t size_oat_header_image_file_location_; uint32_t size_dex_file_; uint32_t size_interpreter_to_interpreter_bridge_; uint32_t size_interpreter_to_compiled_code_bridge_; |