Граф коммитов

104 Коммитов

Автор SHA1 Сообщение Дата
Nathan Froyd 3393422869 Bug 1401662 - don't inline nsThreadManager::get(); r=erahm
Defining get() in the declaration of nsThreadManager implicitly sticks
an "inline" on the function, which is not what we want: inlining it
spreads around a lot of static initialization code.  Providing an
out-of-line definition is much better in terms of code size.
2017-09-20 17:10:20 -04:00
Philippe Normand fb80b50e2e Bug 1399825 - Include nsXULAppAPI.h in nsThreadManager.cpp. r=Ms2ger
This ensures XRE_IsContentProcess() is defined, as it's used in this file.

MozReview-Commit-ID: GwBYcFBiUBK
2017-09-14 12:51:41 +01:00
James Cheng 0c675a3236 Bug 1393710 - Add thread name into NS_DebugBreak for better debugging. r=froydnj
MozReview-Commit-ID: AvqajMgtpuh

--HG--
extra : rebase_source : 13e99f103abc9e39ec4cff15f720cd09a9e6b2c5
2017-08-30 11:13:50 +08:00
Bill McCloskey 9cbaae8cfc Bug 1396155 - Allow LabeledEventQueue to be used outside the Scheduler (r=froydnj)
MozReview-Commit-ID: 4yEX39HXh9W
2017-09-07 22:31:34 -07:00
Bill McCloskey f90a87caa9 Bug 1350432 - Initial Quantum DOM scheduler implementation, disabled by default (r=froydnj)
MozReview-Commit-ID: JWBxz3bwgwD
2017-08-25 10:28:23 -07:00
Sebastian Hengst 99e5cb9c14 merge mozilla-inbound to mozilla-central. r=merge a=merge
MozReview-Commit-ID: GSKVB94r7Kk
2017-08-23 16:29:51 +02:00
Andrew McCreight 2e0a92099c Bug 1392483 - ifdef out mNextIdleDeadline in a few more places. r=froydnj
MozReview-Commit-ID: D9bW4jEHlhl

--HG--
extra : rebase_source : a5a67943b389e5f54b80ee60ab2c60aa4d3f8205
2017-08-22 15:00:45 -07:00
Stone Shih 2c638fc04f Bug 1389314 Part2: Support enabling and disabling the input priority events in runtime. r=smaug.
MozReview-Commit-ID: 3a2TNVqguVb
2017-07-28 15:14:54 +08:00
Stone Shih 60d437ddc2 Bug 1389314 Part1: Rename event prioritization to input event queue. r=smaug.
MozReview-Commit-ID: 7wPWYwIjIet
2017-07-27 16:20:01 +08:00
Bill McCloskey 9edd615af7 Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:

Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.

Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.

There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.

The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.

One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.

MozReview-Commit-ID: 9Evtr9oIJvx
2017-08-16 20:55:43 -07:00
Stone Shih 393c62eba7 Bug 1351148 Part3: Synthesize native input events with priority. f=kats,smaug. r=smaug.
The test helper_touch_action_regions.html uses nsDOMWindowUtils to synthesize native input events and creates some runnables to trigger the test. It expects the runnables which synthesize native input events are processed first, then the runnables to continue the test, and finally the input events are forwarded from chrome process to content process. Enabling event prioritization may change the execution order.
Wraps those runnables to synthesize native input events as priority=input and dispatches those runnables to continue the test with priority=input to make sure the execution order is as expected.

MozReview-Commit-ID: 8hkaB1FRW9T
2017-05-19 15:41:24 +08:00
Stone Shih de7f705042 Bug 1351148 Part2: Add a priority queue for input events. r=smaug.
MozReview-Commit-ID: 5ud1Ex9UNVo
2017-03-21 15:44:12 +08:00
Stone Shih 7de447a25a Backed out changeset 46d8f42863af (bug 1351148) 2017-08-11 15:19:44 +08:00
Stone Shih f5cb5ecde2 Backed out changeset 07b66fb75c71 (bug 1351148) 2017-08-11 15:19:37 +08:00
Stone Shih b15ea606eb Bug 1351148 Part3: Synthesize native input events with priority. f=kats,smaug. r=smaug.
The test helper_touch_action_regions.html uses nsDOMWindowUtils to synthesize native input events and creates some runnables to trigger the test. It expects the runnables which synthesize native input events are processed first, then the runnables to continue the test, and finally the input events are forwarded from chrome process to content process. Enabling event prioritization may change the execution order.
Wraps those runnables to synthesize native input events as priority=input and dispatches those runnables to continue the test with priority=input to make sure the execution order is as expected.

