Commit Graph

895 Commits

Author SHA1 Message Date
Olli Pettay
d4b1fee6dc Bug 1907794, trace certainly black event listeners, r=mccr8,dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D217125
2024-07-24 15:24:17 +00:00
aiunusov
1fb2fba720 Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth
Differential Revision: https://phabricator.services.mozilla.com/D209334
2024-06-27 12:39:47 +00:00
Emilio Cobos Álvarez
d1a07840f8 Bug 1897589 - Simplify worker shutdown checks. r=jstutte,dom-worker-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D214740
2024-06-27 11:09:54 +00:00
Eden Chuang
feb314e721 Bug 1894231 - P3 Remove WorkerPrivate* in WorkerMainThreadRunnable. r=dom-worker-reviewers,extension-reviewers,smaug,rpl
Remove mWorkerPrivate from WorkerMainThreadRunnable. Instead, using a ThreadSafeWorkerRef to keep Worker alive until the created syncLoop is destroyed.

In general, WorkerMainThreadRunnable::mWorkerPrivate is only used for dispatching the MainThreadStopSyncLoopRunnable back to the Worker thread. Because of the syncLoop, the Worker is supposed to be kept alive until the created syncLoop is destroyed.

RefPtr<ThreadSafeWorkerRef> WorkerMainThreadRunnable::mWorkerRef is introduced to ensure a valid WorkerPrivate during WorkerMainThreadRunnable's execution.

WorkerMainThreadRunnable::mWorkerRef is allocated just before creating a syncLoop in WorkerMainThreadRunnable::Dispatch. And released after the created syncLoop::Run() finishes.

Depends on D212556

Differential Revision: https://phabricator.services.mozilla.com/D212557
2024-06-24 22:20:51 +00:00
pstanciu
1dd9e24c1d Backed out changeset 08430749c503 (bug 1817981) for causing mochitest failures on test_worker_in_background.html 2024-06-19 03:11:23 +03:00
aiunusov
ba7f0001ff Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth
Differential Revision: https://phabricator.services.mozilla.com/D209334
2024-06-18 21:36:01 +00:00
Stanca Serban
4f6cd29ecf Backed out changeset e1c3d0c745df (bug 1817981) for causing mochitests failures in test_worker_in_background.html. 2024-06-18 07:12:30 +03:00
aiunusov
e3b021f035 Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth
Differential Revision: https://phabricator.services.mozilla.com/D209334
2024-06-17 20:53:36 +00:00
Cristian Tuns
3592169d4b Backed out changeset 072c9a687784 (bug 1817981) for causing mochitest failures in test_worker_in_background.html CLOSED TREE 2024-06-13 23:30:43 -04:00
aiunusov
2d09a12c0b Bug 1817981 - Add possibility to mark worker private being in background, r=smaug,asuth
Differential Revision: https://phabricator.services.mozilla.com/D209334
2024-06-13 22:43:23 +00:00
Eden Chuang
2cf44dc031 Bug 1895515 - Correct RunLoopNeverRan() and ResetWorkerPrivateInWorkerThread() sequence for Worker initialization fails. r=dom-worker-reviewers,asuth,smaug
Once WorkerPrivate::ResetWorkerPrivateInWorkerThread() is called, the connection between the WorkerPrivate and the WorkerThread is decoupled. This means the WorkerPrivate is not valid anymore for any WorkerThreadRunnables. So, before decoupling the WorkerPrivate and WorkerThread, we should ensure all pending WorkerThreadRunnables are executed, and the Worker should be in the "Dead" status.

It means the logic in the WorkerPrivate::RunLoopNeverRan() except WorkerPrivate::ScheduleDeletion() should be executed before WorkerPrivate::ResetWorkerPrivateInWorkerThread(). However, currently, these logic are executed after ResetWorkerPrivateInWorkerThread().

Differential Revision: https://phabricator.services.mozilla.com/D210775
2024-05-24 10:09:01 +00:00
Jon Coppeard
e429b81609 Bug 1895661 - Part 2: Add browser prefs for GC zeal r=sfink
There was existing code to read the prefs, but the prefs themselves had been removed.

