diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 53 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.h | 2 | ||||
| -rw-r--r-- | compiler/image_writer.cc | 6 |
3 files changed, 37 insertions, 24 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 6f6eeece84..b99aca17a5 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -508,7 +508,7 @@ void CompilerDriver::CompileAll(jobject class_loader, TimingLogger* timings) { DCHECK(!Runtime::Current()->IsStarted()); std::unique_ptr<ThreadPool> thread_pool(new ThreadPool("Compiler driver thread pool", thread_count_ - 1)); - VLOG(compiler) << "Before precompile " << GetMemoryUsageString(); + VLOG(compiler) << "Before precompile " << GetMemoryUsageString(false); PreCompile(class_loader, dex_files, thread_pool.get(), timings); Compile(class_loader, dex_files, thread_pool.get(), timings); if (dump_stats_) { @@ -605,10 +605,10 @@ void CompilerDriver::Resolve(jobject class_loader, const std::vector<const DexFi void CompilerDriver::PreCompile(jobject class_loader, const std::vector<const DexFile*>& dex_files, ThreadPool* thread_pool, TimingLogger* timings) { LoadImageClasses(timings); - VLOG(compiler) << "LoadImageClasses: " << GetMemoryUsageString(); + VLOG(compiler) << "LoadImageClasses: " << GetMemoryUsageString(false); Resolve(class_loader, dex_files, thread_pool, timings); - VLOG(compiler) << "Resolve: " << GetMemoryUsageString(); + VLOG(compiler) << "Resolve: " << GetMemoryUsageString(false); if (!compiler_options_->IsVerificationEnabled()) { VLOG(compiler) << "Verify none mode specified, skipping verification."; @@ -617,13 +617,13 @@ void CompilerDriver::PreCompile(jobject class_loader, const std::vector<const De } Verify(class_loader, dex_files, thread_pool, timings); - VLOG(compiler) << "Verify: " << GetMemoryUsageString(); + VLOG(compiler) << "Verify: " << GetMemoryUsageString(false); InitializeClasses(class_loader, dex_files, thread_pool, timings); - VLOG(compiler) << "InitializeClasses: " << GetMemoryUsageString(); + VLOG(compiler) << "InitializeClasses: " << GetMemoryUsageString(false); UpdateImageClasses(timings); - VLOG(compiler) << "UpdateImageClasses: " << GetMemoryUsageString(); + VLOG(compiler) << "UpdateImageClasses: " << GetMemoryUsageString(false); } bool CompilerDriver::IsImageClass(const char* descriptor) const { @@ -1184,14 +1184,15 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType // TODO: support patching on all architectures. use_dex_cache = use_dex_cache || (force_relocations && !support_boot_image_fixup_); } - bool method_code_in_boot = (method->GetDeclaringClass()->GetClassLoader() == nullptr); + mirror::Class* declaring_class = method->GetDeclaringClass(); + bool method_code_in_boot = (declaring_class->GetClassLoader() == nullptr); if (!use_dex_cache) { if (!method_code_in_boot) { use_dex_cache = true; } else { bool has_clinit_trampoline = - method->IsStatic() && !method->GetDeclaringClass()->IsInitialized(); - if (has_clinit_trampoline && (method->GetDeclaringClass() != referrer_class)) { + method->IsStatic() && !declaring_class->IsInitialized(); + if (has_clinit_trampoline && (declaring_class != referrer_class)) { // Ensure we run the clinit trampoline unless we are invoking a static method in the same // class. use_dex_cache = true; @@ -1202,7 +1203,15 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType *stats_flags |= kFlagDirectCallToBoot | kFlagDirectMethodToBoot; } if (!use_dex_cache && force_relocations) { - if (!IsImage() || !IsImageClass(method->GetDeclaringClassDescriptor())) { + bool is_in_image; + if (IsImage()) { + is_in_image = IsImageClass(method->GetDeclaringClassDescriptor()); + } else { + is_in_image = instruction_set_ != kX86 && instruction_set_ != kX86_64 && + Runtime::Current()->GetHeap()->FindSpaceFromObject(declaring_class, + false)->IsImageSpace(); + } + if (!is_in_image) { // We can only branch directly to Methods that are resolved in the DexCache. // Otherwise we won't invoke the resolution trampoline. use_dex_cache = true; @@ -1211,7 +1220,7 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType // 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; - if (target_method->dex_file == method->GetDeclaringClass()->GetDexCache()->GetDexFile()) { + if (target_method->dex_file == declaring_class->GetDexCache()->GetDexFile()) { target_method->dex_method_index = method->GetDexMethodIndex(); } else { if (no_guarantee_of_dex_cache_entry) { @@ -1225,7 +1234,7 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType } else { if (force_relocations && !use_dex_cache) { target_method->dex_method_index = method->GetDexMethodIndex(); - target_method->dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); + target_method->dex_file = declaring_class->GetDexCache()->GetDexFile(); } must_use_direct_pointers = true; } @@ -1248,14 +1257,14 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType *type = sharp_type; *direct_method = force_relocations ? -1 : reinterpret_cast<uintptr_t>(method); *direct_code = force_relocations ? -1 : compiler_->GetEntryPointOf(method); - target_method->dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); + target_method->dex_file = declaring_class->GetDexCache()->GetDexFile(); target_method->dex_method_index = method->GetDexMethodIndex(); } else if (!must_use_direct_pointers) { // Set the code and rely on the dex cache for the method. *type = sharp_type; if (force_relocations) { *direct_code = -1; - target_method->dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); + target_method->dex_file = declaring_class->GetDexCache()->GetDexFile(); target_method->dex_method_index = method->GetDexMethodIndex(); } else { *direct_code = compiler_->GetEntryPointOf(method); @@ -1976,7 +1985,7 @@ void CompilerDriver::Compile(jobject class_loader, const std::vector<const DexFi CHECK(dex_file != nullptr); CompileDexFile(class_loader, *dex_file, dex_files, thread_pool, timings); } - VLOG(compiler) << "Compile: " << GetMemoryUsageString(); + VLOG(compiler) << "Compile: " << GetMemoryUsageString(false); } void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, size_t class_def_index) { @@ -2289,7 +2298,7 @@ bool CompilerDriver::SkipCompilation(const std::string& method_name) { return !compile; } -std::string CompilerDriver::GetMemoryUsageString() const { +std::string CompilerDriver::GetMemoryUsageString(bool extended) const { std::ostringstream oss; const ArenaPool* arena_pool = GetArenaPool(); gc::Heap* heap = Runtime::Current()->GetHeap(); @@ -2305,11 +2314,13 @@ std::string CompilerDriver::GetMemoryUsageString() const { if (swap_space_.get() != nullptr) { oss << " swap=" << PrettySize(swap_space_->GetSize()); } - oss << "\nCode dedupe: " << dedupe_code_.DumpStats(); - oss << "\nMapping table dedupe: " << dedupe_mapping_table_.DumpStats(); - oss << "\nVmap table dedupe: " << dedupe_vmap_table_.DumpStats(); - oss << "\nGC map dedupe: " << dedupe_gc_map_.DumpStats(); - oss << "\nCFI info dedupe: " << dedupe_cfi_info_.DumpStats(); + if (extended) { + oss << "\nCode dedupe: " << dedupe_code_.DumpStats(); + oss << "\nMapping table dedupe: " << dedupe_mapping_table_.DumpStats(); + oss << "\nVmap table dedupe: " << dedupe_vmap_table_.DumpStats(); + oss << "\nGC map dedupe: " << dedupe_gc_map_.DumpStats(); + oss << "\nCFI info dedupe: " << dedupe_cfi_info_.DumpStats(); + } return oss.str(); } diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 58285cc888..db07a61085 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -665,7 +665,7 @@ class CompilerDriver { bool SkipCompilation(const std::string& method_name); // Get memory usage during compilation. - std::string GetMemoryUsageString() const; + std::string GetMemoryUsageString(bool extended) const; private: // These flags are internal to CompilerDriver for collecting INVOKE resolution statistics. diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index a20592c469..1b7ac0648e 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -592,8 +592,10 @@ void ImageWriter::ProcessStrings() { for (size_t i = 0; i < total_strings; ++i) { strings->GetWithoutChecks(i)->SetArray(array); } - LOG(INFO) << "Total # image strings=" << total_strings << " combined length=" - << total_length << " prefix saved chars=" << prefix_saved_chars; + if (kIsDebugBuild || VLOG_IS_ON(compiler)) { + LOG(INFO) << "Total # image strings=" << total_strings << " combined length=" + << total_length << " prefix saved chars=" << prefix_saved_chars; + } ComputeEagerResolvedStrings(); } |