diff options
Diffstat (limited to 'compiler/oat_test.cc')
| -rw-r--r-- | compiler/oat_test.cc | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index 030451c1cb..cd0f0d2c6f 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -27,14 +27,17 @@ #include "dex/verification_results.h" #include "driver/compiler_driver.h" #include "driver/compiler_options.h" +#include "dwarf/method_debug_info.h" +#include "elf_writer.h" +#include "elf_writer_quick.h" #include "entrypoints/quick/quick_entrypoints.h" +#include "linker/vector_output_stream.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "oat_file-inl.h" #include "oat_writer.h" #include "scoped_thread_state_change.h" -#include "vector_output_stream.h" namespace art { @@ -134,11 +137,31 @@ class OatTest : public CommonCompilerTest { /*compiling_boot_image*/false, &timings, &key_value_store); - return compiler_driver_->WriteElf(GetTestAndroidRoot(), - !kIsTargetBuild, - dex_files, - &oat_writer, - file); + std::unique_ptr<ElfWriter> elf_writer = CreateElfWriterQuick( + compiler_driver_->GetInstructionSet(), + &compiler_driver_->GetCompilerOptions(), + file); + + elf_writer->Start(); + + OutputStream* rodata = elf_writer->StartRoData(); + if (!oat_writer.WriteRodata(rodata)) { + return false; + } + elf_writer->EndRoData(rodata); + + OutputStream* text = elf_writer->StartText(); + if (!oat_writer.WriteCode(text)) { + return false; + } + elf_writer->EndText(text); + + elf_writer->SetBssSize(oat_writer.GetBssSize()); + elf_writer->WriteDynamicSection(); + elf_writer->WriteDebugInfo(oat_writer.GetMethodDebugInfo()); + elf_writer->WritePatchLocations(oat_writer.GetAbsolutePatchLocations()); + + return elf_writer->End(); } std::unique_ptr<const InstructionSetFeatures> insn_features_; @@ -176,7 +199,7 @@ TEST_F(OatTest, WriteRead) { ASSERT_TRUE(oat_file.get() != nullptr) << error_msg; const OatHeader& oat_header = oat_file->GetOatHeader(); ASSERT_TRUE(oat_header.IsValid()); - ASSERT_EQ(1U, oat_header.GetDexFileCount()); // core + ASSERT_EQ(class_linker->GetBootClassPath().size(), 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))); @@ -201,8 +224,9 @@ TEST_F(OatTest, WriteRead) { } const char* descriptor = dex_file.GetClassDescriptor(class_def); - mirror::Class* klass = class_linker->FindClass(soa.Self(), descriptor, - NullHandle<mirror::ClassLoader>()); + mirror::Class* klass = class_linker->FindClass(soa.Self(), + descriptor, + ScopedNullHandle<mirror::ClassLoader>()); const OatFile::OatClass oat_class = oat_dex_file->GetOatClass(i); CHECK_EQ(mirror::Class::Status::kStatusNotReady, oat_class.GetStatus()) << descriptor; @@ -215,12 +239,12 @@ TEST_F(OatTest, WriteRead) { ++method_index; } size_t visited_virtuals = 0; - for (auto& m : klass->GetVirtualMethods(pointer_size)) { - if (!m.IsMiranda()) { - CheckMethod(&m, oat_class.GetOatMethod(method_index), dex_file); - ++method_index; - ++visited_virtuals; - } + // TODO We should also check copied methods in this test. + for (auto& m : klass->GetDeclaredVirtualMethods(pointer_size)) { + EXPECT_FALSE(m.IsMiranda()); + CheckMethod(&m, oat_class.GetOatMethod(method_index), dex_file); + ++method_index; + ++visited_virtuals; } EXPECT_EQ(visited_virtuals, num_virtual_methods); } @@ -232,7 +256,7 @@ TEST_F(OatTest, OatHeaderSizeCheck) { EXPECT_EQ(72U, sizeof(OatHeader)); EXPECT_EQ(4U, sizeof(OatMethodOffsets)); EXPECT_EQ(28U, sizeof(OatQuickMethodHeader)); - EXPECT_EQ(114 * GetInstructionSetPointerSize(kRuntimeISA), sizeof(QuickEntryPoints)); + EXPECT_EQ(132 * GetInstructionSetPointerSize(kRuntimeISA), sizeof(QuickEntryPoints)); } TEST_F(OatTest, OatHeaderIsValid) { @@ -241,14 +265,9 @@ TEST_F(OatTest, OatHeaderIsValid) { std::unique_ptr<const InstructionSetFeatures> insn_features( InstructionSetFeatures::FromVariant(insn_set, "default", &error_msg)); ASSERT_TRUE(insn_features.get() != nullptr) << error_msg; - std::vector<const DexFile*> dex_files; - uint32_t image_file_location_oat_checksum = 0; - uint32_t image_file_location_oat_begin = 0; std::unique_ptr<OatHeader> oat_header(OatHeader::Create(insn_set, insn_features.get(), - &dex_files, - image_file_location_oat_checksum, - image_file_location_oat_begin, + 0u, nullptr)); ASSERT_NE(oat_header.get(), nullptr); ASSERT_TRUE(oat_header->IsValid()); |