Backed out 12 changesets (bug 1471025) for build bustages on dom/ipc/ContentProcess.cpp. CLOSED TREE
authorBrindusan Cristian <cbrindusan@mozilla.com>
Fri, 13 Jul 2018 22:11:24 +0300
changeset 426575 bd747e24063da7d803dc5fd20b5a8af0d036f4d5
parent 426574 72c622b851f3b5402f0e954ce5f578caa645182c
child 426576 4c9aa8e48d61555d84847adf67b41b4e846f7ddd
push id34275
push usernerli@mozilla.com
push dateFri, 13 Jul 2018 21:53:18 +0000
treeherdermozilla-central@b79457b703d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1471025
milestone63.0a1
backs out398ccedc20dc1c3f29332dd5a4791b9ab96eb547
599895de063ef005dbd34847db9ee555410a878f
dc7ec17179d1961d91b897cec9f409786363ec9e
5051f15fc2005667cfe76ccae0afb1fb0657c103
faef4df47b2089592df7637f5b8f4ae193e98046
d344247b870668f53fa645e72bda4bb4309346c8
83d98ea5ebaccded8a20929c0f3316e5618f1f76
38f690f30e78764763bb012045073fa781efa691
4b7a8a35ed956159e2f443c6211164c0cbf3d926
e3bbc87b71af2f2ce1fa8bdf2cf26857c071ba5e
68bb03c63b3cee1d47cbddfd3abf919f5783c04b
4a8fbb472c91f13554cac3d0ea638cf9f368ff11
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 12 changesets (bug 1471025) for build bustages on dom/ipc/ContentProcess.cpp. CLOSED TREE Backed out changeset 398ccedc20dc (bug 1471025) Backed out changeset 599895de063e (bug 1471025) Backed out changeset dc7ec17179d1 (bug 1471025) Backed out changeset 5051f15fc200 (bug 1471025) Backed out changeset faef4df47b20 (bug 1471025) Backed out changeset d344247b8706 (bug 1471025) Backed out changeset 83d98ea5ebac (bug 1471025) Backed out changeset 38f690f30e78 (bug 1471025) Backed out changeset 4b7a8a35ed95 (bug 1471025) Backed out changeset e3bbc87b71af (bug 1471025) Backed out changeset 68bb03c63b3c (bug 1471025) Backed out changeset 4a8fbb472c91 (bug 1471025)
browser/base/content/test/performance/browser_preferences_usage.js
dom/ipc/ContentParent.cpp
dom/ipc/ContentProcess.cpp
dom/ipc/ContentProcess.h
dom/ipc/MemMapSnapshot.h
dom/ipc/SharedStringMap.cpp
dom/ipc/SharedStringMap.h
dom/ipc/StringTable.h
dom/ipc/moz.build
ipc/glue/GeckoChildProcessHost.cpp
mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/process/IChildProcess.aidl
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoServiceChildProcess.java
modules/libpref/Preferences.cpp
modules/libpref/Preferences.h
modules/libpref/SharedPrefMap.cpp
modules/libpref/SharedPrefMap.h
modules/libpref/moz.build
modules/libpref/nsIPrefService.idl
modules/libpref/test/unit/test_libPrefs.js
modules/libpref/test/unit_ipc/test_large_pref.js
modules/libpref/test/unit_ipc/test_sharedMap.js
modules/libpref/test/unit_ipc/xpcshell.ini
mozglue/android/APKOpen.cpp
toolkit/components/extensions/ExtensionXPCShellUtils.jsm
toolkit/xre/Bootstrap.cpp
toolkit/xre/Bootstrap.h
toolkit/xre/nsEmbedFunctions.cpp
xpcom/build/nsXULAppAPI.h
--- a/browser/base/content/test/performance/browser_preferences_usage.js
+++ b/browser/base/content/test/performance/browser_preferences_usage.js
@@ -84,19 +84,16 @@ add_task(async function startup() {
     "browser.search.log": {
       min: 100,
       max: 150,
     },
     "layout.css.dpi": {
       min: 45,
       max: 75,
     },
-    "network.loadinfo.skip_type_assertion": {
-      max: 650,
-    },
     "extensions.getAddons.cache.enabled": {
       min: 9,
       max: 55,
     },
   };
 
   let startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject;
   await startupRecorder.done;
@@ -136,21 +133,18 @@ add_task(async function open_10_tabs() {
     },
     "dom.ipc.processCount": {
       min: 10,
       max: 15,
     },
     "browser.startup.record": {
       max: 20,
     },
-    "browser.tabs.remote.logSwitchTiming": {
-      max: 25,
-    },
-    "network.loadinfo.skip_type_assertion": {
-      max: 60,
+    "dom.max_chrome_script_run_time": {
+      max: 20,
     },
     "toolkit.cosmeticAnimations.enabled": {
       min: 5,
       max: 20,
     },
   };
 
   Services.prefs.resetStats();
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2021,19 +2021,16 @@ ContentParent::LaunchSubprocess(ProcessP
   char idStr[21];
   SprintfLiteral(idStr, "%" PRId64, static_cast<uint64_t>(mChildID));
   extraArgs.push_back(idStr);
   extraArgs.push_back(IsForBrowser() ? "-isForBrowser" : "-notForBrowser");
 
   // Prefs information is passed via anonymous shared memory to avoid bloating
   // the command line.
 
-  size_t prefMapSize;
-  auto prefMapHandle = Preferences::EnsureSnapshot(&prefMapSize).ClonePlatformHandle();
-
   // Serialize the early prefs.
   nsAutoCStringN<1024> prefs;
   Preferences::SerializePreferences(prefs);
 
   // Set up the shared memory.
   base::SharedMemory shm;
   if (!shm.Create(prefs.Length())) {
     NS_ERROR("failed to create shared memory in the parent");
@@ -2044,50 +2041,38 @@ ContentParent::LaunchSubprocess(ProcessP
     NS_ERROR("failed to map shared memory in the parent");
     MarkAsDead();
     return false;
   }
 
   // Copy the serialized prefs into the shared memory.
   memcpy(static_cast<char*>(shm.memory()), prefs.get(), prefs.Length());
 
-  // Formats a pointer or pointer-sized-integer as a string suitable for passing
-  // in an arguments list.
-  auto formatPtrArg = [] (auto arg) {
-    return nsPrintfCString("%zu", uintptr_t(arg));
-  };
-
 #if defined(XP_WIN)
   // Record the handle as to-be-shared, and pass it via a command flag. This
   // works because Windows handles are system-wide.
   HANDLE prefsHandle = shm.handle();
   mSubprocess->AddHandleToShare(prefsHandle);
-  mSubprocess->AddHandleToShare(prefMapHandle.get());
   extraArgs.push_back("-prefsHandle");
-  extraArgs.push_back(formatPtrArg(prefsHandle).get());
-  extraArgs.push_back("-prefMapHandle");
-  extraArgs.push_back(formatPtrArg(prefMapHandle.get()).get());
+  extraArgs.push_back(
+    nsPrintfCString("%zu", reinterpret_cast<uintptr_t>(prefsHandle)).get());
 #else
   // In contrast, Unix fds are per-process. So remap the fd to a fixed one that
   // will be used in the child.
   // XXX: bug 1440207 is about improving how fixed fds are used.
   //
   // Note: on Android, AddFdToRemap() sets up the fd to be passed via a Parcel,
   // and the fixed fd isn't used. However, we still need to mark it for
   // remapping so it doesn't get closed in the child.
   mSubprocess->AddFdToRemap(shm.handle().fd, kPrefsFileDescriptor);
-  mSubprocess->AddFdToRemap(prefMapHandle.get(), kPrefMapFileDescriptor);
 #endif
 
-  // Pass the lengths via command line flags.
+  // Pass the length via a command flag.
   extraArgs.push_back("-prefsLen");
-  extraArgs.push_back(formatPtrArg(prefs.Length()).get());
-
-  extraArgs.push_back("-prefMapSize");
-  extraArgs.push_back(formatPtrArg(prefMapSize).get());
+  extraArgs.push_back(nsPrintfCString("%zu", uintptr_t(prefs.Length())).get());
 
   // Scheduler prefs need to be handled differently because the scheduler needs
   // to start up in the content process before the normal preferences service.
   nsCString schedulerPrefs = Scheduler::GetPrefs();
   extraArgs.push_back("-schedulerPrefs");
   extraArgs.push_back(schedulerPrefs.get());
 
   if (gSafeMode) {
@@ -2916,22 +2901,19 @@ ContentParent::Observe(nsISupports* aSub
       const char16_t* mPrefBranch;
       size_t mLen;
     };
     // These prefs are not useful in child processes.
     static const BlacklistEntry sContentPrefBranchBlacklist[] = {
       BLACKLIST_ENTRY(u"app.update.lastUpdateTime."),
       BLACKLIST_ENTRY(u"datareporting.policy."),
       BLACKLIST_ENTRY(u"browser.safebrowsing.provider."),
-      BLACKLIST_ENTRY(u"browser.shell."),
-      BLACKLIST_ENTRY(u"browser.slowstartup."),
       BLACKLIST_ENTRY(u"extensions.getAddons.cache."),
       BLACKLIST_ENTRY(u"media.gmp-manager."),
       BLACKLIST_ENTRY(u"media.gmp-gmpopenh264."),
-      BLACKLIST_ENTRY(u"privacy.sanitize."),
     };
 #undef BLACKLIST_ENTRY
 
     for (const auto& entry : sContentPrefBranchBlacklist) {
       if (NS_strncmp(entry.mPrefBranch, aData, entry.mLen) == 0) {
         return NS_OK;
       }
     }
--- a/dom/ipc/ContentProcess.cpp
+++ b/dom/ipc/ContentProcess.cpp
@@ -78,60 +78,37 @@ SetUpSandboxEnvironment()
   }
 
   SetTmpEnvironmentVariable(sandboxedContentTemp);
 }
 #endif
 
 #ifdef ANDROID
 static int gPrefsFd = -1;
-static int gPrefMapFd = -1;
 
 void
 SetPrefsFd(int aFd)
 {
   gPrefsFd = aFd;
 }
-
-void
-SetPrefMapFd(int aFd)
-{
-  gPrefMapFd = aFd;
-}
 #endif
 
 bool
 ContentProcess::Init(int aArgc, char* aArgv[])
 {
   Maybe<uint64_t> childID;
   Maybe<bool> isForBrowser;
   Maybe<base::SharedMemoryHandle> prefsHandle;
-  Maybe<FileDescriptor> prefMapHandle;
   Maybe<size_t> prefsLen;
-  Maybe<size_t> prefMapSize;
   Maybe<const char*> schedulerPrefs;
   Maybe<const char*> parentBuildID;
 #if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
   nsCOMPtr<nsIFile> profileDir;
 #endif
 
-  // Parses an arg containing a pointer-sized-integer.
-  auto parseUIntPtrArg = [] (char*& aArg) {
-    // ContentParent uses %zu to print a word-sized unsigned integer. So
-    // even though strtoull() returns a long long int, it will fit in a
-    // uintptr_t.
-    return uintptr_t(strtoull(aArg, &aArg, 10));
-  };
-
-#ifdef XP_WIN
-  auto parseHandleArg = [] (char*& aArg) {
-    return HANDLE(parseUIntPtrArg(aArg));
-  };
-#endif
-
   for (int i = 1; i < aArgc; i++) {
     if (!aArgv[i]) {
       continue;
     }
 
     if (strcmp(aArgv[i], "-appdir") == 0) {
       if (++i == aArgc) {
         return false;
@@ -155,53 +132,35 @@ ContentProcess::Init(int aArgc, char* aA
     } else if (strcmp(aArgv[i], "-notForBrowser") == 0) {
       isForBrowser = Some(false);
 
 #ifdef XP_WIN
     } else if (strcmp(aArgv[i], "-prefsHandle") == 0) {
       if (++i == aArgc) {
         return false;
       }
+      // ContentParent uses %zu to print a word-sized unsigned integer. So
+      // even though strtoull() returns a long long int, it will fit in a
+      // uintptr_t.
       char* str = aArgv[i];
-      prefsHandle = Some(parseHandleArg(str));
-      if (str[0] != '\0') {
-        return false;
-      }
-
-    } else if (strcmp(aArgv[i], "-prefMapHandle") == 0) {
-      if (++i == aArgc) {
-        return false;
-      }
-      char* str = aArgv[i];
-      // The FileDescriptor constructor will clone this handle when constructed,
-      // so store it in a UniquePlatformHandle to make sure the original gets
-      // closed.
-      FileDescriptor::UniquePlatformHandle handle(parseHandleArg(str));
-      prefMapHandle.emplace(handle.get());
+      prefsHandle = Some(reinterpret_cast<HANDLE>(strtoull(str, &str, 10)));
       if (str[0] != '\0') {
         return false;
       }
 #endif
 
     } else if (strcmp(aArgv[i], "-prefsLen") == 0) {
       if (++i == aArgc) {
         return false;
       }
+      // ContentParent uses %zu to print a word-sized unsigned integer. So
+      // even though strtoull() returns a long long int, it will fit in a
+      // uintptr_t.
       char* str = aArgv[i];
-      prefsLen = Some(parseUIntPtrArg(str));
-      if (str[0] != '\0') {
-        return false;
-      }
-
-    } else if (strcmp(aArgv[i], "-prefMapSize") == 0) {
-      if (++i == aArgc) {
-        return false;
-      }
-      char* str = aArgv[i];
-      prefMapSize = Some(parseUIntPtrArg(str));
+      prefsLen = Some(strtoull(str, &str, 10));
       if (str[0] != '\0') {
         return false;
       }
 
     } else if (strcmp(aArgv[i], "-schedulerPrefs") == 0) {
       if (++i == aArgc) {
         return false;
       }
@@ -230,46 +189,31 @@ ContentProcess::Init(int aArgc, char* aA
 #endif /* XP_MACOSX && MOZ_CONTENT_SANDBOX */
     }
   }
 
 #ifdef ANDROID
   // Android is different; get the FD via gPrefsFd instead of a fixed fd.
   MOZ_RELEASE_ASSERT(gPrefsFd != -1);
   prefsHandle = Some(base::FileDescriptor(gPrefsFd, /* auto_close */ true));
-
-  FileDescriptor::UniquePlatformHandle handle(gPrefMapFd);
-  prefMapHandle.emplace(handle.get());
 #elif XP_UNIX
   prefsHandle = Some(base::FileDescriptor(kPrefsFileDescriptor,
                                           /* auto_close */ true));
-
-  // The FileDescriptor constructor will clone this handle when constructed,
-  // so store it in a UniquePlatformHandle to make sure the original gets
-  // closed.
-  FileDescriptor::UniquePlatformHandle handle(kPrefMapFileDescriptor);
-  prefMapHandle.emplace(handle.get());
 #endif
 
   // Did we find all the mandatory flags?
   if (childID.isNothing() ||
       isForBrowser.isNothing() ||
       prefsHandle.isNothing() ||
       prefsLen.isNothing() ||
-      prefMapHandle.isNothing() ||
-      prefMapSize.isNothing() ||
       schedulerPrefs.isNothing() ||
       parentBuildID.isNothing()) {
     return false;
   }
 
-  // Init the shared-memory base preference mapping first, so that only changed
-  // preferences wind up in heap memory.
-  Preferences::InitSnapshot(prefMapHandle.ref(), *prefMapSize);
-
   // Set up early prefs from the shared memory.
   base::SharedMemory shm;
   if (!shm.SetHandle(*prefsHandle, /* read_only */ true)) {
     NS_ERROR("failed to open shared memory in the child");
     return false;
   }
   if (!shm.Map(*prefsLen)) {
     NS_ERROR("failed to map shared memory in the child");
--- a/dom/ipc/ContentProcess.h
+++ b/dom/ipc/ContentProcess.h
@@ -45,18 +45,16 @@ private:
   // This object initializes and configures COM.
   mozilla::mscom::MainThreadRuntime mCOMRuntime;
 #endif
 
   DISALLOW_EVIL_CONSTRUCTORS(ContentProcess);
 };
 
 #ifdef ANDROID
-// Android doesn't use -prefsHandle or -prefMapHandle. It gets those FDs
-// another way.
+// Android doesn't use -prefsHandle, it gets that FD another way.
 void SetPrefsFd(int aFd);
-void SetPrefMapFd(int aFd);
 #endif
 
 } // namespace dom
 } // namespace mozilla
 
 #endif  // ifndef dom_tabs_ContentThread_h
--- a/dom/ipc/MemMapSnapshot.h
+++ b/dom/ipc/MemMapSnapshot.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=4 et sw=4 tw=99: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef dom_ipc_MemMapSnapshot_h
 #define dom_ipc_MemMapSnapshot_h
 
-#include "mozilla/AutoMemMap.h"
+#include "AutoMemMap.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Result.h"
 #ifdef XP_WIN
 #  include "mozilla/ipc/FileDescriptor.h"
 #endif
 
--- a/dom/ipc/SharedStringMap.cpp
+++ b/dom/ipc/SharedStringMap.cpp
@@ -85,17 +85,18 @@ SharedStringMap::Find(const nsCString& a
                         },
                         aIndex);
 }
 
 
 void
 SharedStringMapBuilder::Add(const nsCString& aKey, const nsString& aValue)
 {
-  mEntries.Put(aKey, {mKeyTable.Add(aKey), mValueTable.Add(aValue)});
+  mEntries.Put(aKey, {{mKeyTable.Add(aKey), aKey.Length()},
+                      {mValueTable.Add(aValue), aValue.Length()}});
 }
 
 Result<Ok, nsresult>
 SharedStringMapBuilder::Finalize(loader::AutoMemMap& aMap)
 {
   using Header = SharedStringMap::Header;
 
   MOZ_ASSERT(mEntries.Count() == mKeyTable.Count());
--- a/dom/ipc/SharedStringMap.h
+++ b/dom/ipc/SharedStringMap.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef dom_ipc_SharedStringMap_h
 #define dom_ipc_SharedStringMap_h
 
 #include "mozilla/AutoMemMap.h"
 #include "mozilla/Result.h"
-#include "mozilla/dom/ipc/StringTable.h"
+#include "mozilla/TypeTraits.h"
 #include "nsDataHashtable.h"
 
 namespace mozilla {
 namespace dom {
 namespace ipc {
 
 class SharedStringMapBuilder;
 
@@ -71,24 +71,34 @@ public:
     // The raw byte offset of the beginning of the value string table, from the
     // start of the shared memory region, and its size in bytes (*not*
     // characters).
     size_t mValueStringsOffset;
     size_t mValueStringsSize;
   };
 
   /**
+   * Contains the character offset and character length of an entry in a string
+   * table. This may be used for either 8-bit or 16-bit strings, and is required
+   * to retrieve an entry from a string table.
+   */
+  struct StringEntry {
+    uint32_t mOffset;
+    uint32_t mLength;
+  };
+
+  /**
    * Describes a value in the string map, as offsets into the key and value
    * string tables.
    */
   struct Entry {
     // The offset and size of the entry's UTF-8 key in the key string table.
-    StringTableEntry mKey;
+    StringEntry mKey;
     // The offset and size of the entry's UTF-16 value in the value string table.
-    StringTableEntry mValue;
+    StringEntry mValue;
   };
 
   NS_INLINE_DECL_REFCOUNTING(SharedStringMap)
 
   // Note: These constructors are infallible on the premise that this class
   // is used primarily in cases where it is critical to platform
   // functionality.
   explicit SharedStringMap(const FileDescriptor&, size_t);
@@ -159,16 +169,45 @@ public:
   FileDescriptor CloneFileDescriptor() const;
 
   size_t MapSize() const { return mMap.size(); }
 
 protected:
   ~SharedStringMap() = default;
 
 private:
+  template <typename StringType>
+  class StringTable
+  {
+    using ElemType = decltype(DeclVal<StringType>()[0]);
+
+  public:
+    MOZ_IMPLICIT StringTable(const RangedPtr<uint8_t>& aBuffer)
+      : mBuffer(aBuffer.ReinterpretCast<ElemType>())
+    {
+      MOZ_ASSERT(uintptr_t(aBuffer.get()) % alignof(ElemType) == 0,
+                 "Got misalinged buffer");
+    }
+
+    StringType Get(const StringEntry& aEntry) const
+    {
+      StringType res;
+      res.AssignLiteral(GetBare(aEntry), aEntry.mLength);
+      return res;
+    }
+
+    const ElemType* GetBare(const StringEntry& aEntry) const
+    {
+      return &mBuffer[aEntry.mOffset];
+    }
+
+  private:
+    RangedPtr<ElemType> mBuffer;
+  };
+
 
   // Type-safe getters for values in the shared memory region:
   const Header& GetHeader() const
   {
     return mMap.get<Header>()[0];
   }
 
   RangedPtr<const Entry> Entries() const
@@ -218,16 +257,62 @@ public:
   /**
    * Finalizes the binary representation of the map, writes it to a shared
    * memory region, and then initializes the given AutoMemMap with a reference
    * to the read-only copy of it.
    */
   Result<Ok, nsresult> Finalize(loader::AutoMemMap& aMap);
 
 private:
+  template <typename KeyType, typename StringType>
+  class StringTableBuilder
+  {
+  public:
+    using ElemType = typename StringType::char_type;
+
+    uint32_t Add(const StringType& aKey)
+    {
+      auto entry = mEntries.LookupForAdd(aKey).OrInsert([&] () {
+        Entry newEntry { mSize, aKey };
+        mSize += aKey.Length() + 1;
+
+        return newEntry;
+      });
+
+      return entry.mOffset;
+    }
+
+    void Write(const RangedPtr<uint8_t>& aBuffer)
+    {
+      auto buffer = aBuffer.ReinterpretCast<ElemType>();
+
+      for (auto iter = mEntries.Iter(); !iter.Done(); iter.Next()) {
+        auto& entry = iter.Data();
+        memcpy(&buffer[entry.mOffset], entry.mValue.BeginReading(),
+               sizeof(ElemType) * (entry.mValue.Length() + 1));
+      }
+    }
+
+    uint32_t Count() const { return mEntries.Count(); }
+
+    uint32_t Size() const { return mSize * sizeof(ElemType); }
+
+    void Clear() { mEntries.Clear(); }
+
+  private:
+    struct Entry
+    {
+      uint32_t mOffset;
+      StringType mValue;
+    };
+
+    nsDataHashtable<KeyType, Entry> mEntries;
+    uint32_t mSize = 0;
+  };
+
   using Entry = SharedStringMap::Entry;
 
   StringTableBuilder<nsCStringHashKey, nsCString> mKeyTable;
   StringTableBuilder<nsStringHashKey, nsString> mValueTable;
 
   nsDataHashtable<nsCStringHashKey, Entry> mEntries;
 };
 
deleted file mode 100644
--- a/dom/ipc/StringTable.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=99: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef dom_ipc_StringTable_h
-#define dom_ipc_StringTable_h
-
-#include "mozilla/RangedPtr.h"
-#include "nsDataHashtable.h"
-
-/**
- * This file contains helper classes for creating and accessing compact string
- * tables, which can be used as the building blocks of shared memory databases.
- * Each string table a de-duplicated set of strings which can be referenced
- * using their character offsets within a data block and their lengths. The
- * string tables, once created, cannot be modified, and are primarily useful in
- * read-only shared memory or memory mapped files.
- */
-
-namespace mozilla {
-namespace dom {
-namespace ipc {
-
-/**
- * Contains the character offset and character length of an entry in a string
- * table. This may be used for either 8-bit or 16-bit strings, and is required
- * to retrieve an entry from a string table.
- */
-struct StringTableEntry
-{
-  uint32_t mOffset;
-  uint32_t mLength;
-
-  // Ignore mLength. It must be the same for any two strings with the same
-  // offset.
-  uint32_t Hash() const { return mOffset; }
-
-  bool operator==(const StringTableEntry& aOther) const
-  {
-    return mOffset == aOther.mOffset;
-  }
-};
-
-template <typename StringType>
-class StringTable
-{
-  using ElemType = typename StringType::char_type;
-
-public:
-  MOZ_IMPLICIT StringTable(const RangedPtr<uint8_t>& aBuffer)
-    : mBuffer(aBuffer.ReinterpretCast<ElemType>())
-  {
-    MOZ_ASSERT(uintptr_t(aBuffer.get()) % alignof(ElemType) == 0,
-               "Got misalinged buffer");
-  }
-
-  StringType Get(const StringTableEntry& aEntry) const
-  {
-    StringType res;
-    res.AssignLiteral(GetBare(aEntry), aEntry.mLength);
-    return res;
-  }
-
-  const ElemType* GetBare(const StringTableEntry& aEntry) const
-  {
-    return &mBuffer[aEntry.mOffset];
-  }
-
-private:
-  RangedPtr<ElemType> mBuffer;
-};
-
-template <typename KeyType, typename StringType>
-class StringTableBuilder
-{
-public:
-  using ElemType = typename StringType::char_type;
-
-  StringTableEntry Add(const StringType& aKey)
-  {
-    const auto& entry = mEntries.LookupForAdd(aKey).OrInsert([&] () {
-      Entry newEntry { mSize, aKey };
-      mSize += aKey.Length() + 1;
-
-      return newEntry;
-    });
-
-    return { entry.mOffset, aKey.Length() };
-  }
-
-  void Write(const RangedPtr<uint8_t>& aBuffer)
-  {
-    auto buffer = aBuffer.ReinterpretCast<ElemType>();
-
-    for (auto iter = mEntries.Iter(); !iter.Done(); iter.Next()) {
-      auto& entry = iter.Data();
-      memcpy(&buffer[entry.mOffset], entry.mValue.BeginReading(),
-             sizeof(ElemType) * (entry.mValue.Length() + 1));
-    }
-  }
-
-  uint32_t Count() const { return mEntries.Count(); }
-
-  uint32_t Size() const { return mSize * sizeof(ElemType); }
-
-  void Clear() { mEntries.Clear(); }
-
-  static constexpr size_t Alignment() { return alignof(ElemType); }
-
-private:
-  struct Entry
-  {
-    uint32_t mOffset;
-    StringType mValue;
-  };
-
-  nsDataHashtable<KeyType, Entry> mEntries;
-  uint32_t mSize = 0;
-};
-
-} // namespace ipc
-} // namespace dom
-} // namespace mozilla
-
-#endif
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -10,21 +10,19 @@ with Files("**"):
 XPIDL_SOURCES += [
     'nsIHangReport.idl',
 ]
 
 XPIDL_MODULE = 'dom'
 
 EXPORTS.mozilla.dom.ipc += [
     'IdType.h',
-    'MemMapSnapshot.h',
     'SharedMap.h',
     'SharedMapChangeEvent.h',
     'SharedStringMap.h',
-    'StringTable.h',
     'StructuredCloneData.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'CoalescedInputData.h',
     'CoalescedMouseData.h',
     'CoalescedWheelData.h',
     'ContentBridgeChild.h',
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -1253,27 +1253,26 @@ GeckoChildProcessHost::LaunchAndroidServ
   }
 
   // XXX: this processing depends entirely on the internals of
   // ContentParent::LaunchSubprocess()
   // GeckoChildProcessHost::PerformAsyncLaunchInternal(), and the order in
   // which they append to fds_to_remap. There must be a better way to do it.
   // See bug 1440207.
   int32_t prefsFd = fds_to_remap[0].first;
-  int32_t prefMapFd = fds_to_remap[1].first;
-  int32_t ipcFd = fds_to_remap[2].first;
+  int32_t ipcFd = fds_to_remap[1].first;
   int32_t crashFd = -1;
   int32_t crashAnnotationFd = -1;
+  if (fds_to_remap.size() == 3) {
+    crashAnnotationFd = fds_to_remap[2].first;
+  }
   if (fds_to_remap.size() == 4) {
+    crashFd = fds_to_remap[2].first;
     crashAnnotationFd = fds_to_remap[3].first;
   }
-  if (fds_to_remap.size() == 5) {
-    crashFd = fds_to_remap[3].first;
-    crashAnnotationFd = fds_to_remap[4].first;
-  }
 
-  int32_t handle = java::GeckoProcessManager::Start(type, jargs, prefsFd, prefMapFd, ipcFd, crashFd, crashAnnotationFd);
+  int32_t handle = java::GeckoProcessManager::Start(type, jargs, prefsFd, ipcFd, crashFd, crashAnnotationFd);
 
   if (process_handle) {
     *process_handle = handle;
   }
 }
 #endif
--- a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/process/IChildProcess.aidl
+++ b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/process/IChildProcess.aidl
@@ -7,15 +7,14 @@ package org.mozilla.gecko.process;
 import org.mozilla.gecko.process.IProcessManager;
 
 import android.os.Bundle;
 import android.os.ParcelFileDescriptor;
 
 interface IChildProcess {
     int getPid();
     boolean start(in IProcessManager procMan, in String[] args, in Bundle extras, int flags,
-                  in ParcelFileDescriptor prefsPfd, in ParcelFileDescriptor prefMapPfd,
-                  in ParcelFileDescriptor ipcPfd,
+                  in ParcelFileDescriptor prefsPfd, in ParcelFileDescriptor ipcPfd,
                   in ParcelFileDescriptor crashReporterPfd,
                   in ParcelFileDescriptor crashAnnotationPfd);
 
     void crash();
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoThread.java
@@ -127,17 +127,16 @@ public class GeckoThread extends Thread 
     // Main process parameters
     public static final int FLAG_DEBUGGING = 1 << 0; // Debugging mode.
     public static final int FLAG_PRELOAD_CHILD = 1 << 1; // Preload child during main thread start.
     public static final int FLAG_ENABLE_NATIVE_CRASHREPORTER = 1 << 2; // Enable native crash reporting
     public static final int FLAG_ENABLE_JAVA_CRASHREPORTER = 1 << 3; // Enable java crash reporting
 
     /* package */ static final String EXTRA_ARGS = "args";
     private static final String EXTRA_PREFS_FD = "prefsFd";
-    private static final String EXTRA_PREF_MAP_FD = "prefMapFd";
     private static final String EXTRA_IPC_FD = "ipcFd";
     private static final String EXTRA_CRASH_FD = "crashFd";
     private static final String EXTRA_CRASH_ANNOTATION_FD = "crashAnnotationFd";
 
     private boolean mInitialized;
     private GeckoProfile mProfile;
     private String[] mArgs;
     private Bundle mExtras;
@@ -149,60 +148,56 @@ public class GeckoThread extends Thread 
 
     @WrapForJNI
     private static boolean isChildProcess() {
         return INSTANCE.mExtras.getInt(EXTRA_IPC_FD, -1) != -1;
     }
 
     private synchronized boolean init(final GeckoProfile profile, final String[] args,
                                       final Bundle extras, final int flags,
-                                      final int prefsFd, final int prefMapFd,
-                                      final int ipcFd,
+                                      final int prefsFd, final int ipcFd,
                                       final int crashFd,
                                       final int crashAnnotationFd) {
         ThreadUtils.assertOnUiThread();
         uiThreadId = android.os.Process.myTid();
 
         if (mInitialized) {
             return false;
         }
 
         mProfile = profile;
         mArgs = args;
         mFlags = flags;
 
         mExtras = (extras != null) ? new Bundle(extras) : new Bundle(3);
         mExtras.putInt(EXTRA_PREFS_FD, prefsFd);
-        mExtras.putInt(EXTRA_PREF_MAP_FD, prefMapFd);
         mExtras.putInt(EXTRA_IPC_FD, ipcFd);
         mExtras.putInt(EXTRA_CRASH_FD, crashFd);
         mExtras.putInt(EXTRA_CRASH_ANNOTATION_FD, crashAnnotationFd);
 
         mInitialized = true;
         notifyAll();
         return true;
     }
 
     public static boolean initMainProcess(final GeckoProfile profile, final String[] args,
                                           final Bundle extras, final int flags) {
         return INSTANCE.init(profile, args, extras, flags, /* fd */ -1,
-                             /* fd */ -1, /* fd */ -1, /* fd */ -1,
-                             /* fd */ -1);
+                             /* fd */ -1, /* fd */ -1, /* fd */ -1);
     }
 
     public static boolean initChildProcess(final String[] args,
                                            final Bundle extras,
                                            final int flags,
                                            final int prefsFd,
-                                           final int prefMapFd,
                                            final int ipcFd,
                                            final int crashFd,
                                            final int crashAnnotationFd) {
         return INSTANCE.init(/* profile */ null, args, extras, flags,
-                             prefsFd, prefMapFd, ipcFd, crashFd, crashAnnotationFd);
+                             prefsFd, ipcFd, crashFd, crashAnnotationFd);
     }
 
     private static boolean canUseProfile(final Context context, final GeckoProfile profile,
                                          final String profileName, final File profileDir) {
         if (profileDir != null && !profileDir.isDirectory()) {
             return false;
         }
 
@@ -497,17 +492,16 @@ public class GeckoThread extends Thread 
             GeckoAppShell.ensureCrashHandling();
         }
 
         GeckoLoader.setupGeckoEnvironment(context, context.getFilesDir().getPath(), env);
 
         // And go.
         GeckoLoader.nativeRun(args,
                               mExtras.getInt(EXTRA_PREFS_FD, -1),
-                              mExtras.getInt(EXTRA_PREF_MAP_FD, -1),
                               mExtras.getInt(EXTRA_IPC_FD, -1),
                               mExtras.getInt(EXTRA_CRASH_FD, -1),
                               mExtras.getInt(EXTRA_CRASH_ANNOTATION_FD, -1));
 
         // And... we're done.
         final boolean restarting = isState(State.RESTARTING);
         setState(State.EXITED);
 
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
@@ -451,15 +451,15 @@ public final class GeckoLoader {
         }
     }
 
     // These methods are implemented in mozglue/android/nsGeckoUtils.cpp
     private static native void putenv(String map);
     public static native boolean verifyCRCs(String apkName);
 
     // These methods are implemented in mozglue/android/APKOpen.cpp
-    public static native void nativeRun(String[] args, int prefsFd, int prefMapFd, int ipcFd, int crashFd, int crashAnnotationFd);
+    public static native void nativeRun(String[] args, int prefsFd, int ipcFd, int crashFd, int crashAnnotationFd);
     private static native void loadGeckoLibsNative(String apkName);
     private static native void loadSQLiteLibsNative(String apkName);
     private static native void loadNSSLibsNative(String apkName);
     public static native boolean neonCompatible();
     public static native void suppressCrashDialog();
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoProcessManager.java
@@ -177,71 +177,67 @@ public final class GeckoProcessManager e
         try {
             mConnections.get("tab").bind().crash();
         } catch (RemoteException e) {
         }
     }
 
     @WrapForJNI
     private static int start(final String type, final String[] args,
-                             final int prefsFd, final int prefMapFd,
-                             final int ipcFd,
+                             final int prefsFd, final int ipcFd,
                              final int crashFd, final int crashAnnotationFd) {
-        return INSTANCE.start(type, args, prefsFd, prefMapFd, ipcFd, crashFd, crashAnnotationFd, /* retry */ false);
+        return INSTANCE.start(type, args, prefsFd, ipcFd, crashFd, crashAnnotationFd, /* retry */ false);
     }
 
     private int filterFlagsForChild(int flags) {
         return flags & (GeckoThread.FLAG_ENABLE_JAVA_CRASHREPORTER |
                 GeckoThread.FLAG_ENABLE_NATIVE_CRASHREPORTER);
     }
 
-    private int start(final String type, final String[] args,
-                      final int prefsFd, final int prefMapFd,
+    private int start(final String type, final String[] args, final int prefsFd,
                       final int ipcFd, final int crashFd,
                       final int crashAnnotationFd, final boolean retry) {
         final ChildConnection connection = getConnection(type);
         final IChildProcess child = connection.bind();
         if (child == null) {
             return 0;
         }
 
         final Bundle extras = GeckoThread.getActiveExtras();
         final ParcelFileDescriptor prefsPfd;
-        final ParcelFileDescriptor prefMapPfd;
         final ParcelFileDescriptor ipcPfd;
         final ParcelFileDescriptor crashPfd;
         final ParcelFileDescriptor crashAnnotationPfd;
         try {
             prefsPfd = ParcelFileDescriptor.fromFd(prefsFd);
-            prefMapPfd = ParcelFileDescriptor.fromFd(prefMapFd);
             ipcPfd = ParcelFileDescriptor.fromFd(ipcFd);
             crashPfd = (crashFd >= 0) ? ParcelFileDescriptor.fromFd(crashFd) : null;
             crashAnnotationPfd = (crashAnnotationFd >= 0) ? ParcelFileDescriptor.fromFd(crashAnnotationFd) : null;
         } catch (final IOException e) {
             Log.e(LOGTAG, "Cannot create fd for " + type, e);
             return 0;
         }
 
         final int flags = filterFlagsForChild(GeckoThread.getActiveFlags());
 
         boolean started = false;
         try {
-            started = child.start(this, args, extras, flags, prefsPfd, prefMapPfd,
-                                  ipcPfd, crashPfd, crashAnnotationPfd);
+            started = child.start(this, args, extras, flags, prefsPfd, ipcPfd, crashPfd,
+                                  crashAnnotationPfd);
         } catch (final RemoteException e) {
         }
 
         if (!started) {
             if (retry) {
                 Log.e(LOGTAG, "Cannot restart child " + type);
                 return 0;
             }
             Log.w(LOGTAG, "Attempting to kill running child " + type);
             connection.unbind();
-            return start(type, args, prefsFd, prefMapFd, ipcFd, crashFd, crashAnnotationFd, /* retry */ true);
+            return start(type, args, prefsFd, ipcFd, crashFd, crashAnnotationFd, /* retry */ true);
         }
 
         try {
             if (crashAnnotationPfd != null) {
                 crashAnnotationPfd.close();
             }
             if (crashPfd != null) {
                 crashPfd.close();
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoServiceChildProcess.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/process/GeckoServiceChildProcess.java
@@ -57,41 +57,39 @@ public class GeckoServiceChildProcess ex
         }
 
         @Override
         public boolean start(final IProcessManager procMan,
                              final String[] args,
                              final Bundle extras,
                              final int flags,
                              final ParcelFileDescriptor prefsPfd,
-                             final ParcelFileDescriptor prefMapPfd,
                              final ParcelFileDescriptor ipcPfd,
                              final ParcelFileDescriptor crashReporterPfd,
                              final ParcelFileDescriptor crashAnnotationPfd) {
             synchronized (GeckoServiceChildProcess.class) {
                 if (sProcessManager != null) {
                     Log.e(LOGTAG, "Child process already started");
                     return false;
                 }
                 sProcessManager = procMan;
             }
 
             final int prefsFd = prefsPfd.detachFd();
-            final int prefMapFd = prefMapPfd.detachFd();
             final int ipcFd = ipcPfd.detachFd();
             final int crashReporterFd = crashReporterPfd != null ?
                                         crashReporterPfd.detachFd() : -1;
             final int crashAnnotationFd = crashAnnotationPfd != null ?
                                           crashAnnotationPfd.detachFd() : -1;
 
             ThreadUtils.postToUiThread(new Runnable() {
                 @Override
                 public void run() {
-                    if (GeckoThread.initChildProcess(args, extras, flags, prefsFd, prefMapFd, ipcFd,
-                                                     crashReporterFd, crashAnnotationFd)) {
+                    if (GeckoThread.initChildProcess(args, extras, flags, prefsFd, ipcFd, crashReporterFd,
+                                                     crashAnnotationFd)) {
                         GeckoThread.launch();
                     }
                 }
             });
             return true;
         }
 
         @Override
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -3,18 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "SharedPrefMap.h"
-
 #include "base/basictypes.h"
 #include "GeckoProfiler.h"
 #include "MainThreadUtils.h"
 #include "mozilla/ArenaAllocatorExtensions.h"
 #include "mozilla/ArenaAllocator.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/PContent.h"
@@ -90,18 +88,16 @@
 #endif
 
 #ifdef XP_WIN
 #include "windows.h"
 #endif
 
 using namespace mozilla;
 
-using mozilla::ipc::FileDescriptor;
-
 #ifdef DEBUG
 
 #define ENSURE_PARENT_PROCESS(func, pref)                                      \
   do {                                                                         \
     if (MOZ_UNLIKELY(!XRE_IsParentProcess())) {                                \
       nsPrintfCString msg(                                                     \
         "ENSURE_PARENT_PROCESS: called %s on %s in a non-parent process",      \
         func,                                                                  \
@@ -126,16 +122,25 @@ using mozilla::ipc::FileDescriptor;
 
 typedef nsTArray<nsCString> PrefSaveData;
 
 // 1 MB should be enough for everyone.
 static const uint32_t MAX_PREF_LENGTH = 1 * 1024 * 1024;
 // Actually, 4kb should be enough for everyone.
 static const uint32_t MAX_ADVISABLE_PREF_LENGTH = 4 * 1024;
 
+// Keep this in sync with PrefType in parser/src/lib.rs.
+enum class PrefType : uint8_t
+{
+  None = 0, // only used when neither the default nor user value is set
+  String = 1,
+  Int = 2,
+  Bool = 3,
+};
+
 // This is used for pref names and string pref values. We encode the string
 // length, then a '/', then the string chars. This encoding means there are no
 // special chars that are forbidden or require escaping.
 static void
 SerializeAndAppendString(const char* aChars, nsCString& aStr)
 {
   aStr.AppendInt(uint32_t(strlen(aChars)));
   aStr.Append('/');
@@ -155,33 +160,16 @@ DeserializeString(char* aChars, nsCStrin
 }
 
 // Keep this in sync with PrefValue in prefs_parser/src/lib.rs.
 union PrefValue {
   const char* mStringVal;
   int32_t mIntVal;
   bool mBoolVal;
 
-  PrefValue() = default;
-
-  explicit PrefValue(bool aVal)
-    : mBoolVal(aVal)
-  {
-  }
-
-  explicit PrefValue(int32_t aVal)
-    : mIntVal(aVal)
-  {
-  }
-
-  explicit PrefValue(const char* aVal)
-    : mStringVal(aVal)
-  {
-  }
-
   bool Equals(PrefType aType, PrefValue aValue)
   {
     switch (aType) {
       case PrefType::String: {
         if (mStringVal && aValue.mStringVal) {
           return strcmp(mStringVal, aValue.mStringVal) == 0;
         }
         if (!mStringVal && !aValue.mStringVal) {
@@ -196,19 +184,16 @@ union PrefValue {
       case PrefType::Bool:
         return mBoolVal == aValue.mBoolVal;
 
       default:
         MOZ_CRASH("Unhandled enum value");
     }
   }
 
-  template<typename T>
-  T Get() const;
-
   void Init(PrefType aNewType, PrefValue aNewValue)
   {
     if (aNewType == PrefType::String) {
       MOZ_ASSERT(aNewValue.mStringVal);
       aNewValue.mStringVal = moz_xstrdup(aNewValue.mStringVal);
     }
     *this = aNewValue;
   }
@@ -328,37 +313,16 @@ union PrefValue {
       }
 
       default:
         MOZ_CRASH();
     }
   }
 };
 
-template<>
-bool
-PrefValue::Get() const
-{
-  return mBoolVal;
-}
-
-template<>
-int32_t
-PrefValue::Get() const
-{
-  return mIntVal;
-}
-
-template<>
-nsDependentCString
-PrefValue::Get() const
-{
-  return nsDependentCString(mStringVal);
-}
-
 #ifdef DEBUG
 const char*
 PrefTypeToString(PrefType aType)
 {
   switch (aType) {
     case PrefType::None:
       return "none";
     case PrefType::String:
@@ -447,138 +411,162 @@ struct PrefsSizes
   size_t mRootBranches;
   size_t mPrefNameArena;
   size_t mCallbacksObjects;
   size_t mCallbacksDomains;
   size_t mMisc;
 };
 }
 
-static StaticRefPtr<SharedPrefMap> gSharedMap;
-
-static ArenaAllocator<4096, 1> gPrefNameArena;
-
-class PrefWrapper;
+static ArenaAllocator<8192, 1> gPrefNameArena;
 
 class Pref
 {
 public:
   explicit Pref(const char* aName)
     : mName(ArenaStrdup(aName, gPrefNameArena))
     , mType(static_cast<uint32_t>(PrefType::None))
     , mIsSticky(false)
     , mIsLocked(false)
     , mHasDefaultValue(false)
     , mHasUserValue(false)
+    , mHasChangedSinceInit(false)
     , mDefaultValue()
     , mUserValue()
   {
   }
 
   ~Pref()
   {
     // There's no need to free mName because it's allocated in memory owned by
     // gPrefNameArena.
 
     mDefaultValue.Clear(Type());
     mUserValue.Clear(Type());
   }
 
-  const char* Name() const { return mName; }
-  nsDependentCString NameString() const { return nsDependentCString(mName); }
+  const char* Name() { return mName; }
 
   // Types.
 
   PrefType Type() const { return static_cast<PrefType>(mType); }
   void SetType(PrefType aType) { mType = static_cast<uint32_t>(aType); }
 
   bool IsType(PrefType aType) const { return Type() == aType; }
   bool IsTypeNone() const { return IsType(PrefType::None); }
   bool IsTypeString() const { return IsType(PrefType::String); }
   bool IsTypeInt() const { return IsType(PrefType::Int); }
   bool IsTypeBool() const { return IsType(PrefType::Bool); }
 
   // Other properties.
 
   bool IsLocked() const { return mIsLocked; }
-  void SetIsLocked(bool aValue) { mIsLocked = aValue; }
-
-  bool IsSticky() const { return mIsSticky; }
+  void SetIsLocked(bool aValue)
+  {
+    mIsLocked = aValue;
+    mHasChangedSinceInit = true;
+  }
 
   bool HasDefaultValue() const { return mHasDefaultValue; }
   bool HasUserValue() const { return mHasUserValue; }
 
-  template<typename T>
-  void AddToMap(SharedPrefMapBuilder& aMap)
+  // When a content process is created we could tell it about every pref. But
+  // the content process also initializes prefs from file, so we save a lot of
+  // IPC if we only tell it about prefs that have changed since initialization.
+  //
+  // Specifically, we send a pref if any of the following conditions are met.
+  //
+  // - If the pref has changed in any way (default value, user value, or other
+  //   attribute, such as whether it is locked) since being initialized from
+  //   file.
+  //
+  // - If the pref has a user value. (User values are more complicated than
+  //   default values, because they can be loaded from file after
+  //   initialization with Preferences::ReadUserPrefsFromFile(), so we are
+  //   conservative with them.)
+  //
+  // In other words, prefs that only have a default value and haven't changed
+  // need not be sent. One could do better with effort, but it's ok to be
+  // conservative and this still greatly reduces the number of prefs sent.
+  //
+  // Note: This function is only useful in the parent process.
+  bool MustSendToContentProcesses() const
   {
-    aMap.Add(Name(),
-             { HasDefaultValue(), HasUserValue(), IsSticky(), IsLocked() },
-             HasDefaultValue() ? mDefaultValue.Get<T>() : T(),
-             HasUserValue() ? mUserValue.Get<T>() : T());
-  }
-
-  void AddToMap(SharedPrefMapBuilder& aMap)
-  {
-    if (IsTypeBool()) {
-      AddToMap<bool>(aMap);
-    } else if (IsTypeInt()) {
-      AddToMap<int32_t>(aMap);
-    } else if (IsTypeString()) {
-      AddToMap<nsDependentCString>(aMap);
-    } else {
-      MOZ_ASSERT_UNREACHABLE("Unexpected preference type");
-    }
+    MOZ_ASSERT(XRE_IsParentProcess());
+    return mHasUserValue || mHasChangedSinceInit;
   }
 
   // Other operations.
 
   bool MatchEntry(const char* aPrefName)
   {
     if (!mName || !aPrefName) {
       return false;
     }
 
     return strcmp(mName, aPrefName) == 0;
   }
 
-  bool GetBoolValue(PrefValueKind aKind = PrefValueKind::User) const
+  nsresult GetBoolValue(PrefValueKind aKind, bool* aResult)
   {
-    MOZ_ASSERT(IsTypeBool());
-    MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                               : HasUserValue());
-
-    return aKind == PrefValueKind::Default ? mDefaultValue.mBoolVal
-                                           : mUserValue.mBoolVal;
-  }
-
-  int32_t GetIntValue(PrefValueKind aKind = PrefValueKind::User) const
+    if (!IsTypeBool()) {
+      return NS_ERROR_UNEXPECTED;
+    }
+
+    if (aKind == PrefValueKind::Default || IsLocked() || !mHasUserValue) {
+      // Do we have a default?
+      if (!mHasDefaultValue) {
+        return NS_ERROR_UNEXPECTED;
+      }
+      *aResult = mDefaultValue.mBoolVal;
+    } else {
+      *aResult = mUserValue.mBoolVal;
+    }
+
+    return NS_OK;
+  }
+
+  nsresult GetIntValue(PrefValueKind aKind, int32_t* aResult)
   {
-    MOZ_ASSERT(IsTypeInt());
-    MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                               : HasUserValue());
-
-    return aKind == PrefValueKind::Default ? mDefaultValue.mIntVal
-                                           : mUserValue.mIntVal;
-  }
-
-  const char* GetBareStringValue(
-    PrefValueKind aKind = PrefValueKind::User) const
+    if (!IsTypeInt()) {
+      return NS_ERROR_UNEXPECTED;
+    }
+
+    if (aKind == PrefValueKind::Default || IsLocked() || !mHasUserValue) {
+      // Do we have a default?
+      if (!mHasDefaultValue) {
+        return NS_ERROR_UNEXPECTED;
+      }
+      *aResult = mDefaultValue.mIntVal;
+    } else {
+      *aResult = mUserValue.mIntVal;
+    }
+
+    return NS_OK;
+  }
+
+  nsresult GetCStringValue(PrefValueKind aKind, nsACString& aResult)
   {
-    MOZ_ASSERT(IsTypeString());
-    MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                               : HasUserValue());
-
-    return aKind == PrefValueKind::Default ? mDefaultValue.mStringVal
-                                           : mUserValue.mStringVal;
-  }
-
-  nsDependentCString GetStringValue(
-    PrefValueKind aKind = PrefValueKind::User) const
-  {
-    return nsDependentCString(GetBareStringValue(aKind));
+    if (!IsTypeString()) {
+      return NS_ERROR_UNEXPECTED;
+    }
+
+    if (aKind == PrefValueKind::Default || IsLocked() || !mHasUserValue) {
+      // Do we have a default?
+      if (!mHasDefaultValue) {
+        return NS_ERROR_UNEXPECTED;
+      }
+      MOZ_ASSERT(mDefaultValue.mStringVal);
+      aResult = mDefaultValue.mStringVal;
+    } else {
+      MOZ_ASSERT(mUserValue.mStringVal);
+      aResult = mUserValue.mStringVal;
+    }
+
+    return NS_OK;
   }
 
   void ToDomPref(dom::Pref* aDomPref)
   {
     MOZ_ASSERT(XRE_IsParentProcess());
 
     aDomPref->name() = mName;
 
@@ -640,23 +628,23 @@ public:
         mHasUserValue = true;
         userValueChanged = true;
       }
     } else if (mHasUserValue) {
       ClearUserValue();
       userValueChanged = true;
     }
 
+    mHasChangedSinceInit = true;
+
     if (userValueChanged || (defaultValueChanged && !mHasUserValue)) {
       *aValueChanged = true;
     }
   }
 
-  void FromWrapper(PrefWrapper& aWrapper);
-
   bool HasAdvisablySizedValues()
   {
     MOZ_ASSERT(XRE_IsParentProcess());
 
     if (!IsTypeString()) {
       return true;
     }
 
@@ -687,38 +675,43 @@ private:
               : mHasUserValue && mUserValue.Equals(aType, aValue));
   }
 
 public:
   void ClearUserValue()
   {
     mUserValue.Clear(Type());
     mHasUserValue = false;
+    mHasChangedSinceInit = true;
   }
 
   nsresult SetDefaultValue(PrefType aType,
                            PrefValue aValue,
                            bool aIsSticky,
                            bool aIsLocked,
+                           bool aFromInit,
                            bool* aValueChanged)
   {
     // Types must always match when setting the default value.
     if (!IsType(aType)) {
       return NS_ERROR_UNEXPECTED;
     }
 
     // Should we set the default value? Only if the pref is not locked, and
     // doing so would change the default value.
     if (!IsLocked()) {
       if (aIsLocked) {
         SetIsLocked(true);
       }
       if (!ValueMatches(PrefValueKind::Default, aType, aValue)) {
         mDefaultValue.Replace(mHasDefaultValue, Type(), aType, aValue);
         mHasDefaultValue = true;
+        if (!aFromInit) {
+          mHasChangedSinceInit = true;
+        }
         if (aIsSticky) {
           mIsSticky = true;
         }
         if (!mHasUserValue) {
           *aValueChanged = true;
         }
         // What if we change the default to be the same as the user value?
         // Should we clear the user value? Currently we don't.
@@ -751,23 +744,50 @@ public:
       }
 
       // Otherwise, should we set the user value? Only if doing so would
       // change the user value.
     } else if (!ValueMatches(PrefValueKind::User, aType, aValue)) {
       mUserValue.Replace(mHasUserValue, Type(), aType, aValue);
       SetType(aType); // needed because we may have changed the type
       mHasUserValue = true;
+      if (!aFromInit) {
+        mHasChangedSinceInit = true;
+      }
       if (!IsLocked()) {
         *aValueChanged = true;
       }
     }
     return NS_OK;
   }
 
+  // Returns false if this pref doesn't have a user value worth saving.
+  bool UserValueToStringForSaving(nsCString& aStr)
+  {
+    // Should we save the user value, if present? Only if it does not match the
+    // default value, or it is sticky.
+    if (mHasUserValue &&
+        (!ValueMatches(PrefValueKind::Default, Type(), mUserValue) ||
+         mIsSticky)) {
+      if (IsTypeString()) {
+        StrEscape(mUserValue.mStringVal, aStr);
+
+      } else if (IsTypeInt()) {
+        aStr.AppendInt(mUserValue.mIntVal);
+
+      } else if (IsTypeBool()) {
+        aStr = mUserValue.mBoolVal ? "true" : "false";
+      }
+      return true;
+    }
+
+    // Do not save default prefs that haven't changed.
+    return false;
+  }
+
   // Prefs are serialized in a manner that mirrors dom::Pref. The two should be
   // kept in sync. E.g. if something is added to one it should also be added to
   // the other. (It would be nice to be able to use the code generated from
   // IPDL for serializing dom::Pref here instead of writing by hand this
   // serialization/deserialization. Unfortunately, that generated code is
   // difficult to use directly, outside of the IPDL IPC code.)
   //
   // The grammar for the serialized prefs has the following form.
@@ -933,256 +953,59 @@ public:
 private:
   const char* mName; // allocated in gPrefNameArena
 
   uint32_t mType : 2;
   uint32_t mIsSticky : 1;
   uint32_t mIsLocked : 1;
   uint32_t mHasDefaultValue : 1;
   uint32_t mHasUserValue : 1;
+  uint32_t mHasChangedSinceInit : 1;
 
   PrefValue mDefaultValue;
   PrefValue mUserValue;
 };
 
 class PrefEntry : public PLDHashEntryHdr
 {
 public:
+#ifdef DEBUG
+  // This field is before mPref to minimize sizeof(PrefEntry) on 64-bit.
+  uint32_t mAccessCount;
+#endif
   Pref* mPref; // Note: this is never null in a live entry.
 
   static bool MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
   {
     auto entry = static_cast<const PrefEntry*>(aEntry);
     auto prefName = static_cast<const char*>(aKey);
 
     return entry->mPref->MatchEntry(prefName);
   }
 
   static void InitEntry(PLDHashEntryHdr* aEntry, const void* aKey)
   {
     auto entry = static_cast<PrefEntry*>(aEntry);
     auto prefName = static_cast<const char*>(aKey);
 
+#ifdef DEBUG
+    entry->mAccessCount = 0;
+#endif
     entry->mPref = new Pref(prefName);
   }
 
   static void ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
   {
     auto entry = static_cast<PrefEntry*>(aEntry);
 
     delete entry->mPref;
     entry->mPref = nullptr;
   }
 };
 
-using PrefWrapperBase = Variant<Pref*, SharedPrefMap::Pref>;
-class MOZ_STACK_CLASS PrefWrapper : public PrefWrapperBase
-{
-  using SharedPref = const SharedPrefMap::Pref;
-
-public:
-  MOZ_IMPLICIT PrefWrapper(Pref* aPref)
-    : PrefWrapperBase(AsVariant(aPref))
-  {
-  }
-
-  MOZ_IMPLICIT PrefWrapper(const SharedPrefMap::Pref& aPref)
-    : PrefWrapperBase(AsVariant(aPref))
-  {
-  }
-
-  // Types.
-
-  bool IsType(PrefType aType) const { return Type() == aType; }
-  bool IsTypeNone() const { return IsType(PrefType::None); }
-  bool IsTypeString() const { return IsType(PrefType::String); }
-  bool IsTypeInt() const { return IsType(PrefType::Int); }
-  bool IsTypeBool() const { return IsType(PrefType::Bool); }
-
-#define FORWARD(retType, method)                                               \
-  retType method() const                                                       \
-  {                                                                            \
-    struct Matcher                                                             \
-    {                                                                          \
-      retType match(const Pref* aPref) { return aPref->method(); }             \
-      retType match(SharedPref& aPref) { return aPref.method(); }              \
-    };                                                                         \
-    return match(Matcher());                                                   \
-  }
-
-  FORWARD(bool, IsLocked)
-  FORWARD(bool, IsSticky)
-  FORWARD(bool, HasDefaultValue)
-  FORWARD(bool, HasUserValue)
-  FORWARD(const char*, Name)
-  FORWARD(nsCString, NameString)
-  FORWARD(PrefType, Type)
-#undef FORWARD
-
-#define FORWARD(retType, method)                                               \
-  retType method(PrefValueKind aKind = PrefValueKind::User) const              \
-  {                                                                            \
-    struct Matcher                                                             \
-    {                                                                          \
-      PrefValueKind mKind;                                                     \
-                                                                               \
-      retType match(const Pref* aPref) { return aPref->method(mKind); }        \
-      retType match(SharedPref& aPref) { return aPref.method(mKind); }         \
-    };                                                                         \
-    return match(Matcher{ aKind });                                            \
-  }
-
-  FORWARD(bool, GetBoolValue)
-  FORWARD(int32_t, GetIntValue)
-  FORWARD(nsCString, GetStringValue)
-  FORWARD(const char*, GetBareStringValue)
-#undef FORWARD
-
-  PrefValue GetValue(PrefValueKind aKind = PrefValueKind::User) const
-  {
-    switch (Type()) {
-      case PrefType::Bool:
-        return PrefValue{ GetBoolValue(aKind) };
-      case PrefType::Int:
-        return PrefValue{ GetIntValue(aKind) };
-      case PrefType::String:
-        return PrefValue{ GetBareStringValue(aKind) };
-      default:
-        MOZ_ASSERT_UNREACHABLE("Unexpected pref type");
-        return PrefValue{};
-    }
-  }
-
-  Result<PrefValueKind, nsresult> WantValueKind(PrefType aType,
-                                                PrefValueKind aKind) const
-  {
-    if (Type() != aType) {
-      return Err(NS_ERROR_UNEXPECTED);
-    }
-
-    if (aKind == PrefValueKind::Default || IsLocked() || !HasUserValue()) {
-      if (!HasDefaultValue()) {
-        return Err(NS_ERROR_UNEXPECTED);
-      }
-      return PrefValueKind::Default;
-    }
-    return PrefValueKind::User;
-  }
-
-  nsresult GetBoolValue(PrefValueKind aKind, bool* aResult) const
-  {
-    PrefValueKind kind;
-    MOZ_TRY_VAR(kind, WantValueKind(PrefType::Bool, aKind));
-
-    *aResult = GetBoolValue(kind);
-    return NS_OK;
-  }
-
-  nsresult GetIntValue(PrefValueKind aKind, int32_t* aResult) const
-  {
-    PrefValueKind kind;
-    MOZ_TRY_VAR(kind, WantValueKind(PrefType::Int, aKind));
-
-    *aResult = GetIntValue(kind);
-    return NS_OK;
-  }
-
-  nsresult GetCStringValue(PrefValueKind aKind, nsACString& aResult) const
-  {
-    PrefValueKind kind;
-    MOZ_TRY_VAR(kind, WantValueKind(PrefType::String, aKind));
-
-    aResult = GetStringValue(kind);
-    return NS_OK;
-  }
-
-  // Returns false if this pref doesn't have a user value worth saving.
-  bool UserValueToStringForSaving(nsCString& aStr)
-  {
-    // Should we save the user value, if present? Only if it does not match the
-    // default value, or it is sticky.
-    if (HasUserValue() &&
-        (!ValueMatches(PrefValueKind::Default, Type(), GetValue()) ||
-         IsSticky())) {
-      if (IsTypeString()) {
-        StrEscape(GetStringValue().get(), aStr);
-
-      } else if (IsTypeInt()) {
-        aStr.AppendInt(GetIntValue());
-
-      } else if (IsTypeBool()) {
-        aStr = GetBoolValue() ? "true" : "false";
-      }
-      return true;
-    }
-
-    // Do not save default prefs that haven't changed.
-    return false;
-  }
-
-  bool Matches(PrefType aType,
-               PrefValueKind aKind,
-               PrefValue& aValue,
-               bool aIsSticky,
-               bool aIsLocked) const
-  {
-    return (ValueMatches(aKind, aType, aValue) && aIsSticky == IsSticky() &&
-            aIsLocked == IsLocked());
-  }
-
-  bool ValueMatches(PrefValueKind aKind,
-                    PrefType aType,
-                    const PrefValue& aValue) const
-  {
-    if (!IsType(aType)) {
-      return false;
-    }
-    if (!(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                          : HasUserValue())) {
-      return false;
-    }
-    switch (aType) {
-      case PrefType::Bool:
-        return GetBoolValue(aKind) == aValue.mBoolVal;
-      case PrefType::Int:
-        return GetIntValue(aKind) == aValue.mIntVal;
-      case PrefType::String:
-        return strcmp(GetBareStringValue(aKind), aValue.mStringVal) == 0;
-      default:
-        MOZ_ASSERT_UNREACHABLE("Unexpected preference type");
-        return false;
-    }
-  }
-};
-
-void
-Pref::FromWrapper(PrefWrapper& aWrapper)
-{
-  MOZ_ASSERT(aWrapper.is<SharedPrefMap::Pref>());
-  auto pref = aWrapper.as<SharedPrefMap::Pref>();
-
-  MOZ_ASSERT(IsTypeNone());
-  MOZ_ASSERT(strcmp(mName, pref.Name()) == 0);
-
-  mType = uint32_t(pref.Type());
-
-  mIsLocked = pref.IsLocked();
-  mIsSticky = pref.IsSticky();
-
-  mHasDefaultValue = pref.HasDefaultValue();
-  mHasUserValue = pref.HasUserValue();
-
-  if (mHasDefaultValue) {
-    mDefaultValue.Init(Type(), aWrapper.GetValue(PrefValueKind::Default));
-  }
-  if (mHasUserValue) {
-    mUserValue.Init(Type(), aWrapper.GetValue(PrefValueKind::User));
-  }
-}
-
 class CallbackNode
 {
 public:
   CallbackNode(const nsACString& aDomain,
                PrefChangedFunc aFunc,
                void* aData,
                Preferences::MatchKind aMatchKind)
     : mDomain(aDomain)
@@ -1248,332 +1071,44 @@ private:
 
 static PLDHashTable* gHashTable;
 
 // The callback list contains all the priority callbacks followed by the
 // non-priority callbacks. gLastPriorityNode records where the first part ends.
 static CallbackNode* gFirstCallback = nullptr;
 static CallbackNode* gLastPriorityNode = nullptr;
 
-#ifdef DEBUG
-#define ACCESS_COUNTS
-#endif
-
-#ifdef ACCESS_COUNTS
-using AccessCountsHashTable = nsDataHashtable<nsCStringHashKey, uint32_t>;
-static AccessCountsHashTable* gAccessCounts;
-
-static void
-AddAccessCount(const nsACString& aPrefName)
-{
-  // FIXME: Servo reads preferences from background threads in unsafe ways (bug
-  // 1474789), and triggers assertions here if we try to add usage count entries
-  // from background threads.
-  if (NS_IsMainThread()) {
-    uint32_t& count = gAccessCounts->GetOrInsert(aPrefName);
-    count++;
-  }
-}
-
-static void
-AddAccessCount(const char* aPrefName)
-{
-  AddAccessCount(nsDependentCString(aPrefName));
-}
-#else
-static void MOZ_MAYBE_UNUSED
-AddAccessCount(const nsACString& aPrefName)
-{
-}
-
-static void
-AddAccessCount(const char* aPrefName)
-{
-}
-#endif
-
 // These are only used during the call to NotifyCallbacks().
 static bool gCallbacksInProgress = false;
 static bool gShouldCleanupDeadNodes = false;
 
 static PLDHashTableOps pref_HashTableOps = {
   PLDHashTable::HashStringKey, PrefEntry::MatchEntry,
   PLDHashTable::MoveEntryStub, PrefEntry::ClearEntry,
   PrefEntry::InitEntry,
 };
 
-class PrefsHashIter
-{
-  using Iterator = decltype(gHashTable->Iter());
-  using ElemType = Pref*;
-
-  Iterator mIter;
-
-public:
-  explicit PrefsHashIter(PLDHashTable* aTable)
-    : mIter(aTable->Iter())
-  {
-  }
-
-  class Elem
-  {
-    friend class PrefsHashIter;
-
-    PrefsHashIter& mParent;
-    bool mDone;
-
-    Elem(PrefsHashIter& aIter, bool aDone)
-      : mParent(aIter)
-      , mDone(aDone)
-    {
-    }
-
-    Iterator& Iter() { return mParent.mIter; }
-
-  public:
-    Elem& operator*() { return *this; }
-
-    ElemType get()
-    {
-      if (mDone) {
-        return nullptr;
-      }
-      return static_cast<PrefEntry*>(Iter().Get())->mPref;
-    }
-    ElemType get() const { return const_cast<Elem*>(this)->get(); }
-
-    ElemType operator->() { return get(); }
-    ElemType operator->() const { return get(); }
-
-    operator ElemType() { return get(); }
-
-    void Remove() { Iter().Remove(); }
-
-    Elem& operator++()
-    {
-      MOZ_ASSERT(!mDone);
-      Iter().Next();
-      mDone = Iter().Done();
-      return *this;
-    }
-
-    bool operator!=(Elem& other)
-    {
-      return mDone != other.mDone || this->get() != other.get();
-    }
-  };
-
-  Elem begin() { return Elem(*this, mIter.Done()); }
-
-  Elem end() { return Elem(*this, true); }
-};
-
-class PrefsIter
-{
-  using Iterator = decltype(gHashTable->Iter());
-  using ElemType = PrefWrapper;
-
-  using HashElem = PrefsHashIter::Elem;
-  using SharedElem = SharedPrefMap::Pref;
-
-  using ElemTypeVariant = Variant<HashElem, SharedElem>;
-
-  SharedPrefMap* mSharedMap;
-  PLDHashTable* mHashTable;
-  PrefsHashIter mIter;
-
-  ElemTypeVariant mPos;
-  ElemTypeVariant mEnd;
-
-  Maybe<PrefWrapper> mEntry;
-
-public:
-  PrefsIter(PLDHashTable* aHashTable, SharedPrefMap* aSharedMap)
-    : mSharedMap(aSharedMap)
-    , mHashTable(aHashTable)
-    , mIter(aHashTable)
-    , mPos(AsVariant(mIter.begin()))
-    , mEnd(AsVariant(mIter.end()))
-  {
-    if (Done()) {
-      NextIterator();
-    }
-  }
-
-private:
-#define MATCH(type, ...)                                                       \
-  do {                                                                         \
-    struct Matcher                                                             \
-    {                                                                          \
-      PrefsIter& mIter;                                                        \
-      type match(HashElem& pos)                                                \
-      {                                                                        \
-        HashElem& end MOZ_MAYBE_UNUSED = mIter.mEnd.as<HashElem>();            \
-        __VA_ARGS__;                                                           \
-      }                                                                        \
-      type match(SharedElem& pos)                                              \
-      {                                                                        \
-        SharedElem& end MOZ_MAYBE_UNUSED = mIter.mEnd.as<SharedElem>();        \
-        __VA_ARGS__;                                                           \
-      }                                                                        \
-    };                                                                         \
-    return mPos.match(Matcher{ *this });                                       \
-  } while (0);
-
-  bool Done() { MATCH(bool, return pos == end); }
-
-  PrefWrapper MakeEntry() { MATCH(PrefWrapper, return PrefWrapper(pos)); }
-
-  void NextEntry()
-  {
-    mEntry.reset();
-    MATCH(void, ++pos);
-  }
-#undef MATCH
-
-  bool Next()
-  {
-    NextEntry();
-    return !Done() || NextIterator();
-  }
-
-  bool NextIterator()
-  {
-    if (mPos.is<HashElem>() && mSharedMap) {
-      mPos = AsVariant(mSharedMap->begin());
-      mEnd = AsVariant(mSharedMap->end());
-      return !Done();
-    }
-    return false;
-  }
-
-  bool IteratingBase() { return mPos.is<SharedElem>(); }
-
-  PrefWrapper& Entry()
-  {
-    MOZ_ASSERT(!Done());
-
-    if (!mEntry.isSome()) {
-      mEntry.emplace(MakeEntry());
-    }
-    return mEntry.ref();
-  }
-
-public:
-  class Elem
-  {
-    friend class PrefsIter;
-
-    PrefsIter& mParent;
-    bool mDone;
-
-    Elem(PrefsIter& aIter, bool aDone)
-      : mParent(aIter)
-      , mDone(aDone)
-    {
-      SkipDuplicates();
-    }
-
-    void Next() { mDone = !mParent.Next(); }
-
-    void SkipDuplicates()
-    {
-      while (!mDone && (mParent.IteratingBase()
-                          ? !!mParent.mHashTable->Search(ref().Name())
-                          : ref().IsTypeNone())) {
-        Next();
-      }
-    }
-
-  public:
-    Elem& operator*() { return *this; }
-
-    ElemType& ref() { return mParent.Entry(); }
-    const ElemType& ref() const { return const_cast<Elem*>(this)->ref(); }
-
-    ElemType* operator->() { return &ref(); }
-    const ElemType* operator->() const { return &ref(); }
-
-    operator ElemType() { return ref(); }
-
-    void Remove()
-    {
-      MOZ_ASSERT(!mParent.IteratingBase());
-      mParent.mPos.as<HashElem>().Remove();
-    }
-
-    Elem& operator++()
-    {
-      MOZ_ASSERT(!mDone);
-      Next();
-      SkipDuplicates();
-      return *this;
-    }
-
-    bool operator!=(Elem& other)
-    {
-      if (mDone != other.mDone) {
-        return true;
-      }
-      if (mDone) {
-        return false;
-      }
-      return &this->ref() != &other.ref();
-    }
-  };
-
-  Elem begin() { return { *this, Done() }; }
-
-  Elem end() { return { *this, true }; }
-};
-
 static Pref*
 pref_HashTableLookup(const char* aPrefName);
 
 static void
-NotifyCallbacks(const char* aPrefName, const PrefWrapper* aPref = nullptr);
-
-static void
-NotifyCallbacks(const char* aPrefName, const PrefWrapper& aPref)
-{
-  NotifyCallbacks(aPrefName, &aPref);
-}
-
-// The approximate number of preferences in the dynamic hashtable for the parent
-// and content processes, respectively. These numbers are used to determine the
-// initial size of the dynamic preference hashtables, and should be chosen to
-// avoid rehashing during normal usage. The actual number of preferences will,
-// or course, change over time, but these numbers only need to be within a
-// binary order of magnitude of the actual values to remain effective.
-//
-// The number for the parent process should reflect the total number of
-// preferences in the database, since the parent process needs to initially
-// build a dynamic hashtable of the entire preference database. The number for
-// the child process should reflect the number of preferences which are likely
-// to change after the startup of the first content process, since content
-// processes only store changed preferences on top of a snapshot of the database
-// created at startup.
-//
-// Note: The capacity of a hashtable doubles when its length reaches an exact
-// power of two. A table with an initial length of 64 is twice as large as one
-// with an initial length of 63. This is important in content processes, where
-// lookup speed is less critical and we pay the price of the additional overhead
-// for each content process. So the initial content length should generally be
-// *under* the next power-of-two larger than its expected length.
-constexpr size_t kHashTableInitialLengthParent = 3000;
-constexpr size_t kHashTableInitialLengthContent = 64;
+NotifyCallbacks(const char* aPrefName);
+
+#define PREF_HASHTABLE_INITIAL_LENGTH 1024
 
 static PrefSaveData
 pref_savePrefs()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   PrefSaveData savedPrefs(gHashTable->EntryCount());
 
-  for (auto& pref : PrefsIter(gHashTable, gSharedMap)) {
+  for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
+    Pref* pref = static_cast<PrefEntry*>(iter.Get())->mPref;
+
     nsAutoCString prefValueStr;
     if (!pref->UserValueToStringForSaving(prefValueStr)) {
       continue;
     }
 
     nsAutoCString prefNameStr;
     StrEscape(pref->Name(), prefNameStr);
 
@@ -1607,120 +1142,54 @@ pref_HashTableLookupInner(const char* aP
 static Pref*
 pref_HashTableLookup(const char* aPrefName)
 {
   PrefEntry* entry = pref_HashTableLookupInner(aPrefName);
   if (!entry) {
     return nullptr;
   }
 
+#ifdef DEBUG
+  entry->mAccessCount += 1;
+#endif
+
   return entry->mPref;
 }
 
-// While notifying preference callbacks, this holds the wrapper for the
-// preference being notified, in order to optimize lookups.
-//
-// Note: Callbacks and lookups only happen on the main thread, so this is safe
-// to use without locking.
-static const PrefWrapper* gCallbackPref;
-
-Maybe<PrefWrapper>
-pref_Lookup(const char* aPrefName, bool aIncludeTypeNone = false)
-{
-  Maybe<PrefWrapper> result;
-
-  MOZ_ASSERT(NS_IsMainThread() || mozilla::ServoStyleSet::IsInServoTraversal());
-
-  AddAccessCount(aPrefName);
-
-  if (gCallbackPref && strcmp(aPrefName, gCallbackPref->Name()) == 0) {
-    result.emplace(*gCallbackPref);
-  } else if (Pref* pref = pref_HashTableLookup(aPrefName)) {
-    if (aIncludeTypeNone || !pref->IsTypeNone()) {
-      result.emplace(pref);
-    }
-  } else if (gSharedMap) {
-    Maybe<SharedPrefMap::Pref> pref = gSharedMap->Get(aPrefName);
-    if (pref.isSome()) {
-      result.emplace(*pref);
-    }
-  }
-
-  return result;
-}
-
-static Result<Pref*, nsresult>
-pref_LookupForModify(const char* aPrefName,
-                     const std::function<bool(const PrefWrapper&)>& aCheckFn)
-{
-  Maybe<PrefWrapper> wrapper = pref_Lookup(aPrefName, /* includeTypeNone */ true);
-  if (wrapper.isNothing()) {
-    return Err(NS_ERROR_INVALID_ARG);
-  }
-  if (!aCheckFn(*wrapper)) {
-    return nullptr;
-  }
-  if (wrapper->is<Pref*>()) {
-    return wrapper->as<Pref*>();
-  }
-
-  auto entry = static_cast<PrefEntry*>(gHashTable->Add(aPrefName, fallible));
-  if (!entry) {
-    return Err(NS_ERROR_OUT_OF_MEMORY);
-  }
-  Pref* pref = entry->mPref;
-  pref->FromWrapper(*wrapper);
-  return pref;
-}
-
 static nsresult
 pref_SetPref(const char* aPrefName,
              PrefType aType,
              PrefValueKind aKind,
              PrefValue aValue,
              bool aIsSticky,
              bool aIsLocked,
              bool aFromInit)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!gHashTable) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  Pref* pref = nullptr;
-  if (gSharedMap) {
-    auto result =
-      pref_LookupForModify(aPrefName, [&](const PrefWrapper& aWrapper) {
-        return !aWrapper.Matches(aType, aKind, aValue, aIsSticky, aIsLocked);
-      });
-    if (result.isOk() && !(pref = result.unwrap())) {
-      // No changes required.
-      return NS_OK;
-    }
-  }
-
-  if (!pref) {
-    auto entry = static_cast<PrefEntry*>(gHashTable->Add(aPrefName, fallible));
-    if (!entry) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    pref = entry->mPref;
-
-    if (pref->IsTypeNone()) {
-      // New entry. Set the type.
-      pref->SetType(aType);
-    }
+  auto entry = static_cast<PrefEntry*>(gHashTable->Add(aPrefName, fallible));
+  if (!entry) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+
+  Pref* pref = entry->mPref;
+  if (pref->IsTypeNone()) {
+    // New entry. Set the type.
+    pref->SetType(aType);
   }
 
   bool valueChanged = false;
   nsresult rv;
   if (aKind == PrefValueKind::Default) {
     rv = pref->SetDefaultValue(
-      aType, aValue, aIsSticky, aIsLocked, &valueChanged);
+      aType, aValue, aIsSticky, aIsLocked, aFromInit, &valueChanged);
   } else {
     MOZ_ASSERT(!aIsLocked); // `locked` is disallowed in user pref files
     rv = pref->SetUserValue(aType, aValue, aFromInit, &valueChanged);
   }
   if (NS_FAILED(rv)) {
     NS_WARNING(
       nsPrintfCString(
         "Rejected attempt to change type of pref %s's %s value from %s to %s",
@@ -1732,17 +1201,17 @@ pref_SetPref(const char* aPrefName,
 
     return rv;
   }
 
   if (valueChanged) {
     if (aKind == PrefValueKind::User && XRE_IsParentProcess()) {
       Preferences::HandleDirty();
     }
-    NotifyCallbacks(aPrefName, PrefWrapper(pref));
+    NotifyCallbacks(aPrefName);
   }
 
   return NS_OK;
 }
 
 // Removes |node| from callback list. Returns the node after the deleted one.
 static CallbackNode*
 pref_RemoveCallbackNode(CallbackNode* aNode, CallbackNode* aPrevNode)
@@ -1760,23 +1229,20 @@ pref_RemoveCallbackNode(CallbackNode* aN
   if (gLastPriorityNode == aNode) {
     gLastPriorityNode = aPrevNode;
   }
   delete aNode;
   return next_node;
 }
 
 static void
-NotifyCallbacks(const char* aPrefName, const PrefWrapper* aPref)
+NotifyCallbacks(const char* aPrefName)
 {
   bool reentered = gCallbacksInProgress;
 
-  gCallbackPref = aPref;
-  auto cleanup = MakeScopeExit([]() { gCallbackPref = nullptr; });
-
   // Nodes must not be deleted while gCallbacksInProgress is true.
   // Nodes that need to be deleted are marked for deletion by nulling
   // out the |func| pointer. We release them at the end of this function
   // if we haven't reentered.
   gCallbacksInProgress = true;
 
   nsDependentCString prefName(aPrefName);
 
@@ -2882,19 +2348,20 @@ nsPrefBranch::GetChildList(const char* a
   *aChildArray = nullptr;
   *aCount = 0;
 
   // This will contain a list of all the pref name strings. Allocated on the
   // stack for speed.
 
   const PrefName& parent = GetPrefName(aStartingAt);
   size_t parentLen = parent.Length();
-  for (auto& pref : PrefsIter(gHashTable, gSharedMap)) {
+  for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
+    Pref* pref = static_cast<PrefEntry*>(iter.Get())->mPref;
     if (strncmp(pref->Name(), parent.get(), parentLen) == 0) {
-      prefArray.AppendElement(pref->NameString());
+      prefArray.AppendElement(pref->Name());
     }
   }
 
   // Now that we've built up the list, run the callback on all the matching
   // elements.
   numPrefs = prefArray.Length();
 
   if (numPrefs) {
@@ -3518,20 +2985,16 @@ PreferenceServiceReporter::CollectReport
   }
 
   sizes.mPrefNameArena += gPrefNameArena.SizeOfExcludingThis(mallocSizeOf);
 
   for (CallbackNode* node = gFirstCallback; node; node = node->Next()) {
     node->AddSizeOfIncludingThis(mallocSizeOf, sizes);
   }
 
-  if (gSharedMap) {
-    sizes.mMisc += mallocSizeOf(gSharedMap);
-  }
-
   MOZ_COLLECT_REPORT("explicit/preferences/hash-table",
                      KIND_HEAP,
                      UNITS_BYTES,
                      sizes.mHashTable,
                      "Memory used by libpref's hash table.");
 
   MOZ_COLLECT_REPORT("explicit/preferences/pref-values",
                      KIND_HEAP,
@@ -3577,27 +3040,16 @@ PreferenceServiceReporter::CollectReport
                      "prefixes).");
 
   MOZ_COLLECT_REPORT("explicit/preferences/misc",
                      KIND_HEAP,
                      UNITS_BYTES,
                      sizes.mMisc,
                      "Miscellaneous memory used by libpref.");
 
-  if (gSharedMap) {
-    if (XRE_IsParentProcess()) {
-      MOZ_COLLECT_REPORT("explicit/preferences/shared-memory-map",
-                         KIND_NONHEAP,
-                         UNITS_BYTES,
-                         gSharedMap->MapSize(),
-                         "The shared memory mapping used to share a "
-                         "snapshot of preference values across processes.");
-    }
-  }
-
   nsPrefBranch* rootBranch =
     static_cast<nsPrefBranch*>(Preferences::GetRootBranch());
   if (!rootBranch) {
     return NS_OK;
   }
 
   size_t numStrong = 0;
   size_t numWeakAlive = 0;
@@ -3812,30 +3264,22 @@ Preferences::GetInstanceForService()
   if (sShutdown) {
     gCacheDataDesc = "shutting down in GetInstanceForService()";
     return nullptr;
   }
 
   sPreferences = new Preferences();
 
   MOZ_ASSERT(!gHashTable);
-  gHashTable =
-    new PLDHashTable(&pref_HashTableOps,
-                     sizeof(PrefEntry),
-                     (XRE_IsParentProcess() ? kHashTableInitialLengthParent
-                                            : kHashTableInitialLengthContent));
+  gHashTable = new PLDHashTable(
+    &pref_HashTableOps, sizeof(PrefEntry), PREF_HASHTABLE_INITIAL_LENGTH);
 
   gTelemetryLoadData =
     new nsDataHashtable<nsCStringHashKey, TelemetryLoadData>();
 
-#ifdef ACCESS_COUNTS
-  MOZ_ASSERT(!gAccessCounts);
-  gAccessCounts = new AccessCountsHashTable();
-#endif
-
   gCacheData = new nsTArray<nsAutoPtr<CacheData>>();
   gCacheDataDesc = "set by GetInstanceForService() (1)";
 
   Result<Ok, const char*> res = InitInitialObjects(/* isStartup */ true);
   if (res.isErr()) {
     sPreferences = nullptr;
     gCacheDataDesc = res.unwrapErr();
     return nullptr;
@@ -3959,22 +3403,16 @@ Preferences::~Preferences()
   gLastPriorityNode = gFirstCallback = nullptr;
 
   delete gHashTable;
   gHashTable = nullptr;
 
   delete gTelemetryLoadData;
   gTelemetryLoadData = nullptr;
 
-#ifdef ACCESS_COUNTS
-  delete gAccessCounts;
-#endif
-
-  gSharedMap = nullptr;
-
   gPrefNameArena.Clear();
 }
 
 NS_IMPL_ISUPPORTS(Preferences,
                   nsIPrefService,
                   nsIObserver,
                   nsIPrefBranch,
                   nsISupportsWeakReference)
@@ -3983,17 +3421,17 @@ NS_IMPL_ISUPPORTS(Preferences,
 Preferences::SerializePreferences(nsCString& aStr)
 {
   MOZ_RELEASE_ASSERT(InitStaticMembers());
 
   aStr.Truncate();
 
   for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
     Pref* pref = static_cast<PrefEntry*>(iter.Get())->mPref;
-    if (!pref->IsTypeNone() && pref->HasAdvisablySizedValues()) {
+    if (pref->MustSendToContentProcesses() && pref->HasAdvisablySizedValues()) {
       pref->SerializeAndAppend(aStr);
     }
   }
 
   aStr.Append('\0');
 }
 
 /* static */ void
@@ -4016,58 +3454,16 @@ Preferences::DeserializePreferences(char
   MOZ_ASSERT(p == aStr + aPrefsLen - 1);
 
 #ifdef DEBUG
   MOZ_ASSERT(!gContentProcessPrefsAreInited);
   gContentProcessPrefsAreInited = true;
 #endif
 }
 
-/* static */ FileDescriptor
-Preferences::EnsureSnapshot(size_t* aSize)
-{
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  if (!gSharedMap) {
-    SharedPrefMapBuilder builder;
-
-    for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
-      Pref* pref = static_cast<PrefEntry*>(iter.Get())->mPref;
-
-      pref->AddToMap(builder);
-    }
-
-    gSharedMap = new SharedPrefMap(std::move(builder));
-
-    // Once we've built a snapshot of the database, there's no need to continue
-    // storing dynamic copies of the preferences it contains. Once we reset the
-    // hashtable, preference lookups will fall back to the snapshot for any
-    // preferences not in the dynamic hashtable.
-    //
-    // And since the majority of the database is now contained in the snapshot,
-    // we can initialize the hashtable with the expected number of per-session
-    // changed preferences, rather than the expected total number of
-    // preferences.
-    gHashTable->ClearAndPrepareForLength(kHashTableInitialLengthContent);
-    gPrefNameArena.Clear();
-  }
-
-  *aSize = gSharedMap->MapSize();
-  return gSharedMap->CloneFileDescriptor();
-}
-
-/* static */ void
-Preferences::InitSnapshot(const FileDescriptor& aHandle, size_t aSize)
-{
-  MOZ_ASSERT(!XRE_IsParentProcess());
-  MOZ_ASSERT(!gSharedMap);
-
-  gSharedMap = new SharedPrefMap(aHandle, aSize);
-}
-
 /* static */ void
 Preferences::InitializeUserPrefs()
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(!sPreferences->mCurrentFile, "Should only initialize prefs once");
 
   // Prefs which are set before we initialize the profile are silently
   // discarded. This is stupid, but there are various tests which depend on
@@ -4156,21 +3552,17 @@ Preferences::ReadUserPrefsFromFile(nsIFi
   return openPrefFile(aFile, PrefValueKind::User);
 }
 
 NS_IMETHODIMP
 Preferences::ResetPrefs()
 {
   ENSURE_PARENT_PROCESS("Preferences::ResetPrefs", "all prefs");
 
-  if (gSharedMap) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  gHashTable->ClearAndPrepareForLength(kHashTableInitialLengthParent);
+  gHashTable->ClearAndPrepareForLength(PREF_HASHTABLE_INITIAL_LENGTH);
   gPrefNameArena.Clear();
 
   return InitInitialObjects(/* isStartup */ false).isOk() ? NS_OK
                                                           : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 Preferences::ResetUserPrefs()
@@ -4274,35 +3666,24 @@ Preferences::SetPreference(const dom::Pr
   // - There was an existing pref with only a user value. FromDomPref() will
   //   have just cleared that user value, so the pref can be removed.
   //
   // - There was no existing pref. FromDomPref() will have done nothing, and
   //   `pref` will be valueless. We will end up adding and removing the value
   //   needlessly, but that's ok because this case is rare.
   //
   if (!pref->HasDefaultValue() && !pref->HasUserValue()) {
-    // If the preference exists in the shared map, we need to keep the dynamic
-    // entry around to mask it.
-    if (gSharedMap->Has(pref->Name())) {
-      pref->SetType(PrefType::None);
-    } else {
-      gHashTable->RemoveEntry(entry);
-    }
-    pref = nullptr;
+    gHashTable->RemoveEntry(entry);
   }
 
   // Note: we don't have to worry about HandleDirty() because we are setting
   // prefs in the content process that have come from the parent process.
 
   if (valueChanged) {
-    if (pref) {
-      NotifyCallbacks(prefName, PrefWrapper(pref));
-    } else {
-      NotifyCallbacks(prefName);
-    }
+    NotifyCallbacks(prefName);
   }
 }
 
 /* static */ void
 Preferences::GetPreference(dom::Pref* aDomPref)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
@@ -4358,32 +3739,35 @@ Preferences::GetDefaultBranch(const char
 
   prefBranch.forget(aRetVal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Preferences::ReadStats(nsIPrefStatsCallback* aCallback)
 {
-#ifdef ACCESS_COUNTS
-  for (auto iter = gAccessCounts->Iter(); !iter.Done(); iter.Next()) {
-    aCallback->Visit(iter.Key(), iter.Data());
+#ifdef DEBUG
+  for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
+    PrefEntry* entry = static_cast<PrefEntry*>(iter.Get());
+    aCallback->Visit(entry->mPref->Name(), entry->mAccessCount);
   }
 
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 NS_IMETHODIMP
 Preferences::ResetStats()
 {
-#ifdef ACCESS_COUNTS
-  gAccessCounts->Clear();
+#ifdef DEBUG
+  for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
+    static_cast<PrefEntry*>(iter.Get())->mAccessCount = 0;
+  }
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 NS_IMETHODIMP
 Preferences::GetDirty(bool* aRetVal)
@@ -4741,38 +4125,16 @@ pref_ReadPrefFromJar(nsZipArchive* aJarR
 // resources.
 /* static */ Result<Ok, const char*>
 Preferences::InitInitialObjects(bool aIsStartup)
 {
   // Initialize static prefs before prefs from data files so that the latter
   // will override the former.
   StaticPrefs::InitAll(aIsStartup);
 
-  if (!XRE_IsParentProcess()) {
-    MOZ_ASSERT(gSharedMap);
-
-    // We got our initial preference values from the content process, so we
-    // don't need to add them to the DB. For static var caches, though, the
-    // current preference values may differ from their static defaults. So we
-    // still need to notify callbacks for each of our shared prefs which have
-    // user values.
-    //
-    // While it is technically also possible for the default values to have
-    // changed at runtime, and therefore not match the static defaults, we don't
-    // support that for static preferences in this configuration, and therefore
-    // ignore the possibility.
-    for (auto& pref : gSharedMap->Iter()) {
-      if (pref.HasUserValue()) {
-        NotifyCallbacks(pref.Name(), PrefWrapper(pref));
-      }
-    }
-
-    return Ok();
-  }
-
   // In the omni.jar case, we load the following prefs:
   // - jar:$gre/omni.jar!/greprefs.js
   // - jar:$gre/omni.jar!/defaults/pref/*.js
   //
   // In the non-omni.jar case, we load:
   // - $gre/greprefs.js
   //
   // In both cases, we also load:
@@ -4949,32 +4311,30 @@ Preferences::InitInitialObjects(bool aIs
 }
 
 /* static */ nsresult
 Preferences::GetBool(const char* aPrefName, bool* aResult, PrefValueKind aKind)
 {
   MOZ_ASSERT(aResult);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  return pref.isSome() ? pref->GetBoolValue(aKind, aResult)
-                       : NS_ERROR_UNEXPECTED;
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref ? pref->GetBoolValue(aKind, aResult) : NS_ERROR_UNEXPECTED;
 }
 
 /* static */ nsresult
 Preferences::GetInt(const char* aPrefName,
                     int32_t* aResult,
                     PrefValueKind aKind)
 {
   MOZ_ASSERT(aResult);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  return pref.isSome() ? pref->GetIntValue(aKind, aResult)
-                       : NS_ERROR_UNEXPECTED;
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref ? pref->GetIntValue(aKind, aResult) : NS_ERROR_UNEXPECTED;
 }
 
 /* static */ nsresult
 Preferences::GetFloat(const char* aPrefName,
                       float* aResult,
                       PrefValueKind aKind)
 {
   MOZ_ASSERT(aResult);
@@ -4991,19 +4351,18 @@ Preferences::GetFloat(const char* aPrefN
 Preferences::GetCString(const char* aPrefName,
                         nsACString& aResult,
                         PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
   aResult.SetIsVoid(true);
 
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  return pref.isSome() ? pref->GetCStringValue(aKind, aResult)
-                       : NS_ERROR_UNEXPECTED;
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref ? pref->GetCStringValue(aKind, aResult) : NS_ERROR_UNEXPECTED;
 }
 
 /* static */ nsresult
 Preferences::GetString(const char* aPrefName,
                        nsAString& aResult,
                        PrefValueKind aKind)
 {
   nsAutoCString result;
@@ -5126,111 +4485,94 @@ Preferences::SetComplex(const char* aPre
 }
 
 /* static */ nsresult
 Preferences::Lock(const char* aPrefName)
 {
   ENSURE_PARENT_PROCESS("Lock", aPrefName);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
-  Pref* pref;
-  MOZ_TRY_VAR(pref,
-              pref_LookupForModify(aPrefName, [](const PrefWrapper& aPref) {
-                return !aPref.IsLocked();
-              }));
-
-  if (pref) {
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  if (!pref) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  if (!pref->IsLocked()) {
     pref->SetIsLocked(true);
-    NotifyCallbacks(aPrefName, PrefWrapper(pref));
+    NotifyCallbacks(aPrefName);
   }
 
   return NS_OK;
 }
 
 /* static */ nsresult
 Preferences::Unlock(const char* aPrefName)
 {
   ENSURE_PARENT_PROCESS("Unlock", aPrefName);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
-  Pref* pref;
-  MOZ_TRY_VAR(pref,
-              pref_LookupForModify(aPrefName, [](const PrefWrapper& aPref) {
-                return aPref.IsLocked();
-              }));
-
-  if (pref) {
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  if (!pref) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  if (pref->IsLocked()) {
     pref->SetIsLocked(false);
-    NotifyCallbacks(aPrefName, PrefWrapper(pref));
+    NotifyCallbacks(aPrefName);
   }
 
   return NS_OK;
 }
 
 /* static */ bool
 Preferences::IsLocked(const char* aPrefName)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), false);
 
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  return pref.isSome() && pref->IsLocked();
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref && pref->IsLocked();
 }
 
 /* static */ nsresult
 Preferences::ClearUser(const char* aPrefName)
 {
   ENSURE_PARENT_PROCESS("ClearUser", aPrefName);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
-  auto result = pref_LookupForModify(
-    aPrefName, [](const PrefWrapper& aPref) { return aPref.HasUserValue(); });
-  if (result.isErr()) {
-    return NS_OK;
-  }
-
-  if (Pref* pref = result.unwrap()) {
+  PrefEntry* entry = pref_HashTableLookupInner(aPrefName);
+  Pref* pref;
+  if (entry && (pref = entry->mPref) && pref->HasUserValue()) {
     pref->ClearUserValue();
 
     if (!pref->HasDefaultValue()) {
-      if (!gSharedMap || !gSharedMap->Has(pref->Name())) {
-        gHashTable->Remove(aPrefName);
-      } else {
-        pref->SetType(PrefType::None);
-      }
-
-      NotifyCallbacks(aPrefName);
-    } else {
-      NotifyCallbacks(aPrefName, PrefWrapper(pref));
+      gHashTable->RemoveEntry(entry);
     }
 
+    NotifyCallbacks(aPrefName);
     Preferences::HandleDirty();
   }
   return NS_OK;
 }
 
 /* static */ bool
 Preferences::HasUserValue(const char* aPrefName)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), false);
 
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  return pref.isSome() && pref->HasUserValue();
+  Pref* pref = pref_HashTableLookup(aPrefName);
+  return pref && pref->HasUserValue();
 }
 
 /* static */ int32_t
 Preferences::GetType(const char* aPrefName)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), nsIPrefBranch::PREF_INVALID);
 
-  if (!gHashTable) {
-    return PREF_INVALID;
-  }
-
-  Maybe<PrefWrapper> pref = pref_Lookup(aPrefName);
-  if (!pref.isSome()) {
+  Pref* pref;
+  if (!gHashTable || !(pref = pref_HashTableLookup(aPrefName))) {
     return PREF_INVALID;
   }
 
   switch (pref->Type()) {
     case PrefType::String:
       return PREF_STRING;
 
     case PrefType::Int:
@@ -5856,39 +5198,32 @@ InitVarCachePref(const nsACString& aName
   if (aIsStartup) {
     Preferences::AddFloatVarCache(aCache, aName, aDefaultValue, true);
   }
 }
 
 /* static */ void
 StaticPrefs::InitAll(bool aIsStartup)
 {
-  // For prefs like these:
-  //
-  //   PREF("foo.bar.baz", bool, true)
-  //   VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99)
-  //
-  // we generate registration calls:
-  //
-  //   if (isParent)
-  //     SetPref_bool("foo.bar.baz", true);
-  //   InitVarCachePref("my.varcache", &StaticPrefs::sVarCache_my_varcache, 99,
-  //                    aIsStartup);
-  //
-  // The SetPref_*() functions have a type suffix to avoid ambiguity between
-  // prefs having int32_t and float default values. That suffix is not needed
-  // for the InitVarCachePref() functions because they take a pointer parameter,
-  // which prevents automatic int-to-float coercion.
-  //
-  // In content processes, we rely on the parent to send us the correct initial
-  // values via shared memory, so we do not re-initialize them here.
-  bool isParent = XRE_IsParentProcess();
-#define PREF(name, cpp_type, value)                                            \
-  if (isParent)                                                                \
-    SetPref_##cpp_type(name, value);
+// For prefs like these:
+//
+//   PREF("foo.bar.baz", bool, true)
+//   VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99)
+//
+// we generate registration calls:
+//
+//   SetPref_bool("foo.bar.baz", true);
+//   InitVarCachePref("my.varcache", &StaticPrefs::sVarCache_my_varcache, 99,
+//                    aIsStartup);
+//
+// The SetPref_*() functions have a type suffix to avoid ambiguity between
+// prefs having int32_t and float default values. That suffix is not needed for
+// the InitVarCachePref() functions because they take a pointer parameter,
+// which prevents automatic int-to-float coercion.
+#define PREF(name, cpp_type, value) SetPref_##cpp_type(name, value);
 #define VARCACHE_PREF(name, id, cpp_type, value)                               \
   InitVarCachePref(NS_LITERAL_CSTRING(name),                                   \
                    &StaticPrefs::sVarCache_##id,                               \
                    value,                                                      \
                    aIsStartup);
 #include "mozilla/StaticPrefList.h"
 #undef PREF
 #undef VARCACHE_PREF
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -34,54 +34,21 @@ class nsPrefBranch;
 
 namespace mozilla {
 
 namespace dom {
 class Pref;
 class PrefValue;
 } // namespace dom
 
-namespace ipc {
-class FileDescriptor;
-} // namespace ipc
-
 struct PrefsSizes;
 
-// Xlib.h defines Bool as a macro constant. Don't try to define this enum if
-// it's already been included.
-#ifndef Bool
-
-// Keep this in sync with PrefType in parser/src/lib.rs.
-enum class PrefType : uint8_t
-{
-  None = 0, // only used when neither the default nor user value is set
-  String = 1,
-  Int = 2,
-  Bool = 3,
-};
-
-#endif
-
 #ifdef XP_UNIX
-// We need to send two shared memory descriptors to every child process:
-//
-// 1) A read-only/write-protected snapshot of the initial state of the
-//    preference database. This memory is shared between all processes, and
-//    therefore cannot be modified once it has been created.
-//
-// 2) A set of changes on top of the snapshot, containing the current values of
-//    all preferences which have changed since it was created.
-//
-// Since the second set will be different for every process, and the first set
-// cannot be modified, it is unfortunately not possible to combine them into a
-// single file descriptor.
-//
 // XXX: bug 1440207 is about improving how fixed fds such as this are used.
 static const int kPrefsFileDescriptor = 8;
-static const int kPrefMapFileDescriptor = 9;
 #endif
 
 // Keep this in sync with PrefType in parser/src/lib.rs.
 enum class PrefValueKind : uint8_t
 {
   Default,
   User
 };
@@ -509,19 +476,16 @@ public:
       aVariable, nsLiteralCString(aPref), aDefault, aSkipAssignment);
   }
 
   // When a content process is created these methods are used to pass changed
   // prefs in bulk from the parent process, via shared memory.
   static void SerializePreferences(nsCString& aStr);
   static void DeserializePreferences(char* aStr, size_t aPrefsLen);
 
-  static mozilla::ipc::FileDescriptor EnsureSnapshot(size_t* aSize);
-  static void InitSnapshot(const mozilla::ipc::FileDescriptor&, size_t aSize);
-
   // When a single pref is changed in the parent process, these methods are
   // used to pass the update to content processes.
   static void GetPreference(dom::Pref* aPref);
   static void SetPreference(const dom::Pref& aPref);
 
 #ifdef DEBUG
   static bool ArePrefsInitedInContentProcess();
 #endif
deleted file mode 100644
--- a/modules/libpref/SharedPrefMap.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=99: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "SharedPrefMap.h"
-
-#include "mozilla/dom/ipc/MemMapSnapshot.h"
-
-#include "mozilla/BinarySearch.h"
-#include "mozilla/ResultExtensions.h"
-#include "mozilla/ipc/FileDescriptor.h"
-
-using namespace mozilla::loader;
-
-namespace mozilla {
-
-using namespace ipc;
-
-static inline size_t
-GetAlignmentOffset(size_t aOffset, size_t aAlign)
-{
-  auto mod = aOffset % aAlign;
-  return mod ? aAlign - mod : 0;
-}
-
-SharedPrefMap::SharedPrefMap(const FileDescriptor& aMapFile, size_t aMapSize)
-{
-  auto result = mMap.initWithHandle(aMapFile, aMapSize);
-  MOZ_RELEASE_ASSERT(result.isOk());
-  // We return literal nsCStrings pointing to the mapped data for preference
-  // names and string values, which means that we may still have references to
-  // the mapped data even after this instance is destroyed. That means that we
-  // need to keep the mapping alive until process shutdown, in order to be safe.
-  mMap.setPersistent();
-}
-
-SharedPrefMap::SharedPrefMap(SharedPrefMapBuilder&& aBuilder)
-{
-  auto result = aBuilder.Finalize(mMap);
-  MOZ_RELEASE_ASSERT(result.isOk());
-  mMap.setPersistent();
-}
-
-mozilla::ipc::FileDescriptor
-SharedPrefMap::CloneFileDescriptor() const
-{
-  return mMap.cloneHandle();
-}
-
-bool
-SharedPrefMap::Has(const char* aKey) const
-{
-  size_t index;
-  return Find(aKey, &index);
-}
-
-Maybe<const SharedPrefMap::Pref>
-SharedPrefMap::Get(const char* aKey) const
-{
-  Maybe<const Pref> result;
-
-  size_t index;
-  if (Find(aKey, &index)) {
-    result.emplace(Pref{ this, &Entries()[index] });
-  }
-
-  return result;
-}
-
-bool
-SharedPrefMap::Find(const char* aKey, size_t* aIndex) const
-{
-  const auto& keys = KeyTable();
-
-  return BinarySearchIf(Entries(),
-                        0,
-                        EntryCount(),
-                        [&](const Entry& aEntry) {
-                          return strcmp(aKey, keys.GetBare(aEntry.mKey));
-                        },
-                        aIndex);
-}
-
-void
-SharedPrefMapBuilder::Add(const char* aKey,
-                          const Flags& aFlags,
-                          bool aDefaultValue,
-                          bool aUserValue)
-{
-  mEntries.AppendElement(Entry{
-    aKey,
-    mKeyTable.Add(aKey),
-    { aDefaultValue, aUserValue },
-    uint8_t(PrefType::Bool),
-    aFlags.mHasDefaultValue,
-    aFlags.mHasUserValue,
-    aFlags.mIsSticky,
-    aFlags.mIsLocked,
-  });
-}
-
-void
-SharedPrefMapBuilder::Add(const char* aKey,
-                          const Flags& aFlags,
-                          int32_t aDefaultValue,
-                          int32_t aUserValue)
-{
-  ValueIdx index;
-  if (aFlags.mHasUserValue) {
-    index = mIntValueTable.Add(aDefaultValue, aUserValue);
-  } else {
-    index = mIntValueTable.Add(aDefaultValue);
-  }
-
-  mEntries.AppendElement(Entry{
-    aKey,
-    mKeyTable.Add(aKey),
-    { index },
-    uint8_t(PrefType::Int),
-    aFlags.mHasDefaultValue,
-    aFlags.mHasUserValue,
-    aFlags.mIsSticky,
-    aFlags.mIsLocked,
-  });
-}
-
-void
-SharedPrefMapBuilder::Add(const char* aKey,
-                          const Flags& aFlags,
-                          const nsCString& aDefaultValue,
-                          const nsCString& aUserValue)
-{
-  ValueIdx index;
-  StringTableEntry defaultVal = mValueStringTable.Add(aDefaultValue);
-  if (aFlags.mHasUserValue) {
-    StringTableEntry userVal = mValueStringTable.Add(aUserValue);
-    index = mStringValueTable.Add(defaultVal, userVal);
-  } else {
-    index = mStringValueTable.Add(defaultVal);
-  }
-
-  mEntries.AppendElement(Entry{
-    aKey,
-    mKeyTable.Add(aKey),
-    { index },
-    uint8_t(PrefType::String),
-    aFlags.mHasDefaultValue,
-    aFlags.mHasUserValue,
-    aFlags.mIsSticky,
-    aFlags.mIsLocked,
-  });
-}
-
-Result<Ok, nsresult>
-SharedPrefMapBuilder::Finalize(loader::AutoMemMap& aMap)
-{
-  using Header = SharedPrefMap::Header;
-
-  // Create an array of entry pointers for the entry array, and sort it by
-  // preference name prior to serialization, so that entries can be looked up
-  // using binary search.
-  nsTArray<Entry*> entries(mEntries.Length());
-  for (auto& entry : mEntries) {
-    entries.AppendElement(&entry);
-  }
-  entries.Sort([](const Entry* aA, const Entry* aB) {
-    return strcmp(aA->mKeyString, aB->mKeyString);
-  });
-
-  Header header = { uint32_t(entries.Length()) };
-
-  size_t offset = sizeof(header);
-  offset += GetAlignmentOffset(offset, alignof(Header));
-
-  offset += entries.Length() * sizeof(SharedPrefMap::Entry);
-
-  header.mKeyStrings.mOffset = offset;
-  header.mKeyStrings.mSize = mKeyTable.Size();
-  offset += header.mKeyStrings.mSize;
-
-  offset += GetAlignmentOffset(offset, mIntValueTable.Alignment());
-  header.mUserIntValues.mOffset = offset;
-  header.mUserIntValues.mSize = mIntValueTable.UserSize();
-  offset += header.mUserIntValues.mSize;
-
-  offset += GetAlignmentOffset(offset, mIntValueTable.Alignment());
-  header.mDefaultIntValues.mOffset = offset;
-  header.mDefaultIntValues.mSize = mIntValueTable.DefaultSize();
-  offset += header.mDefaultIntValues.mSize;
-
-  offset += GetAlignmentOffset(offset, mStringValueTable.Alignment());
-  header.mUserStringValues.mOffset = offset;
-  header.mUserStringValues.mSize = mStringValueTable.UserSize();
-  offset += header.mUserStringValues.mSize;
-
-  offset += GetAlignmentOffset(offset, mStringValueTable.Alignment());
-  header.mDefaultStringValues.mOffset = offset;
-  header.mDefaultStringValues.mSize = mStringValueTable.DefaultSize();
-  offset += header.mDefaultStringValues.mSize;
-
-  header.mValueStrings.mOffset = offset;
-  header.mValueStrings.mSize = mValueStringTable.Size();
-  offset += header.mValueStrings.mSize;
-
-  MemMapSnapshot mem;
-  MOZ_TRY(mem.Init(offset));
-
-  auto headerPtr = mem.Get<Header>();
-  headerPtr[0] = header;
-
-  auto* entryPtr = reinterpret_cast<SharedPrefMap::Entry*>(&headerPtr[1]);
-  for (auto* entry : entries) {
-    *entryPtr = {
-      entry->mKey,          GetValue(*entry),
-      entry->mType,         entry->mHasDefaultValue,
-      entry->mHasUserValue, entry->mIsSticky,
-      entry->mIsLocked,
-    };
-    entryPtr++;
-  }
-
-  auto ptr = mem.Get<uint8_t>();
-
-  mKeyTable.Write(
-    { &ptr[header.mKeyStrings.mOffset], header.mKeyStrings.mSize });
-
-  mValueStringTable.Write(
-    { &ptr[header.mValueStrings.mOffset], header.mValueStrings.mSize });
-
-  mIntValueTable.WriteDefaultValues(
-    { &ptr[header.mDefaultIntValues.mOffset], header.mDefaultIntValues.mSize });
-  mIntValueTable.WriteUserValues(
-    { &ptr[header.mUserIntValues.mOffset], header.mUserIntValues.mSize });
-
-  mStringValueTable.WriteDefaultValues(
-    { &ptr[header.mDefaultStringValues.mOffset],
-      header.mDefaultStringValues.mSize });
-  mStringValueTable.WriteUserValues(
-    { &ptr[header.mUserStringValues.mOffset], header.mUserStringValues.mSize });
-
-  mKeyTable.Clear();
-  mValueStringTable.Clear();
-  mIntValueTable.Clear();
-  mStringValueTable.Clear();
-  mEntries.Clear();
-
-  return mem.Finalize(aMap);
-}
-
-} // mozilla
deleted file mode 100644
--- a/modules/libpref/SharedPrefMap.h
+++ /dev/null
@@ -1,895 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=99: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef dom_ipc_SharedPrefMap_h
-#define dom_ipc_SharedPrefMap_h
-
-#include "mozilla/AutoMemMap.h"
-#include "mozilla/HashFunctions.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/Result.h"
-#include "mozilla/dom/ipc/StringTable.h"
-#include "nsDataHashtable.h"
-
-namespace mozilla {
-
-// The approximate number of preferences expected to be in an ordinary
-// preferences database.
-//
-// This number is used to determine initial allocation sizes for data structures
-// when building the shared preference map, and should be slightly higher than
-// the expected number of preferences in an ordinary database to avoid
-// unnecessary reallocations/rehashes.
-constexpr size_t kExpectedPrefCount = 4000;
-
-class SharedPrefMapBuilder;
-
-// This class provides access to a compact, read-only copy of a preference
-// database, backed by a shared memory buffer which can be shared between
-// processes. All state data for the database is stored in the shared memory
-// region, so individual instances require no dynamic memory allocation.
-//
-// Further, all strings returned from this API are nsLiteralCStrings with
-// pointers into the shared memory region, which means that they can be copied
-// into new nsCString instances without additional allocations. For instance,
-// the following (where `pref` is a Pref object) will not cause any string
-// copies, memory allocations, or atomic refcount changes:
-//
-//   nsCString prefName(pref.NameString());
-//
-// whereas if we returned a nsDependentCString or a dynamically allocated
-// nsCString, it would.
-//
-// The set of entries is stored in sorted order by preference name, so look-ups
-// are done by binary search. This means that look-ups have O(log n) complexity,
-// rather than the O(1) complexity of a dynamic hashtable. Consumers should keep
-// this in mind when planning their accesses.
-//
-// Important: The mapped memory created by this class is persistent. Once an
-// instance has been initialized, the memory that it allocates can never be
-// freed before process shutdown. Do not use it for short-lived mappings.
-class SharedPrefMap
-{
-  using FileDescriptor = mozilla::ipc::FileDescriptor;
-
-  friend class SharedPrefMapBuilder;
-
-  // Describes a block of memory within the shared memory region.
-  struct DataBlock
-  {
-    // The byte offset from the start of the shared memory region to the start
-    // of the block.
-    size_t mOffset;
-    // The size of the block, in bytes. This is typically used only for bounds
-    // checking in debug builds.
-    size_t mSize;
-  };
-
-  // Describes the contents of the shared memory region, which is laid-out as
-  // follows:
-  //
-  // - The Header struct
-  //
-  // - An array of Entry structs with mEntryCount elements, lexicographically
-  //   sorted by preference name.
-  //
-  // - A set of data blocks, with offsets and sizes described by the DataBlock
-  //   entries in the header, described below.
-  //
-  // Each entry stores its name string and values as indices into these blocks,
-  // as documented in the Entry struct, but with some important optimizations:
-  //
-  // - Boolean values are always stored inline. Both the default and user
-  //   values can be retrieved directly from the entry. Other types have only
-  //   one value index, and their values appear at the same indices in the
-  //   default and user value arrays.
-  //
-  //   Aside from reducing our memory footprint, this space-efficiency means
-  //   that we can fit more entries in the CPU cache at once, and reduces the
-  //   number of likely cache misses during lookups.
-  //
-  // - Key strings are stored in a separate string table from value strings. As
-  //   above, this makes it more likely that the strings we need will be
-  //   available in the CPU cache during lookups by not interleaving them with
-  //   extraneous data.
-  //
-  // - Default and user values are stored in separate arrays. Entries with user
-  //   values always appear before entries with default values in the value
-  //   arrays, and entries without user values do not have entries in the user
-  //   array at all. Since the same index is used for both arrays, this means
-  //   that entries with a default value but no user value do not allocate any
-  //   space to store their user value.
-  //
-  // - For preferences with no user value, the entries in the default value are
-  //   de-duplicated. All preferences with the same default value (and no user
-  //   value) point to the same index in the default value array.
-  //
-  //
-  // For example, a preference database containing:
-  //
-  // +---------+-------------------------------+-------------------------------+
-  // | Name    | Default Value | User Value    |                               |
-  // +---------+---------------+---------------+-------------------------------+
-  // | string1 | "meh"         | "hem"         |                               |
-  // | string2 |               | "b"           |                               |
-  // | string3 | "a"           |               |                               |
-  // | string4 | "foo"         |               |                               |
-  // | string5 | "foo"         |               |                               |
-  // | string6 | "meh"         |               |                               |
-  // +---------+---------------+---------------+-------------------------------+
-  // | bool1   | false         | true          |                               |
-  // | bool2   |               | false         |                               |
-  // | bool3   | true          |               |                               |
-  // +---------+---------------+---------------+-------------------------------+
-  // | int1    | 18            | 16            |                               |
-  // | int2    |               | 24            |                               |
-  // | int3    | 42            |               |                               |
-  // | int4    | 12            |               |                               |
-  // | int5    | 12            |               |                               |
-  // | int6    | 18            |               |                               |
-  // +---------+---------------+---------------+-------------------------------+
-  //
-  // Results in a database that looks like:
-  //
-  // +-------------------------------------------------------------------------+
-  // | Header:                                                                 |
-  // +-------------------------------------------------------------------------+
-  // |  mEntryCount = 15                                                       |
-  // |  ...                                                                    |
-  // +-------------------------------------------------------------------------+
-  //
-  // +-------------------------------------------------------------------------+
-  // | Key strings:                                                            |
-  // +--------+----------------------------------------------------------------+
-  // | Offset | Value                                                          |
-  // +--------+----------------------------------------------------------------+
-  // |      0 | string1\0                                                      |
-  // |      8 | string2\0                                                      |
-  // |     16 | string3\0                                                      |
-  // |     24 | string4\0                                                      |
-  // |     32 | string5\0                                                      |
-  // |     40 | string6\0                                                      |
-  // |     48 | bool1\0                                                        |
-  // |     54 | bool2\0                                                        |
-  // |     60 | bool3\0                                                        |
-  // |     66 | int1\0                                                         |
-  // |     71 | int2\0                                                         |
-  // |     76 | int3\0                                                         |
-  // |     81 | int4\0                                                         |
-  // |     86 | int6\0                                                         |
-  // |     91 | int6\0                                                         |
-  // +--------+----------------------------------------------------------------+
-  //
-  // +-------------------------------------------------------------------------+
-  // | Entries:                                                                |
-  // +---------------------+------+------------+------------+------------------+
-  // | Key[1]              | Type | HasDefault | HasUser    | Value            |
-  // +---------------------+------+------------+------------+------------------+
-  // | K["bool1", 48, 5]   | 3    | true       | true       | { false, true }  |
-  // | K["bool2", 54, 5]   | 3    | false      | true       | { 0,     false } |
-  // | K["bool3", 60, 5]   | 3    | true       | false      | { true,  0    }  |
-  // | K["int1", 66, 4]    | 2    | true       | true       | 0                |
-  // | K["int2", 71, 4]    | 2    | false      | true       | 1                |
-  // | K["int3", 76, 4]    | 2    | true       | false      | 2                |
-  // | K["int4", 81, 4]    | 2    | true       | false      | 3                |
-  // | K["int5", 86, 4]    | 2    | true       | false      | 3                |
-  // | K["int6", 91, 4]    | 2    | true       | false      | 4                |
-  // | K["string1",  0, 6] | 1    | true       | true       | 0                |
-  // | K["string2",  8, 6] | 1    | false      | true       | 1                |
-  // | K["string3", 16, 6] | 1    | true       | false      | 2                |
-  // | K["string4", 24, 6] | 1    | true       | false      | 3                |
-  // | K["string5", 32, 6] | 1    | true       | false      | 3                |
-  // | K["string6", 40, 6] | 1    | true       | false      | 4                |
-  // +---------------------+------+------------+------------+------------------+
-  // | [1]: Encoded as an offset into the key table and a length. Specified    |
-  // |      as K[string, offset, length] for clarity.                          |
-  // +-------------------------------------------------------------------------+
-  //
-  // +------------------------------------+------------------------------------+
-  // | User integer values                | Default integer values             |
-  // +-------+----------------------------+-------+----------------------------+
-  // | Index | Contents                   | Index | Contents                   |
-  // +-------+----------------------------+-------+----------------------------+
-  // |     0 | 16                         |     0 | 18                         |
-  // |     1 | 24                         |     1 |                            |
-  // |       |                            |     2 | 42                         |
-  // |       |                            |     3 | 12                         |
-  // |       |                            |     4 | 18                         |
-  // +-------+----------------------------+-------+----------------------------+
-  // | * Note: Tables are laid out sequentially in memory, but displayed       |
-  // |         here side-by-side for clarity.                                  |
-  // +-------------------------------------------------------------------------+
-  //
-  // +------------------------------------+------------------------------------+
-  // | User string values                 | Default string values              |
-  // +-------+----------------------------+-------+----------------------------+
-  // | Index | Contents[1]                | Index | Contents[1]                |
-  // +-------+----------------------------+-------+----------------------------+
-  // |     0 | V["hem", 0, 3]             |     0 | V["meh", 4, 3]             |
-  // |     1 | V["b", 8, 1]               |     1 |                            |
-  // |       |                            |     2 | V["a", 10, 1]              |
-  // |       |                            |     3 | V["foo", 12, 3]            |
-  // |       |                            |     4 | V["meh", 4, 3]             |
-  // |-------+----------------------------+-------+----------------------------+
-  // | [1]: Encoded as an offset into the value table and a length. Specified  |
-  // |      as V[string, offset, length] for clarity.                          |
-  // +-------------------------------------------------------------------------+
-  // | * Note: Tables are laid out sequentially in memory, but displayed       |
-  // |         here side-by-side for clarity.                                  |
-  // +-------------------------------------------------------------------------+
-  //
-  // +-------------------------------------------------------------------------+
-  // | Value strings:                                                          |
-  // +--------+----------------------------------------------------------------+
-  // | Offset | Value                                                          |
-  // +--------+----------------------------------------------------------------+
-  // |      0 | hem\0                                                          |
-  // |      4 | meh\0                                                          |
-  // |      8 | b\0                                                            |
-  // |     10 | a\0                                                            |
-  // |     12 | foo\0                                                          |
-  // +--------+----------------------------------------------------------------+
-  struct Header
-  {
-    // The number of entries in this map.
-    uint32_t mEntryCount;
-
-    // The StringTable data block for preference name strings, which act as keys
-    // in the map.
-    DataBlock mKeyStrings;
-
-    // The int32_t arrays of user and default int preference values. Entries in
-    // the map store their values as indices into these arrays.
-    DataBlock mUserIntValues;
-    DataBlock mDefaultIntValues;
-
-    // The StringTableEntry arrays of user and default string preference values.
-    //
-    // Strings are stored as StringTableEntry structs with character offsets
-    // into the mValueStrings string table and their corresponding lenghts.
-    //
-    // Entries in the map, likewise, store their string values as indices into
-    // these arrays.
-    DataBlock mUserStringValues;
-    DataBlock mDefaultStringValues;
-
-    // The StringTable data block for string preference values, referenced by
-    // the above two data blocks.
-    DataBlock mValueStrings;
-  };
-
-  using StringTableEntry = mozilla::dom::ipc::StringTableEntry;
-
-  // Represents a preference value, as either a pair of boolean values, or an
-  // index into one of the above value arrays.
-  union Value {
-    Value(bool aDefaultValue, bool aUserValue)
-      : mDefaultBool(aDefaultValue)
-      , mUserBool(aUserValue)
-    {
-    }
-
-    MOZ_IMPLICIT Value(uint16_t aIndex)
-      : mIndex(aIndex)
-    {
-    }
-
-    // The index of this entry in the value arrays.
-    //
-    // User and default preference values have the same indices in their
-    // respective arrays. However, entries without a user value are not
-    // guaranteed to have space allocated for them in the user value array, and
-    // likewise for preferences without default values in the default value
-    // array. This means that callers must only access value entries for entries
-    // which claim to have a value of that type.
-    uint16_t mIndex;
-    struct
-    {
-      bool mDefaultBool;
-      bool mUserBool;
-    };
-  };
-
-  // Represents a preference entry in the map, containing its name, type info,
-  // flags, and a reference to its value.
-  struct Entry
-  {
-    // A pointer to the preference name in the KeyTable string table.
-    StringTableEntry mKey;
-
-    // The preference's value, either as a pair of booleans, or an index into
-    // the value arrays. Please see the documentation for the Value struct
-    // above.
-    Value mValue;
-
-    // The preference's type, as a PrefType enum value. This must *never* be
-    // PrefType::None for values in a shared array.
-    uint8_t mType : 2;
-    // True if the preference has a default value. Callers must not attempt to
-    // access the entry's default value if this is false.
-    uint8_t mHasDefaultValue : 1;
-    // True if the preference has a user value. Callers must not attempt to
-    // access the entry's user value if this is false.
-    uint8_t mHasUserValue : 1;
-    // True if the preference is sticky, as defined by the preference service.
-    uint8_t mIsSticky : 1;
-    // True if the preference is locked, as defined by the preference service.
-    uint8_t mIsLocked : 1;
-  };
-
-public:
-  NS_INLINE_DECL_REFCOUNTING(SharedPrefMap)
-
-  // A temporary wrapper class for accessing entries in the array. Instances of
-  // this class are valid as long as SharedPrefMap instance is alive, but
-  // generally should not be stored long term, or allocated on the heap.
-  //
-  // The class is implemented as two pointers, one to the SharedPrefMap
-  // instance, and one to the Entry that corresponds to the preference, and is
-  // meant to be cheaply returned by value from preference lookups and
-  // iterators. All property accessors lazily fetch the appropriate values from
-  // the shared memory region.
-  class MOZ_STACK_CLASS Pref final
-  {
-  public:
-    const char* Name() const { return mMap->KeyTable().GetBare(mEntry->mKey); }
-
-    nsCString NameString() const { return mMap->KeyTable().Get(mEntry->mKey); }
-
-    PrefType Type() const
-    {
-      MOZ_ASSERT(PrefType(mEntry->mType) != PrefType::None);
-      return PrefType(mEntry->mType);
-    }
-
-    bool HasDefaultValue() const { return mEntry->mHasDefaultValue; }
-    bool HasUserValue() const { return mEntry->mHasUserValue; }
-    bool IsLocked() const { return mEntry->mIsLocked; }
-    bool IsSticky() const { return mEntry->mIsSticky; }
-
-    bool GetBoolValue(PrefValueKind aKind = PrefValueKind::User) const
-    {
-      MOZ_ASSERT(Type() == PrefType::Bool);
-      MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                                 : HasUserValue());
-
-      return aKind == PrefValueKind::Default ? mEntry->mValue.mDefaultBool
-                                             : mEntry->mValue.mUserBool;
-    }
-
-    int32_t GetIntValue(PrefValueKind aKind = PrefValueKind::User) const
-    {
-      MOZ_ASSERT(Type() == PrefType::Int);
-      MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                                 : HasUserValue());
-
-      return aKind == PrefValueKind::Default
-               ? mMap->DefaultIntValues()[mEntry->mValue.mIndex]
-               : mMap->UserIntValues()[mEntry->mValue.mIndex];
-    }
-
-  private:
-    const StringTableEntry& GetStringEntry(PrefValueKind aKind) const
-    {
-      MOZ_ASSERT(Type() == PrefType::String);
-      MOZ_ASSERT(aKind == PrefValueKind::Default ? HasDefaultValue()
-                                                 : HasUserValue());
-
-      return aKind == PrefValueKind::Default
-               ? mMap->DefaultStringValues()[mEntry->mValue.mIndex]
-               : mMap->UserStringValues()[mEntry->mValue.mIndex];
-    }
-
-  public:
-    nsCString GetStringValue(PrefValueKind aKind = PrefValueKind::User) const
-    {
-      return mMap->ValueTable().Get(GetStringEntry(aKind));
-    }
-
-    const char* GetBareStringValue(
-      PrefValueKind aKind = PrefValueKind::User) const
-    {
-      return mMap->ValueTable().GetBare(GetStringEntry(aKind));
-    }
-
-    // Returns the entry's index in the map, as understood by GetKeyAt() and
-    // GetValueAt().
-    size_t Index() const { return mEntry - mMap->Entries().get(); }
-
-    bool operator==(const Pref& aPref) const { return mEntry == aPref.mEntry; }
-    bool operator!=(const Pref& aPref) const { return !(*this == aPref); }
-
-    // This is odd, but necessary in order for the C++ range iterator protocol
-    // to work here.
-    Pref& operator*() { return *this; }
-
-    // Updates this wrapper to point to the next entry in the map. This should
-    // not be attempted unless Index() is less than the map's Count().
-    Pref& operator++()
-    {
-      mEntry++;
-      return *this;
-    }
-
-    Pref(const Pref& aPref) = default;
-
-  protected:
-    friend class SharedPrefMap;
-
-    Pref(const SharedPrefMap* aPrefMap, const Entry* aEntry)
-      : mMap(aPrefMap)
-      , mEntry(aEntry)
-    {
-    }
-
-  private:
-    const SharedPrefMap* const mMap;
-    const Entry* mEntry;
-  };
-
-  // Note: These constructors are infallible, because the preference database is
-  // critical to platform functionality, and we cannot operate without it.
-  SharedPrefMap(const FileDescriptor&, size_t);
-  explicit SharedPrefMap(SharedPrefMapBuilder&&);
-
-  // Searches for the given preference in the map, and returns true if it
-  // exists.
-  bool Has(const char* aKey) const;
-
-  bool Has(const nsCString& aKey) const { return Has(aKey.get()); }
-
-  // Searches for the given preference in the map, and if it exists, returns
-  // a Some<Pref> containing its details.
-  Maybe<const Pref> Get(const char* aKey) const;
-
-  Maybe<const Pref> Get(const nsCString& aKey) const { return Get(aKey.get()); }
-
-private:
-  // Searches for an entry for the given key. If found, returns true, and
-  // places its index in the entry array in aIndex.
-  bool Find(const char* aKey, size_t* aIndex) const;
-
-public:
-  // Returns the number of entries in the map.
-  uint32_t Count() const { return EntryCount(); }
-
-  // Returns the string entry at the given index. Keys are guaranteed to be
-  // sorted lexicographically.
-  //
-  // The given index *must* be less than the value returned by Count().
-  //
-  // The returned value is a literal string which references the mapped memory
-  // region.
-  nsCString GetKeyAt(uint32_t aIndex) const
-  {
-    MOZ_ASSERT(aIndex < Count());
-    return KeyTable().Get(Entries()[aIndex].mKey);
-  }
-
-  // Returns the value for the entry at the given index.
-  //
-  // The given index *must* be less than the value returned by Count().
-  //
-  // The returned value is valid for the lifetime of this map instance.
-  const Pref GetValueAt(uint32_t aIndex) const
-  {
-    MOZ_ASSERT(aIndex < Count());
-    return UncheckedGetValueAt(aIndex);
-  }
-
-private:
-  // Returns a wrapper with a pointer to an entry without checking its bounds.
-  // This should only be used by range iterators, to check their end positions.
-  //
-  // Note: In debug builds, the RangePtr returned by entries will still assert
-  // that aIndex is no more than 1 past the last element in the array, since it
-  // also takes into account the ranged iteration use case.
-  Pref UncheckedGetValueAt(uint32_t aIndex) const
-  {
-    return { this, (Entries() + aIndex).get() };
-  }
-
-public:
-  // C++ range iterator protocol. begin() and end() return references to the
-  // first and last entries in the array. The begin wrapper can be incremented
-  // until it matches the last element in the array, at which point it becomes
-  // invalid and the iteration is over.
-  Pref begin() const { return UncheckedGetValueAt(0); }
-  Pref end() const { return UncheckedGetValueAt(Count()); }
-
-  // A cosmetic helper for range iteration. Returns a reference value from a
-  // pointer to this instance so that its .begin() and .end() methods can be
-  // accessed in a ranged for loop. `map->Iter()` is equivalent to `*map`, but
-  // makes its purpose slightly clearer.
-  const SharedPrefMap& Iter() const { return *this; }
-
-  // Returns a copy of the read-only file descriptor which backs the shared
-  // memory region for this map. The file descriptor may be passed between
-  // processes, and used to construct new instances of SharedPrefMap with
-  // the same data as this instance.
-  FileDescriptor CloneFileDescriptor() const;
-
-  // Returns the size of the mapped memory region. This size must be passed to
-  // the constructor when mapping the shared region in another process.
-  size_t MapSize() const { return mMap.size(); }
-
-protected:
-  ~SharedPrefMap() = default;
-
-private:
-  template<typename T>
-  using StringTable = mozilla::dom::ipc::StringTable<T>;
-
-  // Type-safe getters for values in the shared memory region:
-  const Header& GetHeader() const { return mMap.get<Header>()[0]; }
-
-  RangedPtr<const Entry> Entries() const
-  {
-    return { reinterpret_cast<const Entry*>(&GetHeader() + 1), EntryCount() };
-  }
-
-  uint32_t EntryCount() const { return GetHeader().mEntryCount; }
-
-  template<typename T>
-  RangedPtr<const T> GetBlock(const DataBlock& aBlock) const
-  {
-    return RangedPtr<uint8_t>(&mMap.get<uint8_t>()[aBlock.mOffset],
-                              aBlock.mSize)
-      .ReinterpretCast<const T>();
-  }
-
-  RangedPtr<const int32_t> DefaultIntValues() const
-  {
-    return GetBlock<int32_t>(GetHeader().mDefaultIntValues);
-  }
-  RangedPtr<const int32_t> UserIntValues() const
-  {
-    return GetBlock<int32_t>(GetHeader().mUserIntValues);
-  }
-
-  RangedPtr<const StringTableEntry> DefaultStringValues() const
-  {
-    return GetBlock<StringTableEntry>(GetHeader().mDefaultStringValues);
-  }
-  RangedPtr<const StringTableEntry> UserStringValues() const
-  {
-    return GetBlock<StringTableEntry>(GetHeader().mUserStringValues);
-  }
-
-  StringTable<nsCString> KeyTable() const
-  {
-    auto& block = GetHeader().mKeyStrings;
-    return { { &mMap.get<uint8_t>()[block.mOffset], block.mSize } };
-  }
-
-  StringTable<nsCString> ValueTable() const
-  {
-    auto& block = GetHeader().mValueStrings;
-    return { { &mMap.get<uint8_t>()[block.mOffset], block.mSize } };
-  }
-
-  loader::AutoMemMap mMap;
-};
-
-// A helper class which builds the contiguous look-up table used by
-// SharedPrefMap. Each preference in the final map is added to the builder,
-// before it is finalized and transformed into a read-only snapshot.
-class MOZ_RAII SharedPrefMapBuilder
-{
-public:
-  SharedPrefMapBuilder() = default;
-
-  // The set of flags for the preference, as documented in SharedPrefMap::Entry.
-  struct Flags
-  {
-    uint8_t mHasDefaultValue : 1;
-    uint8_t mHasUserValue : 1;
-    uint8_t mIsSticky : 1;
-    uint8_t mIsLocked : 1;
-  };
-
-  void Add(const char* aKey,
-           const Flags& aFlags,
-           bool aDefaultValue,
-           bool aUserValue);
-
-  void Add(const char* aKey,
-           const Flags& aFlags,
-           int32_t aDefaultValue,
-           int32_t aUserValue);
-
-  void Add(const char* aKey,
-           const Flags& aFlags,
-           const nsCString& aDefaultValue,
-           const nsCString& aUserValue);
-
-  // Finalizes the binary representation of the map, writes it to a shared
-  // memory region, and then initializes the given AutoMemMap with a reference
-  // to the read-only copy of it.
-  //
-  // This should generally not be used directly by callers. The
-  // SharedPrefMapBuilder instance should instead be passed to the SharedPrefMap
-  // constructor as a move reference.
-  Result<Ok, nsresult> Finalize(loader::AutoMemMap& aMap);
-
-private:
-  using StringTableEntry = mozilla::dom::ipc::StringTableEntry;
-  template<typename T, typename U>
-  using StringTableBuilder = mozilla::dom::ipc::StringTableBuilder<T, U>;
-
-  // An opaque descriptor of the index of a preference entry in a value array,
-  // which can be converted numeric index after the ValueTableBuilder is
-  // finalized.
-  struct ValueIdx
-  {
-    // The relative index of the entry, based on its class. Entries for
-    // preferences with user values appear at the value arrays. Entries with
-    // only default values begin after the last entry with a user value.
-    uint16_t mIndex;
-    bool mHasUserValue;
-  };
-
-  // A helper class for building default and user value arrays for preferences.
-  //
-  // As described in the SharedPrefMap class, this helper optimizes the way that
-  // it builds its value arrays, in that:
-  //
-  // - It stores value entries for all preferences with user values before
-  //   entries for preferences with only default values, and allocates no
-  //   entries for preferences with only default values in the user value array.
-  //   Since most preferences have only default values, this dramatically
-  //   reduces the space required for value storage.
-  //
-  // - For preferences with only default values, it de-duplicates value entries,
-  //   and returns the same indices for all preferences with the same value.
-  //
-  // One important complication of this approach is that it means we cannot know
-  // the final index of any entry with only a default value until all entries
-  // have been added to the builder, since it depends on the final number of
-  // user entries in the output.
-  //
-  // To deal with this, when entries are added, we return an opaque ValueIndex
-  // struct, from which we can calculate the final index after the map has been
-  // finalized.
-  template<typename HashKey, typename ValueType_>
-  class ValueTableBuilder
-  {
-  public:
-    using ValueType = ValueType_;
-
-    // Adds an entry for a preference with only a default value to the array,
-    // and returns an opaque descriptor for its index.
-    ValueIdx Add(const ValueType& aDefaultValue)
-    {
-      auto index = uint16_t(mDefaultEntries.Count());
-
-      auto entry = mDefaultEntries.LookupForAdd(aDefaultValue).OrInsert([&]() {
-        return Entry{ index, false, aDefaultValue };
-      });
-
-      return { entry.mIndex, false };
-    }
-
-    // Adds an entry for a preference with a user value to the array. Regardless
-    // of whether the preference has a default value, space must be allocated
-    // for it. For preferences with no default value, the actual value which
-    // appears in the array at its value index is ignored.
-    ValueIdx Add(const ValueType& aDefaultValue, const ValueType& aUserValue)
-    {
-      auto index = uint16_t(mUserEntries.Length());
-
-      mUserEntries.AppendElement(
-        Entry{ index, true, aDefaultValue, aUserValue });
-
-      return { index, true };
-    }
-
-    // Returns the final index for an entry based on its opaque index
-    // descriptor. This must only be called after the caller has finished adding
-    // entries to the builder.
-    uint16_t GetIndex(const ValueIdx& aIndex) const
-    {
-      uint16_t base = aIndex.mHasUserValue ? 0 : UserCount();
-      return base + aIndex.mIndex;
-    }
-
-    // Writes out the array of default values at the block beginning at the
-    // given pointer. The block must be at least as large as the value returned
-    // by DefaultSize().
-    void WriteDefaultValues(const RangedPtr<uint8_t>& aBuffer) const
-    {
-      auto buffer = aBuffer.ReinterpretCast<ValueType>();
-
-      for (const auto& entry : mUserEntries) {
-        buffer[entry.mIndex] = entry.mDefaultValue;
-      }
-
-      size_t defaultsOffset = UserCount();
-      for (auto iter = mDefaultEntries.ConstIter(); !iter.Done(); iter.Next()) {
-        const auto& entry = iter.Data();
-        buffer[defaultsOffset + entry.mIndex] = entry.mDefaultValue;
-      }
-    }
-
-    // Writes out the array of user values at the block beginning at the
-    // given pointer. The block must be at least as large as the value returned
-    // by UserSize().
-    void WriteUserValues(const RangedPtr<uint8_t>& aBuffer) const
-    {
-      auto buffer = aBuffer.ReinterpretCast<ValueType>();
-
-      for (const auto& entry : mUserEntries) {
-        buffer[entry.mIndex] = entry.mUserValue;
-      }
-    }
-
-    // These return the number of entries in the default and user value arrays,
-    // respectively.
-    uint32_t DefaultCount() const
-    {
-      return UserCount() + mDefaultEntries.Count();
-    }
-    uint32_t UserCount() const { return mUserEntries.Length(); }
-
-    // These return the byte sizes of the default and user value arrays,
-    // respectively.
-    uint32_t DefaultSize() const { return DefaultCount() * sizeof(ValueType); }
-    uint32_t UserSize() const { return UserCount() * sizeof(ValueType); }
-
-    void Clear()
-    {
-      mUserEntries.Clear();
-      mDefaultEntries.Clear();
-    }
-
-    static constexpr size_t Alignment() { return alignof(ValueType); }
-
-  private:
-    struct Entry
-    {
-      uint16_t mIndex;
-      bool mHasUserValue;
-      ValueType mDefaultValue;
-      ValueType mUserValue{};
-    };
-
-    AutoTArray<Entry, 256> mUserEntries;
-
-    nsDataHashtable<HashKey, Entry> mDefaultEntries;
-  };
-
-  // A special-purpose string table builder for keys which are already
-  // guaranteed to be unique. Duplicate values will not be detected or
-  // de-duplicated.
-  template<typename CharType>
-  class UniqueStringTableBuilder
-  {
-  public:
-    using ElemType = CharType;
-
-    explicit UniqueStringTableBuilder(size_t aCapacity)
-      : mEntries(aCapacity)
-    {
-    }
-
-    StringTableEntry Add(const CharType* aKey)
-    {
-      auto entry =
-        mEntries.AppendElement(Entry{ mSize, uint32_t(strlen(aKey)), aKey });
-
-      mSize += entry->mLength + 1;
-
-      return { entry->mOffset, entry->mLength };
-    }
-
-    void Write(const RangedPtr<uint8_t>& aBuffer)
-    {
-      auto buffer = aBuffer.ReinterpretCast<ElemType>();
-
-      for (auto& entry : mEntries) {
-        memcpy(&buffer[entry.mOffset],
-               entry.mValue,
-               sizeof(ElemType) * (entry.mLength + 1));
-      }
-    }
-
-    uint32_t Count() const { return mEntries.Length(); }
-
-    uint32_t Size() const { return mSize * sizeof(ElemType); }
-
-    void Clear() { mEntries.Clear(); }
-
-    static constexpr size_t Alignment() { return alignof(ElemType); }
-
-  private:
-    struct Entry
-    {
-      uint32_t mOffset;
-      uint32_t mLength;
-      const CharType* mValue;
-    };
-
-    nsTArray<Entry> mEntries;
-    uint32_t mSize = 0;
-  };
-
-  // A preference value entry, roughly corresponding to the
-  // SharedPrefMap::Value struct, but with a temporary place-holder value rather
-  // than a final value index.
-  union Value {
-    Value(bool aDefaultValue, bool aUserValue)
-      : mDefaultBool(aDefaultValue)
-      , mUserBool(aUserValue)
-    {
-    }
-
-    MOZ_IMPLICIT Value(const ValueIdx& aIndex)
-      : mIndex(aIndex)
-    {
-    }
-
-    // For Bool preferences, their default and user bool values.
-    struct
-    {
-      bool mDefaultBool;
-      bool mUserBool;
-    };
-    // For Int and String preferences, an opaque descriptor for their entries in
-    // their value arrays. This must be passed to the appropriate
-    // ValueTableBuilder to obtain the final index when the entry is serialized.
-    ValueIdx mIndex;
-  };
-
-  // A preference entry, to be converted to a SharedPrefMap::Entry struct during
-  // serialization.
-  struct Entry
-  {
-    // The entry's preference name, as passed to Add(). The caller is
-    // responsible for keeping this pointer alive until the builder is
-    // finalized.
-    const char* mKeyString;
-    // The entry in mKeyTable corresponding to mKeyString.
-    StringTableEntry mKey;
-    Value mValue;
-
-    uint8_t mType : 2;
-    uint8_t mHasDefaultValue : 1;
-    uint8_t mHasUserValue : 1;
-    uint8_t mIsSticky : 1;
-    uint8_t mIsLocked : 1;
-  };
-
-  // Converts a builder Value struct to a SharedPrefMap::Value struct for
-  // serialization. This must not be called before callers have finished adding
-  // entries to the value array builders.
-  SharedPrefMap::Value GetValue(const Entry& aEntry) const
-  {
-    switch (PrefType(aEntry.mType)) {
-      case PrefType::Bool:
-        return { aEntry.mValue.mDefaultBool, aEntry.mValue.mUserBool };
-      case PrefType::Int:
-        return { mIntValueTable.GetIndex(aEntry.mValue.mIndex) };
-      case PrefType::String:
-        return { mStringValueTable.GetIndex(aEntry.mValue.mIndex) };
-      default:
-        MOZ_ASSERT_UNREACHABLE("Invalid pref type");
-        return { false, false };
-    }
-  }
-
-  UniqueStringTableBuilder<char> mKeyTable{ kExpectedPrefCount };
-  StringTableBuilder<nsCStringHashKey, nsCString> mValueStringTable;
-
-  ValueTableBuilder<nsUint32HashKey, uint32_t> mIntValueTable;
-  ValueTableBuilder<nsGenericHashKey<StringTableEntry>, StringTableEntry>
-    mStringValueTable;
-
-  nsTArray<Entry> mEntries{ kExpectedPrefCount };
-};
-
-} // mozilla
-
-#endif // dom_ipc_SharedPrefMap_h
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -27,17 +27,16 @@ XPIDL_MODULE = 'pref'
 EXPORTS.mozilla += [
     'init/StaticPrefList.h',
     'Preferences.h',
     'StaticPrefs.h',
 ]
 
 UNIFIED_SOURCES += [
     'Preferences.cpp',
-    'SharedPrefMap.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 DEFINES['OS_ARCH'] = CONFIG['OS_ARCH']
 DEFINES['MOZ_WIDGET_TOOLKIT'] = CONFIG['MOZ_WIDGET_TOOLKIT']
--- a/modules/libpref/nsIPrefService.idl
+++ b/modules/libpref/nsIPrefService.idl
@@ -10,17 +10,17 @@ interface nsIFile;
 
 /**
  * A helper function for reading access statistics for preferences.
  * See nsIPrefService.readStats for more details.
  */
 [function, scriptable, uuid(c3f0cedc-e244-4316-b33a-80306a1c35a1)]
 interface nsIPrefStatsCallback : nsISupports
 {
-  void visit(in ACString prefName, in unsigned long accessCount);
+  void visit(in string prefName, in unsigned long accessCount);
 };
 
 /**
  * The nsIPrefService interface is the main entry point into the back end
  * preferences management library. The preference service is directly
  * responsible for the management of the preferences files and also facilitates
  * access to the preference branch object which allows the direct manipulation
  * of the preferences themselves.
--- a/modules/libpref/test/unit/test_libPrefs.js
+++ b/modules/libpref/test/unit/test_libPrefs.js
@@ -230,19 +230,19 @@ function run_test() {
   Assert.ok(pb1.prefHasUserValue("DefaultPref.char"));
   Assert.equal(ps.getCharPref("DefaultPref.char"), "_user"); 
 
   //**************************************************************************//
   // pref Locking/Unlocking tests
 
   // locking and unlocking a nonexistent pref should throw
   do_check_throws(function() {
-    ps.lockPref("DefaultPref.nonexistent");}, Cr.NS_ERROR_ILLEGAL_VALUE);
+    ps.lockPref("DefaultPref.nonexistent");}, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
-    ps.unlockPref("DefaultPref.nonexistent");}, Cr.NS_ERROR_ILLEGAL_VALUE);
+    ps.unlockPref("DefaultPref.nonexistent");}, Cr.NS_ERROR_UNEXPECTED);
 
   // getting a locked pref branch should return the "default" value
   Assert.ok(!ps.prefIsLocked("DefaultPref.char"));
   ps.lockPref("DefaultPref.char");
   Assert.equal(ps.getCharPref("DefaultPref.char"), "_default"); 
   Assert.ok(ps.prefIsLocked("DefaultPref.char"));
 
   // getting an unlocked pref branch should return the "user" value 
--- a/modules/libpref/test/unit_ipc/test_large_pref.js
+++ b/modules/libpref/test/unit_ipc/test_large_pref.js
@@ -47,24 +47,16 @@ function expectedPrefValue(def, user) {
 
 function run_test() {
   let pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
   let ps = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
   let defaultBranch = ps.getDefaultBranch("");
 
   let isParent = isParentProcess();
   if (isParent) {
-    // Preferences with large values will still appear in the shared memory
-    // snapshot that we share with all processes. They should not, however, be
-    // sent with the list of changes on top of the snapshot.
-    //
-    // So, make sure we've generated the initial snapshot before we set the
-    // preference values by launching a child process with an empty test.
-    sendCommand("");
-
     // Set all combinations of none, small and large, for default and user prefs.
     for (let def of testValues) {
       for (let user of testValues) {
         let currPref = prefName(def, user);
         if (def.value) {
           defaultBranch.setCharPref(currPref, def.value);
         }
         if (user.value) {
@@ -85,18 +77,18 @@ function run_test() {
       let pref_name = prefName(def, user);
       if (isParent || (def.name != "Large" && user.name != "Large")) {
         Assert.equal(pb.getCharPref(pref_name), expectedPrefValue(def, user));
       } else {
         // This is the child, and either the default or user value is
         // large, so the preference should not be set.
         let prefExists;
         try {
-          let val = pb.getCharPref(pref_name);
-          prefExists = val.length > 128;
+          pb.getCharPref(pref_name);
+          prefExists = true;
         } catch(e) {
           prefExists = false;
         }
         ok(!prefExists,
            "Pref " + pref_name + " should not be set in the child");
       }
     }
   }
deleted file mode 100644
--- a/modules/libpref/test/unit_ipc/test_sharedMap.js
+++ /dev/null
@@ -1,302 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
-
-// This file tests the functionality of the preference service when using a
-// shared memory snapshot. In this configuration, a snapshot of the initial
-// state of the preferences database is made when we first spawn a child
-// process, and changes after that point are stored as entries in a dynamic hash
-// table, on top of the snapshot.
-
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://testing-common/ExtensionXPCShellUtils.jsm");
-
-ExtensionTestUtils.init(this);
-
-let contentPage;
-
-const {prefs} = Services;
-const defaultPrefs = prefs.getDefaultBranch("");
-
-const FRAME_SCRIPT_INIT = `
-  ChromeUtils.import("resource://gre/modules/Services.jsm");
-  const {prefs} = Services;
-  const defaultPrefs = prefs.getDefaultBranch("");
-`;
-
-function try_(fn) {
-  try {
-    return fn();
-  } catch (e) {
-    return undefined;
-  }
-}
-
-function getPref(pref) {
-  let flags = {
-    locked: try_(() => prefs.prefIsLocked(pref)),
-    hasUser: try_(() => prefs.prefHasUserValue(pref)),
-  };
-
-  switch (prefs.getPrefType(pref)) {
-    case prefs.PREF_INT:
-      return {
-        ...flags,
-        type: "Int",
-        user: try_(() => prefs.getIntPref(pref)),
-        default: try_(() => defaultPrefs.getIntPref(pref)),
-      };
-    case prefs.PREF_BOOL:
-      return {
-        ...flags,
-        type: "Bool",
-        user: try_(() => prefs.getBoolPref(pref)),
-        default: try_(() => defaultPrefs.getBoolPref(pref)),
-      };
-    case prefs.PREF_STRING:
-      return {
-        ...flags,
-        type: "String",
-        user: try_(() => prefs.getStringPref(pref)),
-        default: try_(() => defaultPrefs.getStringPref(pref)),
-      };
-  }
-  return {};
-}
-
-function getPrefs(prefNames) {
-  let result = {};
-  for (let pref of prefNames) {
-    result[pref] = getPref(pref);
-  }
-  result.childList = prefs.getChildList("");
-  return result;
-}
-
-function checkPref(pref, proc, val, type, userVal, defaultVal, expectedFlags = {}) {
-  info(`Check "${pref}" ${proc} value`);
-
-  equal(val.type, type, `Expected type for "${pref}"`);
-  equal(val.user, userVal, `Expected user value for "${pref}"`);
-
-  // We only send changes to the content process when they'll make a visible
-  // difference, so ignore content process default values when we have a defined
-  // user value.
-  if (proc !== "content" || val.user === undefined) {
-    equal(val.default, defaultVal, `Expected default value for "${pref}"`);
-  }
-
-  for (let [flag, value] of Object.entries(expectedFlags)) {
-    equal(val[flag], value, `Expected ${flag} value for "${pref}"`);
-  }
-}
-
-function getPrefList() {
-  return prefs.getChildList("");
-}
-
-const TESTS = {
-  "exists.thenDoesNot": {
-    beforeContent(PREF) {
-      prefs.setBoolPref(PREF, true);
-
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-    },
-    contentStartup(PREF, val, childList) {
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-      ok(childList.includes(PREF), `Child list includes "${PREF}"`);
-
-      prefs.clearUserPref(PREF);
-      ok(!getPrefList().includes(PREF), `Parent list doesn't include "${PREF}"`);
-    },
-    contentUpdate1(PREF, val, childList) {
-      ok(!getPrefList().includes(PREF), `Parent list doesn't include "${PREF}"`);
-      ok(!childList.includes(PREF), `Child list doesn't include "${PREF}"`);
-
-      prefs.setCharPref(PREF, "foo");
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-      checkPref(PREF, "parent", getPref(PREF), "String", "foo");
-    },
-    contentUpdate2(PREF, val, childList) {
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-      ok(childList.includes(PREF), `Child list includes "${PREF}"`);
-
-      checkPref(PREF, "parent", getPref(PREF), "String", "foo");
-      checkPref(PREF, "child", val, "String", "foo");
-    },
-  },
-  "doesNotExists.thenDoes": {
-    contentStartup(PREF, val, childList) {
-      ok(!getPrefList().includes(PREF), `Parent list doesn't include "${PREF}"`);
-      ok(!childList.includes(PREF), `Child list doesn't include "${PREF}"`);
-
-      prefs.setIntPref(PREF, 42);
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-    },
-    contentUpdate1(PREF, val, childList) {
-      ok(getPrefList().includes(PREF), `Parent list includes "${PREF}"`);
-      ok(childList.includes(PREF), `Child list includes "${PREF}"`);
-
-      checkPref(PREF, "parent", getPref(PREF), "Int", 42);
-      checkPref(PREF, "child", val, "Int", 42);
-    },
-  },
-};
-
-const PREFS = [
-  {type: "Bool", values: [true, false, true]},
-  {type: "Int", values: [24, 42, 73]},
-  {type: "String", values: ["meh", "hem", "hrm"]},
-];
-
-for (let {type, values} of PREFS) {
-  let set = `set${type}Pref`;
-  let get = `get${type}Pref`;
-
-  function prefTest(opts) {
-    function check(pref, proc, val, {expectedVal, defaultVal = undefined, expectedDefault = defaultVal, expectedFlags = {}}) {
-      checkPref(pref, proc, val, type, expectedVal, expectedDefault, expectedFlags);
-    }
-
-    function updatePref(PREF,
-                        {userVal = undefined,
-                         defaultVal = undefined,
-                         flags = {}}) {
-      info(`Update "${PREF}"`);
-      if (userVal !== undefined) {
-        prefs[set](PREF, userVal);
-      }
-      if (defaultVal !== undefined) {
-        defaultPrefs[set](PREF, defaultVal);
-      }
-      if (flags.locked === true) {
-        prefs.lockPref(PREF);
-      } else if (flags.locked === false) {
-        prefs.unlockPref(PREF);
-      }
-    }
-
-    return {
-      beforeContent(PREF) {
-        updatePref(PREF, opts.initial)
-        check(PREF, "parent", getPref(PREF), opts.initial);
-      },
-      contentStartup(PREF, contentVal) {
-        check(PREF, "content", contentVal, opts.initial);
-        check(PREF, "parent", getPref(PREF), opts.initial);
-
-        updatePref(PREF, opts.change1)
-        check(PREF, "parent", getPref(PREF), opts.change1);
-      },
-      contentUpdate1(PREF, contentVal) {
-        check(PREF, "content", contentVal, opts.change1);
-        check(PREF, "parent", getPref(PREF), opts.change1);
-
-        if (opts.change2) {
-          updatePref(PREF, opts.change2)
-          check(PREF, "parent", getPref(PREF), opts.change2);
-        }
-      },
-      contentUpdate2(PREF, contentVal) {
-        if (opts.change2) {
-          check(PREF, "content", contentVal, opts.change2);
-          check(PREF, "parent", getPref(PREF), opts.change2);
-        }
-      },
-    };
-  }
-
-  for (let i of [0, 1]) {
-    let userVal = values[i];
-    let defaultVal = values[+!i];
-
-    TESTS[`type.${type}.${i}.default`] = prefTest({
-      initial: {defaultVal, expectedVal: defaultVal},
-      change1: {defaultVal: values[2], expectedVal: values[2]},
-    });
-
-    TESTS[`type.${type}.${i}.user`] = prefTest({
-      initial: {userVal, expectedVal: userVal},
-      change1: {defaultVal: values[2], expectedVal: userVal},
-      change2: {userVal: values[2],
-                expectedDefault: values[2],
-                expectedVal: values[2]},
-    });
-
-    TESTS[`type.${type}.${i}.both`] = prefTest({
-      initial: {userVal, defaultVal, expectedVal: userVal},
-      change1: {defaultVal: values[2], expectedVal: userVal},
-      change2: {userVal: values[2],
-                expectedDefault: values[2],
-                expectedVal: values[2]},
-    });
-
-    TESTS[`type.${type}.${i}.both.thenLock`] = prefTest({
-      initial: {userVal, defaultVal, expectedVal: userVal},
-      change1: {expectedDefault: defaultVal,
-                expectedVal: defaultVal,
-                flags: {locked: true},
-                expectFlags: {locked: true}},
-    });
-
-    TESTS[`type.${type}.${i}.both.thenUnlock`] = prefTest({
-      initial: {userVal, defaultVal, expectedVal: defaultVal,
-                flags: {locked: true}, expectedFlags: {locked: true}},
-      change1: {expectedDefault: defaultVal,
-                expectedVal: userVal,
-                flags: {locked: false},
-                expectFlags: {locked: false}},
-    });
-
-    TESTS[`type.${type}.${i}.both.locked`] = prefTest({
-      initial: {userVal, defaultVal, expectedVal: defaultVal,
-                flags: {locked: true}, expectedFlags: {locked: true}},
-      change1: {userVal: values[2],
-                expectedDefault: defaultVal,
-                expectedVal: defaultVal,
-                expectedFlags: {locked: true}},
-      change2: {defaultVal: values[2],
-                expectedDefault: defaultVal,
-                expectedVal: defaultVal,
-                expectedFlags: {locked: true}},
-    });
-  }
-}
-
-add_task(async function test_sharedMap_prefs() {
-  let prefValues = {};
-
-  async function runChecks(op) {
-    for (let [pref, ops] of Object.entries(TESTS)) {
-      if (ops[op]) {
-        info(`Running ${op} for "${pref}"`);
-        await ops[op](pref,
-                      prefValues[pref] || undefined,
-                      prefValues.childList || undefined);
-      }
-    }
-  }
-
-  await runChecks("beforeContent");
-
-  contentPage = await ExtensionTestUtils.loadContentPage("about:blank", {remote: true});
-  registerCleanupFunction(() => contentPage.close());
-
-  contentPage.addFrameScriptHelper(FRAME_SCRIPT_INIT);
-  contentPage.addFrameScriptHelper(try_);
-  contentPage.addFrameScriptHelper(getPref);
-
-  let prefNames = Object.keys(TESTS);
-  prefValues = await contentPage.spawn(prefNames, getPrefs);
-
-  await runChecks("contentStartup");
-
-  prefValues = await contentPage.spawn(prefNames, getPrefs);
-
-  await runChecks("contentUpdate1");
-
-  prefValues = await contentPage.spawn(prefNames, getPrefs);
-
-  await runChecks("contentUpdate2");
-});
--- a/modules/libpref/test/unit_ipc/xpcshell.ini
+++ b/modules/libpref/test/unit_ipc/xpcshell.ini
@@ -3,10 +3,9 @@ head =
 skip-if = toolkit == 'android'
 
 [test_existing_prefs.js]
 [test_initial_prefs.js]
 [test_large_pref.js]
 [test_locked_prefs.js]
 [test_observed_prefs.js]
 [test_update_prefs.js]
-[test_sharedMap.js]
 [test_user_default_prefs.js]
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -388,32 +388,32 @@ FreeArgv(char** argv, int argc)
   for (int ix=0; ix < argc; ix++) {
     // String was allocated with strndup, so need to use free to deallocate.
     free(argv[ix]);
   }
   delete[](argv);
 }
 
 extern "C" APKOPEN_EXPORT void MOZ_JNICALL
-Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv *jenv, jclass jc, jobjectArray jargs, int prefsFd, int prefMapFd, int ipcFd, int crashFd, int crashAnnotationFd)
+Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv *jenv, jclass jc, jobjectArray jargs, int prefsFd, int ipcFd, int crashFd, int crashAnnotationFd)
 {
   int argc = 0;
   char** argv = CreateArgvFromObjectArray(jenv, jargs, &argc);
 
   if (ipcFd < 0) {
     if (gBootstrap == nullptr) {
       FreeArgv(argv, argc);
       return;
     }
 
     ElfLoader::Singleton.ExpectShutdown(false);
     gBootstrap->GeckoStart(jenv, argv, argc, sAppData);
     ElfLoader::Singleton.ExpectShutdown(true);
   } else {
-    gBootstrap->XRE_SetAndroidChildFds(jenv, { prefsFd, prefMapFd, ipcFd, crashFd, crashAnnotationFd });
+    gBootstrap->XRE_SetAndroidChildFds(jenv, prefsFd, ipcFd, crashFd, crashAnnotationFd);
     gBootstrap->XRE_SetProcessType(argv[argc - 1]);
 
     XREChildData childData;
     gBootstrap->XRE_InitChildProcess(argc - 1, argv, &childData);
   }
 
   gBootstrap.reset();
   FreeArgv(argv, argc);
--- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
+++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
@@ -162,21 +162,16 @@ class ContentPage {
     return MessageChannel.sendMessage(this.browser.messageManager, msg, data);
   }
 
   loadFrameScript(func) {
     let frameScript = `data:text/javascript,(${encodeURI(func)}).call(this)`;
     this.browser.messageManager.loadFrameScript(frameScript, true);
   }
 
-  addFrameScriptHelper(func) {
-    let frameScript = `data:text/javascript,${encodeURI(func)}`;
-    this.browser.messageManager.loadFrameScript(frameScript, false, true);
-  }
-
   async loadURL(url, redirectUrl = undefined) {
     await this.browserReady;
 
     this.browser.loadURI(url);
     return promiseBrowserLoaded(this.browser, url, redirectUrl);
   }
 
   async fetch(url, options) {
--- a/toolkit/xre/Bootstrap.cpp
+++ b/toolkit/xre/Bootstrap.cpp
@@ -73,18 +73,18 @@ public:
     ::XRE_EnableSameExecutableForContentProc();
   }
 
 #ifdef MOZ_WIDGET_ANDROID
   virtual void GeckoStart(JNIEnv* aEnv, char** argv, int argc, const StaticXREAppData& aAppData) override {
     ::GeckoStart(aEnv, argv, argc, aAppData);
   }
 
-  virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, const XRE_AndroidChildFds& aFds) override {
-    ::XRE_SetAndroidChildFds(aEnv, aFds);
+  virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, int aPrefsFd, int aIPCFd, int aCrashFd, int aCrashAnnotationFd) override {
+    ::XRE_SetAndroidChildFds(aEnv, aPrefsFd, aIPCFd, aCrashFd, aCrashAnnotationFd);
   }
 #endif
 
 #ifdef LIBFUZZER
   virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) override {
     ::XRE_LibFuzzerSetDriver(aDriver);
   }
 #endif
--- a/toolkit/xre/Bootstrap.h
+++ b/toolkit/xre/Bootstrap.h
@@ -108,17 +108,17 @@ public:
 
   virtual nsresult XRE_InitChildProcess(int argc, char* argv[], const XREChildData* aChildData) = 0;
 
   virtual void XRE_EnableSameExecutableForContentProc() = 0;
 
 #ifdef MOZ_WIDGET_ANDROID
   virtual void GeckoStart(JNIEnv* aEnv, char** argv, int argc, const StaticXREAppData& aAppData) = 0;
 
-  virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, const XRE_AndroidChildFds& fds) = 0;
+  virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv, int aPrefsFd, int aIPCFd, int aCrashFd, int aCrashAnnotationFd) = 0;
 #endif
 
 #ifdef LIBFUZZER
   virtual void XRE_LibFuzzerSetDriver(LibFuzzerDriver aDriver) = 0;
 #endif
 
 #ifdef MOZ_IPDL_TESTS
   virtual int XRE_RunIPDLTest(int argc, char **argv) = 0;
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -239,24 +239,23 @@ XRE_ChildProcessTypeToString(GeckoProces
 namespace mozilla {
 namespace startup {
 GeckoProcessType sChildProcessType = GeckoProcessType_Default;
 } // namespace startup
 } // namespace mozilla
 
 #if defined(MOZ_WIDGET_ANDROID)
 void
-XRE_SetAndroidChildFds (JNIEnv* env, const XRE_AndroidChildFds& fds)
+XRE_SetAndroidChildFds (JNIEnv* env, int prefsFd, int ipcFd, int crashFd, int crashAnnotationFd)
 {
   mozilla::jni::SetGeckoThreadEnv(env);
-  mozilla::dom::SetPrefsFd(fds.mPrefsFd);
-  mozilla::dom::SetPrefMapFd(fds.mPrefMapFd);
-  IPC::Channel::SetClientChannelFd(fds.mIpcFd);
-  CrashReporter::SetNotificationPipeForChild(fds.mCrashFd);
-  CrashReporter::SetCrashAnnotationPipeForChild(fds.mCrashAnnotationFd);
+  mozilla::dom::SetPrefsFd(prefsFd);
+  IPC::Channel::SetClientChannelFd(ipcFd);
+  CrashReporter::SetNotificationPipeForChild(crashFd);
+  CrashReporter::SetCrashAnnotationPipeForChild(crashAnnotationFd);
 }
 #endif // defined(MOZ_WIDGET_ANDROID)
 
 void
 XRE_SetProcessType(const char* aProcessTypeString)
 {
   static bool called = false;
   if (called) {
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -392,27 +392,18 @@ static const char* const kGeckoProcessTy
 static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) ==
               GeckoProcessType_End,
               "Array length mismatch");
 
 XRE_API(const char*,
         XRE_ChildProcessTypeToString, (GeckoProcessType aProcessType))
 
 #if defined(MOZ_WIDGET_ANDROID)
-struct XRE_AndroidChildFds
-{
-  int mPrefsFd;
-  int mPrefMapFd;
-  int mIpcFd;
-  int mCrashFd;
-  int mCrashAnnotationFd;
-};
-
 XRE_API(void,
-        XRE_SetAndroidChildFds, (JNIEnv* env, const XRE_AndroidChildFds& fds))
+        XRE_SetAndroidChildFds, (JNIEnv* env, int prefsFd, int ipcFd, int crashFd, int crashAnnotationFd))
 #endif // defined(MOZ_WIDGET_ANDROID)
 
 XRE_API(void,
         XRE_SetProcessType, (const char* aProcessTypeString))
 
 // Used in the "master" parent process hosting the crash server
 XRE_API(bool,
         XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump,