summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dex2oat/dex2oat.cc3
-rw-r--r--dex2oat/dex2oat_image_test.cc48
-rw-r--r--libartbase/base/common_art_test.cc3
-rw-r--r--runtime/common_runtime_test.cc5
-rw-r--r--runtime/common_runtime_test.h10
-rw-r--r--runtime/gc/space/image_space_test.cc2
6 files changed, 41 insertions, 30 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index cd87eb49a3..02afa7c23d 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -2348,7 +2348,8 @@ class Dex2Oat final {
// default profile arena). However the setup logic is messy and needs
// cleaning up before that (e.g. the oat writers are created before the
// runtime).
- profile_compilation_info_.reset(new ProfileCompilationInfo());
+ bool for_boot_image = IsBootImage() || IsBootImageExtension();
+ profile_compilation_info_.reset(new ProfileCompilationInfo(for_boot_image));
// Dex2oat only uses the reference profile and that is not updated concurrently by the app or
// other processes. So we don't need to lock (as we have to do in profman or when writing the
// profile info).
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index 20841f7524..a44a3e4e55 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -199,10 +199,10 @@ TEST_F(Dex2oatImageTest, TestModesAndFilters) {
ArrayRef<const std::string> libcore_dexes_array(libcore_dexes);
{
ScratchFile profile_file;
- GenerateProfile(libcore_dexes_array,
- profile_file.GetFile(),
- /*method_frequency=*/ 1u,
- /*type_frequency=*/ 1u);
+ GenerateBootProfile(libcore_dexes_array,
+ profile_file.GetFile(),
+ /*method_frequency=*/ 1u,
+ /*type_frequency=*/ 1u);
everything_sizes = CompileImageAndGetSizes(
dex_files,
{"--profile-file=" + profile_file.GetFilename(),
@@ -219,10 +219,10 @@ TEST_F(Dex2oatImageTest, TestModesAndFilters) {
// Test compiling fewer methods and classes.
{
ScratchFile profile_file;
- GenerateProfile(libcore_dexes_array,
- profile_file.GetFile(),
- kMethodFrequency,
- kTypeFrequency);
+ GenerateBootProfile(libcore_dexes_array,
+ profile_file.GetFile(),
+ kMethodFrequency,
+ kTypeFrequency);
filter_sizes = CompileImageAndGetSizes(
dex_files,
{"--profile-file=" + profile_file.GetFilename(),
@@ -310,22 +310,22 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// Create profiles.
ScratchFile head_profile_file;
- GenerateProfile(head_dex_files,
- head_profile_file.GetFile(),
- /*method_frequency=*/ 1u,
- /*type_frequency=*/ 1u);
+ GenerateBootProfile(head_dex_files,
+ head_profile_file.GetFile(),
+ /*method_frequency=*/ 1u,
+ /*type_frequency=*/ 1u);
const std::string& head_profile_filename = head_profile_file.GetFilename();
ScratchFile mid_profile_file;
- GenerateProfile(mid_dex_files,
- mid_profile_file.GetFile(),
- /*method_frequency=*/ 5u,
- /*type_frequency=*/ 4u);
+ GenerateBootProfile(mid_dex_files,
+ mid_profile_file.GetFile(),
+ /*method_frequency=*/ 5u,
+ /*type_frequency=*/ 4u);
const std::string& mid_profile_filename = mid_profile_file.GetFilename();
ScratchFile tail_profile_file;
- GenerateProfile(tail_dex_files,
- tail_profile_file.GetFile(),
- /*method_frequency=*/ 5u,
- /*type_frequency=*/ 4u);
+ GenerateBootProfile(tail_dex_files,
+ tail_profile_file.GetFile(),
+ /*method_frequency=*/ 5u,
+ /*type_frequency=*/ 4u);
const std::string& tail_profile_filename = tail_profile_file.GetFilename();
// Compile the "head", i.e. the primary boot image.
@@ -376,10 +376,10 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// Create a smaller profile for the single-image test that squashes the "mid" and "tail".
ScratchFile single_profile_file;
- GenerateProfile(single_dex_files,
- single_profile_file.GetFile(),
- /*method_frequency=*/ 5u,
- /*type_frequency=*/ 4u);
+ GenerateBootProfile(single_dex_files,
+ single_profile_file.GetFile(),
+ /*method_frequency=*/ 5u,
+ /*type_frequency=*/ 4u);
const std::string& single_profile_filename = single_profile_file.GetFilename();
// Prepare the single image name and location.
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 042ce55350..698ff87e09 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -126,10 +126,11 @@ int ScratchFile::GetFd() const {
}
void ScratchFile::Close() {
- if (file_.get() != nullptr) {
+ if (file_ != nullptr) {
if (file_->FlushCloseOrErase() != 0) {
PLOG(WARNING) << "Error closing scratch file.";
}
+ file_.reset();
}
}
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 45095732be..0d21de148a 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -571,8 +571,9 @@ void CommonRuntimeTestImpl::VisitDexes(ArrayRef<const std::string> dexes,
void CommonRuntimeTestImpl::GenerateProfile(ArrayRef<const std::string> dexes,
File* out_file,
size_t method_frequency,
- size_t type_frequency) {
- ProfileCompilationInfo profile;
+ size_t type_frequency,
+ bool for_boot_image) {
+ ProfileCompilationInfo profile(for_boot_image);
VisitDexes(
dexes,
[&profile](MethodReference ref) {
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index cc23620a54..cc347a1e16 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -174,7 +174,15 @@ class CommonRuntimeTestImpl : public CommonArtTestImpl {
void GenerateProfile(ArrayRef<const std::string> dexes,
File* out_file,
size_t method_frequency = 1u,
- size_t type_frequency = 1u);
+ size_t type_frequency = 1u,
+ bool for_boot_image = false);
+ void GenerateBootProfile(ArrayRef<const std::string> dexes,
+ File* out_file,
+ size_t method_frequency = 1u,
+ size_t type_frequency = 1u) {
+ return GenerateProfile(
+ dexes, out_file, method_frequency, type_frequency, /*for_boot_image=*/ true);
+ }
std::unique_ptr<Runtime> runtime_;
diff --git a/runtime/gc/space/image_space_test.cc b/runtime/gc/space/image_space_test.cc
index 0b22a6f83f..885dd218de 100644
--- a/runtime/gc/space/image_space_test.cc
+++ b/runtime/gc/space/image_space_test.cc
@@ -79,7 +79,7 @@ TEST_F(ImageSpaceTest, StringDeduplication) {
std::string jar_name = GetTestDexFileName(base_name);
ArrayRef<const std::string> dex_files(&jar_name, /*size=*/ 1u);
ScratchFile profile_file;
- GenerateProfile(dex_files, profile_file.GetFile());
+ GenerateBootProfile(dex_files, profile_file.GetFile());
std::vector<std::string> extra_args = {
"--profile-file=" + profile_file.GetFilename(),
"--runtime-arg",