summaryrefslogtreecommitdiffstats
path: root/runtime/runtime.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-03-17 13:48:29 -0700
committerMathieu Chartier <mathieuc@google.com>2015-03-18 18:49:28 -0700
commit455f67c4cf0b4f04e117db3024fd189fa1c7dab9 (patch)
tree3f89fdc8ba9b31cc0205945410a75d63e2f25000 /runtime/runtime.cc
parent5747266d57445ecdd026a4705d62768faad09b01 (diff)
downloadart-455f67c4cf0b4f04e117db3024fd189fa1c7dab9.zip
art-455f67c4cf0b4f04e117db3024fd189fa1c7dab9.tar.gz
art-455f67c4cf0b4f04e117db3024fd189fa1c7dab9.tar.bz2
Fix JIT options with late init
Previously we couldn't create the JIT since we didn't have any JITOptions. Bug: 19735273 Change-Id: I24b8ed131ed8b18f75ec94291e135d8a1c089ebd
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r--runtime/runtime.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 189559e..0f0c327 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -483,11 +483,10 @@ bool Runtime::Start() {
}
}
- // If we are the zygote then we need to wait until after forking to create the code cache due to
- // SELinux restrictions on r/w/x memory regions.
- if (!IsZygote() && jit_.get() != nullptr) {
- jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold());
- jit_->CreateThreadPool();
+ // If we are the zygote then we need to wait until after forking to create the code cache
+ // due to SELinux restrictions on r/w/x memory regions.
+ if (!IsZygote() && jit_options_->UseJIT()) {
+ CreateJit();
}
if (!IsImageDex2OatEnabled() || !GetHeap()->HasImageSpace()) {
@@ -611,11 +610,9 @@ void Runtime::DidForkFromZygote(JNIEnv* env, NativeBridgeAction action, const ch
// Create the thread pools.
heap_->CreateThreadPool();
- if (jit_options_.get() != nullptr && jit_.get() == nullptr) {
+ if (jit_.get() == nullptr && jit_options_->UseJIT()) {
// Create the JIT if the flag is set and we haven't already create it (happens for run-tests).
CreateJit();
- jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold());
- jit_->CreateThreadPool();
}
StartSignalCatcher();
@@ -843,20 +840,19 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
Dbg::ConfigureJdwp(runtime_options.GetOrDefault(Opt::JdwpOptions));
}
- if (!IsAotCompiler()) {
+ jit_options_.reset(jit::JitOptions::CreateFromRuntimeArguments(runtime_options));
+ bool use_jit = jit_options_->UseJIT();
+ if (IsAotCompiler()) {
// If we are already the compiler at this point, we must be dex2oat. Don't create the jit in
// this case.
// If runtime_options doesn't have UseJIT set to true then CreateFromRuntimeArguments returns
// nullptr and we don't create the jit.
- jit_options_.reset(jit::JitOptions::CreateFromRuntimeArguments(runtime_options));
- }
- if (!IsZygote() && jit_options_.get() != nullptr) {
- CreateJit();
+ use_jit = false;
}
// Use MemMap arena pool for jit, malloc otherwise. Malloc arenas are faster to allocate but
// can't be trimmed as easily.
- const bool use_malloc = jit_options_.get() == nullptr;
+ const bool use_malloc = !use_jit;
arena_pool_.reset(new ArenaPool(use_malloc));
BlockSignals();
@@ -1661,11 +1657,13 @@ void Runtime::UpdateProfilerState(int state) {
}
void Runtime::CreateJit() {
- CHECK(jit_options_.get() != nullptr);
+ CHECK(!IsAotCompiler());
std::string error_msg;
jit_.reset(jit::Jit::Create(jit_options_.get(), &error_msg));
if (jit_.get() != nullptr) {
compiler_callbacks_ = jit_->GetCompilerCallbacks();
+ jit_->CreateInstrumentationCache(jit_options_->GetCompileThreshold());
+ jit_->CreateThreadPool();
} else {
LOG(WARNING) << "Failed to create JIT " << error_msg;
}