Fix memory leak in CommonCompilerTest::CompileMethod().
And enforce that we successfully compile the method.
This fixes ASAN tests broken by
https://android-review.googlesource.com/919053
Test: run_build_test_target.py art-gtest-heap-poisoning
Change-Id: I98b6c11e097bd9aea6605f3b77b1bcbb2206dbd0
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index d59cb17..a44b9ae 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -173,7 +173,7 @@
TimingLogger timings("CommonCompilerTest::CompileMethod", false, false);
TimingLogger::ScopedTiming t(__FUNCTION__, &timings);
CompiledMethodStorage storage(/*swap_fd=*/ -1);
- const CompiledMethod* compiled_method = nullptr;
+ CompiledMethod* compiled_method = nullptr;
{
DCHECK(!Runtime::Current()->IsStarted());
Thread* self = Thread::Current();
@@ -204,8 +204,12 @@
}
compiler_options_->verification_results_ = nullptr;
}
- TimingLogger::ScopedTiming t2("MakeExecutable", &timings);
- MakeExecutable(method, compiled_method);
+ CHECK(method != nullptr);
+ {
+ TimingLogger::ScopedTiming t2("MakeExecutable", &timings);
+ MakeExecutable(method, compiled_method);
+ }
+ CompiledMethod::ReleaseSwapAllocatedCompiledMethod(&storage, compiled_method);
}
void CommonCompilerTest::CompileDirectMethod(Handle<mirror::ClassLoader> class_loader,