Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1538279) for mass test failures. CLOSED …
Browse files Browse the repository at this point in the history
…TREE

Backed out changeset af07f58d18cc (bug 1538279)
Backed out changeset 508ee4cf9ea2 (bug 1538279)
Backed out changeset 6f2e7c819c11 (bug 1538279)
  • Loading branch information
CosminSabou committed Apr 12, 2019
1 parent 0e6aee2 commit c64f16b
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 143 deletions.
11 changes: 4 additions & 7 deletions browser/app/nsBrowserApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
29 changes: 26 additions & 3 deletions modules/libjar/nsZipArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions mozglue/android/APKOpen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
12 changes: 2 additions & 10 deletions toolkit/xre/Bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
36 changes: 2 additions & 34 deletions xpcom/glue/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
50 changes: 0 additions & 50 deletions xpcom/glue/MemUtils.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions xpcom/glue/MemUtils.h

This file was deleted.

1 change: 0 additions & 1 deletion xpcom/glue/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ DIRS += ['standalone']

EXPORTS.mozilla += [
'FileUtils.h',
'MemUtils.h',
]
1 change: 0 additions & 1 deletion xpcom/glue/objs.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

xpcom_glue_src_lcppsrcs = [
'FileUtils.cpp',
'MemUtils.cpp',
'XREAppData.cpp',
]

Expand Down
1 change: 0 additions & 1 deletion xpcom/glue/standalone/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

SOURCES += [
'../FileUtils.cpp',
'../MemUtils.cpp',
'nsXPCOMGlue.cpp',
]

Expand Down
25 changes: 10 additions & 15 deletions xpcom/glue/standalone/nsXPCOMGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ static void AppendDependentLib(LibHandleType aLibHandle) {
sTop = d;
}

static bool ReadDependentCB(pathstr_t aDependentLib,
LibLoadingStrategy aLibLoadingStrategy) {
static bool ReadDependentCB(pathstr_t aDependentLib) {
#ifndef MOZ_LINKER
if (aLibLoadingStrategy == LibLoadingStrategy::ReadAhead) {
ReadAheadLib(aDependentLib);
}
// We do this unconditionally because of data in bug 771745
ReadAheadLib(aDependentLib);
#endif
LibHandleType libHandle = GetLibHandle(aDependentLib);
if (libHandle) {
Expand All @@ -139,12 +137,11 @@ static bool ReadDependentCB(pathstr_t aDependentLib,
}

#ifdef XP_WIN
static bool ReadDependentCB(const char* aDependentLib,
LibLoadingStrategy aLibLoadingStrategy) {
static bool ReadDependentCB(const char* aDependentLib) {
wchar_t wideDependentLib[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, aDependentLib, -1, wideDependentLib,
MAX_PATH);
return ReadDependentCB(wideDependentLib, aLibLoadingStrategy);
return ReadDependentCB(wideDependentLib);
}

inline FILE* TS_tfopen(const char* path, const wchar_t* mode) {
Expand Down Expand Up @@ -201,10 +198,9 @@ static const char* ns_strrpbrk(const char* string, const char* strCharSet) {
}
#endif

static nsresult XPCOMGlueLoad(const char* aXPCOMFile,
LibLoadingStrategy aLibLoadingStrategy) {
static nsresult XPCOMGlueLoad(const char* aXPCOMFile) {
#ifdef MOZ_LINKER
if (!ReadDependentCB(aXPCOMFile, aLibLoadingStrategy)) {
if (!ReadDependentCB(aXPCOMFile)) {
return NS_ERROR_FAILURE;
}
#else
Expand Down Expand Up @@ -300,7 +296,7 @@ static nsresult XPCOMGlueLoad(const char* aXPCOMFile,
}

strcpy(cursor, buffer);
if (!ReadDependentCB(xpcomDir, aLibLoadingStrategy)) {
if (!ReadDependentCB(xpcomDir)) {
XPCOMGlueUnload();
return NS_ERROR_FAILURE;
}
Expand Down Expand Up @@ -346,8 +342,7 @@ class GSliceInit {

namespace mozilla {

Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile,
LibLoadingStrategy aLibLoadingStrategy) {
Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile) {
#ifdef MOZ_GSLICE_INIT
GSliceInit gSliceInit;
#endif
Expand All @@ -368,7 +363,7 @@ Bootstrap::UniquePtr GetBootstrap(const char* aXPCOMFile,
memcpy(file.get(), aXPCOMFile, base_len);
memcpy(file.get() + base_len, XPCOM_DLL, sizeof(XPCOM_DLL));

if (NS_FAILED(XPCOMGlueLoad(file.get(), aLibLoadingStrategy))) {
if (NS_FAILED(XPCOMGlueLoad(file.get()))) {
return nullptr;
}

Expand Down

0 comments on commit c64f16b

Please sign in to comment.