Loading mozglue/linker/CustomElf.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,7 @@ CustomElf::Load(Mappable *mappable, const char *path, int flags) if (!elf->InitDyn(dyn)) return NULL; elf->stats("oneLibLoaded"); debug("CustomElf::Load(\"%s\", %x) = %p", path, flags, static_cast<void *>(elf)); return elf; Loading Loading @@ -303,6 +304,8 @@ CustomElf::GetSymbolPtrInDeps(const char *symbol) const return FunctionPtr(&ElfLoader::__wrap_cxa_finalize); if (strcmp(symbol + 2, "dso_handle") == 0) return const_cast<CustomElf *>(this); if (strcmp(symbol + 2, "moz_linker_stats") == 0) return FunctionPtr(&ElfLoader::stats); } else if (symbol[0] == 's' && symbol[1] == 'i') { if (strcmp(symbol + 2, "gnal") == 0) return FunctionPtr(__wrap_signal); Loading Loading @@ -370,6 +373,12 @@ CustomElf::Contains(void *addr) const return base.Contains(addr); } void CustomElf::stats(const char *when) const { mappable->stats(when, GetPath()); } bool CustomElf::LoadSegment(const Phdr *pt_load) const { Loading mozglue/linker/CustomElf.h +7 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,13 @@ public: virtual void *GetSymbolPtr(const char *symbol) const; virtual bool Contains(void *addr) const; /** * 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; private: /** * Returns a pointer to the Elf Symbol in the Dynamic Symbol table Loading mozglue/linker/ElfLoader.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,15 @@ ElfLoader::~ElfLoader() } } void ElfLoader::stats(const char *when) { for (LibHandleList::iterator it = Singleton.handles.begin(); it < Singleton.handles.end(); ++it) if (!(*it)->IsSystemElf()) static_cast<CustomElf *>(*it)->stats(when); } #ifdef __ARM_EABI__ int ElfLoader::__wrap_aeabi_atexit(void *that, ElfLoader::Destructor destructor, Loading mozglue/linker/ElfLoader.h +7 −0 Original line number Diff line number Diff line Loading @@ -284,6 +284,13 @@ private: protected: friend class CustomElf; /** * Show some stats about Mappables in CustomElfs. The when argument is to * be used by the caller to give an identifier of the when the stats call * is made. */ static void stats(const char *when); /* Definition of static destructors as to be used for C++ ABI compatibility */ typedef void (*Destructor)(void *object); Loading mozglue/linker/Mappable.cpp +27 −1 Original line number Diff line number Diff line Loading @@ -350,7 +350,7 @@ MappableSeekableZStream::Create(const char *name, Zip *zip, } MappableSeekableZStream::MappableSeekableZStream(Zip *zip) : zip(zip) { } : zip(zip), chunkAvailNum(0) { } MappableSeekableZStream::~MappableSeekableZStream() { Loading Loading @@ -473,6 +473,10 @@ MappableSeekableZStream::ensure(const void *addr) reinterpret_cast<uintptr_t>(*buffer + (chunkStart + length)), 0); } #endif /* Only count if we haven't already decompressed parts of the chunk */ if (chunkAvail[chunk] == 0) chunkAvailNum++; chunkAvail[chunk] = (length + PAGE_SIZE - 1) / PAGE_SIZE; } Loading @@ -498,3 +502,25 @@ MappableSeekableZStream::ensure(const void *addr) log("mprotect failed"); return false; } void MappableSeekableZStream::stats(const char *when, const char *name) const { size_t nEntries = zStream.GetChunksNum(); debug("%s: %s; %ld/%ld chunks decompressed", name, when, chunkAvailNum, nEntries); size_t len = 64; AutoDeleteArray<char> map = new char[len + 3]; map[0] = '['; for (size_t i = 0, j = 1; i < nEntries; i++, j++) { map[j] = chunkAvail[i] ? '*' : '_'; if ((j == len) || (i == nEntries - 1)) { map[j + 1] = ']'; map[j + 2] = '\0'; debug("%s", static_cast<char *>(map)); j = 0; } } } Loading
mozglue/linker/CustomElf.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,7 @@ CustomElf::Load(Mappable *mappable, const char *path, int flags) if (!elf->InitDyn(dyn)) return NULL; elf->stats("oneLibLoaded"); debug("CustomElf::Load(\"%s\", %x) = %p", path, flags, static_cast<void *>(elf)); return elf; Loading Loading @@ -303,6 +304,8 @@ CustomElf::GetSymbolPtrInDeps(const char *symbol) const return FunctionPtr(&ElfLoader::__wrap_cxa_finalize); if (strcmp(symbol + 2, "dso_handle") == 0) return const_cast<CustomElf *>(this); if (strcmp(symbol + 2, "moz_linker_stats") == 0) return FunctionPtr(&ElfLoader::stats); } else if (symbol[0] == 's' && symbol[1] == 'i') { if (strcmp(symbol + 2, "gnal") == 0) return FunctionPtr(__wrap_signal); Loading Loading @@ -370,6 +373,12 @@ CustomElf::Contains(void *addr) const return base.Contains(addr); } void CustomElf::stats(const char *when) const { mappable->stats(when, GetPath()); } bool CustomElf::LoadSegment(const Phdr *pt_load) const { Loading
mozglue/linker/CustomElf.h +7 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,13 @@ public: virtual void *GetSymbolPtr(const char *symbol) const; virtual bool Contains(void *addr) const; /** * 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; private: /** * Returns a pointer to the Elf Symbol in the Dynamic Symbol table Loading
mozglue/linker/ElfLoader.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,15 @@ ElfLoader::~ElfLoader() } } void ElfLoader::stats(const char *when) { for (LibHandleList::iterator it = Singleton.handles.begin(); it < Singleton.handles.end(); ++it) if (!(*it)->IsSystemElf()) static_cast<CustomElf *>(*it)->stats(when); } #ifdef __ARM_EABI__ int ElfLoader::__wrap_aeabi_atexit(void *that, ElfLoader::Destructor destructor, Loading
mozglue/linker/ElfLoader.h +7 −0 Original line number Diff line number Diff line Loading @@ -284,6 +284,13 @@ private: protected: friend class CustomElf; /** * Show some stats about Mappables in CustomElfs. The when argument is to * be used by the caller to give an identifier of the when the stats call * is made. */ static void stats(const char *when); /* Definition of static destructors as to be used for C++ ABI compatibility */ typedef void (*Destructor)(void *object); Loading
mozglue/linker/Mappable.cpp +27 −1 Original line number Diff line number Diff line Loading @@ -350,7 +350,7 @@ MappableSeekableZStream::Create(const char *name, Zip *zip, } MappableSeekableZStream::MappableSeekableZStream(Zip *zip) : zip(zip) { } : zip(zip), chunkAvailNum(0) { } MappableSeekableZStream::~MappableSeekableZStream() { Loading Loading @@ -473,6 +473,10 @@ MappableSeekableZStream::ensure(const void *addr) reinterpret_cast<uintptr_t>(*buffer + (chunkStart + length)), 0); } #endif /* Only count if we haven't already decompressed parts of the chunk */ if (chunkAvail[chunk] == 0) chunkAvailNum++; chunkAvail[chunk] = (length + PAGE_SIZE - 1) / PAGE_SIZE; } Loading @@ -498,3 +502,25 @@ MappableSeekableZStream::ensure(const void *addr) log("mprotect failed"); return false; } void MappableSeekableZStream::stats(const char *when, const char *name) const { size_t nEntries = zStream.GetChunksNum(); debug("%s: %s; %ld/%ld chunks decompressed", name, when, chunkAvailNum, nEntries); size_t len = 64; AutoDeleteArray<char> map = new char[len + 3]; map[0] = '['; for (size_t i = 0, j = 1; i < nEntries; i++, j++) { map[j] = chunkAvail[i] ? '*' : '_'; if ((j == len) || (i == nEntries - 1)) { map[j + 1] = ']'; map[j + 2] = '\0'; debug("%s", static_cast<char *>(map)); j = 0; } } }