Commit Graph

561 Commits

Author SHA1 Message Date
Randell Jesup
ac8dd14d50 Bug 1211602: Never timeout if timeout == UINT32_MAX r=jib,froydnj 2015-11-18 15:03:17 -05:00
Chris H-C
f2f33bdc16 Bug 1223800 - Accept BHR reports from 50% of beta clients. Up from 1%. r=vladan 2015-11-13 12:09:54 -05:00
Chris H-C
54a4c7b512 Bug 1198196 - rework EVENTLOOP_UI_LAG_EXP_MS to record all lag. r=vladan
Previously we were only logging if we accumulated 50ms of lag. Start logging
all lag so we can use this measure to compare smaller changes in UI
responsiveness.
2015-11-11 14:01:00 +01:00
Carsten "Tomcat" Book
c67642ae48 Backed out changeset 01dac856fde0 (bug 1198196) for mulet problems 2015-11-13 13:39:35 +01:00
Chris H-C
fd87071827 Bug 1198196 - rework EVENTLOOP_UI_LAG_EXP_MS to record all lag. r=vladan
Previously we were only logging if we accumulated 50ms of lag. Start logging
all lag so we can use this measure to compare smaller changes in UI
responsiveness.
2015-11-11 14:01:00 +01:00
Birunthan Mohanathas
94998cf5fe Bug 1219392 - Capitalize mozilla::unused to avoid conflicts. r=froydnj 2015-11-02 07:53:26 +02:00
Alessio Placitelli
687e484283 Bug 1219751 - Change the the depth limit of the thread hangs stack to use the 99th percentile. r=gfritzsche 2015-10-29 08:05:00 +01:00
Alessio Placitelli
d1fc816e7f Bug 1219216 - Fix a wrong comment in BackgroundHangMonitor.h. r=gfritzsche 2015-10-28 05:47:00 +01:00
Eric Rahm
69f9ed90a7 Bug 1174785 - Part 2: Convert xpcom over to LogModule. r=froydnj 2015-10-19 12:50:14 -07:00
Cervantes Yu
5016e195a3 Bug 1213795, Part 1: Don't fire timers in the Nuwa process to fix test case test_NuwaProcessDeadlock.html. r=khuey 2015-10-19 14:32:12 +08:00
Nathan Froyd
e4e2da55c9 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
2015-10-18 01:24:48 -04:00
Nathan Froyd
5254890206 Bug 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>; r=ehsan
This commit was generated using the following script, executed at the
top level of a typical source code checkout.

 # Don't modify select files in mfbt/ because it's not worth trying to
 # tease out the dependencies currently.
 #
 # Don't modify anything in media/gmp-clearkey/0.1/ because those files
 # use their own RefPtr, defined in their own RefCounted.h.
find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    grep -v 'mfbt/RefPtr.h' | \
    grep -v 'mfbt/nsRefPtr.h' | \
    grep -v 'mfbt/RefCounted.h' | \
    grep -v 'media/gmp-clearkey/0.1/' | \
    xargs perl -p -i -e '
 s/mozilla::RefPtr/nsRefPtr/g; # handle declarations in headers
 s/\bRefPtr</nsRefPtr</g; # handle local variables in functions
 s#mozilla/RefPtr.h#mozilla/nsRefPtr.h#; # handle #includes
 s#mfbt/RefPtr.h#mfbt/nsRefPtr.h#;       # handle strange #includes
'

 # |using mozilla::RefPtr;| is OK; |using nsRefPtr;| is invalid syntax.
find . -name '*.cpp' -o -name '*.mm' | xargs sed -i -e '/using nsRefPtr/d'

 # RefPtr.h used |byRef| for dealing with COM-style outparams.
 # nsRefPtr.h uses |getter_AddRefs|.
 # Fixup that mismatch.
find . -name '*.cpp' -o -name '*.h'| \
    xargs perl -p -i -e 's/byRef/getter_AddRefs/g'
