Commit Graph
1484 Commits
Author SHA1 Message Date
Keith Cirkel dabb307cbf Bug 2045043 - Part 1 - Fixup final classes using _FINAL cycle collecting isupports macro in dom/base r=dom-core-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D305280
2026-06-09 11:17:25 +00:00
Masayuki Nakano 6388e58841 Bug 2044523 - Make nsPIDOMWindow.h stop including nsPIDOMWindowInlines.h r=dom-core-reviewers,geckoview-reviewers,media-playback-reviewers,webrtc-reviewers,win-reviewers,layout-reviewers,manuel,aosmond,smaug,bwc,gstoll,dholbert,farre,m_kato
This patch does not make some header files stop including the inline
header because fixing them require more changes.

Note that `#include "nsComponentManagerUtils.h"` is fixing a bustage
caused by "use of undeclared identifier 'do_CreateInstance'" error.

Differential Revision: https://phabricator.services.mozilla.com/D304432
2026-06-09 03:49:55 +00:00
Daniel Holbert 10725540f6 Bug 2037754: Use 'MakeAndAddRef' instead of 'new' when allocating runnable for nsContentUtils::AddScriptRunner. r=dom-core,smaug
MakeAndAddRef ensures that the freshly-allocated object immediately gets a
refcount of 1 (before it's even passed to AddScriptRunner).  This avoids
several potential footguns that otherwise exist with a zero-refcount
freshly-allocated object.

It also makes the ownership-transfer semantics more clear
(via the already_AddRefed type that it produces) - AddScriptRunner is taking
ownership of the object, rather than using it temporarily while the caller
maintains ownership.

Differential Revision: https://phabricator.services.mozilla.com/D299039
2026-05-07 06:35:57 +00:00
Bas Schouten 802d95988e Bug 2035873: Ensure significantly more GC/CC probes report process-specific data. r=smaug,TravisLong
Differential Revision: https://phabricator.services.mozilla.com/D297581
2026-05-01 15:55:01 +00:00
Sylvestre Ledru 9eb1a31a98 Bug 2023419 - Remove Emacs/Vim modelines from dom/ r=emilio,media-playback-reviewers,webidl,padenot
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287843
2026-03-16 21:02:32 +00:00
Jens Stutte be381ad8ad Bug 2019024 - Part 1: Defer post-GC/CC jemalloc purge to idle scheduling. r=smaug
After GC/CC completion, jemalloc_free_dirty_pages() synchronously purges
every arena on the main thread. This is redundant when the idle purge
infrastructure (memory.lazypurge.*) is enabled, since arenas are already
queued for deferred purge during GC by the allocation path.

Add TaskController::RequestIdleMemoryCleanup() which kicks the idle purge
runner without the pending-task guard that MayScheduleIdleMemoryCleanup
has, and falls back to synchronous purge when lazy purge is disabled.
Replace the two jemalloc_free_dirty_pages() calls in nsJSEnvironment.cpp
(GC and CC completion) with this new method.

Differential Revision: https://phabricator.services.mozilla.com/D284731
2026-03-05 16:43:32 +00:00
Jon Coppeard be7ac4944a Bug 1693542 - Part 2: Add GC parameter and shell options to control concurrent marking r=sfink,dom-worker-reviewers,edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D279706
2026-02-06 11:41:36 +00:00
Ryan Hunt b5c06a3466 Bug 1988289 - Don't terminate worker when there are pending JS async tasks. r=iain,asuth,dom-worker-reviewers,smaug,edenchuang
A worker can be GC'ed and shutdown even if there are async tasks pending
if a StrongWorkerRef is not held by the async task. This can result in
a worker being terminated too early if it's just waiting on a WebAssembly
compile task.

Add two new JS-API callbacks for monitoring the progress of async tasks,
and use this in the workers code to create and release StrongWorkerRefs.

These callbacks are used with the Atomics.waitAsync background tasks,
which are tasks that can be canceled if there is an explicit shutdown
request. This previously was handled automatically, but now if there
is StrongWorkerRef for these tasks, it seems like we need a way to
cancel these tasks. A JS::CancelAsyncTasks embedder function is added
to do this and is invoked when the worker is explicitly asked to
shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D265016
2025-12-15 22:17:02 +00:00
Cristina Horotan 52e447e585 Revert "Bug 1988289 - Don't terminate worker when there are pending JS async tasks. r=iain,asuth,dom-worker-reviewers,smaug,edenchuang" for causing SM failures
This reverts commit 54d5bd08f3.
2025-12-12 23:09:36 +00:00
Ryan Hunt 54d5bd08f3 Bug 1988289 - Don't terminate worker when there are pending JS async tasks. r=iain,asuth,dom-worker-reviewers,smaug,edenchuang
A worker can be GC'ed and shutdown even if there are async tasks pending
if a StrongWorkerRef is not held by the async task. This can result in
a worker being terminated too early if it's just waiting on a WebAssembly
compile task.

Add two new JS-API callbacks for monitoring the progress of async tasks,
and use this in the workers code to create and release StrongWorkerRefs.

These callbacks are used with the Atomics.waitAsync background tasks,
which are tasks that can be canceled if there is an explicit shutdown
request. This previously was handled automatically, but now if there
is StrongWorkerRef for these tasks, it seems like we need a way to
cancel these tasks. A JS::CancelAsyncTasks embedder function is added
to do this and is invoked when the worker is explicitly asked to
shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D265016
2025-12-12 22:33:16 +00:00
Emilio Cobos Álvarez 256e9aa1ec Bug 1998225 - Remove some unused nsView includes. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D271260
2025-11-04 19:06:23 +00:00
Emilio Cobos Álvarez 89828b8d4c Bug 1994964 - Remove unused view usage in nsJSEnvironment. r=tnikkel,layout-reviewers
It seems in bug 1377131 this used to call
nsViewManager::GetLastUserEventTime.

Bug 1727972 changed that but likely forgot to remove the early returns.

Differential Revision: https://phabricator.services.mozilla.com/D269030
2025-10-17 16:06:28 +00:00
Atila Butkovits fa287dbc79 Revert "Bug 1994964 - Remove unused view usage in nsJSEnvironment. r=tnikkel,layout-reviewers" for causing failures complaining about document node.
This reverts commit 9fd8c6518f.
2025-10-17 15:32:32 +00:00
Emilio Cobos Álvarez 9fd8c6518f Bug 1994964 - Remove unused view usage in nsJSEnvironment. r=tnikkel,layout-reviewers
It seems in bug 1377131 this used to call
nsViewManager::GetLastUserEventTime.

Bug 1727972 changed that but likely forgot to remove the early returns.

Differential Revision: https://phabricator.services.mozilla.com/D269030
2025-10-17 13:33:29 +00:00
Kelsey Gilbert f5e3591910 Bug 1958371 - Reduce header-header-includes of nsGlobalWindowInner.h. r=mccr8,chutten,timhuang
* Forward s/nsGlobalWindowInner_CachesEnabled/nsGlobalWindowInner::CachesEnabled/.

Differential Revision: https://phabricator.services.mozilla.com/D244408
2025-09-05 19:36:07 +00:00
agoloman 2c8936cbbf Revert "Bug 1958371 - Reduce header-header-includes of nsGlobalWindowInner.h. r=mccr8,chutten,timhuang" for causing build bustages @TimeoutManager.cpp.
This reverts commit 4b30815167.
2025-08-26 16:37:54 +00:00
Kelsey Gilbert 4b30815167 Bug 1958371 - Reduce header-header-includes of nsGlobalWindowInner.h. r=mccr8,chutten,timhuang
* Forward s/nsGlobalWindowInner_CachesEnabled/nsGlobalWindowInner::CachesEnabled/.

Differential Revision: https://phabricator.services.mozilla.com/D244408
2025-08-26 15:30:13 +00:00
Emilio Cobos Álvarez 791917d8af Bug 1976665 - Sort headers in dom/. r=dom-core,media-playback-reviewers,webrtc-reviewers,dom-storage-reviewers,padenot,janv,smaug,jesup,jib
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.

Differential Revision: https://phabricator.services.mozilla.com/D256800
2025-08-05 11:47:34 +00:00
Jon Coppeard 117b4d7cfc Bug 1967467 - Add a GC parameter to control the nursery's max collection time target r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D250397
2025-05-22 07:47:32 +00:00
Iain Ireland 2e888f61c8 Bug 1467846: Part 10: Introduce DelayedDispatchToEventLoopCallback r=arai,dom-worker-reviewers,smaug
[Atomics.waitAsync](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/waitAsync) creates a promise that can be resolved via Atomics.notify, or after an optional timeout. The timeout is [implemented](https://html.spec.whatwg.org/multipage/webappapis.html#hostenqueuetimeoutjob) using the [HostEnqueueTimeoutJob hook](https://html.spec.whatwg.org/multipage/webappapis.html#hostenqueuetimeoutjob), which queues a global task (not a microtask).

This patch adds a new API (DelayedDispatchToEventLoopCallback) accessible by the JS engine that utilized the TimeoutManager for executing the steps outlined in the HostEnqueTimeoutJob. Unlike DispatchToEventCallback, this is currently restricted to only threads which support TimeoutManager (the Main thread and the Workers Thread). This should not be enabled on worklets per the discussion [here](https://phabricator.services.mozilla.com/D212876#inline-1206374). The next patch adds an implementation in worker threads. A later patch in the stack adds an implementation for the shell.

Depends on D212875

Differential Revision: https://phabricator.services.mozilla.com/D212876
2025-05-13 10:04:54 +00:00
Yulia 4a6c4f46f1 Bug 1467846: Part 5: Refactor JS::Dispatchable consumers to use a UniquePtr; r=arai,smaug
This patch is a major refactoring that introduces a concept of ownership of JS::Dispatchables via
UniquePtrs. Embeddings must now use UniquePtrs to reference Dispatchables passed by the engine.

Two static methods are introduced to Dispatchable: Run and ReleaseFailedTask.

Run is used to release the UniquePtr prior to running. We do this because we still rely on the
js_delete(this) call inside of OffThreadPromiseTask::run in cases of web assembly, namely cases when
we never dispatch to the embedding and need to clean up
[1](https://searchfox.org/mozilla-central/rev/6cc05c6620814bf3eb05278ccf3b1f49690b7740/js/src/vm/HelperThreads.cpp#1542).
This will be refactored in a future step covered by Bug# 1959032.

ReleaseFailedTask similarily releases the task. This relies on the task having been registered with
the OffThreadPromiseRuntimeState class. As the only override of `run` is in OffThreadPromiseTask,
thus far there have been no guarantees of how this is done. This will be addressed in the next
patch.

Depends on D212878

Differential Revision: https://phabricator.services.mozilla.com/D244936
2025-05-13 10:04:36 +00:00
Florian Quèze 6147d3f360 Bug 1956726 - Migrate histograms to use Glean APIs in dom/, r=chutten.
Differential Revision: https://phabricator.services.mozilla.com/D244177
2025-04-03 21:02:54 +00:00
Olli Pettay 0b9f7a110d Bug 1929640 - Add a mode to CCGCScheduler where it can collect faster in case lots of garbage is created and there isn't too much idle time to run the slices, r=mccr8,sfink
Differential Revision: https://phabricator.services.mozilla.com/D228215
2024-11-10 17:58:12 +00:00
Sylvestre Ledru fc8493dbfe Bug 1920521 - Remove jprof from m-c r=jesup,zeid
Differential Revision: https://phabricator.services.mozilla.com/D223158
2024-10-01 14:13:43 +00:00
Jon Coppeard 3bed86c091 Bug 1850746 - Part 2: Remove unused JSGC_MAX_EMPTY_CHUNK_COUNT GC parameter r=sfink
Although all the infrastructure is there to set this parameter it is never
actually used for anything.

Differential Revision: https://phabricator.services.mozilla.com/D220408
2024-09-04 11:43:05 +00:00
Steve Fink 3b655af636 Bug 1906255 - Allow disabling the nursery via gcparam r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D217186
2024-07-22 15:55:22 +00:00
Steve Fink 9fdc99ed36 Bug 1899615 - Backed out changeset d24ceaa43f47
Differential Revision: https://phabricator.services.mozilla.com/D215437
2024-07-01 22:46:27 +00:00
Steve Fink ed8f0f2cf1 Bug 1766044 - Emit CC start/end markers for all cycle collections, not just mainthread r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212052
2024-06-25 22:14:09 +00:00
Steve Fink ab2b43bb9f Bug 1766044 - Move ForgetSkippable marker from mainthread only to a common place r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212051
2024-06-25 22:14:09 +00:00
Steve Fink 627b10e934 Bug 1766044 - Give every cycle collecting thread a stats struct r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212050
2024-06-25 22:14:08 +00:00
Steve Fink 94c9e5975f Bug 1766044 - Remove MainThreadCycleCollectorStats and instead make MaybeLogStats and MaybeNotifyStats static functions using sCCStats r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212049
2024-06-25 22:14:08 +00:00
Steve Fink 653c09c1be Bug 1766044 - Move CycleCollectorStats from nsJSEnvironment.cpp to its own file r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212048
2024-06-25 22:14:08 +00:00
Steve Fink 242858bbc1 Bug 1899872 - Move SliceBudget (and {Work,Time}Budget) from js:: namespace to JS:: r=jonco,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212303
2024-06-21 16:22:26 +00:00
pstanciu 66663d5583 Backed out changeset e38543d56e9b (bug 1899872) for causing build bustages CLOSED TREE 2024-06-19 01:26:07 +03:00
Steve Fink 043e1856ca Bug 1899872 - Move SliceBudget (and {Work,Time}Budget) from js:: namespace to JS:: r=jonco,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212303
2024-06-18 21:46:32 +00:00
Noemi Erli f0cee3546c Backed out changeset 2753b7c1309f (bug 1899872) for causing build bustages in testSliceBudget.cpp CLOSED TREE 2024-06-13 03:05:33 +03:00
Steve Fink 180361fc44 Bug 1899872 - Move SliceBudget (and {Work,Time}Budget) from js:: namespace to JS:: r=jonco,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D212303
2024-06-12 23:01:12 +00:00
Steve Fink e68df02440 Bug 1899615 - Document ComputeInterSliceGCBudget r=pbone
Differential Revision: https://phabricator.services.mozilla.com/D212045
2024-05-31 17:33:58 +00:00
Jon Coppeard e8a9833660 Bug 1821671 - Part 2: Add pref for setting the maximum number of marking threads to use r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D207288
2024-04-16 14:33:15 +00:00
Paul Bone b2fb99a6ea Bug 1885859 - Relax rules for running a minor GC during idle time r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D204727
2024-03-19 01:39:20 +00:00
Jon Coppeard 8f75b5a7cf Bug 1787526 - Part 1: Add configuration for semispace nursery r=sfink
Add a GC parameter and pref for semispace nursery which is disabled by default.

Enable it for the shell rootanalysis job to get get some test coverage.

Differential Revision: https://phabricator.services.mozilla.com/D196431
2024-03-18 16:13:50 +00:00
Jon Coppeard 85179f3c49 Bug 1881303 - Part 2: Expose eager nursery collection tunables as prefs r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D202476
2024-02-23 09:20:31 +00:00
Olli Pettay e1d90da6db Bug 1871552, trigger GC soon after CC only if also lots of refcounted objects were unlinked, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D197334
2024-01-22 17:54:48 +00:00
Bas Schouten 8884cd5257 Bug 1869835 - Part 3: Convert CC/GC markers to the new MarkerSchema so it gets full ETW support. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D196374
2023-12-21 18:17:41 +00:00
Olli Pettay 1061b850af Bug 1870477 - Trigger GC soon after CC if CC found lots of GCed garbage, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D196672
2023-12-18 22:49:50 +00:00
Olli Pettay eea8aec6c9 Bug 1868744 - If JS engine triggered a GC slice, don't trigger another too soon from CCGCScheduler, r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D195755
2023-12-07 12:34:33 +00:00
serge-sans-paille 7d287476c5 Bug 1859820 - Remove Global CCGCScheduler initialization r=jonco
Current static variable is just used as a placeholder for in-place
initialization. So use an appropriate static storage instead.

This has the advantage of *not* requiring global initialization,
removing the useless current one (which was overridden by the in-place
new anyway).

It also fixes an initialization order dependency \o/

Differential Revision: https://phabricator.services.mozilla.com/D191489
2023-10-23 17:23:14 +00:00
Olli Pettay 271c1164b1 Bug 1857731 - Schedule PREPARE_FOR_PAGELOAD to happen during idle time, r=jonco
Minor GC doesn't really need any hint from RefreshDriver, it is enough to have idle time.
(separately I'm trying to find a way to remove the explicit GetNextTickHint() for other slices and make also those just rely on the idle time)

On tryserver this doesn't show any major change to the performance
https://treeherder.mozilla.org/perfherder/compare?originalProject=try&originalRevision=126820c114282edb62de142b7f5ac7239e6c5622&newProject=try&newRevision=a376d5835ca8f807913b496aa5140a29026ff74c&page=1&framework=13
but locally this seems to make scheduling a bit more predictable.

Differential Revision: https://phabricator.services.mozilla.com/D190386
2023-10-13 09:58:47 +00:00
Olli Pettay 1f456e4432 Bug 1856577 - Consider to trigger minor GC before a page load, r=jonco
This doesn't cover all the page loads, need to run some more performance tests before using this everywhere.

Depends on D189917

Differential Revision: https://phabricator.services.mozilla.com/D189918
2023-10-05 18:11:36 +00:00
Olli Pettay b2dd243b7b Bug 1856574 - Run GC/CC slices before page load only if GC/CC is ongoing, and increase the slice delays, r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D189917
2023-10-05 18:11:35 +00:00