diff options
| -rw-r--r-- | runtime/runtime.cc | 15 | ||||
| -rw-r--r-- | runtime/runtime.h | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index e5772666d1..3dfa0c4b6a 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -786,7 +786,7 @@ bool Runtime::Start() { // TODO(calin): We use the JIT class as a proxy for JIT compilation and for // recoding profiles. Maybe we should consider changing the name to be more clear it's // not only about compiling. b/28295073. - if (!safe_mode_ && (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo())) { + if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) { // Try to load compiler pre zygote to reduce PSS. b/27744947 std::string error_msg; if (!jit::Jit::LoadCompilerLibrary(&error_msg)) { @@ -2490,7 +2490,7 @@ void Runtime::CreateJitCodeCache(bool rwx_memory_allowed) { DCHECK(!jit_options_->UseJitCompilation()); } - if (safe_mode_ || (!jit_options_->UseJitCompilation() && !jit_options_->GetSaveProfilingInfo())) { + if (!jit_options_->UseJitCompilation() && !jit_options_->GetSaveProfilingInfo()) { return; } @@ -2511,7 +2511,16 @@ void Runtime::CreateJitCodeCache(bool rwx_memory_allowed) { } void Runtime::CreateJit() { + DCHECK(jit_ == nullptr); if (jit_code_cache_.get() == nullptr) { + if (!IsSafeMode()) { + LOG(WARNING) << "Missing code cache, cannot create JIT."; + } + return; + } + if (IsSafeMode()) { + LOG(INFO) << "Not creating JIT because of SafeMode."; + jit_code_cache_.reset(); return; } @@ -2520,7 +2529,7 @@ void Runtime::CreateJit() { if (jit == nullptr) { LOG(WARNING) << "Failed to allocate JIT"; // Release JIT code cache resources (several MB of memory). - jit_code_cache_.reset(nullptr); + jit_code_cache_.reset(); } } diff --git a/runtime/runtime.h b/runtime/runtime.h index 4bc16e24e1..ad4d3bb0d7 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -713,6 +713,11 @@ class Runtime { double GetHashTableMinLoadFactor() const; double GetHashTableMaxLoadFactor() const; + bool IsSafeMode() const { + CHECK(!is_zygote_); + return safe_mode_; + } + void SetSafeMode(bool mode) { safe_mode_ = mode; } |