285 Commits
Author SHA1 Message Date
Daniel Holbert c8723c0549 Bug 2044510: Pass already_AddRefed types by-value instead of by rvalue reference, in xpcom/. r=xpcom-reviewers,emilio
See https://bugzilla.mozilla.org/show_bug.cgi?id=2044510#c0 for more details.

Differential Revision: https://phabricator.services.mozilla.com/D304349
2026-06-05 21:06:31 +00:00
Daniel Holbert efbf700080 Bug 2043788: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{base,ds}/. r=xpcom-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D303597
2026-05-30 17:24:05 +00:00
agoloman 445c467866 Revert "Bug 2043790: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/tests/. r=xpcom-reviewers,emilio" for causing build bustages @TestNonBlockingAsyncInputStream.cpp.
This reverts commit ed098a6dfc.

Revert "Bug 2043789: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{io,ioutils}/. r=xpcom-reviewers,emilio"

This reverts commit aa8e617fd8.

Revert "Bug 2043788: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{base,ds}/. r=xpcom-reviewers,emilio"

This reverts commit 4f52fb1147.
2026-05-30 17:00:34 +00:00
Daniel Holbert 4f52fb1147 Bug 2043788: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/{base,ds}/. r=xpcom-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D303597
2026-05-30 15:26:20 +00:00
Matthew Gaudet ae5f1b7f6c Bug 2036939 - Don't leak user-input-handling-state across coalesced microtasks r=smaug
This is a regresion from Bug 2010960.

This latent bug was revealed by the next patch in this stack where we are able to
coalesce more microtasks than we were able to before.

The core problem is that coalescing microtasks is supposed to be a transparent
operation, such that -semantically- every microtask is executed in a loop in
its own state setup and torn-down between tasks. However because setup and
teardown are costly, 2010960 hides that cost by draining more microtasks if
they are compatible.

The bug here is that if the AutoHandlingUserInputStatePusher on the first
task, before we try to drain more, indictes we're handling user input, that
leaks into subsequent tasks, since AutoHandlingUserInputStatePusher ahuip(false)
does nothing, rather than clearing the state below it (which was semantically
how I thouht it had worked)

Differential Revision: https://phabricator.services.mozilla.com/D299218
2026-05-20 18:15:51 +00:00
Jon Coppeard 6419525152 Bug 2038125 - Part 4: Use designated initializer lists for JSClassOps in the browser r=mccr8,chutten
The only wrinkle here is I had to disable warnings about missing designated
field initializers for security/certverifier because it defines -Wextra which
otherwise causes it to complain about this pattern.

Differential Revision: https://phabricator.services.mozilla.com/D299451
2026-05-13 07:50:42 +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
Lando 8dfb19ec7c Bug 1983159: apply code formatting via Lando
# ignore-this-changeset
2026-04-30 18:18:15 +00:00
Tommy Sandanasamy f3f0b3b539 Bug 1983159 - Allow FinalizationQueueObject to get the incumbent global without scheduling state r=arai,smaug
Stop getting the optionalHostDefinedData object (scheduling state in gecko) for the FinalizationObject
which only needs the incumbent global.

Drive-by: Don't repeat getHostDefined global when it's right there.

Bug 2025988 is about cleaning up some of these naming inconsistencies

Differential Revision: https://phabricator.services.mozilla.com/D284008
2026-04-30 18:18:05 +00:00
Tommy Sandanasamy 725606536e Bug 1983159 - Store incumbent global and optional host defined data in two slots inside the JS engine r=smaug,arai
The general thrust of this patch stack is that we go from having

    [Promise              ]
    |HostDefinedData Slot | --> JSObject [ 0: InbumbentGlobal,
                                           1: SchedulingState] (almost always exists)

to

    [Promise                       ]
    | IncumbentGlobal Slot         |
    | optionalHostDefinedData Slot | --> JSObject [ 0: SchedulingState ] (almost never exists)

