diff options
Diffstat (limited to 'runtime/runtime.cc')
| -rw-r--r-- | runtime/runtime.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 6b144cf48b..8cba1a91d7 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -274,9 +274,6 @@ Runtime::~Runtime() { VLOG(jit) << "Deleting jit"; jit_.reset(nullptr); } - linear_alloc_.reset(); - arena_pool_.reset(); - low_4gb_arena_pool_.reset(); // Shutdown the fault manager if it was initialized. fault_manager.Shutdown(); @@ -290,7 +287,13 @@ Runtime::~Runtime() { Thread::Shutdown(); QuasiAtomic::Shutdown(); verifier::MethodVerifier::Shutdown(); + + // Destroy allocators before shutting down the MemMap because they may use it. + linear_alloc_.reset(); + low_4gb_arena_pool_.reset(); + arena_pool_.reset(); MemMap::Shutdown(); + // TODO: acquire a static mutex on Runtime to avoid racing. CHECK(instance_ == nullptr || instance_ == this); instance_ = nullptr; @@ -941,13 +944,11 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) // can't be trimmed as easily. const bool use_malloc = IsAotCompiler(); arena_pool_.reset(new ArenaPool(use_malloc, false)); - if (IsCompiler() && Is64BitInstructionSet(kRuntimeISA)) { + if (IsAotCompiler() && Is64BitInstructionSet(kRuntimeISA)) { // 4gb, no malloc. Explanation in header. low_4gb_arena_pool_.reset(new ArenaPool(false, true)); - linear_alloc_.reset(new LinearAlloc(low_4gb_arena_pool_.get())); - } else { - linear_alloc_.reset(new LinearAlloc(arena_pool_.get())); } + linear_alloc_.reset(CreateLinearAlloc()); BlockSignals(); InitPlatformSignalHandlers(); @@ -1788,4 +1789,10 @@ bool Runtime::IsVerificationSoftFail() const { return verify_ == verifier::VerifyMode::kSoftFail; } +LinearAlloc* Runtime::CreateLinearAlloc() { + return (IsAotCompiler() && Is64BitInstructionSet(kRuntimeISA)) + ? new LinearAlloc(low_4gb_arena_pool_.get()) + : new LinearAlloc(arena_pool_.get()); +} + } // namespace art |