summaryrefslogtreecommitdiff
path: root/linker/linker.cpp
diff options
context:
space:
mode:
authorDimitry Ivanov <dimitry@google.com>2016-05-23 10:31:11 -0700
committerDimitry Ivanov <dimitry@google.com>2016-05-23 10:31:11 -0700
commit5240863ed559cb4c2b121ddfbf6b3d78ac15e38f (patch)
tree6f511f9f4224a0d91794585297fd728139f5596b /linker/linker.cpp
parent51ee871e19601e1edbac948f961fc557b537870a (diff)
Do not resolve caller_ns when it is not needed
create_namespace resolves caller namespace only when caller did not explicitly specify parent namespace. This saves about 25 microseconds for the case when parent_namepsace is not null (for example when creating second classloader for the app). Bug: http://b/28801010 Change-Id: I50ded272c931db701e5a1d8c88ed5ffb13416539
Diffstat (limited to 'linker/linker.cpp')
-rw-r--r--linker/linker.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 09286c021..719b00a42 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2417,7 +2417,7 @@ bool init_namespaces(const char* public_ns_sonames, const char* anon_ns_library_
// is still pointing to the default one.
android_namespace_t* anon_ns =
create_namespace(nullptr, "(anonymous)", nullptr, anon_ns_library_path,
- ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr);
+ ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, &g_default_namespace);
if (anon_ns == nullptr) {
g_public_namespace_initialized = false;
@@ -2440,15 +2440,13 @@ android_namespace_t* create_namespace(const void* caller_addr,
return nullptr;
}
- soinfo* caller_soinfo = find_containing_library(caller_addr);
-
- android_namespace_t* caller_ns = caller_soinfo != nullptr ?
- caller_soinfo->get_primary_namespace() :
- g_anonymous_namespace;
-
- // if parent_namespace is nullptr -> set it to the caller namespace
if (parent_namespace == nullptr) {
- parent_namespace = caller_ns;
+ // if parent_namespace is nullptr -> set it to the caller namespace
+ soinfo* caller_soinfo = find_containing_library(caller_addr);
+
+ parent_namespace = caller_soinfo != nullptr ?
+ caller_soinfo->get_primary_namespace() :
+ g_anonymous_namespace;
}
ProtectedDataGuard guard;