The result of this is improved performance in the common case where the
host never provides anything beyond the incumbent global for the JS engine to carry
about.

Prior to this patch microtasks store incumbent global in one of two ways:
Either as the 'hostDefinedGlobal' or as the incumbent global on the host
defined data object.

After this patch the incumbent global is _always_ stored the same way, and can
be handled the same way; the only thing that is stored in the
'optionalHostDefinedData' is the scheduling state if it exists.

This means incumbent global handling in ExtractIncumbentAndSchedulingState is
nicely simplified.

This is a rollup of D277008, D277009, D277010, D277011, D282284, D284008.

Differential Revision: https://phabricator.services.mozilla.com/D297138
2026-04-30 18:18:02 +00:00
Florian Quèze bb79a8d71c Bug 2033448 - Clear mUncaughtRejectionObservers in ~CycleCollectedJSContext to avoid shutdown crash on opt builds, r=smaug.
Differential Revision: https://phabricator.services.mozilla.com/D295279
2026-04-20 21:57:59 +00:00
Jon Coppeard 6ba219064a Bug 2025962 - Add back pointer to queued CleanupRunnable r=mccr8
Currently this checks whether it needs to dispatch a runnable based on whether
there are already callbacks in mCallbacks, but it can just as easily keep a
weak pointer to any dispatched runnable and that lets us signal to the runnable
that there's nothting to do when FinalizationRegistryCleanup is destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D289786
2026-03-31 13:21:31 +00:00
rperta 590c62d425 Revert "Bug 2025962 - Add back pointer to queued CleanupRunnable r=mccr8" for causing failures at CycleCollectedJSContext.cpp
This reverts commit 88d7be48eb.
2026-03-30 19:14:29 +00:00
Jon Coppeard 88d7be48eb Bug 2025962 - Add back pointer to queued CleanupRunnable r=mccr8
Currently this checks whether it needs to dispatch a runnable based on whether
there are already callbacks in mCallbacks, but it can just as easily keep a
weak pointer to any dispatched runnable and that lets us signal to the runnable
that there's nothting to do when FinalizationRegistryCleanup is destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D289786
2026-03-30 17:36:24 +00:00
Cosmin Sabou 61c78c13b2 Revert "Bug 2025962 - Add back pointer to queued CleanupRunnable r=mccr8" for causing frequent asan failures on CycleCollectedJSContext.
This reverts commit 621e29eb2b.
2026-03-26 22:52:22 +00:00
Jon Coppeard 621e29eb2b Bug 2025962 - Add back pointer to queued CleanupRunnable r=mccr8
Currently this checks whether it needs to dispatch a runnable based on whether
there are already callbacks in mCallbacks, but it can just as easily keep a
weak pointer to any dispatched runnable and that lets us signal to the runnable
that there's nothting to do when FinalizationRegistryCleanup is destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D289786
2026-03-26 12:29:30 +00:00
Sylvestre Ledru 6149f49299 Bug 2023419 - Remove Emacs/Vim modelines from xpcom/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287878
2026-03-16 17:22:07 +00:00
Matthew Gaudet 3088b30b59 Bug 2010960 - Fix parameter names to match DOM style r=smaug
(Squshing this is into the stack has gotten to be a bit exhausting, so putting
 this one on top)

Differential Revision: https://phabricator.services.mozilla.com/D285618
2026-03-05 23:55:32 +00:00
Matthew Gaudet 73a02f08b1 Bug 2010960 - Coalesce MicroTask execution r=smaug
Add an inner loop for after task setup has occurred where we continue to try and drain
compatible microtasks.

Differential Revision: https://phabricator.services.mozilla.com/D282844
2026-03-05 23:55:26 +00:00
Matthew Gaudet 05e43e2494 Bug 2010960 - Split apart MustConsumeMicroTask r=smaug
To be able to use the same interface for inspecting microtasks which get peeked,
we break apart the class into a small hierarchy to make it clear what consumes which when.

