Bug 1570575 - Remove `MirrorKind`. r=KrisWright
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 02 Aug 2019 06:31:05 +0000
changeset 485876 89b4edfa815032849012bbb7d24f980348201831
parent 485875 677bcc847e072dd2bfa98e1e50af6240c3a3e294
child 485877 0873eeda2c22179e0d3d347f2833d37eb5e43889
push id36377
push usercsabou@mozilla.com
push dateFri, 02 Aug 2019 15:59:52 +0000
treeherdermozilla-central@4391599b7268 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersKrisWright
bugs1570575
milestone70.0a1
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
Bug 1570575 - Remove `MirrorKind`. r=KrisWright This commit removes `MirrorKind` by splitting the `VARCACHE_PREF` macros in two, giving `ALWAYS_PREF` and `ONCE_PREF` macros. This is good because most of the time the generated code is quite different for the two cases. The commit also removes the examples of code produced by the macros in comments. These are kind of useful, but also quite verbose and a pain to maintain. Differential Revision: https://phabricator.services.mozilla.com/D40166
modules/libpref/Preferences.cpp
modules/libpref/StaticPrefsBase.h
modules/libpref/init/StaticPrefListBegin.h
modules/libpref/init/StaticPrefListEnd.h
modules/libpref/init/generate_static_pref_list.py
modules/libpref/test/test_generate_static_pref_list.py
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -4494,39 +4494,33 @@ Result<Ok, const char*> Preferences::Ini
   // Initialize static prefs before prefs from data files so that the latter
   // will override the former.
   StaticPrefs::InitAll(aIsStartup);
 
   if (!XRE_IsParentProcess()) {
     MOZ_DIAGNOSTIC_ASSERT(gSharedMap);
 
 #ifdef DEBUG
-    // For a VarCache pref like this:
-    //
-    //   VARCACHE_PREF($POLICY, "my.pref", my_pref, my_pref, int32_t, 99)
-    //
-    // we generate checking code like this:
-    //
-    //   MOZ_ASSERT(Internals::GetPref<int32_t>(name, value) ==
-    //              StaticPrefs::my_pref(),
-    //              "Incorrect cached value for my.pref");
-    //
-    // This checks that all VarCache preferences match their current values.
-    // This can currently fail if the default value of a static VarCache
-    // preference is changed in a preference file or at runtime, rather than in
-    // StaticPrefList*.h.
-    //
-#  define PREF(name, cpp_type, value)
-#  define VARCACHE_PREF(policy, name, base_id, full_id, cpp_type, value) \
+    // For mirrored prefs we generate code that checks the mirror variable
+    // matches the pref's current value. This can currently fail if the default
+    // value of a static VarCache preference is changed in a preference file or
+    // at runtime, rather than in StaticPrefList*.h.
+#  define NEVER_PREF(name, cpp_type, value)
+#  define ALWAYS_PREF(name, base_id, full_id, cpp_type, value)           \
     MOZ_ASSERT(Internals::GetPref<StripAtomic<cpp_type>>(name, value) == \
                    StaticPrefs::full_id(),                               \
                "Incorrect cached value for " name);
+#  define ONCE_PREF(name, base_id, full_id, cpp_type, value)                 \
+    MOZ_ASSERT(                                                              \
+        Internals::GetPref<cpp_type>(name, value) == StaticPrefs::full_id(), \
+        "Incorrect cached value for " name);
 #  include "mozilla/StaticPrefListAll.h"
-#  undef PREF
-#  undef VARCACHE_PREF
+#  undef NEVER_PREF
+#  undef ALWAYS_PREF
+#  undef ONCE_PREF
 #endif
 
     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
@@ -5366,35 +5360,31 @@ static void InitPref(const char* aName, 
 static void InitPref(const char* aName, uint32_t aDefaultValue) {
   InitPref_uint32_t(aName, aDefaultValue);
 }
 static void InitPref(const char* aName, float aDefaultValue) {
   InitPref_float(aName, aDefaultValue);
 }
 
 template <typename T>
-static void InitMirroredPref(StaticPrefs::MirrorKind aPolicy,
-                             const nsACString& aName, T* aCache,
-                             StripAtomic<T> aDefaultValue, bool aIsStartup,
-                             bool aIsParent) {
+static void InitAlwaysPref(const nsACString& aName, T* aCache,
+                           StripAtomic<T> aDefaultValue, bool aIsStartup,
+                           bool aIsParent) {
   // In the parent process, set/reset the pref value and the `always` mirror (if
   // there is one) to the default value.
   // - `once` mirrors will be initialized lazily in InitOncePrefs().
   // - In child processes, the parent sends the correct initial values via
   //   shared memory, so we do not re-initialize them here.
   if (aIsParent) {
     InitPref(PromiseFlatCString(aName).get(), aDefaultValue);
-    if (MOZ_LIKELY(aPolicy == StaticPrefs::MirrorKind::Always)) {
-      *aCache = aDefaultValue;
-    }
+    *aCache = aDefaultValue;
   }
 
   // At startup, setup the callback for the `always` mirror (if there is one).
-  if (MOZ_LIKELY(aPolicy == StaticPrefs::MirrorKind::Always) &&
-      MOZ_LIKELY(aIsStartup)) {
+  if (MOZ_LIKELY(aIsStartup)) {
     AddVarCacheNoAssignment(aCache, aName, aDefaultValue);
   }
 }
 
 static Atomic<bool> sOncePrefRead(false);
 static StaticMutex sOncePrefMutex;
 
 namespace StaticPrefs {
@@ -5413,121 +5403,99 @@ void MaybeInitOncePrefs() {
         "Preferences::MaybeInitOncePrefs", [&]() { InitOncePrefs(); });
     // This logic needs to run on the main thread
     SyncRunnable::DispatchToThread(
         SystemGroup::EventTargetFor(TaskCategory::Other), runnable);
   }
   sOncePrefRead = true;
 }
 
-// For a pref like this:
-//
-//   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-//
-// we generate a variable definition like this:
-//
-//   int32_t sVarCache_my_pref(99);
-//
-#define PREF(name, cpp_type, value)
-#define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, default_value) \
+// For mirrored prefs we generate a variable definition.
+#define NEVER_PREF(name, cpp_type, value)
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, default_value) \
+  cpp_type sVarCache_##full_id(default_value);
+#define ONCE_PREF(name, base_id, full_id, cpp_type, default_value) \
   cpp_type sVarCache_##full_id(default_value);
 #include "mozilla/StaticPrefListAll.h"
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 
 static void InitAll(bool aIsStartup) {
   MOZ_ASSERT(NS_IsMainThread());
 
   bool isParent = XRE_IsParentProcess();
 
-  // For prefs like these:
-  //
-  //   PREF("foo.bar.baz", bool, true)
-  //   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-  //
-  // we generate registration calls like this:
-  //
-  //   if (isParent) {
-  //     InitPref_bool("foo.bar.baz", true);
-  //   }
-  //   InitMirroredPref($MIRROR, "my.pref", &sVarCache_my_pref, 99, aIsStartup,
-  //                    isParent);
+  // For all prefs we generate some initialization code.
   //
   // The InitPref_*() functions have a type suffix to avoid ambiguity between
   // prefs having int32_t and float default values. That suffix is not needed
-  // for the InitMirroredPref() functions because they take a pointer parameter,
+  // for the InitAlwaysPref() 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.
-#define PREF(name, cpp_type, value)   \
-  if (isParent) {                     \
-    InitPref_##cpp_type(name, value); \
-  }
-#define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, value) \
-  InitMirroredPref(MirrorKind::mirror, NS_LITERAL_CSTRING(name),       \
-                   &sVarCache_##full_id, value, aIsStartup, isParent);
+#define NEVER_PREF(name, cpp_type, value) \
+  if (isParent) {                         \
+    InitPref_##cpp_type(name, value);     \
+  }
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, value)            \
+  InitAlwaysPref(NS_LITERAL_CSTRING(name), &sVarCache_##full_id, value, \
+                 aIsStartup, isParent);
+#define ONCE_PREF(name, base_id, full_id, cpp_type, value) \
+  if (isParent) {                                          \
+    InitPref_##cpp_type(name, value);                      \
+  }
 #include "mozilla/StaticPrefListAll.h"
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 }
 
 static void InitOncePrefs() {
-  // For a pref like this:
-  //
-  //   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-  //
-  // we generate a non-DEBUG initialization like this:
-  //
-  //   if (MirrorKind::$MIRROR == MirrorKind::Once) {
-  //     sVarCache_my_pref = Internals::GetPref("my.pref", 99);
-  //   }
-  //
-  // This is done in case the pref value was updated when reading pref data
-  // files. It's necessary because we don't have callbacks registered for
-  // `once`-mirrored prefs.
+  // For `once`-mirrored prefs we generate some initialization code. This is
+  // done in case the pref value was updated when reading pref data files. It's
+  // necessary because we don't have callbacks registered for `once`-mirrored
+  // prefs.
   //
   // In debug builds, we also install a mechanism that can check if the
   // preference value is modified after `once`-mirrored prefs are initialized.
   // In tests this would indicate a likely misuse of a `once`-mirrored pref and
   // suggest that it should instead be `always`-mirrored.
-  //
-#define PREF(name, cpp_type, value)
+#define NEVER_PREF(name, cpp_type, value)
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, value)
 #ifdef DEBUG
-#  define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, value)       \
-    if (MirrorKind::mirror == MirrorKind::Once) {                              \
+#  define ONCE_PREF(name, base_id, full_id, cpp_type, value)                   \
+    {                                                                          \
       MOZ_ASSERT(gOnceStaticPrefsAntiFootgun);                                 \
-      sVarCache_##full_id =                                                    \
-          Internals::GetPref(name, StripAtomic<cpp_type>(value));              \
+      sVarCache_##full_id = Internals::GetPref(name, cpp_type(value));         \
       auto checkPref = [&]() {                                                 \
         MOZ_ASSERT(sOncePrefRead);                                             \
-        StripAtomic<cpp_type> staticPrefValue = full_id();                     \
-        StripAtomic<cpp_type> preferenceValue = Internals::GetPref(            \
-            GetPrefName_##base_id(), StripAtomic<cpp_type>(value));            \
+        cpp_type staticPrefValue = full_id();                                  \
+        cpp_type preferenceValue =                                             \
+            Internals::GetPref(GetPrefName_##base_id(), cpp_type(value));      \
         MOZ_ASSERT(staticPrefValue == preferenceValue,                         \
                    "Preference '" name                                         \
                    "' got modified since StaticPrefs::" #full_id               \
                    " was initialized. Consider using an `always` mirror kind " \
                    "instead");                                                 \
       };                                                                       \
       gOnceStaticPrefsAntiFootgun->insert(                                     \
           std::pair<const char*, AntiFootgunCallback>(GetPrefName_##base_id(), \
                                                       std::move(checkPref)));  \
     }
 #else
-#  define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, value) \
-    if (MirrorKind::mirror == MirrorKind::Once) {                        \
-      sVarCache_##full_id =                                              \
-          Internals::GetPref(name, StripAtomic<cpp_type>(value));        \
-    }
+#  define ONCE_PREF(name, base_id, full_id, cpp_type, value) \
+    sVarCache_##full_id = Internals::GetPref(name, cpp_type(value));
 #endif
 
 #include "mozilla/StaticPrefListAll.h"
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 }
 
 }  // namespace StaticPrefs
 
 static MOZ_MAYBE_UNUSED void SaveOncePrefToSharedMap(
     SharedPrefMapBuilder& aBuilder, const char* aName, bool aValue) {
   auto oncePref = MakeUnique<Pref>(aName);
   oncePref->SetType(PrefType::Bool);
@@ -5581,79 +5549,58 @@ static MOZ_MAYBE_UNUSED void SaveOncePre
 namespace StaticPrefs {
 
 static void RegisterOncePrefs(SharedPrefMapBuilder& aBuilder) {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_DIAGNOSTIC_ASSERT(!gSharedMap,
                         "Must be called before gSharedMap has been created");
   MaybeInitOncePrefs();
 
-  // For a pref like this:
-  //
-  //   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-  //
-  // we generate a save call like this:
-  //
-  //   if (MirrorKind::$MIRROR == MirrorKind::Once) {
-  //     SaveOncePrefToSharedMap(aBuilder, ONCE_PREF_NAME(my.pref),
-  //                             sVarCache_my_pref);
-  //   }
-  //
-  // This saves the `once`-mirrored value as it was at parent startup. It is
-  // stored in a special (hidden and locked) entry in the global
-  // SharedPreferenceMap. In order for the entry to be hidden and not appear in
-  // about:config nor ever be stored to disk, we set its IsSkippedByIteration
-  // flag to true. We also distinguish it by adding a "$$$" prefix and suffix
-  // to the preference name.
-  //
-#define PREF(name, cpp_type, value)
-#define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, value)   \
-  if (MirrorKind::mirror == MirrorKind::Once) {                          \
-    SaveOncePrefToSharedMap(aBuilder, ONCE_PREF_NAME(name),              \
-                            StripAtomic<cpp_type>(sVarCache_##full_id)); \
-  }
+  // For `once`-mirrored prefs we generate a save call, which saves the value
+  // as it was at parent startup. It is stored in a special (hidden and locked)
+  // entry in the global SharedPreferenceMap. In order for the entry to be
+  // hidden and not appear in about:config nor ever be stored to disk, we set
+  // its IsSkippedByIteration flag to true. We also distinguish it by adding a
+  // "$$$" prefix and suffix to the preference name.
+#define NEVER_PREF(name, cpp_type, value)
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, value)
+#define ONCE_PREF(name, base_id, full_id, cpp_type, value) \
+  SaveOncePrefToSharedMap(aBuilder, ONCE_PREF_NAME(name),  \
+                          cpp_type(sVarCache_##full_id));
 #include "mozilla/StaticPrefListAll.h"
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 }
 
 static void InitStaticPrefsFromShared() {
   MOZ_ASSERT(!XRE_IsParentProcess());
   MOZ_DIAGNOSTIC_ASSERT(gSharedMap,
                         "Must be called once gSharedMap has been created");
 
-  // For a prefs like this:
-  //
-  //   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-  //
-  // we generate an initialization like this:
-  //
-  //   {
-  //     int32_t val;
-  //     nsresult rv = (MirrorKind::$MIRROR == MirrorKind::Once)
-  //                 ? Internals::GetSharedPrefValue("$$$my.pref$$$", &val)
-  //                 : Internals::GetSharedPrefValue("my.pref", &val);
-  //     MOZ_DIAGNOSTIC_ALWAYS_TRUE(NS_SUCCEEDED(rv));
-  //     sVarCache_my_pref = val;
-  //   }
-  //
-#define PREF(name, cpp_type, value)
-#define VARCACHE_PREF(mirror, name, base_id, full_id, cpp_type, value)  \
-  {                                                                     \
-    StripAtomic<cpp_type> val;                                          \
-    nsresult rv =                                                       \
-        (MirrorKind::mirror == MirrorKind::Once)                        \
-            ? Internals::GetSharedPrefValue(ONCE_PREF_NAME(name), &val) \
-            : Internals::GetSharedPrefValue(name, &val);                \
-    MOZ_DIAGNOSTIC_ALWAYS_TRUE(NS_SUCCEEDED(rv));                       \
-    StaticPrefs::sVarCache_##full_id = val;                             \
+  // For mirrored prefs we generate some initialization code.
+#define NEVER_PREF(name, cpp_type, value)
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, value) \
+  {                                                          \
+    StripAtomic<cpp_type> val;                               \
+    nsresult rv = Internals::GetSharedPrefValue(name, &val); \
+    MOZ_DIAGNOSTIC_ALWAYS_TRUE(NS_SUCCEEDED(rv));            \
+    StaticPrefs::sVarCache_##full_id = val;                  \
+  }
+#define ONCE_PREF(name, base_id, full_id, cpp_type, value)                   \
+  {                                                                          \
+    cpp_type val;                                                            \
+    nsresult rv = Internals::GetSharedPrefValue(ONCE_PREF_NAME(name), &val); \
+    MOZ_DIAGNOSTIC_ALWAYS_TRUE(NS_SUCCEEDED(rv));                            \
+    StaticPrefs::sVarCache_##full_id = val;                                  \
   }
 #include "mozilla/StaticPrefListAll.h"
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 
   // `once`-mirrored prefs have been set to their value in the step above and
   // outside the parent process they are immutable. We set sOncePrefRead so
   // that we can directly skip any lazy initializations.
   sOncePrefRead = true;
 }
 
 }  // namespace StaticPrefs
--- a/modules/libpref/StaticPrefsBase.h
+++ b/modules/libpref/StaticPrefsBase.h
@@ -59,28 +59,15 @@ struct IsAtomic : FalseType {};
 template <typename T, MemoryOrdering Order>
 struct IsAtomic<Atomic<T, Order>> : TrueType {};
 
 template <typename T>
 struct IsAtomic<std::atomic<T>> : TrueType {};
 
 namespace StaticPrefs {
 
-// Undo X11/X.h's definition of `Always` so we can use it in `MirrorKind`.
-#undef Always
-
-// Enums for the update policy.
-enum class MirrorKind {
-  // Mirror the pref value once, at startup.
-  Once,
-
-  // Mirror the pref vale always, with live updating. This would be `Always`,
-  // but /usr/include/X11/X.h defines a macro with that name.
-  Always
-};
-
 void MaybeInitOncePrefs();
 
 }  // namespace StaticPrefs
 
 }  // namespace mozilla
 
 #endif  // mozilla_StaticPrefsBase_h
--- a/modules/libpref/init/StaticPrefListBegin.h
+++ b/modules/libpref/init/StaticPrefListBegin.h
@@ -9,47 +9,32 @@
 // namespace.
 
 #include "StaticPrefsBase.h"
 #include "MainThreadUtils.h"  // for NS_IsMainThread()
 
 namespace mozilla {
 namespace StaticPrefs {
 
-// For a VarCache pref like this:
-//
-//   VARCACHE_PREF($MIRROR, "my.pref", my_pref, my_pref, int32_t, 99)
-//
-// we generate an extern variable declaration and three getter
-// declarations/definitions.
-//
-//     extern int32_t sVarCache_my_pref;
-//     inline int32_t my_pref() {
-//       if (MirrorKind::$MIRROR != MirrorKind::Once) {
-//         return sVarCache_my_pref;
-//       }
-//       MaybeInitOncePrefs();
-//       return sVarCache_my_pref();
-//     }
-//     inline const char* GetPrefName_my_pref() { return "my.pref"; }
-//     inline int32_t GetPrefDefault_my_pref() { return 99; }
-//
-// The extern declaration of the variable is necessary for bindgen to see it
-// and generate Rust bindings.
-//
-#define PREF(name, cpp_type, default_value)
-#define VARCACHE_PREF(policy, name, base_id, full_id, cpp_type, default_value) \
-  extern cpp_type sVarCache_##full_id;                                         \
-  inline StripAtomic<cpp_type> full_id() {                                     \
-    if (MirrorKind::policy != MirrorKind::Once) {                              \
-      MOZ_DIAGNOSTIC_ASSERT(                                                   \
-          IsAtomic<cpp_type>::value || NS_IsMainThread(),                      \
-          "Non-atomic static pref '" name                                      \
-          "' being accessed on background thread by getter");                  \
-      return sVarCache_##full_id;                                              \
-    }                                                                          \
-    MaybeInitOncePrefs();                                                      \
-    return sVarCache_##full_id;                                                \
-  }                                                                            \
-  inline const char* GetPrefName_##base_id() { return name; }                  \
-  inline StripAtomic<cpp_type> GetPrefDefault_##base_id() {                    \
-    return default_value;                                                      \
+// For mirrored prefs we generate an extern variable declaration and three
+// getter declarations/definitions. The extern declaration of the variable is
+// necessary for bindgen to see it and generate Rust bindings.
+#define NEVER_PREF(name, cpp_type, default_value)
+#define ALWAYS_PREF(name, base_id, full_id, cpp_type, default_value)          \
+  extern cpp_type sVarCache_##full_id;                                        \
+  inline StripAtomic<cpp_type> full_id() {                                    \
+    MOZ_DIAGNOSTIC_ASSERT(IsAtomic<cpp_type>::value || NS_IsMainThread(),     \
+                          "Non-atomic static pref '" name                     \
+                          "' being accessed on background thread by getter"); \
+    return sVarCache_##full_id;                                               \
+  }                                                                           \
+  inline const char* GetPrefName_##base_id() { return name; }                 \
+  inline StripAtomic<cpp_type> GetPrefDefault_##base_id() {                   \
+    return default_value;                                                     \
   }
+#define ONCE_PREF(name, base_id, full_id, cpp_type, default_value) \
+  extern cpp_type sVarCache_##full_id;                             \
+  inline cpp_type full_id() {                                      \
+    MaybeInitOncePrefs();                                          \
+    return sVarCache_##full_id;                                    \
+  }                                                                \
+  inline const char* GetPrefName_##base_id() { return name; }      \
+  inline cpp_type GetPrefDefault_##base_id() { return default_value; }
--- a/modules/libpref/init/StaticPrefListEnd.h
+++ b/modules/libpref/init/StaticPrefListEnd.h
@@ -6,13 +6,14 @@
 
 // This file should be #included, along with StaticPrefListStart.h, in all
 // headers that contribute prefs to the StaticPrefs namespace.
 
 // This file does not make sense on its own. It must be #included along with
 // StaticPrefsListBegin.h in all headers that contribute prefs to the
 // StaticPrefs namespace.
 
-#undef PREF
-#undef VARCACHE_PREF
+#undef NEVER_PREF
+#undef ALWAYS_PREF
+#undef ONCE_PREF
 
 }  // namespace StaticPrefs
 }  // namespace mozilla
--- a/modules/libpref/init/generate_static_pref_list.py
+++ b/modules/libpref/init/generate_static_pref_list.py
@@ -45,32 +45,30 @@ VALID_TYPES = VALID_BOOL_TYPES.union({
 })
 
 FIRST_LINE = '''\
 // This file was generated by generate_static_pref_list.py. DO NOT EDIT.
 '''
 
 MIRROR_TEMPLATES = {
     'never': '''\
-PREF("{name}", {typ}, {value})
+NEVER_PREF("{name}", {typ}, {value})
 ''',
 
     'once': '''\
-VARCACHE_PREF(
-  Once,
+ONCE_PREF(
   "{name}",
    {base_id},
    {full_id},
   {typ}, {value}
 )
 ''',
 
     'always': '''\
-VARCACHE_PREF(
-  Always,
+ALWAYS_PREF(
   "{name}",
    {base_id},
    {full_id},
   {typ}, {value}
 )
 ''',
 }
 
--- a/modules/libpref/test/test_generate_static_pref_list.py
+++ b/modules/libpref/test/test_generate_static_pref_list.py
@@ -84,71 +84,65 @@ good_input = '''
   type: AtomicFloat
   value: .4455667
   mirror: never
   include: <math.h>
 '''
 
 # The corresponding output for good_input.
 good_output = '''\
-PREF("my.bool", bool, false)
+NEVER_PREF("my.bool", bool, false)
 
-VARCACHE_PREF(
-  Once,
+ONCE_PREF(
   "my.int",
    my_int,
    my_int_AtStartup,
   int32_t, -123
 )
 
-VARCACHE_PREF(
-  Always,
+ALWAYS_PREF(
   "my.uint",
    my_uint,
    my_uint,
   uint32_t, 999
 )
 
-VARCACHE_PREF(
-  Once,
+ONCE_PREF(
   "my.float",
    my_float,
    my_float_AtStartup_DoNotUseDirectly,
   float, 0.0f
 )
 
-PREF("my.string", String, "foo\\"bar")
+NEVER_PREF("my.string", String, "foo\\"bar")
 
-PREF("my.string2", String, "foobar")
+NEVER_PREF("my.string2", String, "foobar")
 
-VARCACHE_PREF(
-  Always,
+ALWAYS_PREF(
   "my.atomic.bool",
    my_atomic_bool,
    my_atomic_bool,
   RelaxedAtomicBool, true
 )
 
-VARCACHE_PREF(
-  Always,
+ALWAYS_PREF(
   "my.atomic.int",
    my_atomic_int,
    my_atomic_int_DoNotUseDirectly,
   ReleaseAcquireAtomicInt32, 10 + 10 * 20
 )
 
-VARCACHE_PREF(
-  Once,
+ONCE_PREF(
   "my.atomic.uint",
    my_atomic_uint,
    my_atomic_uint_AtStartup,
   SequentiallyConsistentAtomicUint32, 68
 )
 
-PREF("my.atomic.float", AtomicFloat, 0.4455667)
+NEVER_PREF("my.atomic.float", AtomicFloat, 0.4455667)
 '''
 
 # A lot of bad inputs, each with an accompanying error message. Listed in order
 # of the relevant `error` calls within generate_static_pref_list.py.
 bad_inputs = [
     ('''
 - name: do_not_use_directly.uselessly.set
   type: int32_t