Inline soinfo::get_tls
The run-time of dl_iterate_phdr can be noticeable for exception-handling.
e.g. I tested extest on the GitHub issue by:
- disabling the dlpi_subs/dlpi_adds-based caching in libgcc
- adding a weaker "load base hint" caching in libgcc that doesn't need
the dlpi_subs/dlpi_adds fields, but still has to iterate over every
module to validate a cache hit
extest throws 10000 exceptions, and I saw a regression from ~1550ms
runtime on Q to about ~1950ms on master. This CL reduces the regression to
about ~1700ms.
Bug: https://github.com/android/ndk/issues/1062
Test: bionic unit tests
Change-Id: I099e97e1a20f5b2aa6737789e49d965170eb85a8
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
index 27032c2..dd3817c 100644
--- a/linker/linker_soinfo.h
+++ b/linker/linker_soinfo.h
@@ -294,7 +294,9 @@
void add_secondary_namespace(android_namespace_t* secondary_ns);
android_namespace_list_t& get_secondary_namespaces();
- soinfo_tls* get_tls() const;
+ soinfo_tls* get_tls() const {
+ return has_min_version(5) ? tls_.get() : nullptr;
+ }
void set_mapped_by_caller(bool reserved_map);
bool is_mapped_by_caller() const;