summaryrefslogtreecommitdiffstats
path: root/runtime/jit
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jit')
-rw-r--r--runtime/jit/jit.cc21
-rw-r--r--runtime/jit/jit.h16
-rw-r--r--runtime/jit/jit_code_cache.cc1
3 files changed, 36 insertions, 2 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 539c181..9b89459 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -40,16 +40,32 @@ JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& opt
options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheCapacity);
jit_options->compile_threshold_ =
options.GetOrDefault(RuntimeArgumentMap::JITCompileThreshold);
+ jit_options->dump_info_on_shutdown_ =
+ options.Exists(RuntimeArgumentMap::DumpJITInfoOnShutdown);
return jit_options;
}
+void Jit::DumpInfo(std::ostream& os) {
+ os << "Code cache size=" << PrettySize(code_cache_->CodeCacheSize())
+ << " data cache size=" << PrettySize(code_cache_->DataCacheSize())
+ << " num methods=" << code_cache_->NumMethods()
+ << "\n";
+ cumulative_timings_.Dump(os);
+}
+
+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) {
+ jit_compile_method_(nullptr), dump_info_on_shutdown_(false),
+ cumulative_timings_("JIT timings") {
}
Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
std::unique_ptr<Jit> jit(new Jit);
+ jit->dump_info_on_shutdown_ = options->DumpJitInfoOnShutdown();
if (!jit->LoadCompiler(error_msg)) {
return nullptr;
}
@@ -133,6 +149,9 @@ void Jit::DeleteThreadPool() {
}
Jit::~Jit() {
+ if (dump_info_on_shutdown_) {
+ DumpInfo(LOG(INFO));
+ }
DeleteThreadPool();
if (jit_compiler_handle_ != nullptr) {
jit_unload_(jit_compiler_handle_);
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index b80015f..6b206d1 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -24,6 +24,7 @@
#include "atomic.h"
#include "base/macros.h"
#include "base/mutex.h"
+#include "base/timing_logger.h"
#include "gc_root.h"
#include "jni.h"
#include "object_callbacks.h"
@@ -61,6 +62,11 @@ class Jit {
return code_cache_.get();
}
void DeleteThreadPool();
+ // Dump interesting info: #methods compiled, code vs data size, compile / verify cumulative
+ // loggers.
+ void DumpInfo(std::ostream& os);
+ // Add a timing logger to cumulative_timings_.
+ void AddTimingLogger(const TimingLogger& logger);
private:
Jit();
@@ -73,6 +79,10 @@ class Jit {
void (*jit_unload_)(void*);
bool (*jit_compile_method_)(void*, mirror::ArtMethod*, Thread*);
+ // Performance monitoring.
+ bool dump_info_on_shutdown_;
+ CumulativeLogger cumulative_timings_;
+
std::unique_ptr<jit::JitInstrumentationCache> instrumentation_cache_;
std::unique_ptr<jit::JitCodeCache> code_cache_;
CompilerCallbacks* compiler_callbacks_; // Owned by the jit compiler.
@@ -87,12 +97,16 @@ class JitOptions {
size_t GetCodeCacheCapacity() const {
return code_cache_capacity_;
}
+ bool DumpJitInfoOnShutdown() const {
+ return dump_info_on_shutdown_;
+ }
private:
size_t code_cache_capacity_;
size_t compile_threshold_;
+ bool dump_info_on_shutdown_;
- JitOptions() : code_cache_capacity_(0), compile_threshold_(0) {
+ JitOptions() : code_cache_capacity_(0), compile_threshold_(0), dump_info_on_shutdown_(false) {
}
};
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 4ae4d57..4d367e0 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -77,6 +77,7 @@ uint8_t* JitCodeCache::ReserveCode(Thread* self, size_t size) {
if (size > CodeCacheRemain()) {
return nullptr;
}
+ ++num_methods_; // TODO: This is hacky but works since each method has exactly one code region.
code_cache_ptr_ += size;
return code_cache_ptr_ - size;
}