diff --git a/browser/app/winlauncher/LauncherProcessWin.cpp b/browser/app/winlauncher/LauncherProcessWin.cpp index 81d4ee91e938..b40e0fceb567 100644 --- a/browser/app/winlauncher/LauncherProcessWin.cpp +++ b/browser/app/winlauncher/LauncherProcessWin.cpp @@ -401,12 +401,8 @@ Maybe LauncherMain(int& argc, wchar_t* argv[], } #endif // defined(MOZ_LAUNCHER_PROCESS) - // Now proceed with setting up the parameters for process creation. - constexpr static const wchar_t* extraArgs[] = { - L"/prefetch:1", // for APFL; see ipc/glue/GeckoChildProcessHost.cpp - }; - UniquePtr cmdLine( - MakeCommandLine(argc, argv, ARRAYSIZE(extraArgs), extraArgs)); + // Now proceed with setting up the parameters for process creation + UniquePtr cmdLine(MakeCommandLine(argc, argv)); if (!cmdLine) { HandleLauncherError(LAUNCHER_ERROR_GENERIC()); return Nothing(); diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 232ee935d66b..bde3a9a3890e 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -13,7 +13,6 @@ #include "base/task.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/process_watcher.h" -#include "mozilla/ProcessType.h" #ifdef MOZ_WIDGET_COCOA # include # include @@ -67,7 +66,6 @@ #ifdef XP_WIN # include -# include "mozilla/WindowsVersion.h" # include "nsIWinTaskbar.h" # define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1" @@ -251,7 +249,7 @@ class BaseProcessLauncher { }; #ifdef XP_WIN -class WindowsProcessLauncher final : public BaseProcessLauncher { +class WindowsProcessLauncher : public BaseProcessLauncher { public: WindowsProcessLauncher(GeckoChildProcessHost* aHost, std::vector&& aExtraOpts) @@ -263,9 +261,6 @@ class WindowsProcessLauncher final : public BaseProcessLauncher { virtual RefPtr DoLaunch() override; virtual Result DoFinishLaunch() override; - private: - void AddApplicationPrefetchArgument(); - mozilla::Maybe mCmdLine; bool mUseSandbox = false; @@ -1393,99 +1388,6 @@ Result MacProcessLauncher::DoFinishLaunch() { #endif // XP_MACOSX #ifdef XP_WIN -void WindowsProcessLauncher::AddApplicationPrefetchArgument() { - // The Application Launch Prefetcher (ALPF) is an ill-documented Windows - // subsystem that's intended to speed up process launching, apparently mostly - // by assuming that a binary is going to want to load the same DLLs as it did - // the last time it launched, and getting those prepped for loading as well. - // - // For most applications, that's a good bet. For Firefox, it's less so, since - // we use the same binary with different arguments to do completely different - // things. Windows does allow applications to take up multiple slots in this - // cache, but the "which bucket does this invocation go in?" mechanism is - // highly unusual: the OS scans the command line and looks for a command-line - // switch of a particular form. - // - // (There is allegedly a way to do this without involving the command line, - // OVERRIDE_PREFETCH_PARAMETER, but it's even more poorly documented.) - - // Applications' different prefetch-cache buckets are named with numbers from - // "1" to some OS-version-determined limit, with an additional implicit "0" - // cache bucket which is used when no valid prefetch cache slot is named. - // - // (The "0" bucket's existence and behavior is not documented, but has been - // confirmed by observing the creation and enumeration of cache files in the - // C:\Windows\Prefetch folder.) - static size_t const kMaxSlotNo = IsWin1122H2OrLater() ? 16 : 8; - - // Determine the prefetch-slot number to be used for the process we're about - // to launch. - // - // This may be changed freely between Firefox versions, as a Firefox update - // will completely invalidate the prefetch cache anyway. - size_t const prefetchSlot = [&]() -> size_t { - switch (mProcessType) { - // This code path is not used when starting the main process... - case GeckoProcessType_Default: - // ...ForkServer is not used on Windows... - case GeckoProcessType_ForkServer: - // ..."End" isn't a process-type, just a limit... - case GeckoProcessType_End: - // ...and any new process-types should be considered explicitly here. - default: - MOZ_ASSERT_UNREACHABLE("Invalid process type"); - return 0; - - // These are started so rarely that we're not concerned about their - // interaction with the prefetch cache. - case GeckoProcessType_IPDLUnitTest: - case GeckoProcessType_VR: - return 0; - - // We reserve 1 for the main process as started by the launcher process. - // (See LauncherProcessWin.cpp.) Otherwise, we mostly match the process- - // type enumeration. - case GeckoProcessType_Content: - return 2; - case GeckoProcessType_Socket: - return 3; // usurps IPDLUnitTest - case GeckoProcessType_GMPlugin: - return 4; - case GeckoProcessType_GPU: - return 5; - case GeckoProcessType_RemoteSandboxBroker: - return 6; // usurps VR - case GeckoProcessType_RDD: - return 7; - - case GeckoProcessType_Utility: - // Continue the enumeration, using the SandboxingKind as a - // probably-passably-precise proxy for the process's purpose. - // - // (On Win10 and earlier this will lump all utility processes - // into slot 8.) - return std::min(kMaxSlotNo, 8 + static_cast(mSandbox)); - } - }(); - MOZ_ASSERT(prefetchSlot <= kMaxSlotNo); - - if (prefetchSlot == 0) { - // default; no explicit argument needed - return; - } - - std::wstring arg(L"/prefetch:"); - { - wchar_t buf[3]; - if (0 != _ultow_s(prefetchSlot, buf, 10)) { - MOZ_ASSERT(false); - return; - } - arg.append(buf); - } - mCmdLine->AppendLooseValue(arg); -} - Result WindowsProcessLauncher::DoSetup() { Result aError = BaseProcessLauncher::DoSetup(); if (aError.isErr()) { @@ -1666,9 +1568,6 @@ Result WindowsProcessLauncher::DoSetup() { // Process type mCmdLine->AppendLooseValue(UTF8ToWide(ChildProcessType())); - // Prefetch cache hint - AddApplicationPrefetchArgument(); - # ifdef MOZ_SANDBOX if (mUseSandbox) { // Mark the handles to inherit as inheritable. diff --git a/toolkit/xre/nsWindowsWMain.cpp b/toolkit/xre/nsWindowsWMain.cpp index 027c8883cc24..7eb9e1104682 100644 --- a/toolkit/xre/nsWindowsWMain.cpp +++ b/toolkit/xre/nsWindowsWMain.cpp @@ -125,22 +125,6 @@ int wmain(int argc, WCHAR** argv) { } #endif // defined(mozilla_LauncherProcessWin_h) - // Remove "/prefetch:##" argument from the command line, if present. (See - // GeckoChildProcessHost.cpp for details.) - // - // Colons are not permitted in path-elements on Windows, so a string of this - // form is extremely unlikely to appear with the intent of being a legitimate - // path-argument. - for (int i = 0; i < argc; ++i) { - constexpr const wchar_t prefix[] = L"/prefetch:"; - auto const cmp = wcsncmp(argv[i], prefix, ARRAYSIZE(prefix) - 1); - if (cmp == 0) { - std::copy(argv + i + 1, argv + argc, argv + i); - --argc; - break; // assume there's only one - } - } - char** argvConverted = new char*[argc + 1]; if (!argvConverted) return 127;