I renamed the prefs in line with all the other JS GC options, so starting
javascript.options.mem.gc_.

Differential Revision: https://phabricator.services.mozilla.com/D210059
2024-05-13 16:31:20 +00:00
Jon Coppeard
524de2ba8b Bug 1895661 - Part 1: Move GC zeal functions to JS namespace and add separate constants for browser and shell frequency r=sfink
Sensible defaults are very different for the browser and the shell so I added
separate constants. I think the JS testing functions can get called from the
browser and so may pick the wrong default but it's not too serious.

Differential Revision: https://phabricator.services.mozilla.com/D210058
2024-05-13 16:31:20 +00:00
Alexandre Poirot
d6657b7af7 Bug 1821250 - Use a timer on debugger control runnable to ensure running them even if worker uses Atomics.wait. r=asuth
Atomics.wait prevent WorkerDebuggerRunnable's from running by blocking the event loop.
While dispatching these runnables, also spawn a short timer which would interrupt the worker
and tentatively try to drain the debugger queue and resume any debugger runnable which may be blocked.

Differential Revision: https://phabricator.services.mozilla.com/D194081
2024-05-13 11:52:08 +00:00
Steve Fink
1f2a9f02c3 Bug 1891277 - correctly match JS GC memory pref names r=arai
Differential Revision: https://phabricator.services.mozilla.com/D207351
2024-04-22 23:55:57 +00:00
Eden Chuang
a718e4758f Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth
WorkerRunnable no longer keeps a raw pointer(mWorkerPrivate) for the associated WorkerPrivate in this patch.
Removing the WorkerRunnable::mWorkerPrivate needs to fix the following problems.

1. Thread assertions in WorkerRunnable::Dispatch()

To fix this problem, the associated WorkerPrivate is as a parameter and passed to WorkerRunnable::Dispatch() for the dispatching thread assertions. This associated WorkerPrivate is also propagated to PreDispatch() and PostDispatch() for the children classes of WorkerRunnable()

2. Get the associated WorkerPrivate in WorkerRunnable::Run() for environment setup(GlobabObject, JSContext setting for the runnable)

- For WorkerThreadRunnable

Since WorkerThreadRunnable is supposed to run on the worker thread, it does not need to keep a raw pointer to WorkerPrivate as its class member. GetCurrentThreadWorkerPrivate() should always get the correct WorkerPrivate for WorkerThreadRunnable.

- For WorkerParentThreadRunnable

WorkerParentRef is introduced to keep a RefPtr<WorkerPrivate> for WorkerParentThreadRunnable instead of using a raw pointer.
Checking the associated WorkerPrivate existence by WorkerParentRef at the beginning of WorkerParentThreadRunnable::Run(). If the Worker has already shut down, WorkerParentThreadRunnable cannot do anything with the associated WorkerPrivate, so WorkerParentThreadRunnable::Run() will return NS_OK directly but with a warning.

The associated WorkerPrivate is also passed into WorkerRun(), PreRun(), and PostRun(), so the majority of implementations of child classes of WorkerRunnable do not need to be changed.

If there are any cases in which the child classes of WorkerThreadRunnable/WorkerParentThreadRunnable want to keep the associated WorkerPrivate, they should use WorkerRefs instead of raw pointers.

Depends on D205679

Differential Revision: https://phabricator.services.mozilla.com/D207039
2024-04-19 09:41:58 +00:00
Eden Chuang
11d8c5840b Bug 1769913 - P2 WorkerParentThreadRunnable for the runnables dispatched to worker's parent thread. r=dom-worker-reviewers,asuth
In this patch, WorkerParentThreadRunnable is extracted from WorkerThreadRunnable for runnable on the parent thread.

WorkerParentControlRunnable and WorkerParentDebuggeeRunnable are also created for control runnable and debuggee runnable on the parent thread.

Instead of using WorkerRunnable::Target to indicate the thread target, inheriting WorkerThreadRunnable or WorkerParentThreadRunnable to point out that this runnable should run on the worker thread or on the parent thread. So WorkerRunnable::Target is removed in this patch.

This patch also move the dispatching logic into WorkerPrivate to simplify WorkerRunnable::DispatchInternal()'s implementation.

Depends on D205178

Differential Revision: https://phabricator.services.mozilla.com/D205679
2024-04-19 09:41:57 +00:00
Eden Chuang
f9b64790d7 Bug 1769913 - P1 Make WorkerRunnable to be a base class for runnables on Worker thread and Worker's parent thread. r=dom-worker-reviewers,asuth
This is the first step in splitting the parent thread runnable out of WorkerRunnable.

To reuse the runnable dispatching codes in Worker, we still need a base class for runnable on the worker thread and the parent thread.

In this patch, we rename the original WorkerRunnable to WorkerThreadRunnable and make WorkerRunnable to be WorkerThreadRunnable's parent class.

In the second patch, we will create WorkerParentThreadRunnable and its sub-classes, split from WorkerThreadRunnable for runnable on the Worker's parent thread.

And in the third patch, we will re-structure the content of WorkerParentThreadRunnable to remove unnecessary members.

Differential Revision: https://phabricator.services.mozilla.com/D205178
2024-04-19 09:41:57 +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
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
Jan Varga
492e6f8efc Bug 1855142 - Ensure IndexedDabaseManager::mLocale separately; r=dom-storage-reviewers,jari
mLocale is currently initialized in IndexedDatabaseManager::Init which is
called from IndexedDatabaseManager::GetOrCreate if the manager doesn't exist.
This can be a problem when IndexedDatabaseManager::GetOrCreate is called very
early,for example in nsLayoutStatics::Initialize in the parent process.

This is a preparation for moving IndexedDatabaseManager::GetOrCreate from
FactoryOp::Open to InitializeQuotaManager.

Differential Revision: https://phabricator.services.mozilla.com/D189891
2024-02-29 15:28:47 +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
Jon Coppeard
1b29ae75b0 Bug 1875304 - Enable parallel marking on workers r=sfink
This adds a per-process count of helper threads 'reserved' for parallel
marking. This means reserved with respect to parallel marking but not anything
else, so helper threads can still be used for other tasks (including GC
parallel tasks) but the number of runtimes that can mark in parallel is
limited.

The main runtime reserves threads when parallel marking is enabled to
priviledge it over worker runtimes. Workers reserve threads only for the
duration of collection. Failure to reserve threads means parallel marking is
not used.

I don't love the term 'reserved' beacuse it implies the threads cannot be used
for anything else, but I couldn't think of anything better. I've added comments
to describe what it actually means.

Differential Revision: https://phabricator.services.mozilla.com/D201695
2024-02-19 15:45:02 +00:00
Cristian Tuns
b8e971d10b Backed out 2 changesets (bug 1821250) for causing dt failures in Mutex_posix.cpp CLOSED TREE
Backed out changeset d46945ada9ec (bug 1821250)
Backed out changeset 94145877428a (bug 1821250)
2024-02-14 16:58:46 -05:00
Alexandre Poirot
aa44b4dd66 Bug 1821250 - Use a timer on debugger control runnable to ensure running them even if worker uses Atomics.wait. r=asuth
Atomics.wait prevent WorkerDebuggerRunnable's from running by blocking the event loop.
While dispatching these runnables, also spawn a short timer which would interrupt the worker
and tentatively try to drain the debugger queue and resume any debugger runnable which may be blocked.

Differential Revision: https://phabricator.services.mozilla.com/D194081
2024-02-14 17:18:44 +00:00
Jens Stutte
aa54dcc26f Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth,smaug
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-24 16:00:26 +00:00
Daniel Holbert
70297ae259 Bug 1875430 part 2: Convert 'static UniquePtr' global vars to use StaticAutoPtr, in dom/workers. r=dom-worker-reviewers,smaug
Depends on D199167

Differential Revision: https://phabricator.services.mozilla.com/D199168
2024-01-23 19:00:49 +00:00
Cristian Tuns
5de093dcd2 Backed out changeset f3efca74da0f (bug 1875800) for causing build bustages in WorkerPrivate.cpp CLOSED TREE 2024-01-23 11:20:38 -05:00
Jens Stutte
926a1907f0 Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-23 11:23:41 +00:00
Tooru Fujisawa
209a1f050c Bug 1864168 - Part 1: Use 1-origin column number in nsIContentSecurityPolicy. r=smaug,devtools-reviewers,ochameau,ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D193369
2023-11-22 12:31:30 +00:00
Natalia Csoregi
e0d56104a6 Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug 1862693) for causing bustage on nsRFPService.cpp. CLOSED TREE
Backed out changeset a4f3e7625abf (bug 1865005)
Backed out changeset ab38141e470b (bug 1862814)
Backed out changeset a679b50dc4a9 (bug 1862814)
Backed out changeset e340886ce62a (bug 1862814)
Backed out changeset 1378502e64b0 (bug 1862814)
Backed out changeset 8ee94e5e79c2 (bug 1862814)
Backed out changeset 6d4ef1cdfabb (bug 1864168)
Backed out changeset 2c30c4d757fc (bug 1864168)
Backed out changeset d4db9576559b (bug 1864168)
Backed out changeset 8ffec0d83028 (bug 1864168)
Backed out changeset fa77d852b494 (bug 1864168)
Backed out changeset f6646771a26a (bug 1864168)
Backed out changeset 7bd0ff6986df (bug 1864155)
Backed out changeset 39867b503289 (bug 1862693)
2023-11-22 14:01:55 +02:00
Tooru Fujisawa
676bd2ea73 Bug 1864168 - Part 1: Use 1-origin column number in nsIContentSecurityPolicy. r=smaug,devtools-reviewers,ochameau,ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D193369
2023-11-22 11:13:54 +00:00
Eden Chuang
5ca02c8ea0 Bug 1836700 - Remove BusyCount of WorkerPrivate. r=asuth,ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D182718
2023-11-13 04:00:40 +00:00
Tooru Fujisawa
8b51569f3f Bug 1862692 - Part 16: Use 1-origin column number type in JS::DescribeScriptedCaller. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D193029
2023-11-09 11:41:10 +00:00
Tooru Fujisawa
b4da7fa0cf Bug 1847469 - Part 24: Use column number types in JS::DescribeScriptedCaller. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185762
2023-08-16 17:31:42 +00:00
Cristian Tuns
77d753c741 Backed out 27 changesets (bug 1847469) for causing spidermonkey bustages in Script.cpp CLOSED TREE
Backed out changeset 9d6e2651a013 (bug 1847469)
Backed out changeset 9b72d668efd2 (bug 1847469)
Backed out changeset 86abf5cf0a22 (bug 1847469)
Backed out changeset 46833087f8ac (bug 1847469)
Backed out changeset f3e2207fdeec (bug 1847469)
Backed out changeset aed75776cfff (bug 1847469)
Backed out changeset 8292a38bd99f (bug 1847469)
Backed out changeset 1320f83fb8c7 (bug 1847469)
Backed out changeset df9f925f9837 (bug 1847469)
Backed out changeset 69f32cf1862a (bug 1847469)
Backed out changeset b2ddddec8818 (bug 1847469)
Backed out changeset 056eed7abc97 (bug 1847469)
Backed out changeset 5df4f43ac0bf (bug 1847469)
Backed out changeset cb57923f6532 (bug 1847469)
Backed out changeset a0993f2a2195 (bug 1847469)
Backed out changeset 782499fbedf2 (bug 1847469)
Backed out changeset cf84fb98c5e1 (bug 1847469)
Backed out changeset 1fa5ab59814b (bug 1847469)
Backed out changeset f5f78944df81 (bug 1847469)
Backed out changeset aa14337bf5c6 (bug 1847469)
Backed out changeset 6757db4575d7 (bug 1847469)
Backed out changeset 236ff135701e (bug 1847469)
Backed out changeset 9b4d5b435020 (bug 1847469)
Backed out changeset a0f789621bc8 (bug 1847469)
Backed out changeset c19b81f48055 (bug 1847469)
Backed out changeset b4521e546d7e (bug 1847469)
Backed out changeset f26a10289316 (bug 1847469)
2023-08-16 07:08:01 -04:00
Tooru Fujisawa
fb38c26358 Bug 1847469 - Part 24: Use column number types in JS::DescribeScriptedCaller. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185762
2023-08-16 10:26:33 +00:00
Tom Schuster
2454d6dc41 Bug 1843841 - Make navigator.appName constant. r=dom-worker-reviewers,webidl,smaug,timhuang
This is supposed to constant per https://html.spec.whatwg.org/#client-identification.

Differential Revision: https://phabricator.services.mozilla.com/D183723
2023-07-19 17:00:53 +00:00
Barret Rennie
f555038ba5 Bug 1786885 - Remove OS.Constants r=nika
Differential Revision: https://phabricator.services.mozilla.com/D179384
2023-07-12 03:57:12 +00:00
Eden Chuang
b1c66d53bf Bug 1800659 - P2 remove nsICancelableRunnable inheriting form WorkerRunnable. r=asuth
This patch is only remove the inheriting, but keeping Cancel() implmentation.
The Cancel() is needed in some special cases, such as Worker enters Canceling when WorkerScope is not created.

Depends on D176915

Differential Revision: https://phabricator.services.mozilla.com/D173850
2023-06-06 06:36:50 +00:00
Jens Stutte
df968c6e08 Bug 1830278 - CC on worker shutdown until there remains nothing we can collect. r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D176651
2023-04-27 12:58:38 +00:00
Jens Stutte
f445a26b69 Bug 1826416 - Avoid the use of strong references to check if global scope is alive. r=dom-worker-reviewers,mccr8,asuth
Differential Revision: https://phabricator.services.mozilla.com/D174743
2023-04-12 08:54:09 +00:00
Cristina Horotan
6acde38519 Backed out changeset 0825b12caee2 (bug 1826416) for causing multiple failures at RuntimeService.cpp 2023-04-12 10:40:45 +03:00
Jens Stutte
4896bc6f38 Bug 1826416 - Avoid the use of strong references to check if global scope is alive. r=dom-worker-reviewers,mccr8,asuth
Differential Revision: https://phabricator.services.mozilla.com/D174743
2023-04-12 07:04:08 +00:00
Jens Stutte
c5fa7ccd1e Bug 1825589 - Relax globalScopeAlive assertion to happen after potentially deferred CC release have happened on JS context destruction. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D174496
2023-04-03 18:44:40 +00:00
Butkovits Atila
5ff465c923 Backed out changeset b5217784536c (bug 1777921) for causing assertion failures at WorkerPrivate.h. CLOSED TREE 2023-03-31 18:36:39 +03:00
Jens Stutte
7a7df1c06d Bug 1777921 - Assert that StrongWorkerRefs are not lazily released during final GC/CC. r=dom-worker-reviewers,smaug,asuth
And relax the check if someone carries away a stale reference to our global scope to happen after the JS context has gone out of scope.

Differential Revision: https://phabricator.services.mozilla.com/D150942
2023-03-31 14:33:15 +00:00
Joshua Marshall
e90e9dc56f Bug 1805613 - Dump worker info on shutdown hang r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D173430
2023-03-30 13:44:34 +00:00
Yulia
09b46d0966 Bug 1540913 - Part 2: Clear and shutdown ModuleLoader at worker termination; r=asuth,jonco
When running an infinitely-looping dynamic import, it is possible for the module loader to still be
holding on to that module at shutdown. Shutdown on the worker means that we will no longer run the
event loop, which will execute the dynamic import promises necessary to clear the global. The result
is that the global is kept alive. By calling `Shutdown()` we prevent this partially. We additionally
need to address the failure in the module code (next patch).

Differential Revision: https://phabricator.services.mozilla.com/D171683
2023-03-14 18:16:31 +00:00
Jon Coppeard
58d22da98a Bug 1817757 - Part 1: Remove support for parallel marking from workers r=sfink
Depends on D170374

Differential Revision: https://phabricator.services.mozilla.com/D170375
2023-02-22 08:56:28 +00:00