summaryrefslogtreecommitdiff
path: root/runtime/jit/jit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jit/jit.cc')
-rw-r--r--runtime/jit/jit.cc67
1 files changed, 31 insertions, 36 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 4b39c03e0c..05668a97b3 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -26,6 +26,7 @@
#include "jit_instrumentation.h"
#include "oat_file_manager.h"
#include "offline_profiling_info.h"
+#include "profile_saver.h"
#include "runtime.h"
#include "runtime_options.h"
#include "utils.h"
@@ -63,10 +64,14 @@ void Jit::AddTimingLogger(const TimingLogger& logger) {
cumulative_timings_.AddLogger(logger);
}
-Jit::Jit()
- : jit_library_handle_(nullptr), jit_compiler_handle_(nullptr), jit_load_(nullptr),
- jit_compile_method_(nullptr), dump_info_on_shutdown_(false),
- cumulative_timings_("JIT timings") {
+Jit::Jit() : jit_library_handle_(nullptr),
+ jit_compiler_handle_(nullptr),
+ jit_load_(nullptr),
+ jit_compile_method_(nullptr),
+ dump_info_on_shutdown_(false),
+ cumulative_timings_("JIT timings"),
+ save_profiling_info_(false),
+ generate_debug_info_(false) {
}
Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
@@ -76,18 +81,19 @@ Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
return nullptr;
}
jit->code_cache_.reset(JitCodeCache::Create(
- options->GetCodeCacheInitialCapacity(), options->GetCodeCacheMaxCapacity(), error_msg));
+ options->GetCodeCacheInitialCapacity(),
+ options->GetCodeCacheMaxCapacity(),
+ jit->generate_debug_info_,
+ error_msg));
if (jit->GetCodeCache() == nullptr) {
return nullptr;
}
- jit->offline_profile_info_.reset(nullptr);
- if (options->GetSaveProfilingInfo()) {
- jit->offline_profile_info_.reset(new OfflineProfilingInfo());
- }
+ jit->save_profiling_info_ = options->GetSaveProfilingInfo();
LOG(INFO) << "JIT created with initial_capacity="
<< PrettySize(options->GetCodeCacheInitialCapacity())
<< ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity())
- << ", compile_threshold=" << options->GetCompileThreshold();
+ << ", compile_threshold=" << options->GetCompileThreshold()
+ << ", save_profiling_info=" << options->GetSaveProfilingInfo();
return jit.release();
}
@@ -100,7 +106,7 @@ bool Jit::LoadCompiler(std::string* error_msg) {
*error_msg = oss.str();
return false;
}
- jit_load_ = reinterpret_cast<void* (*)(CompilerCallbacks**)>(
+ jit_load_ = reinterpret_cast<void* (*)(CompilerCallbacks**, bool*)>(
dlsym(jit_library_handle_, "jit_load"));
if (jit_load_ == nullptr) {
dlclose(jit_library_handle_);
@@ -122,9 +128,10 @@ bool Jit::LoadCompiler(std::string* error_msg) {
return false;
}
CompilerCallbacks* callbacks = nullptr;
+ bool will_generate_debug_symbols = false;
VLOG(jit) << "Calling JitLoad interpreter_only="
<< Runtime::Current()->GetInstrumentation()->InterpretOnly();
- jit_compiler_handle_ = (jit_load_)(&callbacks);
+ jit_compiler_handle_ = (jit_load_)(&callbacks, &will_generate_debug_symbols);
if (jit_compiler_handle_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't load compiler";
@@ -137,6 +144,7 @@ bool Jit::LoadCompiler(std::string* error_msg) {
return false;
}
compiler_callbacks_ = callbacks;
+ generate_debug_info_ = will_generate_debug_symbols;
return true;
}
@@ -173,34 +181,21 @@ void Jit::DeleteThreadPool() {
}
}
-void Jit::SaveProfilingInfo(const std::string& filename) {
- if (offline_profile_info_ == nullptr) {
- return;
- }
- // Note that we can't check the PrimaryOatFile when constructing the offline_profilie_info_
- // because it becomes known to the Runtime after we create and initialize the JIT.
- const OatFile* primary_oat_file = Runtime::Current()->GetOatFileManager().GetPrimaryOatFile();
- if (primary_oat_file == nullptr) {
- LOG(WARNING) << "Couldn't find a primary oat file when trying to save profile info to "
- << filename;
- return;
- }
-
- uint64_t last_update_ns = code_cache_->GetLastUpdateTimeNs();
- if (offline_profile_info_->NeedsSaving(last_update_ns)) {
- VLOG(profiler) << "Initiate save profiling information to: " << filename;
- std::set<ArtMethod*> methods;
- {
- ScopedObjectAccess soa(Thread::Current());
- code_cache_->GetCompiledArtMethods(primary_oat_file, methods);
- }
- offline_profile_info_->SaveProfilingInfo(filename, last_update_ns, methods);
- } else {
- VLOG(profiler) << "No need to save profiling information to: " << filename;
+void Jit::StartProfileSaver(const std::string& filename,
+ const std::vector<std::string>& code_paths) {
+ if (save_profiling_info_) {
+ ProfileSaver::Start(filename, code_cache_.get(), code_paths);
+ }
+}
+
+void Jit::StopProfileSaver() {
+ if (save_profiling_info_ && ProfileSaver::IsStarted()) {
+ ProfileSaver::Stop();
}
}
Jit::~Jit() {
+ DCHECK(!save_profiling_info_ || !ProfileSaver::IsStarted());
if (dump_info_on_shutdown_) {
DumpInfo(LOG(INFO));
}