diff options
author | Calin Juravle <calin@google.com> | 2014-10-23 10:58:45 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-10-23 10:58:46 +0000 |
commit | 1e4dc259b4242c1a03415b5b5f4aed7a23e53f79 (patch) | |
tree | edfca45c7c199c285c736076615553bae96f5cb4 /runtime/runtime.cc | |
parent | 1122c7fc277130814dd1d47b5e8be3ac35b1a5fc (diff) | |
parent | 07d83c7a25022064ac0a8dac4fe2a7a38681fa4b (diff) | |
download | art-1e4dc259b4242c1a03415b5b5f4aed7a23e53f79.tar.gz art-1e4dc259b4242c1a03415b5b5f4aed7a23e53f79.tar.bz2 art-1e4dc259b4242c1a03415b5b5f4aed7a23e53f79.zip |
Merge "[native bridge] Make sure we always unload the native bridge"
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index da513080d5..8ba098f5d9 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -147,11 +147,15 @@ Runtime::Runtime() target_sdk_version_(0), implicit_null_checks_(false), implicit_so_checks_(false), - implicit_suspend_checks_(false) { + implicit_suspend_checks_(false), + is_native_bridge_loaded_(false) { CheckAsmSupportOffsetsAndSizes(); } Runtime::~Runtime() { + if (is_native_bridge_loaded_) { + UnloadNativeBridge(); + } if (dump_gc_performance_on_shutdown_) { // This can't be called from the Heap destructor below because it // could call RosAlloc::InspectAll() which needs the thread_list @@ -431,12 +435,11 @@ bool Runtime::Start() { return false; } } else { - bool have_native_bridge = !native_bridge_library_filename_.empty(); - if (have_native_bridge) { + if (is_native_bridge_loaded_) { PreInitializeNativeBridge("."); } - DidForkFromZygote(self->GetJniEnv(), have_native_bridge ? NativeBridgeAction::kInitialize : - NativeBridgeAction::kUnload, GetInstructionSetString(kRuntimeISA)); + DidForkFromZygote(self->GetJniEnv(), NativeBridgeAction::kInitialize, + GetInstructionSetString(kRuntimeISA)); } StartDaemonThreads(); @@ -515,14 +518,17 @@ bool Runtime::InitZygote() { void Runtime::DidForkFromZygote(JNIEnv* env, NativeBridgeAction action, const char* isa) { is_zygote_ = false; - switch (action) { - case NativeBridgeAction::kUnload: - UnloadNativeBridge(); - break; + if (is_native_bridge_loaded_) { + switch (action) { + case NativeBridgeAction::kUnload: + UnloadNativeBridge(); + is_native_bridge_loaded_ = false; + break; - case NativeBridgeAction::kInitialize: - InitializeNativeBridge(env, isa); - break; + case NativeBridgeAction::kInitialize: + InitializeNativeBridge(env, isa); + break; + } } // Create the thread pool. @@ -890,8 +896,7 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) // Runtime::Start(): // DidForkFromZygote(kInitialize) -> try to initialize any native bridge given. // No-op wrt native bridge. - native_bridge_library_filename_ = options->native_bridge_library_filename_; - LoadNativeBridge(native_bridge_library_filename_); + is_native_bridge_loaded_ = LoadNativeBridge(options->native_bridge_library_filename_); VLOG(startup) << "Runtime::Init exiting"; return true; |