summaryrefslogtreecommitdiff
path: root/compiler/oat_test.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-11-25 14:33:36 +0000
committer Vladimir Marko <vmarko@google.com> 2015-11-30 18:19:44 +0000
commit10c13565474de2786aad7c2e79757ea250747a15 (patch)
tree759bdf7aab97ab45e1a3e09f5d627e568f6e7084 /compiler/oat_test.cc
parente928dc587718d00d234768f76d1efb2ffe74e885 (diff)
Refactor oat file writing to give Dex2Oat more control.
This is the first step towards writing dex files to oat file and mapping them from there for the actual AOT compilation. Change-Id: Icb0d27487eaf6ba3a66c157e695f9bdc5bb9cf9a
Diffstat (limited to 'compiler/oat_test.cc')
-rw-r--r--compiler/oat_test.cc38
1 files changed, 33 insertions, 5 deletions
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index 030451c1cb..c305b120cb 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -27,6 +27,9 @@
#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 "mirror/class-inl.h"
#include "mirror/object_array-inl.h"
@@ -134,11 +137,36 @@ 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();
+
+ ArrayRef<const dwarf::MethodDebugInfo> method_infos(oat_writer.GetMethodDebugInfo());
+ elf_writer->WriteDebugInfo(method_infos);
+
+ ArrayRef<const uintptr_t> patch_locations(oat_writer.GetAbsolutePatchLocations());
+ elf_writer->WritePatchLocations(patch_locations);
+
+ return elf_writer->End();
}
std::unique_ptr<const InstructionSetFeatures> insn_features_;