MozReview-Commit-ID: 8hkaB1FRW9T
2017-05-19 15:41:24 +08:00
Stone Shih 9d1d77d849 Bug 1351148 Part2: Add a priority queue for input events. r=smaug.
MozReview-Commit-ID: 5ud1Ex9UNVo
2017-03-21 15:44:12 +08:00
Eric Rahm 5aeb1f0c4b Bug 1369002 - Stop warning if the mainThread is null in GetCurrentThread. r=froydnj 2017-06-20 09:51:29 -07:00
Bill McCloskey 55f153be76 Bug 1383328 - Use TabGroup as event target for browser-status-filter (r=smaug)
MozReview-Commit-ID: HOSmqr5Vpwh
2017-07-28 13:11:59 -07:00
Carsten "Tomcat" Book de369deb98 Backed out changeset 284af26c1b53 (bug 1351148) 2017-07-28 09:20:27 +02:00
Carsten "Tomcat" Book 6ddad46b40 Backed out changeset 1662b38e3107 (bug 1351148) 2017-07-28 09:20:23 +02:00
Carsten "Tomcat" Book bd7b184c91 Backed out changeset e3e924da5d5f (bug 1383328) 2017-07-28 09:20:05 +02:00
Carsten "Tomcat" Book 6f0703e0c4 Backed out changeset 95c0feba19ec (bug 1369002) 2017-07-28 09:19:59 +02:00
Eric Rahm 08daad2b64 Bug 1369002 - Stop warning if the mainThread is null in GetCurrentThread. r=froydnj 2017-06-20 09:51:29 -07:00
Bill McCloskey fff3f0890c Bug 1383328 - Use TabGroup as event target for browser-status-filter (r=smaug)
MozReview-Commit-ID: HOSmqr5Vpwh
2017-07-25 19:52:36 -07:00
Stone Shih 5c6d99d228 Bug 1351148 Part3: Synthesize native input events with priority. f=kats,smaug. r=smaug.
The test helper_touch_action_regions.html uses nsDOMWindowUtils to synthesize native input events and creates some runnables to trigger the test. It expects the runnables which synthesize native input events are processed first, then the runnables to continue the test, and finally the input events are forwarded from chrome process to content process. Enabling event prioritization may change the execution order.
Wraps those runnables to synthesize native input events as priority=input and dispatches those runnables to continue the test with priority=input to make sure the execution order is as expected.

MozReview-Commit-ID: 8hkaB1FRW9T
2017-05-19 15:41:24 +08:00
Stone Shih 9573b6e439 Bug 1351148 Part2: Add a priority queue for input events. r=smaug.
MozReview-Commit-ID: 5ud1Ex9UNVo
2017-03-21 15:44:12 +08:00
Andreas Farre 2a138dd325 Bug 1368072 - Move idle dispatch to thread manager. r=froydnj
Also exposes idle dispatch with timeout.
2017-06-22 11:14:10 +02:00
Phil Ringnalda 08e2f5187b Backed out 3 changesets (bug 1368072) for colliding with a new use of the thing it was renaming
Backed out changeset 1d7e008d7d70 (bug 1368072)
Backed out changeset c4a1ddf9be0d (bug 1368072)
Backed out changeset ba1cdae5a8d6 (bug 1368072)
2017-06-21 23:28:37 -07:00
Nathan Froyd b28fcc5c4b Bug 1372670 - part 5 - add nsIThreadManager::spinEventLoopUntilEmpty; r=erahm,florian
A number of places in JS need to drain the current thread's event queue,
which cannot be done with nsIThreadManager::spinEventLoopUntil, since we
need to not wait for an incoming event when attempting to process one.
2017-06-21 12:59:28 -04:00
Nathan Froyd 27c58cf89f Bug 1372670 - part 3 - add spinEventLoopUntil to nsIThreadManager; r=erahm,florian 2017-06-21 12:59:28 -04:00
Nathan Froyd 2c70f522cc Bug 1372670 - part 2 - remove nsIThreadManager::isMainThread; r=erahm
Nobody calls this from JS, and we have better ways to accomplish the
same task in C++
2017-06-21 12:59:28 -04:00
Andreas Farre 2a8a39cf8e Bug 1368072 - Move idle dispatch to thread manager. r=froydnj
Also exposes idle dispatch with timeout.
2017-06-21 12:36:41 +02:00
Phil Ringnalda 44f60566a9 Backed out 3 changesets (bug 1368072) for timeouts in test_TelemetrySession.js and test_fullscreen-api.html and unhandled "TypeError: Services.tm.mainThread.idleDispatch is not a function" promise rejections
Backed out changeset 357635c84e49 (bug 1368072)
Backed out changeset 1797afe16a2a (bug 1368072)
Backed out changeset 4782401394a9 (bug 1368072)

