[Libreoffice-commits] core.git: cppu/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 8 13:20:17 UTC 2019
cppu/source/uno/loadmodule.cxx | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
New commits:
commit ecf708e90d96d5a72491e40fa679c47e66eebd49
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Nov 8 12:45:26 2019 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Nov 8 14:19:10 2019 +0100
Avoid repeated calls cppu::detail::loadModule -> osl_getModuleURLFromAddress
...where the latter are reportedly expensive. Both
<https://gerrit.libreoffice.org/#/c/75162/> "tdf#121740 related, cache external
mapping in cppu::loadExternal" and <https://gerrit.libreoffice.org/#/c/82261/>
"tdf#121740 add cache to win osl_getModuleURLFromAddress" attempted to reduce
the costs observed when loading one specific document by introducing caches
below cppu::detail::loadModule's call to osl::Module::loadRelative.
On the other hand, this change reduces the number of calls to
osl_getModuleURLFromAddress by computing the base URI in
cppu::detail::loadModule only once. For my local Linux --enable-dbgutil build,
for `instdir/program/soffice '109340 class14.ppt'` and then exiting LO again
(with the document attached at
<https://bugs.documentfoundation.org/show_bug.cgi?id=121740#c0>), this reduces
the number of calls to osl_getModuleURLFromAddress from 3775 to 22.
(Many of those calls originated from cppu::getCaughtException or
cppu::throwException, as in
osl_getModuleURLFromAddress
osl_getModuleURLFromFunctionAddress
osl::Module::getUrlFromAddress
osl_loadModuleRelative
osl::Module::loadRelative
cppu::detail::loadModule
cppu::loadModule
cppu::loadExternalMapping
uno_getMapping
com::sun::star::uno::Mapping::Mapping
cppu::throwException
.)
Unfortunately, this needs to duplicate functionality from osl_loadModuleRelative
(sal/osl/all/loadmodulerelative.cxx) somewhat, as the stable SAL interface only
offers functionality to load relative to a given function, not relative to a
given base URI. (And extending the stable SAL interface for this one use is not
worth the maintenance costs.)
Change-Id: Ib58814136d11c67d1419b0224d12e30bb710e613
Reviewed-on: https://gerrit.libreoffice.org/82290
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/cppu/source/uno/loadmodule.cxx b/cppu/source/uno/loadmodule.cxx
index 9e970b754536..359227b24206 100644
--- a/cppu/source/uno/loadmodule.cxx
+++ b/cppu/source/uno/loadmodule.cxx
@@ -20,10 +20,15 @@
#include <sal/config.h>
+#include <cassert>
+
#include <osl/module.h>
#include <osl/module.hxx>
+#include <rtl/malformeduriexception.hxx>
+#include <rtl/uri.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
+#include <sal/log.hxx>
#include "loadmodule.hxx"
@@ -32,14 +37,34 @@ namespace cppu { namespace detail {
#ifndef DISABLE_DYNLOADING
bool loadModule(osl::Module& rModule, OUString const & name) {
+ static OUString base = [] {
+ OUString url;
+ if (!osl::Module::getUrlFromAddress(
+ reinterpret_cast<oslGenericFunction>(&loadModule), url))
+ {
+ SAL_WARN("cppu", "osl::Module::getUrlFromAddress failed");
+ return OUString();
+ }
+ assert(!url.isEmpty());
+ return url;
+ }();
+ if (base.isEmpty()) {
+ SAL_INFO("cppu", "osl::Module::getUrlFromAddress had failed");
+ return false;
+ }
OUString b =
#if defined SAL_DLLPREFIX
SAL_DLLPREFIX +
#endif
name +
SAL_DLLEXTENSION;
- return rModule.loadRelative(
- reinterpret_cast< oslGenericFunction >(&loadModule),
+ try {
+ b = rtl::Uri::convertRelToAbs(base, b);
+ } catch (rtl::MalformedUriException & e) {
+ SAL_INFO("cppu", "rtl::MalformedUriException <" << e.getMessage() << ">");
+ return false;
+ }
+ return rModule.load(
b,
SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY);
}
More information about the Libreoffice-commits
mailing list