Commit Graph

426 Commits

Author SHA1 Message Date
Nicholas Nethercote
187ada3c7d Bug 1569526 - Remove CacheData. r=froydnj
A `CacheData` object holds two things: a VarCache/mirror variable address, and
a default value. The previous patch removed the use of the default value.
Therefore, `CacheData` now only holds an address, so there's no need for a
distinct heap object for it, and we can eliminate `CacheData` entirely and just
use the mirror variable address (a `void*`) directly.

The removal of the `CacheData` objects removes one reason for `gCacheData` to
exist (which is to have an owner for those objects). The other reason is to
detect if two or more prefs get VarCached onto a single variable. But given
that VarCaches are on the way out in favour of static prefs (bug 1448219) this
checking is no longer important. So the commit removes `gCacheData` as well.

The above changes save 20-32 KiB per process on 64-bit platforms.

The patch also removes `gCacheDataDesc`, a diagnostic thing from bug 1276488
that isn't relevant with `gCacheData` removed. This means the return type of
`InitInitialObjects` can be simplified.

Finally, the commit renames a few things, taking another step along the path of
renaming VarCache prefs as mirrored prefs, a much better name.

Differential Revision: https://phabricator.services.mozilla.com/D40906

--HG--
extra : moz-landing-system : lando
2019-08-09 00:59:46 +00:00
Nicholas Nethercote
ec0336e701 Bug 1569526 - Don't use default values as fallbacks for VarCache prefs. r=froydnj
This patch changes how a VarCache pref works when deleted (in some cases) --
the VarCache variable keeps its existing value instead of being reset to a
pre-specified default.

In bug 1570212 I have made sure that no VarCache prefs exhibit this behaviour
in practice any more, so this change should not affect functionality. There is
an assertion that checks this.

The next patch will take advantage of this change by removing the need to
store the pre-specified defaults, which will save memory.

Differential Revision: https://phabricator.services.mozilla.com/D39805

--HG--
extra : moz-landing-system : lando
2019-08-09 00:59:34 +00:00
Nicholas Nethercote
0c1c7fcd20 Bug 1563555 - Rename sVarCache_* as sMirror_*. r=KrisWright
Another step in the renaming of VarCache variables as mirror variables,
matching the 'mirror' field used in StaticPrefList.yaml.

Differential Revision: https://phabricator.services.mozilla.com/D40794

--HG--
extra : moz-landing-system : lando
2019-08-08 21:33:22 +00:00
Nicholas Nethercote
30218bffe1 Bug 1571961 - Shrink InitAll(). r=KrisWright
Avoiding lots of `if (isParent)` conditions reduces code size by 2016 bytes for
a local build on my Linux64 box.

Differential Revision: https://phabricator.services.mozilla.com/D40921

--HG--
extra : moz-landing-system : lando
2019-08-07 21:39:08 +00:00
Nicholas Nethercote
12640bca82 Bug 1563555 - Generate static pref getters usable from Rust code. r=glandium
This patch introduces a new Rust crate called `static_prefs`.

It also changes generate_static_pref_list.py to generate two new files.

- StaticPrefsCGetters.cpp: contains C getters, which are just wrappers around
  the C++ getters. This is included into Preferences.cpp.

- static_prefs.rs: contains declarations for the C getters, plus the `pref!`
  macro which provides nice syntax for calling the C getters. This is included
  into static_prefs/src/lib.rs.

The new code is only generated for prefs marked with the new `rust` field in
the YAML. It's opt-in because there's no point generating additional code for
900+ static prefs when only about 20 are currently used from Rust.

