mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 810151: readahead for ordered jar files r=taras
--HG-- extra : rebase_source : dd7984ff2dd7a57e77b8c5c74ab82ad5d033a772
This commit is contained in:
parent
10eff2ffe5
commit
1a9e9e36e7
@ -30,6 +30,7 @@
|
|||||||
#define ZIP_ARENABLOCKSIZE (1*1024)
|
#define ZIP_ARENABLOCKSIZE (1*1024)
|
||||||
|
|
||||||
#ifdef XP_UNIX
|
#ifdef XP_UNIX
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -156,6 +157,9 @@ nsresult gZlibInit(z_stream *zs)
|
|||||||
nsZipHandle::nsZipHandle()
|
nsZipHandle::nsZipHandle()
|
||||||
: mFileData(nullptr)
|
: mFileData(nullptr)
|
||||||
, mLen(0)
|
, mLen(0)
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
, mFd(nullptr)
|
||||||
|
#endif
|
||||||
, mMap(nullptr)
|
, mMap(nullptr)
|
||||||
, mRefCnt(0)
|
, mRefCnt(0)
|
||||||
{
|
{
|
||||||
@ -168,7 +172,11 @@ NS_IMPL_THREADSAFE_RELEASE(nsZipHandle)
|
|||||||
nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret)
|
nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret)
|
||||||
{
|
{
|
||||||
mozilla::AutoFDClose fd;
|
mozilla::AutoFDClose fd;
|
||||||
nsresult rv = file->OpenNSPRFileDesc(PR_RDONLY, 0000, &fd.rwget());
|
int32_t flags = PR_RDONLY;
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
flags |= nsIFile::OS_READAHEAD;
|
||||||
|
#endif
|
||||||
|
nsresult rv = file->OpenNSPRFileDesc(flags, 0000, &fd.rwget());
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@ -194,6 +202,9 @@ nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret)
|
|||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
handle->mFd = fd.forget();
|
||||||
|
#endif
|
||||||
handle->mMap = map;
|
handle->mMap = map;
|
||||||
handle->mFile.Init(file);
|
handle->mFile.Init(file);
|
||||||
handle->mLen = (uint32_t) size;
|
handle->mLen = (uint32_t) size;
|
||||||
@ -231,6 +242,11 @@ int64_t nsZipHandle::SizeOfMapping()
|
|||||||
|
|
||||||
nsZipHandle::~nsZipHandle()
|
nsZipHandle::~nsZipHandle()
|
||||||
{
|
{
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
if (mFd) {
|
||||||
|
PR_Close(mFd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (mMap) {
|
if (mMap) {
|
||||||
PR_MemUnmap((void *)mFileData, mLen);
|
PR_MemUnmap((void *)mFileData, mLen);
|
||||||
PR_CloseFileMap(mMap);
|
PR_CloseFileMap(mMap);
|
||||||
@ -569,6 +585,15 @@ MOZ_WIN_MEM_TRY_BEGIN
|
|||||||
uint32_t centralOffset = 4;
|
uint32_t centralOffset = 4;
|
||||||
if (mFd->mLen > ZIPCENTRAL_SIZE && xtolong(startp + centralOffset) == CENTRALSIG) {
|
if (mFd->mLen > ZIPCENTRAL_SIZE && xtolong(startp + centralOffset) == CENTRALSIG) {
|
||||||
// Success means optimized jar layout from bug 559961 is in effect
|
// Success means optimized jar layout from bug 559961 is in effect
|
||||||
|
uint32_t readaheadLength = xtolong(startp);
|
||||||
|
if (readaheadLength) {
|
||||||
|
#if defined(XP_UNIX)
|
||||||
|
madvise(const_cast<uint8_t*>(startp), readaheadLength, MADV_WILLNEED);
|
||||||
|
#elif defined(XP_WIN)
|
||||||
|
HANDLE hFile = (HANDLE) PR_FileDesc2NativeHandle(mFd->mFd);
|
||||||
|
mozilla::ReadAhead(hFile, 0, readaheadLength);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (buf = endp - ZIPEND_SIZE; buf > startp; buf--)
|
for (buf = endp - ZIPEND_SIZE; buf > startp; buf--)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +392,9 @@ private:
|
|||||||
nsZipHandle();
|
nsZipHandle();
|
||||||
~nsZipHandle();
|
~nsZipHandle();
|
||||||
|
|
||||||
|
#if defined(XP_WIN)
|
||||||
|
PRFileDesc * mFd; /* nspr file descriptor */
|
||||||
|
#endif
|
||||||
PRFileMap * mMap; /* nspr datastructure for mmap */
|
PRFileMap * mMap; /* nspr datastructure for mmap */
|
||||||
nsAutoPtr<nsZipItemPtr<uint8_t> > mBuf;
|
nsAutoPtr<nsZipItemPtr<uint8_t> > mBuf;
|
||||||
nsrefcnt mRefCnt; /* ref count */
|
nsrefcnt mRefCnt; /* ref count */
|
||||||
|
Loading…
Reference in New Issue
Block a user