2015-10-18 00:40:10 -04:00
Alessio Placitelli
24afbe9afd Bug 1211411 - Limit the number of thread hang stats reported to Telemetry. r=vladan 2015-10-16 07:04:00 +02:00
Xidorn Quan
ceb21140b0 Bug 1186745 part 5 - Make nsThread::Dispatch() always leak the event if it fails. r=froydnj 2015-10-06 13:00:59 +11:00
Xidorn Quan
480aa15bc7 Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj 2015-10-06 13:00:59 +11:00
Xidorn Quan
c77cf19cea Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj 2015-10-06 13:00:59 +11:00
Xidorn Quan
067f7da82a Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj 2015-10-06 13:00:59 +11:00
Xidorn Quan
ca2ef41c62 Bug 1186745 part 1 - Add LeakRefPtr for pointer leaking by default. r=froydnj
This class can be used instead of raw pointer for a sound leaking-by-default
behavior. Also it could take advantage of move semantic check in the future.
2015-10-06 13:00:59 +11:00
Wes Kocher
9e15a76411 Backed out 6 changesets (bug 1186745) for android Cpp failures
Backed out changeset 237a6acf0709 (bug 1186745)
Backed out changeset 7b530871783a (bug 1186745)
Backed out changeset 73f73b531fc8 (bug 1186745)
Backed out changeset e36909748ddf (bug 1186745)
Backed out changeset 3a31df8787f0 (bug 1186745)
Backed out changeset df9cb8f5f0a5 (bug 1186745)
2015-10-02 10:35:09 -07:00
Xidorn Quan
15fe3795b1 Bug 1186745 part 5 - Make nsThread::Dispatch() always leak the event if it fails. r=froydnj 2015-10-03 00:18:24 +10:00
Xidorn Quan
573174c479 Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj 2015-10-03 00:18:24 +10:00
Xidorn Quan
62a8216414 Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj 2015-10-03 00:18:24 +10:00
Xidorn Quan
5e0e50ea14 Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj 2015-10-03 00:18:24 +10:00
Xidorn Quan
d599d6de61 Bug 1186745 part 1 - Add LeakRefPtr for pointer leaking by default. r=froydnj
This class can be used instead of raw pointer for a sound leaking-by-default
behavior. Also it could take advantage of move semantic check in the future.
2015-10-03 00:18:24 +10:00
Jean-Yves Avenard
47e4637afd Bug 1207312: P1. Prevent crash when more than one promise is rejected. r=bholley 2015-10-01 19:07:36 +10:00
Phil Ringnalda
1e38f6291b Back out 6 changesets (bug 1186745) for cpptest failure in runnable_utils_unittest, nrappkit_unittest, test_nr_socket_unittest
Backed out changeset c6142b815de0 (bug 1186745)
Backed out changeset d8f740ef2430 (bug 1186745)
Backed out changeset edc0b56d81fa (bug 1186745)
Backed out changeset 383f8ac033ea (bug 1186745)
Backed out changeset ce960a661987 (bug 1186745)
Backed out changeset 3e9783023fb2 (bug 1186745)
2015-09-28 19:05:02 -07:00
Xidorn Quan
591705d6c9 Bug 1186745 part 5 - Make nsThread::Dispatch() always leak the event if it fails. r=froydnj 2015-09-29 09:28:22 +10:00
Xidorn Quan
4707215240 Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj 2015-09-29 09:28:22 +10:00
Xidorn Quan
ad0c24a0c5 Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj 2015-09-29 09:28:22 +10:00
Xidorn Quan
e6088a6eb9 Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj 2015-09-29 09:28:22 +10:00
Xidorn Quan
8290934aa6 Bug 1186745 part 1 - Add LeakRefPtr for pointer leaking by default. r=froydnj
This class can be used instead of raw pointer for a sound leaking-by-default
behavior. Also it could take advantage of move semantic check in the future.
2015-09-29 09:28:22 +10:00
James Cheng
d9b4b77dd6 Bug 1206598 - Use universal reference to reduce the redundant copy. r=nfroyd 2015-09-20 23:30:00 +02:00
Chris Peterson
b30743a530 Bug 1207031 - Suppress -Wshadow warnings from google-breakpad headers in xpcom/threads. r=froydnj 2015-09-21 22:41:52 -07:00
Nathan Froyd
fa54535e01 Bug 1202497 - follow-up - fix static analysis bustage; r=me 2015-09-22 19:25:37 -04:00
Nathan Froyd
6f8bd8b8e5 Bug 1202497 - part 7 - make nsEventQueue use external locking; r=gerald
We want to ensure that nsThread's use of nsEventQueue uses locking done
in nsThread instead of nsEventQueue, for efficiency's sake: we only need
to lock once in nsThread, rather than the current situation of locking
in nsThread and additionally in nsEventQueue.  With the current
structure of nsEventQueue, that would mean that nsThread should be using
a Monitor internally, rather than a Mutex.