Differential Revision: https://phabricator.services.mozilla.com/D282843
2026-03-05 23:55:22 +00:00
Matthew Gaudet a4e07959cf Bug 2010960 - Move flow markers closer to task execution r=smaug
There's a small functionality change here: a task which is discarded and never run will not have a
~zero duration marker in the profiler, unlike previously

(also moved comment where more relevant)

Differential Revision: https://phabricator.services.mozilla.com/D282841
2026-03-05 23:55:16 +00:00
Matthew Gaudet 61ec178914 Bug 2010960 - Extract userInputStateSwitching code into a function r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282840
2026-03-05 23:55:13 +00:00
Matthew Gaudet 64e8db46e9 Bug 2010960 - Extract pre-execution checks for JS microtasks into a method r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282839
2026-03-05 23:55:10 +00:00
Matthew Gaudet 227eab45c0 Bug 2010960 - Refactor task data management into functions r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282838
2026-03-05 23:55:07 +00:00
Matthew Gaudet 5bb3a29f39 Bug 2010960 - Remove superflous cx parameter r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282837
2026-03-05 23:55:04 +00:00
Matthew Gaudet e92488e77a Bug 2010960 - Some more tidying; hoist check r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282836
2026-03-05 23:55:00 +00:00
Matthew Gaudet 90eeda4e9d Bug 2010960 - Extract host-defined data interaction into function r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282835
2026-03-05 23:54:57 +00:00
Matthew Gaudet caa285d7af Bug 2010960 - Restructure to put job-dependent stuff closer to job-execution r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282834
2026-03-05 23:54:54 +00:00
Matthew Gaudet 7b462df263 Bug 2010960 - Restructure RunJSMicroTask to use scopes rather than Maybe<T> initialization r=smaug
Once we have broken apart CallSetup we can actually just use scoped allocation and deallocation.

This patch also takes the opportunity to stop doing a TLS get for CycleCollectedJSContext given
we always already have that pointer just up the callstack.

Differential Revision: https://phabricator.services.mozilla.com/D282833
2026-03-05 23:54:51 +00:00
Matthew Gaudet 41db1a3231 Bug 2010960 - Tidy up before restructuring r=smaug
A small group of cleanups to set up future patches

Differential Revision: https://phabricator.services.mozilla.com/D282832
2026-03-05 23:54:48 +00:00
Matthew Gaudet fdcbad894f Bug 2010960 - Inline CallSetup for specialization r=smaug
This is an extremely simple hand-inlining of CallSetup. This is done to reveal
specialization and reorganization opportunities that are hidden behind the
CallSetup interface.

Differential Revision: https://phabricator.services.mozilla.com/D282831
2026-03-05 23:54:45 +00:00
Matthew Gaudet 308afbd565 Bug 2010960 - Split RunMicroTask in two r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282830
2026-03-05 23:54:42 +00:00
Serban Stanca 230d1f3730 Revert "Bug 2010960 - Fix parameter names to match DOM style r=smaug" for causing junit failures in JSContext.h.
This reverts commit 6b0f5771dc.

This reverts commit f7a0b7753b.

This reverts commit 885268980b.

This reverts commit 9cde06fcd4.

This reverts commit b3616bd564.

This reverts commit 08aa61d904.

This reverts commit 35de1cab05.

This reverts commit b5c62a0df2.

This reverts commit ad19a9f43f.

This reverts commit 7ff517c384.

This reverts commit 0715dc06d2.

This reverts commit d063a51562.

This reverts commit 16501e779c.

This reverts commit 87551c2729.

This reverts commit 110b553305.

This reverts commit e813783f69.

This reverts commit 4c53314026.
2026-03-04 00:58:46 +00:00
Matthew Gaudet 6b0f5771dc Bug 2010960 - Fix parameter names to match DOM style r=smaug
(Squshing this is into the stack has gotten to be a bit exhausting, so putting
 this one on top)

