Loading browser/app/nsBrowserApp.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -212,14 +212,14 @@ static int do_main(int argc, char* argv[], char* envp[]) { return gBootstrap->XRE_main(argc, argv, config); } static nsresult InitXPCOMGlue(LibLoadingStrategy aLibLoadingStrategy) { static nsresult InitXPCOMGlue() { UniqueFreePtr<char> exePath = BinaryPath::Get(); if (!exePath) { Output("Couldn't find the application directory.\n"); return NS_ERROR_FAILURE; } gBootstrap = mozilla::GetBootstrap(exePath.get(), aLibLoadingStrategy); gBootstrap = mozilla::GetBootstrap(exePath.get()); if (!gBootstrap) { Output("Couldn't load XPCOM.\n"); return NS_ERROR_FAILURE; Loading Loading @@ -255,10 +255,7 @@ int main(int argc, char* argv[], char* envp[]) { } # endif // Don't bother doing a ReadAhead if we're not in the parent process. // What we need from the library should already be in the system file // cache. nsresult rv = InitXPCOMGlue(LibLoadingStrategy::NoReadAhead); nsresult rv = InitXPCOMGlue(); if (NS_FAILED(rv)) { return 255; } Loading @@ -280,7 +277,7 @@ int main(int argc, char* argv[], char* envp[]) { DllBlocklist_Initialize(gBlocklistInitFlags); #endif nsresult rv = InitXPCOMGlue(LibLoadingStrategy::ReadAhead); nsresult rv = InitXPCOMGlue(); if (NS_FAILED(rv)) { return 255; } Loading modules/libjar/nsZipArchive.cpp +26 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ #include "plstr.h" #include "mozilla/Attributes.h" #include "mozilla/Logging.h" #include "mozilla/MemUtils.h" #include "mozilla/UniquePtrExtensions.h" #include "stdlib.h" #include "nsDirectoryService.h" Loading Loading @@ -651,8 +650,32 @@ nsresult nsZipArchive::BuildFileList(PRFileDesc *aFd) { xtolong(startp + centralOffset) == CENTRALSIG) { // Success means optimized jar layout from bug 559961 is in effect uint32_t readaheadLength = xtolong(startp); mozilla::MaybePrefetchMemory(const_cast<uint8_t *>(startp), readaheadLength); if (readaheadLength) { #if defined(XP_SOLARIS) posix_madvise(const_cast<uint8_t *>(startp), readaheadLength, POSIX_MADV_WILLNEED); #elif defined(XP_UNIX) madvise(const_cast<uint8_t *>(startp), readaheadLength, MADV_WILLNEED); #elif defined(XP_WIN) static auto prefetchVirtualMemory = reinterpret_cast<BOOL(WINAPI *)(HANDLE, ULONG_PTR, PVOID, ULONG)>( GetProcAddress(GetModuleHandle(L"kernel32.dll"), "PrefetchVirtualMemory")); if (prefetchVirtualMemory) { // Normally, we'd use WIN32_MEMORY_RANGE_ENTRY, but that requires // a different _WIN32_WINNT value before including windows.h, but // that causes complications with unified sources. It's a simple // enough struct anyways. struct { PVOID VirtualAddress; SIZE_T NumberOfBytes; } entry; entry.VirtualAddress = const_cast<uint8_t *>(startp); entry.NumberOfBytes = readaheadLength; prefetchVirtualMemory(GetCurrentProcess(), 1, &entry, 0); } #endif } } else { for (buf = endp - ZIPEND_SIZE; buf > startp; buf--) { if (xtolong(buf) == ENDSIG) { Loading mozglue/android/APKOpen.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -196,8 +196,7 @@ static mozglueresult loadGeckoLibs() { getrusage(RUSAGE_THREAD, &usage1_thread); getrusage(RUSAGE_SELF, &usage1); gBootstrap = GetBootstrap(getUnpackedLibraryName("libxul.so").get(), LibLoadingStrategy::ReadAhead); gBootstrap = GetBootstrap(getUnpackedLibraryName("libxul.so").get()); if (!gBootstrap) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!"); Loading toolkit/xre/Bootstrap.h +2 −10 Original line number Diff line number Diff line Loading @@ -128,11 +128,6 @@ class Bootstrap { #endif }; enum class LibLoadingStrategy { NoReadAhead, ReadAhead, }; /** * Creates and returns the singleton instnace of the bootstrap object. * @param `b` is an outparam. We use a parameter and not a return value Loading @@ -142,15 +137,12 @@ enum class LibLoadingStrategy { */ #ifdef XPCOM_GLUE typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&); Bootstrap::UniquePtr GetBootstrap( const char* aXPCOMFile = nullptr, LibLoadingStrategy aLibLoadingStrategy = LibLoadingStrategy::NoReadAhead); Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile = nullptr); #else extern "C" NS_EXPORT void NS_FROZENCALL XRE_GetBootstrap(Bootstrap::UniquePtr& b); inline Bootstrap::UniquePtr GetBootstrap( const char* aXPCOMFile = nullptr) { inline Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile = nullptr) { Bootstrap::UniquePtr bootstrap; XRE_GetBootstrap(bootstrap); return bootstrap; Loading xpcom/glue/FileUtils.cpp +2 −34 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ #include "private/pprio.h" #include "prmem.h" #include "mozilla/Assertions.h" #include "mozilla/MemUtils.h" #if defined(XP_MACOSX) # include <fcntl.h> Loading @@ -33,8 +32,7 @@ # include <sys/types.h> # include <sys/stat.h> #elif defined(XP_WIN) # include <nsWindowsHelpers.h> # include <mozilla/ScopeExit.h> # include <windows.h> #endif // Functions that are not to be used in standalone glue must be implemented Loading Loading @@ -357,37 +355,7 @@ void mozilla::ReadAheadLib(mozilla::pathstr_t aFilePath) { return; } #if defined(XP_WIN) nsAutoHandle fd(CreateFileW(aFilePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr)); if (!fd) { return; } LARGE_INTEGER fileSize = {}; BOOL success = GetFileSizeEx(fd, &fileSize); if (!success || !fileSize.QuadPart || fileSize.QuadPart > std::numeric_limits<size_t>::max()) { return; } nsAutoHandle mapping(CreateFileMapping(fd, nullptr, SEC_IMAGE | PAGE_READONLY, 0, 0, nullptr)); if (!mapping) { return; } PVOID data = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0); auto guard = MakeScopeExit([=]() { UnmapViewOfFile(data); }); if (!MaybePrefetchMemory((uint8_t*)data, (size_t)fileSize.QuadPart)) { volatile uint8_t read = 0; for(size_t i = 0; i < (size_t)fileSize.QuadPart; i += 4096) { read += ((uint8_t*)data)[i]; } } ReadAheadFile(aFilePath); #elif defined(LINUX) && !defined(ANDROID) int fd = open(aFilePath, O_RDONLY); if (fd < 0) { Loading Loading
browser/app/nsBrowserApp.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -212,14 +212,14 @@ static int do_main(int argc, char* argv[], char* envp[]) { return gBootstrap->XRE_main(argc, argv, config); } static nsresult InitXPCOMGlue(LibLoadingStrategy aLibLoadingStrategy) { static nsresult InitXPCOMGlue() { UniqueFreePtr<char> exePath = BinaryPath::Get(); if (!exePath) { Output("Couldn't find the application directory.\n"); return NS_ERROR_FAILURE; } gBootstrap = mozilla::GetBootstrap(exePath.get(), aLibLoadingStrategy); gBootstrap = mozilla::GetBootstrap(exePath.get()); if (!gBootstrap) { Output("Couldn't load XPCOM.\n"); return NS_ERROR_FAILURE; Loading Loading @@ -255,10 +255,7 @@ int main(int argc, char* argv[], char* envp[]) { } # endif // Don't bother doing a ReadAhead if we're not in the parent process. // What we need from the library should already be in the system file // cache. nsresult rv = InitXPCOMGlue(LibLoadingStrategy::NoReadAhead); nsresult rv = InitXPCOMGlue(); if (NS_FAILED(rv)) { return 255; } Loading @@ -280,7 +277,7 @@ int main(int argc, char* argv[], char* envp[]) { DllBlocklist_Initialize(gBlocklistInitFlags); #endif nsresult rv = InitXPCOMGlue(LibLoadingStrategy::ReadAhead); nsresult rv = InitXPCOMGlue(); if (NS_FAILED(rv)) { return 255; } Loading
modules/libjar/nsZipArchive.cpp +26 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ #include "plstr.h" #include "mozilla/Attributes.h" #include "mozilla/Logging.h" #include "mozilla/MemUtils.h" #include "mozilla/UniquePtrExtensions.h" #include "stdlib.h" #include "nsDirectoryService.h" Loading Loading @@ -651,8 +650,32 @@ nsresult nsZipArchive::BuildFileList(PRFileDesc *aFd) { xtolong(startp + centralOffset) == CENTRALSIG) { // Success means optimized jar layout from bug 559961 is in effect uint32_t readaheadLength = xtolong(startp); mozilla::MaybePrefetchMemory(const_cast<uint8_t *>(startp), readaheadLength); if (readaheadLength) { #if defined(XP_SOLARIS) posix_madvise(const_cast<uint8_t *>(startp), readaheadLength, POSIX_MADV_WILLNEED); #elif defined(XP_UNIX) madvise(const_cast<uint8_t *>(startp), readaheadLength, MADV_WILLNEED); #elif defined(XP_WIN) static auto prefetchVirtualMemory = reinterpret_cast<BOOL(WINAPI *)(HANDLE, ULONG_PTR, PVOID, ULONG)>( GetProcAddress(GetModuleHandle(L"kernel32.dll"), "PrefetchVirtualMemory")); if (prefetchVirtualMemory) { // Normally, we'd use WIN32_MEMORY_RANGE_ENTRY, but that requires // a different _WIN32_WINNT value before including windows.h, but // that causes complications with unified sources. It's a simple // enough struct anyways. struct { PVOID VirtualAddress; SIZE_T NumberOfBytes; } entry; entry.VirtualAddress = const_cast<uint8_t *>(startp); entry.NumberOfBytes = readaheadLength; prefetchVirtualMemory(GetCurrentProcess(), 1, &entry, 0); } #endif } } else { for (buf = endp - ZIPEND_SIZE; buf > startp; buf--) { if (xtolong(buf) == ENDSIG) { Loading
mozglue/android/APKOpen.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -196,8 +196,7 @@ static mozglueresult loadGeckoLibs() { getrusage(RUSAGE_THREAD, &usage1_thread); getrusage(RUSAGE_SELF, &usage1); gBootstrap = GetBootstrap(getUnpackedLibraryName("libxul.so").get(), LibLoadingStrategy::ReadAhead); gBootstrap = GetBootstrap(getUnpackedLibraryName("libxul.so").get()); if (!gBootstrap) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!"); Loading
toolkit/xre/Bootstrap.h +2 −10 Original line number Diff line number Diff line Loading @@ -128,11 +128,6 @@ class Bootstrap { #endif }; enum class LibLoadingStrategy { NoReadAhead, ReadAhead, }; /** * Creates and returns the singleton instnace of the bootstrap object. * @param `b` is an outparam. We use a parameter and not a return value Loading @@ -142,15 +137,12 @@ enum class LibLoadingStrategy { */ #ifdef XPCOM_GLUE typedef void (*GetBootstrapType)(Bootstrap::UniquePtr&); Bootstrap::UniquePtr GetBootstrap( const char* aXPCOMFile = nullptr, LibLoadingStrategy aLibLoadingStrategy = LibLoadingStrategy::NoReadAhead); Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile = nullptr); #else extern "C" NS_EXPORT void NS_FROZENCALL XRE_GetBootstrap(Bootstrap::UniquePtr& b); inline Bootstrap::UniquePtr GetBootstrap( const char* aXPCOMFile = nullptr) { inline Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile = nullptr) { Bootstrap::UniquePtr bootstrap; XRE_GetBootstrap(bootstrap); return bootstrap; Loading
xpcom/glue/FileUtils.cpp +2 −34 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ #include "private/pprio.h" #include "prmem.h" #include "mozilla/Assertions.h" #include "mozilla/MemUtils.h" #if defined(XP_MACOSX) # include <fcntl.h> Loading @@ -33,8 +32,7 @@ # include <sys/types.h> # include <sys/stat.h> #elif defined(XP_WIN) # include <nsWindowsHelpers.h> # include <mozilla/ScopeExit.h> # include <windows.h> #endif // Functions that are not to be used in standalone glue must be implemented Loading Loading @@ -357,37 +355,7 @@ void mozilla::ReadAheadLib(mozilla::pathstr_t aFilePath) { return; } #if defined(XP_WIN) nsAutoHandle fd(CreateFileW(aFilePath, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr)); if (!fd) { return; } LARGE_INTEGER fileSize = {}; BOOL success = GetFileSizeEx(fd, &fileSize); if (!success || !fileSize.QuadPart || fileSize.QuadPart > std::numeric_limits<size_t>::max()) { return; } nsAutoHandle mapping(CreateFileMapping(fd, nullptr, SEC_IMAGE | PAGE_READONLY, 0, 0, nullptr)); if (!mapping) { return; } PVOID data = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0); auto guard = MakeScopeExit([=]() { UnmapViewOfFile(data); }); if (!MaybePrefetchMemory((uint8_t*)data, (size_t)fileSize.QuadPart)) { volatile uint8_t read = 0; for(size_t i = 0; i < (size_t)fileSize.QuadPart; i += 4096) { read += ((uint8_t*)data)[i]; } } ReadAheadFile(aFilePath); #elif defined(LINUX) && !defined(ANDROID) int fd = open(aFilePath, O_RDONLY); if (fd < 0) { Loading