Bug 1083020 - Add a (dummy) stats method to all LibHandles. r=nfroyd
While here, avoid doing anything if debug logging is disabled.
--- a/mozglue/linker/CustomElf.cpp
+++ b/mozglue/linker/CustomElf.cpp
@@ -253,17 +253,19 @@ CustomElf::Load(Mappable *mappable, cons
return nullptr;
#ifdef __ARM_EABI__
if (arm_exidx_phdr)
elf->arm_exidx.InitSize(elf->GetPtr(arm_exidx_phdr->p_vaddr),
arm_exidx_phdr->p_memsz);
#endif
- elf->stats("oneLibLoaded");
+ if (MOZ_UNLIKELY(Logging::isVerbose())) {
+ elf->stats("oneLibLoaded");
+ }
DEBUG_LOG("CustomElf::Load(\"%s\", 0x%x) = %p", path, flags,
static_cast<void *>(elf));
return elf;
}
CustomElf::~CustomElf()
{
DEBUG_LOG("CustomElf::~CustomElf(%p [\"%s\"])",
--- a/mozglue/linker/CustomElf.h
+++ b/mozglue/linker/CustomElf.h
@@ -47,17 +47,17 @@ protected:
virtual Mappable *GetMappable() const;
public:
/**
* Shows some stats about the Mappable instance. The when argument is to be
* used by the caller to give an identifier of the when the stats call is
* made.
*/
- void stats(const char *when) const;
+ virtual void stats(const char *when) const;
private:
/**
* Scan dependent libraries to find the address corresponding to the
* given symbol name. This is used to find symbols that are undefined
* in the Elf object.
*/
void *GetSymbolPtrInDeps(const char *symbol) const;
--- a/mozglue/linker/ElfLoader.cpp
+++ b/mozglue/linker/ElfLoader.cpp
@@ -568,20 +568,22 @@ ElfLoader::~ElfLoader()
* belong to it. */
if (self_elf)
self_elf->base.release();
}
void
ElfLoader::stats(const char *when)
{
+ if (MOZ_LIKELY(!Logging::isVerbose()))
+ return;
+
for (LibHandleList::iterator it = Singleton.handles.begin();
it < Singleton.handles.end(); ++it)
- if (!(*it)->IsSystemElf())
- static_cast<CustomElf *>(*it)->stats(when);
+ (*it)->stats(when);
}
#ifdef __ARM_EABI__
int
ElfLoader::__wrap_aeabi_atexit(void *that, ElfLoader::Destructor destructor,
void *dso_handle)
{
Singleton.destructors.push_back(
--- a/mozglue/linker/ElfLoader.h
+++ b/mozglue/linker/ElfLoader.h
@@ -198,16 +198,23 @@ public:
#ifdef __ARM_EABI__
/**
* Find the address and entry count of the ARM.exidx section
* associated with the library
*/
virtual const void *FindExidx(int *pcount) const = 0;
#endif
+ /**
+ * Shows some stats about the Mappable instance. The when argument is to be
+ * used by the caller to give an identifier of the when the stats call is
+ * made.
+ */
+ virtual void stats(const char *when) const { };
+
protected:
/**
* Returns a mappable object for use by MappableMMap and related functions.
*/
virtual Mappable *GetMappable() const = 0;
/**
* Returns whether the handle is a SystemElf or not. (short of a better way