Which would be well and good, except that DOM workers use nsThread's
mutex to protect their own, internal CondVar.  Switching nsThread to use
a Monitor would mean that either:

- DOM workers drop their internal CondVar in favor of nsThread's
  Monitor-owned CondVar.  This change seems unlikely to work out well,
  because now the Monitor-owned CondVar is performing double duty:
  tracking availability of events in nsThread's event queue and
  additionally whatever DOM workers were using a CondVar for.  Having a
  single CondVar track two things in such a fashion is for Experts Only.

- DOM workers grow their own Mutex to protect their own CondVar.  Adding
  a mutex like this would change locking in subtle ways and seems
  unlikely to lead to success.

Using a Monitor in nsThread is therefore untenable, and we would like to
retain the current Mutex that lives in nsThread.  Therefore, we need to
have nsEventQueue manage its own condition variable and push the
required (Mutex) locking to the client of nsEventQueue.  This scheme
also seems more fitting: external clients merely need synchronized
access to the event queue; the details of managing notifications about
events in the event queue should be left up to the event queue itself.

Doing so also forces us to merge nsEventQueueBase and nsEventQueue:
there's no way to have nsEventQueueBase require an externally-defined
Mutex and then have nsEventQueue subclass nsEventQueueBase and provide
its own Mutex to the superclass.  C++ initialization rules (and the way
things like CondVar are constructed) simply forbid it.  But that's OK,
because we want a world where nsEventQueue is externally locked anyway,
so there's no reason to have separate classes here.

One casualty of this work is removing ChaosMode support from
nsEventQueue.  nsEventQueue had support to delay placing events into the
queue, theoretically giving other threads the chance to put events there
first.  Unfortunately, since the thread would have been holding a lock
(as is evident from the MutexAutoLock& parameter required), sleeping in
PutEvent accomplishes nothing but delaying the thread from getting
useful work done.  We should support this, but it's complicated to
figure out how to reasonably support this right now.

A wrinkle in this overall pleasant refactoring is that nsThreadPool's
threads wait for limited amounts of time for new events to be placed in
the event queue, so that they can shut themselves down if no new events
are appearing.  Setting limits on the number of threads also needs to be
able to wake up all threads, so threads can shut themselves down if
necessary.

Unfortunately, with the transition to nsEventQueue managing its own
condition variable, there's no way for nsThreadPool to perform these
functions, since there's no Monitor to wait on.  Therefore, we add a
private API for accessing the condition variable and performing the
tasks nsThreadPool needs.