MozReview-Commit-ID: 6kdcSkERjTD
2017-06-20 21:41:14 -07:00
Andreas Farre 9598aa65ed Bug 1368072 - Move idle dispatch to thread manager. r=froydnj
Also exposes idle dispatch with timeout.
2017-06-19 06:36:00 +02:00
Kan-Ru Chen 36e1ce5909 Bug 1313200 - Init AbstractThread properly and early. r=froydnj
Separate AbstractThread::InitTLS and
AbstractThread::InitMainThread. Init AbstractThread main thread when
init nsThreadManager. Init AbstractThread TLS for all content process
types because for plugin and gmp processes we are doing IPC even
without init XPCOM and for content process init XPCOM requires IPC.

MozReview-Commit-ID: DhLub23oZz8

--HG--
extra : rebase_source : 6e4bfa03ec69e1eb694924903f1fa5e7259cbba3
2017-04-19 13:24:09 +08:00
Florian Queze 3d54f37495 Bug 1355161 - provide a scriptable equivalent of NS_DispatchToMainThread, r=froydnj. 2017-04-14 18:27:32 +02:00
Sebastian Hengst 3e4f0fc9b9 Backed out changeset 781aa8ce66f6 (bug 1355161) for supposedly breaking crashtests and reftests on Android 4.3. r=backout 2017-04-14 23:39:23 +02:00
Florian Queze 65ba8f32ee Bug 1355161 - provide a scriptable equivalent of NS_DispatchToMainThread, r=froydnj. 2017-04-14 18:27:32 +02:00
Markus Stange 8924022f9d Bug 1323100 - Add nsThreadManager::NewNamedThread API. r=froydnj
The point of this exercise is to make the thread name available in the thread
func of the thread, so that we can register the thread with the profiler from
the very start of its lifetime, and so that registration and unregistration
can be inside the same function.

MozReview-Commit-ID: DiiMKUQVr55

--HG--
extra : rebase_source : 24b15d56315ad49e72b3e9b76db7fb634f3bfe01
2016-12-20 15:10:20 +01:00
Andreas Farre d87b4d239b Bug 1198381 - Extend nsIThread with idleDispatch, r=froydnj,smaug
The intent of idleDispatch is the possibility to have a runnable
executed when the thread is idle. This is accomplished by adding an
event queue for idle tasks that will only be considered when the main
event queue is empty and the caller of ProcessNextEvent doesn't
require that we wait until there is an event on the main event queue.

MozReview-Commit-ID: IDWQfzZqWpZ

--HG--
extra : rebase_source : 0d5bfeebd08e01597c2cd8b76e8e848d9f9c58f0
2016-08-24 16:18:06 +02:00
Carsten "Tomcat" Book e42af6918c Backed out changeset 333a899fb5e6 (bug 1198381) 2016-10-25 12:32:56 +02:00
Andreas Farre 60a3a10742 Bug 1198381 - Extend nsIThread with idleDispatch, r=froydnj,smaug
The intent of idleDispatch is the possibility to have a runnable
executed when the thread is idle. This is accomplished by adding an
event queue for idle tasks that will only be considered when the main
event queue is empty and the caller of ProcessNextEvent doesn't
require that we wait until there is an event on the main event queue.

MozReview-Commit-ID: IDWQfzZqWpZ

--HG--
extra : rebase_source : b16ff65d7a9b2fa16216a9ce8756358014d7ad96
2016-08-24 16:18:06 +02:00
Nicholas Nethercote 819433bae0 Bug 1299389 - Replace some raw pointers in nsThreadManager. r=froydnj.
nsThreadManager::get() can return a reference. This lets us remove some
redundant assertions.

nsThreadArray elements can be NotNull<>s.

--HG--
extra : rebase_source : fd49010167101bc15f7f6d01bf95fd63b81d60fb
2016-06-10 16:04:49 +10:00
Tom Tromey 5412728905 Bug 757969 - use __thread in ThreadLocal; r=froydnj 2016-01-22 10:33:44 -07:00
Kyle Huey a80e57e854 Bug 1204784: Do not shut the main thread down before all outstanding asynchronous thread shutdowns complete. r=froydnj
--HG--
extra : rebase_source : 9f4c8a219e2fa6dfbfec78f9f390726f2f07f683
2016-01-18 09:34:38 -08:00
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Kyle Huey ee4f5ba9fb Bug 1185470: Remove 'Get' prefixes from hashtable iterator methods. r=froydnj 2015-07-20 20:21:28 +08:00
Nicholas Nethercote f32a629f7d Bug 1181445 (part 12) - Use nsBaseHashTable::Iterator in xpcom/threads/. r=froydnj.
--HG--
extra : rebase_source : 76f747c7ac22df28cc78a8afea0e25f3b4b2aa07
2015-07-09 16:54:59 -07:00
Cervantes Yu 55152ad9d9 Backout change 39e167bbd14c, a80140872ea5, adae9be2294d and b71ccef9c674 (bug 970307). 2015-05-19 14:31:25 +08:00
Cervantes Yu 910ee84a4d Backout change b371db089894 (bug 1138620) due to backout of bug 970307. 2015-05-19 11:26:24 +08:00