Add option to never interpret.
Change-Id: Ib6d6170fa60c77c2e6a8844964f14fa0de4c9e7b
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 8f4d24f..f540814 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -202,6 +202,13 @@
}
}
+bool Jit::JitAtFirstUse() {
+ if (instrumentation_cache_ != nullptr) {
+ return instrumentation_cache_->HotMethodThreshold() == 0;
+ }
+ return false;
+}
+
Jit::~Jit() {
DCHECK(!save_profiling_info_ || !ProfileSaver::IsStarted());
if (dump_info_on_shutdown_) {
@@ -217,7 +224,6 @@
}
void Jit::CreateInstrumentationCache(size_t compile_threshold, size_t warmup_threshold) {
- CHECK_GT(compile_threshold, 0U);
instrumentation_cache_.reset(
new jit::JitInstrumentationCache(compile_threshold, warmup_threshold));
}
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 429edf6..a80f51f 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -86,6 +86,8 @@
// into the specified class linker to the jit debug interface,
void DumpTypeInfoForLoadedTypes(ClassLinker* linker);
+ bool JitAtFirstUse();
+
private:
Jit();
bool LoadCompiler(std::string* error_msg);
@@ -142,6 +144,10 @@
void SetSaveProfilingInfo(bool b) {
save_profiling_info_ = b;
}
+ void SetJitAtFirstUse() {
+ use_jit_ = true;
+ compile_threshold_ = 0;
+ }
private:
bool use_jit_;
diff --git a/runtime/jit/jit_instrumentation.cc b/runtime/jit/jit_instrumentation.cc
index 6b47b67..d597b36 100644
--- a/runtime/jit/jit_instrumentation.cc
+++ b/runtime/jit/jit_instrumentation.cc
@@ -162,6 +162,14 @@
mirror::Object* /*this_object*/,
ArtMethod* method,
uint32_t /*dex_pc*/) {
+ if (UNLIKELY(Runtime::Current()->GetJit()->JitAtFirstUse())) {
+ // The compiler requires a ProfilingInfo object.
+ ProfilingInfo::Create(thread, method, /* retry_allocation */ true);
+ JitCompileTask compile_task(method, JitCompileTask::kCompile);
+ compile_task.Run(thread);
+ return;
+ }
+
instrumentation_cache_->AddSamples(thread, method, 1);
}
diff --git a/runtime/jit/jit_instrumentation.h b/runtime/jit/jit_instrumentation.h
index 620c087..06559ad 100644
--- a/runtime/jit/jit_instrumentation.h
+++ b/runtime/jit/jit_instrumentation.h
@@ -101,6 +101,11 @@
SHARED_REQUIRES(Locks::mutator_lock_);
void CreateThreadPool();
void DeleteThreadPool(Thread* self);
+
+ size_t HotMethodThreshold() const {
+ return hot_method_threshold_;
+ }
+
// Wait until there is no more pending compilation tasks.
void WaitForCompilationToFinish(Thread* self);