Differential Revision: https://phabricator.services.mozilla.com/D285618
2026-03-03 21:34:27 +00:00
Matthew Gaudet 885268980b Bug 2010960 - Coalesce MicroTask execution r=smaug
Add an inner loop for after task setup has occurred where we continue to try and drain
compatible microtasks.

Differential Revision: https://phabricator.services.mozilla.com/D282844
2026-03-03 21:34:21 +00:00
Matthew Gaudet 9cde06fcd4 Bug 2010960 - Split apart MustConsumeMicroTask r=smaug
To be able to use the same interface for inspecting microtasks which get peeked,
we break apart the class into a small hierarchy to make it clear what consumes which when.

Differential Revision: https://phabricator.services.mozilla.com/D282843
2026-03-03 21:34:19 +00:00
Matthew Gaudet 08aa61d904 Bug 2010960 - Move flow markers closer to task execution r=smaug
There's a small functionality change here: a task which is discarded and never run will not have a
~zero duration marker in the profiler, unlike previously

(also moved comment where more relevant)

Differential Revision: https://phabricator.services.mozilla.com/D282841
2026-03-03 21:34:13 +00:00
Matthew Gaudet 35de1cab05 Bug 2010960 - Extract userInputStateSwitching code into a function r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282840
2026-03-03 21:34:11 +00:00
Matthew Gaudet b5c62a0df2 Bug 2010960 - Extract pre-execution checks for JS microtasks into a method r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282839
2026-03-03 21:34:08 +00:00
Matthew Gaudet ad19a9f43f Bug 2010960 - Refactor task data management into functions r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282838
2026-03-03 21:34:05 +00:00
Matthew Gaudet 7ff517c384 Bug 2010960 - Remove superflous cx parameter r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282837
2026-03-03 21:34:02 +00:00
Matthew Gaudet 0715dc06d2 Bug 2010960 - Some more tidying; hoist check r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282836
2026-03-03 21:34:00 +00:00
Matthew Gaudet d063a51562 Bug 2010960 - Extract host-defined data interaction into function r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282835
2026-03-03 21:33:57 +00:00
Matthew Gaudet 16501e779c Bug 2010960 - Restructure to put job-dependent stuff closer to job-execution r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282834
2026-03-03 21:33:54 +00:00
Matthew Gaudet 87551c2729 Bug 2010960 - Restructure RunJSMicroTask to use scopes rather than Maybe<T> initialization r=smaug
Once we have broken apart CallSetup we can actually just use scoped allocation and deallocation.

This patch also takes the opportunity to stop doing a TLS get for CycleCollectedJSContext given
we always already have that pointer just up the callstack.

Differential Revision: https://phabricator.services.mozilla.com/D282833
2026-03-03 21:33:52 +00:00
Matthew Gaudet 110b553305 Bug 2010960 - Tidy up before restructuring r=smaug
A small group of cleanups to set up future patches

Differential Revision: https://phabricator.services.mozilla.com/D282832
2026-03-03 21:33:49 +00:00
Matthew Gaudet e813783f69 Bug 2010960 - Inline CallSetup for specialization r=smaug
This is an extremely simple hand-inlining of CallSetup. This is done to reveal
specialization and reorganization opportunities that are hidden behind the
CallSetup interface.

Differential Revision: https://phabricator.services.mozilla.com/D282831
2026-03-03 21:33:46 +00:00
Matthew Gaudet 4c53314026 Bug 2010960 - Split RunMicroTask in two r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D282830
2026-03-03 21:33:43 +00:00
Matthew Gaudet 3aa380c71b Bug 1983157 - Remove JobQueue subclassing support for job storage r=arai,smaug
Differential Revision: https://phabricator.services.mozilla.com/D281802
2026-02-05 03:08:57 +00:00
Matthew Gaudet 0b02c4cf28 Bug 2010911 - Cleanup PromiseJobRunnable r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D279353
2026-01-19 16:09:09 +00:00