Remove OatWriter buffering to memory for ElfWriterQuick
This allows the oat contents to be directly written to the file.
Change-Id: Ibc7ddf57477b152f07784b52f7334be73fd22833
diff --git a/runtime/image_test.cc b/runtime/image_test.cc
index 11218ad..75eead4 100644
--- a/runtime/image_test.cc
+++ b/runtime/image_test.cc
@@ -41,7 +41,6 @@
TEST_F(ImageTest, WriteRead) {
ScratchFile tmp_elf;
{
- std::vector<uint8_t> oat_contents;
{
jobject class_loader = NULL;
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
@@ -49,17 +48,14 @@
compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings);
ScopedObjectAccess soa(Thread::Current());
- VectorOutputStream output_stream(tmp_elf.GetFilename(), oat_contents);
- bool success_oat = OatWriter::Create(output_stream, class_linker->GetBootClassPath(),
- 0, 0, "", *compiler_driver_.get());
- ASSERT_TRUE(success_oat);
-
- bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(),
- !kIsTargetBuild,
- class_linker->GetBootClassPath(),
- oat_contents,
- tmp_elf.GetFile());
- ASSERT_TRUE(success_elf);
+ OatWriter oat_writer(class_linker->GetBootClassPath(),
+ 0, 0, "", compiler_driver_.get());
+ bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(),
+ !kIsTargetBuild,
+ class_linker->GetBootClassPath(),
+ oat_writer,
+ tmp_elf.GetFile());
+ ASSERT_TRUE(success);
}
}
// Workound bug that mcld::Linker::emit closes tmp_elf by reopening as tmp_oat.
diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc
index 9a6bc19..3f2e43e 100644
--- a/runtime/oat_test.cc
+++ b/runtime/oat_test.cc
@@ -83,21 +83,17 @@
ScopedObjectAccess soa(Thread::Current());
ScratchFile tmp;
- std::vector<uint8_t> oat_contents;
- VectorOutputStream output_stream(tmp.GetFilename(), oat_contents);
- bool success_oat = OatWriter::Create(output_stream,
- class_linker->GetBootClassPath(),
- 42U,
- 4096U,
- "lue.art",
- *compiler_driver_.get());
- ASSERT_TRUE(success_oat);
- bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(),
- !kIsTargetBuild,
- class_linker->GetBootClassPath(),
- oat_contents,
- tmp.GetFile());
- ASSERT_TRUE(success_elf);
+ OatWriter oat_writer(class_linker->GetBootClassPath(),
+ 42U,
+ 4096U,
+ "lue.art",
+ compiler_driver_.get());
+ bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(),
+ !kIsTargetBuild,
+ class_linker->GetBootClassPath(),
+ oat_writer,
+ tmp.GetFile());
+ ASSERT_TRUE(success);
if (compile) { // OatWriter strips the code, regenerate to compare
TimingLogger timings("CommonTest::WriteRead", false);