Loading mozglue/linker/ElfLoader.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -232,7 +232,7 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent) * environment variable. */ const char *extract = getenv("MOZ_LINKER_EXTRACT"); if (extract && !strncmp(extract, "1", 2 /* Including '\0' */)) mappable = MappableExtractFile::Create(name, &s); mappable = MappableExtractFile::Create(name, zip, &s); if (!mappable) { if (s.GetType() == Zip::Stream::DEFLATE) { mappable = MappableDeflate::Create(name, zip, &s); Loading mozglue/linker/Mappable.cpp +17 −6 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ #ifdef ANDROID #include <linux/ashmem.h> #endif #include <sys/stat.h> #include "ElfLoader.h" #include "SeekableZStream.h" #include "Logging.h" Loading @@ -24,7 +25,8 @@ #define PAGE_MASK (~ (PAGE_SIZE - 1)) #endif MappableFile *MappableFile::Create(const char *path) Mappable * MappableFile::Create(const char *path) { int fd = open(path, O_RDONLY); if (fd != -1) Loading Loading @@ -62,8 +64,8 @@ MappableFile::finalize() fd = -1; } MappableExtractFile * MappableExtractFile::Create(const char *name, Zip::Stream *stream) Mappable * MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream) { const char *cachePath = getenv("MOZ_LINKER_CACHE"); if (!cachePath || !*cachePath) { Loading @@ -73,7 +75,16 @@ MappableExtractFile::Create(const char *name, Zip::Stream *stream) } AutoDeleteArray<char> path = new char[strlen(cachePath) + strlen(name) + 2]; sprintf(path, "%s/%s", cachePath, name); debug("Extracting to %s", (char *)path); struct stat cacheStat; if (stat(path, &cacheStat) == 0) { struct stat zipStat; stat(zip->GetName(), &zipStat); if (cacheStat.st_mtime > zipStat.st_mtime) { debug("Reusing %s", static_cast<char *>(path)); return MappableFile::Create(path); } } debug("Extracting to %s", static_cast<char *>(path)); AutoCloseFD fd = open(path, O_TRUNC | O_RDWR | O_CREAT | O_NOATIME, S_IRUSR | S_IWUSR); if (fd == -1) { Loading Loading @@ -246,7 +257,7 @@ private: }; MappableDeflate * Mappable * MappableDeflate::Create(const char *name, Zip *zip, Zip::Stream *stream) { MOZ_ASSERT(stream->GetType() == Zip::Stream::DEFLATE); Loading Loading @@ -324,7 +335,7 @@ MappableDeflate::finalize() zip = NULL; } MappableSeekableZStream * Mappable * MappableSeekableZStream::Create(const char *name, Zip *zip, Zip::Stream *stream) { Loading mozglue/linker/Mappable.h +4 −10 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public: /** * Create a MappableFile instance for the given file path. */ static MappableFile *Create(const char *path); static Mappable *Create(const char *path); /* Inherited from Mappable */ virtual void *mmap(const void *addr, size_t length, int prot, int flags, off_t offset); Loading @@ -99,14 +99,8 @@ public: * Create a MappableExtractFile instance for the given Zip stream. The name * argument is used to create the cache file in the cache directory. */ static MappableExtractFile *Create(const char *name, Zip::Stream *stream); static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /** * Returns the path of the extracted file. */ char *GetPath() { return path; } private: MappableExtractFile(int fd, char *path) : MappableFile(fd), path(path), pid(getpid()) { } Loading Loading @@ -148,7 +142,7 @@ public: * argument is used for an appropriately named temporary file, and the Zip * instance is given for the MappableDeflate to keep a reference of it. */ static MappableDeflate *Create(const char *name, Zip *zip, Zip::Stream *stream); static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /* Inherited from Mappable */ virtual void *mmap(const void *addr, size_t length, int prot, int flags, off_t offset); Loading Loading @@ -182,7 +176,7 @@ public: * Zip instance is given for the MappableSeekableZStream to keep a reference * of it. */ static MappableSeekableZStream *Create(const char *name, Zip *zip, static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /* Inherited from Mappable */ Loading Loading
mozglue/linker/ElfLoader.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -232,7 +232,7 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent) * environment variable. */ const char *extract = getenv("MOZ_LINKER_EXTRACT"); if (extract && !strncmp(extract, "1", 2 /* Including '\0' */)) mappable = MappableExtractFile::Create(name, &s); mappable = MappableExtractFile::Create(name, zip, &s); if (!mappable) { if (s.GetType() == Zip::Stream::DEFLATE) { mappable = MappableDeflate::Create(name, zip, &s); Loading
mozglue/linker/Mappable.cpp +17 −6 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ #ifdef ANDROID #include <linux/ashmem.h> #endif #include <sys/stat.h> #include "ElfLoader.h" #include "SeekableZStream.h" #include "Logging.h" Loading @@ -24,7 +25,8 @@ #define PAGE_MASK (~ (PAGE_SIZE - 1)) #endif MappableFile *MappableFile::Create(const char *path) Mappable * MappableFile::Create(const char *path) { int fd = open(path, O_RDONLY); if (fd != -1) Loading Loading @@ -62,8 +64,8 @@ MappableFile::finalize() fd = -1; } MappableExtractFile * MappableExtractFile::Create(const char *name, Zip::Stream *stream) Mappable * MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream) { const char *cachePath = getenv("MOZ_LINKER_CACHE"); if (!cachePath || !*cachePath) { Loading @@ -73,7 +75,16 @@ MappableExtractFile::Create(const char *name, Zip::Stream *stream) } AutoDeleteArray<char> path = new char[strlen(cachePath) + strlen(name) + 2]; sprintf(path, "%s/%s", cachePath, name); debug("Extracting to %s", (char *)path); struct stat cacheStat; if (stat(path, &cacheStat) == 0) { struct stat zipStat; stat(zip->GetName(), &zipStat); if (cacheStat.st_mtime > zipStat.st_mtime) { debug("Reusing %s", static_cast<char *>(path)); return MappableFile::Create(path); } } debug("Extracting to %s", static_cast<char *>(path)); AutoCloseFD fd = open(path, O_TRUNC | O_RDWR | O_CREAT | O_NOATIME, S_IRUSR | S_IWUSR); if (fd == -1) { Loading Loading @@ -246,7 +257,7 @@ private: }; MappableDeflate * Mappable * MappableDeflate::Create(const char *name, Zip *zip, Zip::Stream *stream) { MOZ_ASSERT(stream->GetType() == Zip::Stream::DEFLATE); Loading Loading @@ -324,7 +335,7 @@ MappableDeflate::finalize() zip = NULL; } MappableSeekableZStream * Mappable * MappableSeekableZStream::Create(const char *name, Zip *zip, Zip::Stream *stream) { Loading
mozglue/linker/Mappable.h +4 −10 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public: /** * Create a MappableFile instance for the given file path. */ static MappableFile *Create(const char *path); static Mappable *Create(const char *path); /* Inherited from Mappable */ virtual void *mmap(const void *addr, size_t length, int prot, int flags, off_t offset); Loading @@ -99,14 +99,8 @@ public: * Create a MappableExtractFile instance for the given Zip stream. The name * argument is used to create the cache file in the cache directory. */ static MappableExtractFile *Create(const char *name, Zip::Stream *stream); static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /** * Returns the path of the extracted file. */ char *GetPath() { return path; } private: MappableExtractFile(int fd, char *path) : MappableFile(fd), path(path), pid(getpid()) { } Loading Loading @@ -148,7 +142,7 @@ public: * argument is used for an appropriately named temporary file, and the Zip * instance is given for the MappableDeflate to keep a reference of it. */ static MappableDeflate *Create(const char *name, Zip *zip, Zip::Stream *stream); static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /* Inherited from Mappable */ virtual void *mmap(const void *addr, size_t length, int prot, int flags, off_t offset); Loading Loading @@ -182,7 +176,7 @@ public: * Zip instance is given for the MappableSeekableZStream to keep a reference * of it. */ static MappableSeekableZStream *Create(const char *name, Zip *zip, static Mappable *Create(const char *name, Zip *zip, Zip::Stream *stream); /* Inherited from Mappable */ Loading