Bug 1083020 - Add a (dummy) stats method to all LibHandles. r=nfroyd
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 16 Oct 2014 09:19:40 +0900
changeset 210596 1f5fdd080b46461c34cfa2c6563358b8c74b2331
parent 210595 5ce2fc3939da728fdfcd4508a031cbcbf780b163
child 210597 b483b12025b0f6135ffa65070cdc250942d91b10
push id50491
push usermh@glandium.org
push dateThu, 16 Oct 2014 00:34:54 +0000
treeherdermozilla-inbound@0004a6330d53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1083020
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1083020 - Add a (dummy) stats method to all LibHandles. r=nfroyd While here, avoid doing anything if debug logging is disabled.
mozglue/linker/CustomElf.cpp
mozglue/linker/CustomElf.h
mozglue/linker/ElfLoader.cpp
mozglue/linker/ElfLoader.h
--- 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