summaryrefslogtreecommitdiff
path: root/compiler/driver
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2015-10-29 12:18:29 +0000
committer Vladimir Marko <vmarko@google.com> 2015-10-30 15:38:39 +0000
commitd1eaf0dc9abc42dbcbbd9c4b98bf930ae5f394f3 (patch)
tree335509fbc92becce5cb08e23361e2cae86756729 /compiler/driver
parent594c0612519e96bcc1bd42ff4dcbfa2c53b09c5a (diff)
Keep list of dex files for oat file in CompilerDriver.
Use this list to improve invoke-static/-direct dispatch for intra-oat calls. Also fix a latent ArmBaseRelativePatcher::ReserveSpaceEnd() bug exposed by a buggy early version of this CL: when we have unresolved patches at the end of all code, we need to emit a final thunk. Though the OatWriter will try to patch the unresolved call to a trampoline at the beginning of the oat file, that trampoline may be too far and the relative patcher doesn't know about it anyway, so it needs to assume that a thunk is needed. This reduces the overall size of oat files present in dalvik cache on Nexus 9 after first boot by over 1MiB, AOSP ToT, aosp_flounder-userdebug build. Change-Id: I98604b70cb17377eed057c1c23971865cf344e43
Diffstat (limited to 'compiler/driver')
-rw-r--r--compiler/driver/compiler_driver.cc4
-rw-r--r--compiler/driver/compiler_driver.h19
2 files changed, 20 insertions, 3 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 8750aa8e4e..fb116bb3da 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -375,6 +375,7 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options,
timings_logger_(timer),
compiler_context_(nullptr),
support_boot_image_fixup_(instruction_set != kMips && instruction_set != kMips64),
+ dex_files_for_oat_file_(nullptr),
compiled_method_storage_(swap_fd) {
DCHECK(compiler_options_ != nullptr);
DCHECK(verification_results_ != nullptr);
@@ -1371,8 +1372,7 @@ uint32_t CompilerDriver::GetReferenceDisableFlagOffset() const {
}
DexCacheArraysLayout CompilerDriver::GetDexCacheArraysLayout(const DexFile* dex_file) {
- // Currently only image dex caches have fixed array layout.
- return IsImage() && GetSupportBootImageFixup()
+ return ContainsElement(GetDexFilesForOatFile(), dex_file)
? DexCacheArraysLayout(GetInstructionSetPointerSize(instruction_set_), dex_file)
: DexCacheArraysLayout();
}
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 485cdcfb1b..4ed4dc60d2 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -39,6 +39,7 @@
#include "runtime.h"
#include "safe_map.h"
#include "thread_pool.h"
+#include "utils/array_ref.h"
#include "utils/dex_cache_arrays_layout.h"
namespace art {
@@ -101,7 +102,20 @@ class CompilerDriver {
~CompilerDriver();
- void CompileAll(jobject class_loader, const std::vector<const DexFile*>& dex_files,
+ // Set dex files that will be stored in the oat file after being compiled.
+ void SetDexFilesForOatFile(const std::vector<const DexFile*>& dex_files) {
+ dex_files_for_oat_file_ = &dex_files;
+ }
+
+ // Get dex file that will be stored in the oat file after being compiled.
+ ArrayRef<const DexFile* const> GetDexFilesForOatFile() const {
+ return (dex_files_for_oat_file_ != nullptr)
+ ? ArrayRef<const DexFile* const>(*dex_files_for_oat_file_)
+ : ArrayRef<const DexFile* const>();
+ }
+
+ void CompileAll(jobject class_loader,
+ const std::vector<const DexFile*>& dex_files,
TimingLogger* timings)
REQUIRES(!Locks::mutator_lock_, !compiled_classes_lock_);
@@ -661,6 +675,9 @@ class CompilerDriver {
bool support_boot_image_fixup_;
+ // List of dex files that will be stored in the oat file.
+ const std::vector<const DexFile*>* dex_files_for_oat_file_;
+
CompiledMethodStorage compiled_method_storage_;
friend class CompileClassVisitor;