This patch only marks a single pref (`browser.display.document_color_use`) with
`rust: true`. That pref isn't accessed from Rust code in this patch, but it's
necessary because the generated Rust code is invalid if there are zero
Rust-accessed prefs. (The next patch will access that pref and others from Rust
code.

Differential Revision: https://phabricator.services.mozilla.com/D40791

--HG--
extra : moz-landing-system : lando
2019-08-07 05:16:55 +00:00
Nicholas Nethercote
a3cf276f46 Bug 1570562 - Remove unnecessary checking in InitInitialObjects(). r=jya
Differential Revision: https://phabricator.services.mozilla.com/D40151

--HG--
extra : moz-landing-system : lando
2019-08-04 23:04:09 +00:00
Nicholas Nethercote
e3aa875efe 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

--HG--
extra : moz-landing-system : lando
2019-08-02 06:31:05 +00:00
Nicholas Nethercote
605fd328b4 Bug 1570575 - Some libpref tidy-ups. r=KrisWright
This commit:

- improves the wording of some comments;

- renames `UpdatePolicy` as `MirrorKind`, to reflect the new terminology we are
  starting to use;

- does a couple of other minor clean-ups.

Differential Revision: https://phabricator.services.mozilla.com/D40161

--HG--
extra : moz-landing-system : lando
2019-08-02 06:36:14 +00:00
Nicholas Nethercote
cb9400e186 Bug 1567074 - Document libpref properly. r=jya
This is a combination of the All About Prefs google doc and kmag's description
of the shared memory work in
https://bugzilla.mozilla.org/show_bug.cgi?id=1471025#c95, with some updates and
tweaks.

Differential Revision: https://phabricator.services.mozilla.com/D38611

--HG--
extra : moz-landing-system : lando
2019-08-01 02:11:07 +00:00
Nicholas Nethercote
cd426e3ad2 Bug 1569526 - Remove return values from Add*VarCache(). r=KrisWright
They're infallible in practice and always `NS_OK`. (This stems from
`AddVarCacheNoAssignment()` always returning `NS_OK`.)

As a result, the commit removes lots of unnecessary checks.

Differential Revision: https://phabricator.services.mozilla.com/D39804

--HG--
extra : moz-landing-system : lando
2019-07-30 06:19:46 +00:00
Nicholas Nethercote
670a5bfd26 Bug 1569526 - Rename PreferencesInternalMethods. r=KrisWright
It's an annoyingly long name that causes lots of line breaking, and it's not
exposed outside of libpref.

Differential Revision: https://phabricator.services.mozilla.com/D39803

--HG--
extra : moz-landing-system : lando
2019-07-30 06:14:48 +00:00
Nicholas Nethercote
a7d5766bb8 Bug 1569526 - Remove PrefsIter::Remove. r=KrisWright
It's unused.

Differential Revision: https://phabricator.services.mozilla.com/D39651

--HG--
extra : moz-landing-system : lando
2019-07-30 06:14:29 +00:00
Nicholas Nethercote
49ad1ba06b Bug 1569526 - Rename SetPref_*() as InitPref_*(). r=KrisWright
This makes it clear that these run when prefs are initialized (like
`InitVarCache()`) rather than being vanilla `set` calls that happen at any
point during runtime.

Differential Revision: https://phabricator.services.mozilla.com/D39650

--HG--
extra : moz-landing-system : lando
2019-07-30 06:14:17 +00:00
Nicholas Nethercote
42b4ba2041 Bug 1569526 - Add more thread/process assertions to libpref. r=KrisWright
Lots of operations in Preferences.cpp can only occur in the parent process
and/or on the main thread. It has a bunch of assertions to enforce/document
this. This commit adds some more, because they're really useful for
understanding the code.

The commit also removes an unnecessary `XRE_IsParentProcess()` check in
`pref_SetPref()` (because that condition is always true, as the added assertion
indicates), and renames a parameter in `InitVarCachePrefs()`.

Differential Revision: https://phabricator.services.mozilla.com/D39649

--HG--
extra : moz-landing-system : lando
2019-07-30 06:14:05 +00:00
Nicholas Nethercote
7774e3aaea Bug 1569036 - Remove all the aSkipAssignment parameters. r=KrisWright
`AddVarCache()` has a `bool aSkipAssignment` parameter. This patch removes that
parameter by splitting the function in two: `AddVarCache()` and
`AddVarCacheNoAssignment()`. (The former calls the latter.)

