ART: Allow method references across oat files for multi-image, 2nd attempt.
These were disabled because we didn't have sufficient
information about the multi-image layout when processing
link-time patches in OatWriter. This CL refactors the
ELF file creation so that the information is available.
Also clean up ImageWriter to use oat file indexes instead
of filenames and avoid reopening the oat file to retrieve
the checksum.
Change-Id: Icc7b528deca29da1e473c8f079521a36d6c4892f
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index 2e2d1f9..0695cb5 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -32,19 +32,19 @@
CompilerDriver driver(&compiler_options,
&verification_results,
&method_inliner_map,
- Compiler::kOptimizing, kNone,
- nullptr,
- false,
- nullptr,
- nullptr,
- nullptr,
- 1u,
- false,
- false,
- nullptr,
- -1,
- nullptr,
- nullptr);
+ Compiler::kOptimizing,
+ /* instruction_set_ */ kNone,
+ /* instruction_set_features */ nullptr,
+ /* boot_image */ false,
+ /* image_classes */ nullptr,
+ /* compiled_classes */ nullptr,
+ /* compiled_methods */ nullptr,
+ /* thread_count */ 1u,
+ /* dump_stats */ false,
+ /* dump_passes */ false,
+ /* timer */ nullptr,
+ /* swap_fd */ -1,
+ /* profile_compilation_info */ nullptr);
CompiledMethodStorage* storage = driver.GetCompiledMethodStorage();
ASSERT_TRUE(storage->DedupeEnabled()); // The default.
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 670fe94..e80730f 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -342,12 +342,15 @@
Compiler::Kind compiler_kind,
InstructionSet instruction_set,
const InstructionSetFeatures* instruction_set_features,
- bool boot_image, std::unordered_set<std::string>* image_classes,
+ bool boot_image,
+ std::unordered_set<std::string>* image_classes,
std::unordered_set<std::string>* compiled_classes,
std::unordered_set<std::string>* compiled_methods,
- size_t thread_count, bool dump_stats, bool dump_passes,
- CumulativeLogger* timer, int swap_fd,
- const std::unordered_map<const DexFile*, const char*>* dex_to_oat_map,
+ size_t thread_count,
+ bool dump_stats,
+ bool dump_passes,
+ CumulativeLogger* timer,
+ int swap_fd,
const ProfileCompilationInfo* profile_compilation_info)
: compiler_options_(compiler_options),
verification_results_(verification_results),
@@ -374,7 +377,6 @@
compiler_context_(nullptr),
support_boot_image_fixup_(instruction_set != kMips && instruction_set != kMips64),
dex_files_for_oat_file_(nullptr),
- dex_file_oat_filename_map_(dex_to_oat_map),
compiled_method_storage_(swap_fd),
profile_compilation_info_(profile_compilation_info) {
DCHECK(compiler_options_ != nullptr);
@@ -1678,12 +1680,6 @@
use_dex_cache = true;
}
}
- if (!use_dex_cache && IsBootImage()) {
- if (!AreInSameOatFile(&(const_cast<mirror::Class*>(referrer_class)->GetDexFile()),
- &declaring_class->GetDexFile())) {
- use_dex_cache = true;
- }
- }
// The method is defined not within this dex file. We need a dex cache slot within the current
// dex file or direct pointers.
bool must_use_direct_pointers = false;
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 5e35cbb..ca340ee 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -94,9 +94,11 @@
bool boot_image, std::unordered_set<std::string>* image_classes,
std::unordered_set<std::string>* compiled_classes,
std::unordered_set<std::string>* compiled_methods,
- size_t thread_count, bool dump_stats, bool dump_passes,
- CumulativeLogger* timer, int swap_fd,
- const std::unordered_map<const DexFile*, const char*>* dex_to_oat_map,
+ size_t thread_count,
+ bool dump_stats,
+ bool dump_passes,
+ CumulativeLogger* timer,
+ int swap_fd,
const ProfileCompilationInfo* profile_compilation_info);
~CompilerDriver();
@@ -113,20 +115,6 @@
: ArrayRef<const DexFile* const>();
}
- // Are the given dex files compiled into the same oat file? Should only be called after
- // GetDexFilesForOatFile, as the conservative answer (when we don't have a map) is true.
- bool AreInSameOatFile(const DexFile* d1, const DexFile* d2) {
- if (dex_file_oat_filename_map_ == nullptr) {
- // TODO: Check for this wrt/ apps and boot image calls.
- return true;
- }
- auto it1 = dex_file_oat_filename_map_->find(d1);
- DCHECK(it1 != dex_file_oat_filename_map_->end());
- auto it2 = dex_file_oat_filename_map_->find(d2);
- DCHECK(it2 != dex_file_oat_filename_map_->end());
- return it1->second == it2->second;
- }
-
void CompileAll(jobject class_loader,
const std::vector<const DexFile*>& dex_files,
TimingLogger* timings)
@@ -700,9 +688,6 @@
// List of dex files that will be stored in the oat file.
const std::vector<const DexFile*>* dex_files_for_oat_file_;
- // Map from dex files to the oat file (name) they will be compiled into.
- const std::unordered_map<const DexFile*, const char*>* dex_file_oat_filename_map_;
-
CompiledMethodStorage compiled_method_storage_;
// Info for profile guided compilation.