Prior to all the previous patches, placing items in an nsThread's event
queue required three lock/unlock pairs: one for nsThread's Mutex, one to
enter nsEventQueue's ReentrantMonitor, and one to exit nsEventQueue's
ReentrantMonitor.  The upshot of all this work is that we now only
require one lock/unlock pair in nsThread itself, as things should be.
2015-09-20 05:13:09 -04:00
Nathan Froyd
4f4449fa7a Bug 1202497 - part 6 - make the locking requirements of nsEventQueue explicit; r=gerald
Like the previous patch, this patch is a no-op change in terms of
functionality.  It does, however, pave part of the way for forcing
clients of nsEventQueue to provide their own locking.
2015-09-21 04:34:51 -04:00
Nathan Froyd
0cd3cf3372 Bug 1202497 - part 5 - make the locking requirements of nsChainedEventQueue explicit; r=gerald
This patch is a no-op in terms of functionality.  It ensures that we're
always holding nsThread's mutex when we touch mEvents, as dictated by
the comments.  Putting this addition into its own patch will help make
the change to having nsEventQueue by guarded by a Mutex, rather than a
Monitor, somewhat clearer.
2015-09-20 04:59:56 -04:00
Nathan Froyd
9291612a7d Bug 1202497 - part 4 - lock around call to nsChainedEventQueue::HasPendingEvent; r=gerald
This is another case of an access to mEvents not being protected by
mLock.  Future patches will make this locking requirement explicit in
nsChainedEventQueue, so we won't have problems like this.  (Since
nsEventQueue has its own locking at this point, this omission didn't
matter much, but the omission will most certainly matter later.)
2015-09-20 04:47:10 -04:00
Nathan Froyd
844d0071cb Bug 1202497 - part 3 - remove nsThread::GetEvent; r=gerald
GetEvent was only called from one place, so it wasn't terribly useful as
an abstraction.  It also broke the invariant that we protect accesses to
mEvents with mLock, as documented in nsThread.h.  While upcoming patches
could have just updated GetEvent to do the necessary locking on its own,
it seemed just as easy to make the locking requirements at the callsite,
as will be done for other accesses to mEvents.
2015-09-20 04:44:51 -04:00
Nathan Froyd
e6d7c9cfe6 Bug 1202497 - part 2 - remove ReentrantMonitor specializations for nsEventQueueBase; r=gerald
Now that nsEventQueue no longer depends on ReentrantMonitors, we can get
rid of these unused specializations.
2015-09-20 04:17:05 -04:00
Nathan Froyd
e37dae4a02 Bug 1202497 - part 1 - switch nsEventQueue to use a non-reentrant Monitor; r=gerald
nsEventQueue's monitor does not require re-entrancy now that the monitor
is not externally visible.  Since ReentrantMonitors require two separate
mutex lock/unlock pairs (one on entry, and one on exit), this cuts the
amount of locking nsEventQueue's methods do by half.
2015-09-14 21:52:08 -04:00
Nicholas Nethercote
76df328230 Bug 1205941 - Make TimerFirings logging output post-processible with fix_linux_stack.py. r=glandium. 2015-09-21 17:13:51 -07:00
Nathan Froyd
037b5ceb0a Bug 1121216 - disable BackgroundHangMonitor for TSan builds; r=jchen 2015-08-04 00:27:59 -04:00
Jim Chen
0fb099680a Bug 1196381 - Eliminate breakpad dependency in ThreadStackHelper; r=nfroyd r=snorp
The breakpad dependency in ThreadStackHelper is preventing us from
upgrading our in-tree copy to a newer version (bug 1069556). This patch
gets rid of that dependency. This makes native stack frames not work
for BHR, but because of the ftp.m.o decommissioning, native
symbolication was already broken and naive stack frames already don't
work, so we don't really lose anything from this patch.

Eventually we want to make ThreadStackHelper use other means of
unwinding, such as LUL for Linux

I added | #if 0 | around the code to fill the thread context, but left
the code in because I think we'll evenually want to reuse some of that
code.
2015-09-18 09:17:10 -04:00
Nicholas Nethercote
a3897fb534 Bug 1203427 (part 6) - Add link to MDN docs about TimerFirings logging. r=me.
DONTBUILD because comment-only change.
2015-09-16 21:49:24 -07:00
Nicholas Nethercote
09b4a9e997 Bug 1203427 (part 5) - Add logging of timer firings. r=froydnj. 2015-09-10 00:50:51 -07:00
Nicholas Nethercote
c65f0f318a Bug 1203427 (part 4) - Remove trailing whitespace from nsITimer.idl. r=froydnj.
IGNORE IDL because whitespace only changes.
2015-09-14 15:57:17 -07:00
Nicholas Nethercote
6a282d633a Bug 1203427 (part 3) - Change order of InitCommon() arguments. r=froydnj.
This makes the order of |aDelay| and |aType| match those of the InitWith*()
functions.

I've made this change because the inconsistency tripped me up during the
development of part 4.
2015-09-14 15:57:17 -07:00
Kyle Huey
2943734a64 Bug 1200922: Add the ability to shut down a thread asynchronously. r=froydnj 2015-09-14 18:24:43 -07:00
Nathan Froyd
9963101cf1 Bug 1202828 - use nsEventQueue::HasPendingEvent in nsThread.cpp; r=mccr8
nsEventQueue's HasPending event is defined to simply:

  return GetEvent(false, nullptr);

So we can substitute HasPendingEvent for this particular GetEvent call
to make the code clearer.
2015-09-04 20:39:10 -04:00