There are also tons of `Add*VarCache()` functions with `aSkipAssignment`
parameters that default to `false`. These defaults are never overridden, so
this patch removes the unnecessary arguments.

Differential Revision: https://phabricator.services.mozilla.com/D39433

--HG--
extra : moz-landing-system : lando
2019-07-26 21:11:18 +00:00
Nicholas Nethercote
18fae65f38 Bug 1563139 - Remove StaticPrefs.h. r=glandium
This requires replacing inclusions of it with inclusions of more specific prefs
files.

The exception is that StaticPrefsAll.h, which is equivalent to StaticPrefs.h,
and is used in `Codegen.py` because doing something smarter is tricky and
suitable for a follow-up. As a result, any change to StaticPrefList.yaml will
still trigger recompilation of all the generated DOM bindings files, but that's
still a big improvement over trigger recompilation of every file that uses
static prefs.

Most of the changes in this commit are very boring. The only changes that are
not boring are modules/libpref/*, Codegen.py, and ServoBindings.toml.

Differential Revision: https://phabricator.services.mozilla.com/D39138

--HG--
extra : moz-landing-system : lando
2019-07-26 01:10:23 +00:00
Nicholas Nethercote
cbaaacf6ae Bug 1563139 - Remove StaticPref{s,List}_accessibility.h. r=glandium
These files exist because they were the proof-of-concept first step for
splitting the static prefs header files. Now that those header files can be
generated from a script, we need to move the `accessibility.*` prefs into the
YAML file.

Differential Revision: https://phabricator.services.mozilla.com/D39132

--HG--
extra : moz-landing-system : lando
2019-07-25 04:08:14 +00:00
Nicholas Nethercote
2c71663c5e Bug 1568516 - Allow a uint32_t static pref with a mirror value of never. r=KrisWright
There was a missing setter function for this combination, which hasn't been
used before.

Differential Revision: https://phabricator.services.mozilla.com/D39263

--HG--
extra : moz-landing-system : lando
2019-07-25 02:26:14 +00:00
Nicholas Nethercote
7974362afd Bug 1567329 - Append _AtStartup to once static pref getters. r=erahm
Currently it's completely unclear at use sites that the getters for `once`
static prefs return the pref value from startup, rather than the current pref
value. (Bugs have been caused by this.) This commit improves things by changing
the getter name to make it clear that the pref value obtained is from startup.

This required changing things within libpref so it distinguishes between the
"base id" (`foo_bar`) and the "full id" (`foo_bar` or
`foo_bar_DoNotUseDirectly` or `foo_bar_AtStartup` or
`foo_bar_AtStartup_DoNotUseDirectly`; the name used depends on the `mirror` and
`do_not_use_directly` values in the YAML definition.) The "full id" is used in
most places, while the "base id" is used for the `GetPrefName_*` and
`GetPrefDefault_*` functions.

(This is a nice demonstration of the benefits of the YAML file, BTW. Making
this change with the old code would have involved adding an entry to every
single pref in StaticPrefList.h.)

The patch also rejigs the comment at the top of StaticPrefList.yaml, to clarify
some things.

Differential Revision: https://phabricator.services.mozilla.com/D38604

--HG--
extra : moz-landing-system : lando
2019-07-22 02:10:14 +00:00
Nicholas Nethercote
33e7c48f42 Bug 1552126: Remove UpdatePolicy::Skip. r=jya
Differential Revision: https://phabricator.services.mozilla.com/D37373

--HG--
extra : moz-landing-system : lando
2019-07-10 22:32:58 +00:00
Barret Rennie
02c0b80c16 Bug 1289211 - Rename InfallibleTArray to nsTArray in modules/ r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D36965

--HG--
extra : moz-landing-system : lando
2019-07-10 03:33:19 +00:00
Nicholas Nethercote
abf15f999d Bug 1560530 - Split StaticPrefs_accessibility.h from StaticPrefs.h. r=froydnj
This implements the machinery for the splitting of static prefs headers, and
uses it for a single header. #includes are used in such a way that the amount
of boilerplate for each static prefs header file is minimal.

Future patches will split the remaining prefs into more header files.

Differential Revision: https://phabricator.services.mozilla.com/D36154

--HG--
rename : modules/libpref/StaticPrefs.h => modules/libpref/StaticPrefsBase.h
rename : modules/libpref/StaticPrefs.h => modules/libpref/init/StaticPrefListBegin.h
extra : moz-landing-system : lando
2019-07-08 23:40:39 +00:00
Nicholas Nethercote
510b8223fb Bug 1562810 - Rename some static pref functions. r=KrisWright
Now that all static pref getters use snake_case, these renamings make sense:
- Getfoo_bar_bazPrefName() -> GetPrefName_foo_bar_baz()
- Getfoo_bar_bazPrefDefault() -> GetPrefDefault_foo_bar_baz()

Differential Revision: https://phabricator.services.mozilla.com/D36563

--HG--
extra : moz-landing-system : lando
2019-07-02 22:32:09 +00:00
Nicholas Nethercote
41b679b6e2 Bug 1561216 - Change StaticPrefs from a class to a namespace. r=froydnj
This doesn't change the way C++ code uses static prefs. But it does slightly
change how Rust code uses static prefs, specifically the name generated by
bindgen is slightly different.

The commit also improves some comments.

Differential Revision: https://phabricator.services.mozilla.com/D35764

--HG--
extra : rebase_source : 13cf215aeb713e188103ef0cd04d094aa150853e
2019-06-25 10:36:59 +10:00
Nicholas Nethercote
9f15052ed8 Bug 1561216 - Remove unneeded mozilla:: qualifiers in Preferences.cpp. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D35772

--HG--
extra : rebase_source : 3844288a7aebe9759e8ba72cec44e94d96925f47
2019-06-25 09:18:07 +10:00
Nicholas Nethercote
c24fbafc40 Bug 1560833 - Remove setters for static VarCache prefs. r=froydnj
Static VarCache prefs have setters. These are dangerous because they can
violate the primary invariant of VarCache prefs, which is that the global
variable always matches the pref value in the table.

Fortunately they are only used in tests, and we can use vanilla pref setters
instead, and get rid of the VarCache setters.

Differential Revision: https://phabricator.services.mozilla.com/D35632

--HG--
extra : moz-landing-system : lando
2019-06-24 16:43:33 +00:00
Jean-Yves Avenard
624887abc5 Bug 1559563 - P2. Small optimization of Once StaticPrefs accessor. r=njn
We can avoid testing if we are running in the parent process.

Differential Revision: https://phabricator.services.mozilla.com/D35125

--HG--
extra : moz-landing-system : lando
2019-06-18 11:26:25 +00:00
Jean-Yves Avenard
b10113a9fc Bug 1559563 - P1. Move StaticPrefs accessor back to header file. r=njn
This allows for the compiler to inline the code where appropriate.

Differential Revision: https://phabricator.services.mozilla.com/D35124

--HG--
extra : moz-landing-system : lando
2019-06-18 11:25:21 +00:00
Jean-Yves Avenard
01ac9fc00f Bug 1559675 - P1. Initialize StaticPrefs early in non-parent process. r=njn
We can initialize the StaticPrefs as soon as the SharedMap object is created outside the parent process.

Additionally when resetting the preferences to their default values, we no longer modify the `Once` StaticPrefs as they are immutable, only the underlying preference.

Differential Revision: https://phabricator.services.mozilla.com/D35263

--HG--
extra : moz-landing-system : lando
2019-06-19 00:22:33 +00:00
Jean-Yves Avenard
35eb8f536a Bug 1556131 - P3. Enable check on automation. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D34475

--HG--
extra : moz-landing-system : lando
2019-06-14 08:26:45 +00:00
Razvan Maries
8712f0bcbd Backed out changeset f2fa56561f9e (bug 1556131) for causing perma failure: Assertion failure: staticPrefValue == preferenceValue 2019-06-13 06:12:12 +03:00
Jean-Yves Avenard
b402df7ecd Bug 1556131 - P2. Enable check on automation. r=njn
Depends on D34107

Differential Revision: https://phabricator.services.mozilla.com/D34475

--HG--
extra : moz-landing-system : lando
2019-06-12 21:49:50 +00:00
Jean-Yves Avenard
5adb6b1a6d Bug 1557630 - P1. Simplify Preferences' getters code. r=njn
We use templates where appropriate instead.

Differential Revision: https://phabricator.services.mozilla.com/D34272

--HG--
extra : moz-landing-system : lando
2019-06-12 08:01:08 +00:00
Bogdan Tara
e1a1a4aacc Backed out changeset c0931707a491 (bug 1556131) for assertion failures in StaticPrefList.h CLOSED TREE 2019-06-12 05:18:24 +03:00
Jean-Yves Avenard
d359bf9fb1 Bug 1556131 - P2. Enable check on automation. r=njn
Depends on D34107

Differential Revision: https://phabricator.services.mozilla.com/D34475

--HG--
extra : moz-landing-system : lando
2019-06-11 20:12:52 +00:00
Brindusan Cristian
f08a75f6a5 Backed out changeset a36380745805 (bug 1557630) for mochitest failures at test_pluginAudioNotification.html. CLOSED TREE 2019-06-11 19:32:38 +03:00
Jean-Yves Avenard
56773e45c8 Bug 1557630 - P1. Simplify Preferences' getters code. r=njn
We use templates where appropriate instead.

Differential Revision: https://phabricator.services.mozilla.com/D34272

--HG--
extra : moz-landing-system : lando
2019-06-11 06:11:50 +00:00
Jean-Yves Avenard
90a852278d Bug 1556131 - P1. Potentially assert that a Once StaticPref stays in sync with underlying preference. r=njn
When testing, the Preference behing a `Once` StaticPrefs should never get modified as this indicate that this StaticPrefs should have a `Live` policy instead.

This is placed behind the preferences.check.once.policy which will get enabled during automated testing.

Differential Revision: https://phabricator.services.mozilla.com/D34107

--HG--
extra : moz-landing-system : lando
2019-06-11 09:56:48 +00:00
Jean-Yves Avenard
4463ad6a27 Bug 1554334 - P2. Assert that Once StaticPrefs setter is never called once initialized. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D33630

--HG--
extra : moz-landing-system : lando
2019-06-11 06:32:59 +00:00
Jean-Yves Avenard
3cfadec356 Bug 1554334 - P1. Lazily initialize StaticPrefs with Once policy. r=njn
Rather than attempting to determine when the Once policy StaticPrefs should be set we initialize them when one of the getter gets called. They become immutable after that.
In a future change we will prevent those values to ever be changed once they have been initialized.

Differential Revision: https://phabricator.services.mozilla.com/D33440

--HG--
extra : moz-landing-system : lando
2019-06-11 06:32:45 +00:00
Jean-Yves Avenard
469acdb7c1 Bug 1554559 - P3. Make Once StaticPrefs immutable once SharedPreferenceMap has been created. r=njn
When we create the SharedPreferenceMap we store the value of the Once pref in it. All child processes will now read the Once pref from the read-only SharedPreferenceMap.
This makes the Once prefs immutable once we start the first child process.

Differential Revision: https://phabricator.services.mozilla.com/D33421

--HG--
extra : moz-landing-system : lando
2019-06-11 06:29:30 +00:00
Jean-Yves Avenard
1fabb3ce0b Bug 1554559 - P2. Add option for pref entry in SharedPrefMap to be skipped by iterator. r=njn
This allows for an entry to not show in about:config.

This will be used to store Once StaticPrefs once they become immutable.

Differential Revision: https://phabricator.services.mozilla.com/D33420

--HG--
extra : moz-landing-system : lando
2019-06-11 06:29:26 +00:00
Boris Zbarsky
89baee69d9 Bug 1557501. Stop using [array] in nsIPrefBranch. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D34032

--HG--
extra : moz-landing-system : lando
2019-06-07 01:01:12 +00:00
Jean-Yves Avenard
62b101eb4f Bug 1550422 - P26. Make setter only usable on main process. r=njn
And set the underlying preference. StaticPrefs::Set becomes a convenience access to the original preference which is what gfxPrefs was actually doing.

Differential Revision: https://phabricator.services.mozilla.com/D31749

--HG--
extra : moz-landing-system : lando
2019-05-26 14:32:27 +00:00
Jean-Yves Avenard
85777eccf3 Bug 1550422 - P13. Add Skip, Once and Live cached preference policy. r=njn,kmag
This works identically to what gfxPrefs UpdatePolicy offers.

Differential Revision: https://phabricator.services.mozilla.com/D31257

--HG--
extra : moz-landing-system : lando
2019-05-26 14:29:52 +00:00
Jean-Yves Avenard
4b77501235 Bug 1550422 - P11. Add atomic float preferences support. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D31255

--HG--
extra : moz-landing-system : lando
2019-05-26 14:29:37 +00:00
Gurzau Raul
967bc2a754 Backed out 31 changesets (bug 1552643, bug 1550422) for xpcshell crash on a CLOSED TREE.
Backed out changeset e30c1aa75529 (bug 1552643)
Backed out changeset caadcd7e02d3 (bug 1552643)
Backed out changeset aa7086ab09be (bug 1552643)
Backed out changeset 0b4029671710 (bug 1550422)
Backed out changeset a16295296035 (bug 1550422)
Backed out changeset 3b70307c0db5 (bug 1550422)
Backed out changeset 69df7818d4a3 (bug 1550422)
Backed out changeset d98dfc565927 (bug 1550422)
Backed out changeset 6f0997976944 (bug 1550422)
Backed out changeset 0edd264464c2 (bug 1550422)
Backed out changeset 9ea6da7a74ec (bug 1550422)
Backed out changeset f855f9309c8b (bug 1550422)
Backed out changeset 1033546224a7 (bug 1550422)
Backed out changeset ade7384c6186 (bug 1550422)
Backed out changeset 75b04de7e99c (bug 1550422)
Backed out changeset 91c3acdb2454 (bug 1550422)
Backed out changeset 77d2f80257d1 (bug 1550422)
Backed out changeset e0cd10d35327 (bug 1550422)
Backed out changeset 097091082423 (bug 1550422)
Backed out changeset 2f328853c1ab (bug 1550422)
Backed out changeset f92f2cc29cb1 (bug 1550422)
Backed out changeset 6dc82f88333d (bug 1550422)
Backed out changeset c20f66494d69 (bug 1550422)
Backed out changeset 2ba22cddeb6f (bug 1550422)
Backed out changeset 3aa72f89e295 (bug 1550422)
Backed out changeset ab4c4e806977 (bug 1550422)
Backed out changeset 72e5de040dda (bug 1550422)
Backed out changeset 7d3c2d486706 (bug 1550422)
Backed out changeset 132e0b8d8468 (bug 1550422)
Backed out changeset 54c85ac75dd0 (bug 1550422)
Backed out changeset d7ba4a18dd54 (bug 1550422)
2019-05-25 09:07:49 +03:00
Jean-Yves Avenard
abc6837058 Bug 1550422 - P26. Make setter only usable on main process. r=njn
And set the underlying preference. StaticPrefs::Set becomes a convenience access to the original preference which is what gfxPrefs was actually doing.

Differential Revision: https://phabricator.services.mozilla.com/D31749

--HG--
extra : moz-landing-system : lando
2019-05-24 11:39:31 +00:00
Jean-Yves Avenard
72db7328f0 Bug 1550422 - P13. Add Skip, Once and Live cached preference policy. r=njn,kmag
This works identically to what gfxPrefs UpdatePolicy offers.

Differential Revision: https://phabricator.services.mozilla.com/D31257

--HG--
extra : moz-landing-system : lando
2019-05-25 00:03:53 +00:00
Jean-Yves Avenard
e47d662928 Bug 1550422 - P11. Add atomic float preferences support. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D31255

--HG--
extra : moz-landing-system : lando
2019-05-23 04:13:08 +00:00