This patch uses the low memory resource notification facility to detect
scenarios where physical memory is running low without polling. This is a
significant change compared to the previous behavior which measured both
available virtual memory (only on 32-bit builds) and available commit space.
Since we're not trying to avoid OOMs anymore we don't save memory reports
anymore when hitting a low-memory condition.
Differential Revision: https://phabricator.services.mozilla.com/D50471
--HG--
extra : moz-landing-system : lando
The problem is that a GC can be triggered in a number of ways, so scheduling zones in nsJSContext::GarbageCollectNow is not effective. This patch schedules these zones in the GC callback, which is always called at the start of GC. This means we have to change the internal logic slightly to allow the GC callback to schedule addional zones; previously this state was saved and restored before/after running the callback.
Differential Revision: https://phabricator.services.mozilla.com/D51145
--HG--
extra : moz-landing-system : lando
This replaces a direct call of an object's finalizer with a more formal API. This adds some assertions and passes a valid FreeOp pointer to the finalizer rather than null.
Differential Revision: https://phabricator.services.mozilla.com/D50571
--HG--
extra : moz-landing-system : lando
This renames the JSStringFinalizer struct to JSExternalStringCallbacks,
makes it a virtual class, and adds a size-of callback to it (to replace
the per-runtime callback).
This will make it possible to implement this callback easily for the
NewExternalString testing function (which we want for bug 1590641)
without having to move this testing function to shell/js.cpp
Differential Revision: https://phabricator.services.mozilla.com/D50234
--HG--
extra : moz-landing-system : lando
We want to remove flat strings (JSFlatString). With this patch we only expose
linear strings (JSLinearString) to API consumers.
This is very mechanical for the most part, because code typically only cares
about linear strings and not the null-termination aspect.
CTypes's Library.cpp has some Windows-specific code where we relied on null-terminated
strings. This patch adds JS_CopyStringCharsZ for that use case.
Differential Revision: https://phabricator.services.mozilla.com/D48314
--HG--
extra : moz-landing-system : lando
This method turned out to only be used for tracing wrapper cached things. The wrapper cache has its own way of implementing barriers and contains a raw JSObject pointer. Changing this trace method to take an nsWrapperCache pointer (effectively a JSObjct**) enforces correct use of Heap<T> for other TraceCallbacks callers.
Differential Revision: https://phabricator.services.mozilla.com/D48693
--HG--
extra : moz-landing-system : lando
This includes some annotations to isOverridableField() that are only necessary at this point in the patch stack; the entire function will be removed shortly.
Differential Revision: https://phabricator.services.mozilla.com/D46565
--HG--
extra : moz-landing-system : lando
GetCurrentPhysicalThread and GetCurrentVirtualThread are, in practice,
identical, as the TLS override that GetCurrentVirtualThread depends on
is never actually set. This simply removes that and renames some things/
deletes some comments.
Differential Revision: https://phabricator.services.mozilla.com/D41247
--HG--
extra : moz-landing-system : lando
Defines an android-only version of nsTraceRefcnt::WalkTheStack that takes a function callback, which outputs the stack frame buffer to `__android_log_print`. Also uses `__wrap_dladdr` in MozDescribeCodeAddress, which outputs slightly more informative data for the stack trace (instead of instances of '???/??? [???]').
Differential Revision: https://phabricator.services.mozilla.com/D46868
--HG--
extra : moz-landing-system : lando
Defines an android-only version of nsTraceRefcnt::WalkTheStack that takes a function callback, which outputs the stack frame buffer to `__android_log_print`. Also uses `__wrap_dladdr` in MozDescribeCodeAddress, which outputs slightly more informative data for the stack trace (instead of instances of '???/??? [???]').
Differential Revision: https://phabricator.services.mozilla.com/D46868
--HG--
extra : moz-landing-system : lando
NS_ERROR_DOM_TYPE_ERR is not much better, but this at least allows us to get
rid of NS_ERROR_TYPE_ERR completely...
Differential Revision: https://phabricator.services.mozilla.com/D46485
--HG--
extra : moz-landing-system : lando
The two remaining consumers don't seem to depend on actually using this
specific nsresult in any way.
Differential Revision: https://phabricator.services.mozilla.com/D46462
--HG--
extra : moz-landing-system : lando
In places where profiler_is_active() was used around a profiler_add_marker() (or
similar) call, replace it with profiler_can_accept_markers().
Differential Revision: https://phabricator.services.mozilla.com/D44435
--HG--
extra : moz-landing-system : lando
mAboutToBeNotifiedRejectedPromises will be clear in AfterProcessMicrotasks()
and mPendingUnhandledRejections will be clear after NotifyUnhandledRejections
runnable is handled.
However, worker could terminate in any time, we still need to clear those
structures manually before CollectData is clear.
Differential Revision: https://phabricator.services.mozilla.com/D46095
--HG--
extra : moz-landing-system : lando
In places where profiler_is_active() was used around a profiler_add_marker() (or
similar) call, replace it with profiler_can_accept_markers().
Differential Revision: https://phabricator.services.mozilla.com/D44435
--HG--
extra : moz-landing-system : lando
This reverts the available memory tracker back to its old implementation that
relied on GlobalMemoryStatusEx() instead of the potentially expensive
K32GetPerformanceInfo(). In spite of its name GlobalMemoryStatusEx() may return
per-process values instead of global ones which might lead to underestimating
the actual memory pressure. Because of this limitation this change is a
stop-gap while we replace this code with a non-polling implementation based on
QueryMemoryResourceNotification().
Differential Revision: https://phabricator.services.mozilla.com/D45338
--HG--
extra : moz-landing-system : lando
All calls to `profiler_add_marker()` (outside of the profilers code) are
now replaced by either:
- `PROFILER_ADD_MARKER(name, categoryPair)`
- `PROFILER_ADD_MARKER_WITH_PAYLOAD(name, categoryPair, TypeOfMarkerPayload,
(payload, ..., arguments))`
This makes all calls consistent, and they won't need to prefix the category pair
with `JS::ProfilingCategoryPair::`.
Also it will make it easier to add (and later remove) internal-profiling
instrumentation (bug 1576550), and to replace heap-allocated payloads with
stack-allocated ones (bug 1576555).
Differential Revision: https://phabricator.services.mozilla.com/D43588
--HG--
extra : moz-landing-system : lando
Compilers have gotten a lot better since the last time we tried this, and the
generated SIMD code for the inlined memcmp is more efficient than our manual
comparison operations.
Differential Revision: https://phabricator.services.mozilla.com/D43802
--HG--
extra : moz-landing-system : lando
Whereas previously MozDescribeCodeAddress would have handled demangling,
we need to explicitly do that from our new GetFunction method. The string we
generate is now more useful for the profiler to merge -- having dropped the
address in the previous patch, and the file & line number and library in this
patch.
While we're at it, try to demangle Rust symbols too.
Ideally we'd add Rust symbol handling to DemangleSymbol in
StackWalk.cpp, but that lives in mozglue, which currently cannot have
any Rust crate dependencies.
Differential Revision: https://phabricator.services.mozilla.com/D43142
--HG--
extra : moz-landing-system : lando
This patch adds `RunOnShutdown`, which allows the caller to supply any callable
to be invoked during the specified shutdown phase. This allows us to do more
than just clear smart pointers without needing to write a bunch of observer
service boilerplate.
We use `std::function` to hold the callable.
Differential Revision: https://phabricator.services.mozilla.com/D41816
--HG--
extra : moz-landing-system : lando
JSClass contained void* members corresponding to the internal pointer members of js::Class. This stores the internal members in JSClass and removes js::Class.
This leaves js::Class aliased to JSClass while we remove references to it. I also aliased Jsvalify and Valueify into global scope temporarily to make this compile. These get removed in the following patches.
I had to remove a few functions which now don't compile with js::Class being the same type as JSClass.
Differential Revision: https://phabricator.services.mozilla.com/D41983
--HG--
extra : moz-landing-system : lando
We always define it to the same thing, and we're inconsistent in whether
we use `CPP_THROW_NEW` or `throw()`, so we might as well just use the
standard C++ thing and get rid of some baggage.
Differential Revision: https://phabricator.services.mozilla.com/D40425
--HG--
extra : moz-landing-system : lando
Patch to report JS GC things that are live at shutdown as leaks by calling MOZ_LOG_CTOR for them. The JS engine now clears any remaining roots to prevent dangling pointers to freed memory after shutdown. I made XPCJSRuntime::Shutdown keep the weak pointer update callbacks as sometimes these tables have entries remaining at shutdown (if there are leaks) and we need the callbacks to update them.
This is looking more green on try now.
Differential Revision: https://phabricator.services.mozilla.com/D40449
--HG--
extra : moz-landing-system : lando
All .xul files have been loading as HTMLDocuments for a few weeks now, so
it should be safe to remove the XULDocument implementation.
Differential Revision: https://phabricator.services.mozilla.com/D41238
--HG--
extra : moz-landing-system : lando
The new StaticLocalAutoPtr smart pointer has a trivial destructor, so we will
either properly clean up this data or leak it on process shutdown. Either way,
we will not destroy it in a way that the underlying type does not support.
Differential Revision: https://phabricator.services.mozilla.com/D40842
--HG--
extra : moz-landing-system : lando
None of the StringTable implementations were freeing their strdup'd
strings, either.
Differential Revision: https://phabricator.services.mozilla.com/D40757
--HG--
extra : moz-landing-system : lando
This patch adds smart pointers to be used for initializing objects as C++11
"magic statics" -- that is, they are able to take advantage of C++11's
guarantee of thread safety during initialization by atomically constructing
both the smart pointer itself as well as the object being pointed to.
Unlike Static{Auto,Ref}Ptr, they have non-trivial constructors, though they
must still have trivial destructors to prevent emission of atexit calls.
The new classes use the new `MOZ_STATIC_LOCAL_CLASS` annotation which ensures
their instantiations are static locals and prevents non-trivial destructors.
Differential Revision: https://phabricator.services.mozilla.com/D40092
--HG--
rename : xpcom/base/StaticPtr.h => xpcom/base/StaticLocalPtr.h
extra : moz-landing-system : lando
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
This patch addresses both Bug 1551913 and Bug 1552206.
This patches the update directory permission-fixing code.
This also fixes a related bug that I discovered while testing this patch: nsAutoSid doesn't actually work because both PSID and HANDLE are both typedef'ed from void*, so the compiler can't actually tell the difference between them and ends up calling CloseHandle instead of FreeSid. To fix this, I removed nsAutoSid and replaced it with UniqueSidPtr, a UniquePtr type that uses a custom deleter class to free the SID properly.
Differential Revision: https://phabricator.services.mozilla.com/D34941
--HG--
rename : toolkit/mozapps/update/common/win_dirent.cpp => toolkit/mozapps/update/common/updateutils_win.cpp
rename : toolkit/mozapps/update/common/win_dirent.h => toolkit/mozapps/update/common/updateutils_win.h
extra : moz-landing-system : lando
Moves the trigger to gather total memory up about a hundred lines to the point before we bail on release so that it always triggers.
Differential Revision: https://phabricator.services.mozilla.com/D38249
--HG--
extra : moz-landing-system : lando
to make AutoJSAPI error reporting safe for worklets.
Parameter order matches xpc::ErrorReport::Init().
Depends on D34477
Differential Revision: https://phabricator.services.mozilla.com/D34478
--HG--
extra : moz-landing-system : lando
The previous error message suggested that this is an internal error message
pointing out a bad state in the XHR state machine, when in fact this is
a user error (calling `overrideMimeType()` or setting `responseType()` after
`send()`).
This commit improves and disambiguates the error messages, pointing out to
the user what they did wrong, like other browsers do.
Differential Revision: https://phabricator.services.mozilla.com/D37659
--HG--
extra : moz-landing-system : lando
I'd like to rely on always getting a stop event when the system recovers from a memory pressure situation. AIUI this already happens on Android platforms but not on Windows. This adds the stop event for Windows.
Differential Revision: https://phabricator.services.mozilla.com/D35679
This uses GetPerformanceInformation() to measure how much commit space is
available globally. Previously we relied on GlobalMemoryStatusEx() but in
spite of the function name the commit-space values it returns are
*per process* and thus unreliable. Available physical memory measurement has
also been removed since it was never used and we don't plan on using it
anytime soon.
Differential Revision: https://phabricator.services.mozilla.com/D35018
--HG--
extra : moz-landing-system : lando
Change the Mac GMP process launch to include sandboxing params on the command line to allow the sandbox to be started earlier during GMP process launch. Content, extension, and RDD processes have already been changed to start the sandbox earlier.
Update GMPProcessParent to override GeckoChildProcessHost methods used to construct sandboxing parameters. Pass the plugin path as a sandbox parameter so that the sandbox rules can whitelist the plugin directory which is now read after the sandbox is enabled in the plugin process. On development builds, pass "testingReadPath" params so directories needed during automated tests can be whitelisted.
Update Mac sandboxing code to detect GMP sandbox params on the command line and enable the sandbox with additional arguments needed for early sandbox start.
Allow reverting to the old implementation by setting security.sandbox.gmp.mac.earlyinit to false.
Differential Revision: https://phabricator.services.mozilla.com/D34085
--HG--
extra : moz-landing-system : lando
Change the Mac GMP process launch to include sandboxing params on the command line to allow the sandbox to be started earlier during GMP process launch. Content, extension, and RDD processes have already been changed to start the sandbox earlier.
Update GMPProcessParent to override GeckoChildProcessHost methods used to construct sandboxing parameters. Pass the plugin path as a sandbox parameter so that the sandbox rules can whitelist the plugin directory which is now read after the sandbox is enabled in the plugin process. On development builds, pass "testingReadPath" params so directories needed during automated tests can be whitelisted.
Update Mac sandboxing code to detect GMP sandbox params on the command line and enable the sandbox with additional arguments needed for early sandbox start.
Allow reverting to the old implementation by setting security.sandbox.gmp.mac.earlyinit to false.
Differential Revision: https://phabricator.services.mozilla.com/D34085
--HG--
extra : moz-landing-system : lando