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

1304 Коммитов

Автор SHA1 Сообщение Дата
Toshihito Kikuchi 18aab300b5 Bug 1576697 - Use LauncherResult in WinHeaderOnlyUtils.h instead of WindowsErrorResult. r=aklotz
`WindowsErrorResult` is a class to hold either a value or a Windows error
code based on the `Result` template.  We also have `LauncherResult` for the
same purpose, which was introduced as a part of the launcher process feature
afterward.  The difference is `LauncherResult` holds a filename and line
number along with an error code.

This patch integrates LauncherResult.h into WinHeaderOnlyUtils.h so that we
can use `LauncherResult` more broadly.

Differential Revision: https://phabricator.services.mozilla.com/D44512

--HG--
extra : moz-landing-system : lando
2019-09-07 18:17:45 +00:00
Gerald Squelart e1481bf4bb Bug 1576550 - AUTO_PROFILER_STATS(add_marker...) - r=gregtatum
Gather stats for most calls to `profiler_add_marker()`, including the time to
allocate payloads if any.

Differential Revision: https://phabricator.services.mozilla.com/D43420

--HG--
extra : moz-landing-system : lando
2019-09-04 07:58:21 +00:00
Gerald Squelart 95f77c2409 Bug 1576819 - Use PROFILER_ADD_MARKER{,_WITH_PAYLOAD} everywhere - r=gregtatum
All calls to `profiler_add_marker()` (outside of the profilers code) are
now replaced by either:
- `PROFILER_ADD_MARKER(name, categoryPair)`
- `PROFILER_ADD_MARKER_WITH_PAYLOAD(name, categoryPair, TypeOfMarkerPayload,
                                    (payload, ..., arguments))`

This makes all calls consistent, and they won't need to prefix the category pair
with `JS::ProfilingCategoryPair::`.

Also it will make it easier to add (and later remove) internal-profiling
instrumentation (bug 1576550), and to replace heap-allocated payloads with
stack-allocated ones (bug 1576555).

Differential Revision: https://phabricator.services.mozilla.com/D43588

--HG--
extra : moz-landing-system : lando
2019-09-04 07:56:51 +00:00
Toshihito Kikuchi 55ae74e010 Bug 1557564 - Enable Base Profiler in Windows. r=aklotz,gerald
Bug 1556993 fixed the crash in PoisonIOInterposer (due to missing stdout&stderr
fd's), bug 1559379 fixed the mozglue memory issue that the unit test
experienced, and this patch also includes a fix for the test failure in
browser_checkdllblockliststate.js.

So now Base Profiler can be enabled by default on Windows, still using
`MOZ_BASE_PROFILER_...` env-vars for now (upcoming bug will merge these with
non-BASE env-vars soon).

Differential Revision: https://phabricator.services.mozilla.com/D44091

--HG--
extra : moz-landing-system : lando
2019-09-03 23:27:46 +00:00
Gerald Squelart 2c3f65a2cf Bug 1577650 - Stop using `using namespace std` in Gecko Profiler - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D44076

--HG--
extra : moz-landing-system : lando
2019-08-30 09:40:30 +00:00
Sylvestre Ledru 36129ce948 Bug 1577236 - clang-10: Fix -Wimplicit-int-float-conversion warnings in various dirs r=glandium
Depends on D43784

Differential Revision: https://phabricator.services.mozilla.com/D43785

--HG--
extra : moz-landing-system : lando
2019-08-30 09:11:19 +00:00
Cameron McCormack a1e18da1b1 Bug 1573090 - Part 2: Look up ELF symbol tables directly when pre-symbolicating Gecko profiles on Linux. r=gerald
Whereas previously MozDescribeCodeAddress would have handled demangling,
we need to explicitly do that from our new GetFunction method.  The string we
generate is now more useful for the profiler to merge -- having dropped the
address in the previous patch, and the file & line number and library in this
patch.

While we're at it, try to demangle Rust symbols too.

Ideally we'd add Rust symbol handling to DemangleSymbol in
StackWalk.cpp, but that lives in mozglue, which currently cannot have
any Rust crate dependencies.

Differential Revision: https://phabricator.services.mozilla.com/D43142

--HG--
extra : moz-landing-system : lando
2019-08-23 05:45:16 +00:00
Gerald Squelart ecb1dfd838 Bug 1575453 - Collect stats for sampling, and markers (add, collect, expire) - r=gregtatum
Use AUTO_PROFILER_STATS in both profilers, in:
- SamplerThread::Run() calling DoPeriodicSample()
- racy_profiler_add_marker
- ProfileBuffer::DeleteExpiredStoredMarkers()

This should cover all areas affected by the upcoming changes to the
ProfileBuffer storage, and how markers are stored.

Differential Revision: https://phabricator.services.mozilla.com/D42826

--HG--
extra : moz-landing-system : lando
2019-08-22 01:01:25 +00:00
Gerald Squelart 74485a5d46 Bug 1575453 - AUTO_PROFILER_STATS (off by default) - r=gregtatum
AUTO_PROFILER_STATS(name) can be used to time a {block}.
Statistics are gathered in a function-static variable, and printf'd when the
program ends.

Differential Revision: https://phabricator.services.mozilla.com/D42825

--HG--
extra : moz-landing-system : lando
2019-08-22 00:33:11 +00:00
Gerald Squelart 608cb489b5 Bug 1575442 - BlocksRingBuffer::LockAndRun - r=gregtatum
Some users will want to lock the buffer but not do any specific operation with
it.

Differential Revision: https://phabricator.services.mozilla.com/D42824

--HG--
extra : moz-landing-system : lando
2019-08-22 00:32:51 +00:00
Cameron Kaiser efe5f0901c Bug 1571613 - basic support for Power ISA SIMD detection (v2). r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D42592

--HG--
extra : moz-landing-system : lando
2019-08-21 03:36:55 +00:00
Gerald Squelart f908211695 Bug 1575141 - BlocksRingBuffer::{S,Des}erializer<BlocksRingBuffer> - r=gregtatum
Backtraces (that are kept in some marker payloads) are stored in a small
ProfileBuffer, we will need to store that data, which will happen to be inside
a BlockRingBuffer, so BlockRingBuffer needs to be able to (de)serialize itself!

This is done by storing the contents in the active buffer range, and some extra
data, to later reconstruct a BlocksRingBuffer that looks like the original.

Depends on D42496

Differential Revision: https://phabricator.services.mozilla.com/D42634

--HG--
extra : moz-landing-system : lando
2019-08-20 21:33:52 +00:00
Gerald Squelart 87c8e35964 Bug 1574896 - BlocksRingBuffer de/serialization methods and helpers - r=gregtatum
Markers and their payloads contain all kinds of objects that we'll need to
serialize into a BlocksRingBuffer (new ProfileBuffer storage).

This patch will add functions to:
- Compute the size needed to store objects,
- Write multiple objects into a BlockRingBuffer entry,
- Read objects back from an entry.

And it will provide a number of useful de/serialization helpers for:
- Trivially-copyable objects,
- Strings of different types,
- Raw pointers (with some safety guards to avoid surprises),
- Tuples (to store multiple sub-objects),
- Spans,
- Maybe (for optional objects),
- Variant.

This should be enough to store most kinds of data. Further specializations
can&will be written as necessary for more complex or obscure types.

Differential Revision: https://phabricator.services.mozilla.com/D42496

--HG--
extra : moz-landing-system : lando
2019-08-20 22:39:12 +00:00
Gerald Squelart a07a9b2250 Bug 1574825 - Make ModuloBuffer::Iterator a proper random-access iterator - r=gregtatum
This allows its use in std algorithms and types that require a real iterator
(like `template <typename InputIt> std::string::string(InputIt, InputIt)`).

Differential Revision: https://phabricator.services.mozilla.com/D42452

--HG--
extra : moz-landing-system : lando
2019-08-20 12:51:31 +00:00
Gerald Squelart ed60590cee Bug 1574824 - BlocksRingBuffer:SizeOf{Ex,In}cludingThis - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D42451

--HG--
extra : moz-landing-system : lando
2019-08-20 12:49:50 +00:00
Gerald Squelart 0a514cb1ca Bug 1574824 - ModuloBuffer:SizeOf{Ex,In}cludingThis - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D42450

--HG--
extra : moz-landing-system : lando
2019-08-20 12:49:32 +00:00
Gerald Squelart 50443e7037 Bug 1574822 - BlocksRingBuffer::Reader::At() - r=gregtatum
`Reader::At()` can be used to get a `BlockIterator` at a given `BlockIndex`,
clamped between `begin()` and `end()`.

This will be useful when we want to iterate starting at a given index, e.g.,
when duplicating stacks.

Differential Revision: https://phabricator.services.mozilla.com/D42449

--HG--
extra : moz-landing-system : lando
2019-08-20 14:26:07 +00:00
Gerald Squelart 46f5e181ee Bug 1574821 - TestBaseProfiler generates more labels and markers - r=gregtatum
The main goal of these bugs is to move markers to a new storage, so I'm adding
lots of markers to TestBaseProfiler.
Also adding labels, easier to read unsymbolicated profiles, and gives a bit more
coverage too.
And adding a separate "fibonacci canceller" thread, which is needed on some
slower platforms (e.g., Linux 64 ASAN times out otherwise); as a bonus, this
tests AUTO_BASE_PROFILER_REGISTER_THREAD.

Differential Revision: https://phabricator.services.mozilla.com/D42448

--HG--
extra : moz-landing-system : lando
2019-08-20 03:29:53 +00:00
Gerald Squelart 16f6820be1 Bug 1569871 - MOZ_PROFILER_STARTUP set to ''/'0'/'N'/'n' does not start the profiler - r=canaltinova
(Also MOZ_BASE_PROFILER_STARTUP.)

This makes it easier to keep that variable setup in the environment, and change
its value to switch between enabling and disabling the profiler.

Differential Revision: https://phabricator.services.mozilla.com/D42447

--HG--
extra : moz-landing-system : lando
2019-08-19 08:36:28 +00:00
Nazım Can Altınova a35427a236 Bug 1574187 - Stabilize profilerOverhead data in profile json. r=gerald
Depends on D42285

Differential Revision: https://phabricator.services.mozilla.com/D42286

--HG--
extra : moz-landing-system : lando
2019-08-16 12:18:01 +00:00
Nazım Can Altınova 6eb786c0d4 Bug 1574187 - Add a samples object that contains all the samples in profilerOverhead. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D42285

--HG--
extra : moz-landing-system : lando
2019-08-16 12:17:29 +00:00
Gerald Squelart e99e0cc6db Bug 1574143 - Make BlocksRingBuffer::Reader RAII - r=gregtatum
In practice the Reader doesn't need to be copied/moved/reassign.
BlocksRingBuffer::Read() can just instantiate one on the stack, and pass it by
reference to callbacks.

Differential Revision: https://phabricator.services.mozilla.com/D42118

--HG--
extra : moz-landing-system : lando
2019-08-16 03:55:08 +00:00
Gerald Squelart ac3d39c7f3 Bug 1574143 - Remove BlocksRingBuffer::EntryReserver - r=gregtatum
The point of the EntryReserver was mainly to have an object that represented a
writing lock on BlocksRingBuffer, so potentially perform multiple consecutive
writes.
After some experience implementing bug 1562604, there's actually no need for it.

So instead of having `Put()` create an `EntryReserver`, we now have
`ReserveAndPut()` that does the whole work in one function.

Differential Revision: https://phabricator.services.mozilla.com/D42116

--HG--
extra : moz-landing-system : lando
2019-08-16 03:54:49 +00:00
Gerald Squelart 11b3a5f66e Bug 1574143 - Make BlocksRingBuffer::EntryWriter RAII - r=gregtatum
EntryWriter doesn't even need to be moveable, as BlocksRingBuffer can just
create one on the stack, and pass it by reference to callbacks.
This removes risks, and potential data copies.

Differential Revision: https://phabricator.services.mozilla.com/D42115

--HG--
extra : moz-landing-system : lando
2019-08-16 04:02:18 +00:00
Makoto Kato c4cb964c8e Bug 1572613 - Use frame pointer based stack walker even if Android/x86 and Android/x86-64. r=jseward
Actually, we use clang for all Linux and Android platform, so it is no reason to use frame pointer based stack walker for LUL on Android/x86 and Android/x86-64 if no DWARF rule.

Differential Revision: https://phabricator.services.mozilla.com/D41320

--HG--
extra : moz-landing-system : lando
2019-08-13 07:34:29 +00:00
Aaron Klotz a69086ea54 Bug 1573273: Add ProfilerLabelBegin and ProfilerLabelEnd to mozglue; r=gerald
While mozglue continues to be the correct location for calling the affected
code in this patch, the calls requiring profiler labels will soon be
originating from firefox.exe via the launcher process.

mozglue will be supplying the launcher process with an interface that consists
of what are effectively "OnBeginDllLoad" and "OnEndDllLoad" callback
notifications; obviously an RAII class is not going to be useful for that case.

We still want to keep the RAII stuff around, however, since we still need it
for cases where we need to fall back to using the legacy DLL blocklist.

Differential Revision: https://phabricator.services.mozilla.com/D41807

--HG--
extra : moz-landing-system : lando
2019-08-14 03:46:41 +00:00
Aaron Klotz 6e2191877a Bug 1573274: Add mozglue-only SuppressStackWalking and DesuppressStackWalking functions to StackWalk on Windows; r=glandium
While mozglue continues to be the correct location for calling the affected
code in this patch, the calls requiring stackwalk suppression will soon be
originating from firefox.exe via the launcher process.

mozglue will be supplying the launcher process with an interface that consists
of what are effectively "OnBeginDllLoad" and "OnEndDllLoad" callback
notifications; obviously an RAII class is not going to be useful for that case.

We still want to keep the RAII stuff around, however, since we still need it
for cases where we need to fall back to using the legacy DLL blocklist.

Differential Revision: https://phabricator.services.mozilla.com/D41808

--HG--
extra : moz-landing-system : lando
2019-08-14 03:34:52 +00:00
Gerald Squelart 86c0b62678 Bug 1573111 - BlocksRingBuffer can switch underlying buffer - r=gregtatum
`BlocksRingBuffer` will be used both inside and outside `ProfileBuffer`:
- Inside to serve as `ProfileBuffer`'s main storage for stack traces,
- Outside to allow marker storage even when `ProfileBuffer` is locked during
  stack sampling.

`ProfileBuffer` only exists while `ActivePS` is alive, but because of the
potential outside accesses above (due to small races between ProfileBuffer
shutdown, and thread-local IsBeingProfiled() flags), we cannot just do the same
for BlocksRingBuffer, and it must remain alive to gracefully deny these accesses
around the profiler startup and shutdown times.

To accomplish this, `BlocksRingBuffer` may be in different states:
- "In-session", we have a real buffer to write to and read from,
- "Out-of-session", without buffer so reads&writes do nothing.
This is implemented by enclosing the underlying `ModuloBuffer` and the entry
deleter in a `Maybe`, which may be `Nothing` when the profiler is not running
and the `ProfileBuffer`'s `BlocksRingBuffer` is out-of-session.

Differential Revision: https://phabricator.services.mozilla.com/D41519

--HG--
extra : moz-landing-system : lando
2019-08-13 12:06:40 +00:00
Emilio Cobos Álvarez c3ee3ac3a8 Bug 1418624 - Allow mozilla::Result to be moved, make unwrap{,Err}() move, and add inspect() APIs that return references. r=froydnj
Also adjust some of the callers that were either calling unwrap() repeatedly on
the same result, or were doing silly copies, to use inspect().

We could try to use stuff like:

https://clang.llvm.org/docs/AttributeReference.html#consumed-annotation-checking

Differential Revision: https://phabricator.services.mozilla.com/D41425

--HG--
extra : moz-landing-system : lando
2019-08-13 08:26:18 +00:00
Sylvestre Ledru 645f2d5773 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D41559

--HG--
extra : moz-landing-system : lando
2019-08-13 07:15:25 +00:00
Brindusan Cristian a8a9f04996 Backed out changeset 58dd47c5aa51 (bug 1573111) for build bustages at TestBaseProfiler.cpp:875:51. CLOSED TREE 2019-08-13 06:21:16 +03:00
Gerald Squelart b2274966d4 Bug 1573111 - BlocksRingBuffer can switch underlying buffer - r=gregtatum
`BlocksRingBuffer` will be used both inside and outside `ProfileBuffer`:
- Inside to serve as `ProfileBuffer`'s main storage for stack traces,
- Outside to allow marker storage even when `ProfileBuffer` is locked during
  stack sampling.

`ProfileBuffer` only exists while `ActivePS` is alive, but because of the
potential outside accesses above (due to small races between ProfileBuffer
shutdown, and thread-local IsBeingProfiled() flags), we cannot just do the same
for BlocksRingBuffer, and it must remain alive to gracefully deny these accesses
around the profiler startup and shutdown times.

To accomplish this, `BlocksRingBuffer` may be in different states:
- "In-session", we have a real buffer to write to and read from,
- "Out-of-session", without buffer so reads&writes do nothing.
This is implemented by enclosing the underlying `ModuloBuffer` and the entry
deleter in a `Maybe`, which may be `Nothing` when the profiler is not running
and the `ProfileBuffer`'s `BlocksRingBuffer` is out-of-session.

Differential Revision: https://phabricator.services.mozilla.com/D41519

--HG--
extra : moz-landing-system : lando
2019-08-13 03:11:53 +00:00
Gerald Squelart 41c580344f Bug 1572027 - Make BlocksRingBuffer::EntryReader move-only - r=gregtatum
After some bad experiences, I think EntryReader should be move-only:
- It needs to be moveable so it can be created from a function, and move-
  constructed into a Maybe<> if needed.
- It can be passed around as a reference.

Previously, it could be passed by value, but it was too easy to create bugs,
e.g.: A function delegates to a sub-function to read something at the beginning,
then the first function wants to read more past that, but if the reader was
passed by value the first function would not see past what the sub-function did
read.

As a bonus, `mRing` can now be a reference instead of a pointer, and other
members can be const.

Differential Revision: https://phabricator.services.mozilla.com/D40958

--HG--
extra : moz-landing-system : lando
2019-08-07 21:33:09 +00:00
Aaron Klotz fb977a3526 Bug 1571875: Part 2 - Change over all existing static local uses of DynamicallyLinkedFunctionPtr to use StaticDynamicallyLinkedFunctionPtr instead; r=mhowell
Depends on D40885

Differential Revision: https://phabricator.services.mozilla.com/D40886

--HG--
extra : moz-landing-system : lando
2019-08-07 15:58:09 +00:00
Aaron Klotz d46e27a5ed Bug 1571875: Part 1 - Refactor DynamicallyLinkedFunctionPtr into static local and normal variants; r=mhowell
This patch does two things:

1. We refactor the resolution of function pointer and return type so that we
may support additional calling conventions besides just __stdcall;

2. We refactor DynamicallyLinkedFunctionPtr into a base class, and create
StaticDynamicallyLinkedFunctionPtr to specifically handle the static local
use case.

Differential Revision: https://phabricator.services.mozilla.com/D40885

--HG--
extra : moz-landing-system : lando
2019-08-07 15:57:23 +00:00
Gerald Squelart 5d6dbb3289 Bug 1571392 - Make BlocksRingBuffer::EntryWriter move-only - r=gregtatum
It makes little sense to copy a writer (also an output iterator).

We're keeping it move-constructible (so it can be passed around for construction
purposes), but not move-assignable to help make more members `const`.

Differential Revision: https://phabricator.services.mozilla.com/D40622

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:45 +00:00
Gerald Squelart c05de0f147 Bug 1571390 - BlocksRingBuffer::GetState() takes a snapshot of the current state - r=gregtatum
This makes it easier to grab all BlocksRingBuffer state variables:
- Range start and end.
- Number of pushed blocks/entries, number of cleared blocks/entries.

The function is thread-safe, and the returned values are consistent with each
other, but they may become stale straight after the function returns (and the
lock is released).
They are still valuable to statistics, and to know how far the range has at
least reached (but may go further soon).

Differential Revision: https://phabricator.services.mozilla.com/D40621

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:31 +00:00
Gerald Squelart f2af619bd3 Bug 1571355 - Base Profiler mutex tweaks - r=gregtatum
Renamed `BPAutoLock` to `BaseProfilerAutoLock`.
DEBUG-build `~BaseProfilerMutex()` checks that it is unlocked.
Prevent `BaseProfilerMutex` and `BaseProfilerAutoLock` copies&moves.
DEBUG-build check that `Lock()` sees `mOwningThreadId`==0 (because that is the
initial value, and the value after a previous `Unlock()`).
Don't preserve atomic `mOwningThreadId` in JS recording.

Differential Revision: https://phabricator.services.mozilla.com/D40620

--HG--
extra : moz-landing-system : lando
2019-08-07 01:54:09 +00:00
Gerald Squelart a2e0f9390e Bug 1571348 - ProfilerMarkerPayload::Set...() can be replaced with constructor arguments - r=gregtatum
`ProfilerMarkerPayload::Set...()` functions are only used by derived classes in
the same files, and these values could just be set during construction.

Differential Revision: https://phabricator.services.mozilla.com/D40619

--HG--
extra : moz-landing-system : lando
2019-08-07 01:53:55 +00:00
Toshihito Kikuchi 82aae30d17 Bug 1568610 - Delete the definition of IATThunks structure. r=aklotz
Differential Revision: https://phabricator.services.mozilla.com/D40703

--HG--
extra : moz-landing-system : lando
2019-08-06 22:58:20 +00:00
Greg Tatum cf59c7c0d7 Bug 1521929 - Remove RSS and USS measurements from the profiler; r=gerald,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D40287

--HG--
extra : moz-landing-system : lando
2019-08-05 15:37:18 +00:00
Sylvestre Ledru a34ae8d650 Bug 1571292 - -Wbool-operation: fix a warning (! instead of ~) r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D40574

--HG--
extra : moz-landing-system : lando
2019-08-04 22:00:40 +00:00
Gerald Squelart a8ae8a7a30 Bug 1569515 - Show overhead stats in Profiler tests - r=canaltinova
cppunittest TestBaseProfiler and gtest GeckoProfiler.Markers now show overhead
stats.
(Separate patch, because we may want to remove them after a while.)

Differential Revision: https://phabricator.services.mozilla.com/D39642

--HG--
extra : moz-landing-system : lando
2019-07-31 01:28:53 +00:00
Gerald Squelart ce889db273 Bug 1569515 - Collect overhead stats in ProfileBuffer - r=canaltinova
`ProfileBuffer` is now responsible for collecting overhead stats, and adding
them to the struct returned by `profiler_get_buffer_info()`.

Differential Revision: https://phabricator.services.mozilla.com/D39641

--HG--
extra : moz-landing-system : lando
2019-07-31 01:28:51 +00:00
Gerald Squelart 68db1b82de Bug 1569506 - SamplerThread can own a Sampler instead of being one - r=canaltinova
`SamplerThread` inheriting from `Sampler` was a bit confusing, and scary with no
virtual destructor&functions.
`SamplerThread` only uses `Sampler`'s `Disable()` and
`SuspendAndSampleAndResumeThread()` functions, and `SamplerThread` is never
accessed through a `Sampler` reference/pointer.
So `SamplerThread` can just own a `Sampler` to make that relationship clearer.

Differential Revision: https://phabricator.services.mozilla.com/D39640

--HG--
extra : moz-landing-system : lando
2019-07-31 01:28:49 +00:00
Gerald Squelart 6abdf8f681 Bug 1569458 - Use mMutex.AssertCurrentThreadOwns() in BlocksRingBuffer - r=gregtatum
This of course checks that the mutex is locked as expected in non-public APIs.
It also checks that user callbacks will not keep readers/writers longer than
they should.

Differential Revision: https://phabricator.services.mozilla.com/D39625

--HG--
extra : moz-landing-system : lando
2019-07-30 12:19:55 +00:00
Gerald Squelart d5ac2c3154 Bug 1569458 - Unify Base Profiler mutexes into one class - r=gregtatum
`BaeProfilerMutex` is a concrete mutex based on MutexImpl, which was previously
implemented twice in both platform.h and BlocksRingBuffer.h.
This combined mutex has some DEBUG code (when MOZ_BASE_PROFILER is #defined) to
catch recursive locking, and to assert that the mutex is held (for code that
cannot easily use the "proof of lock" pattern; e.g., going through user-provided
callbacks).

This class needs to be public (because it is used in public headers), but is an
implementation detail, so it is located in a new header
"mozilla/BaseProfilerDetail.h" that will collect `mozilla::baseprofiler::detail`
code that may be useful to a few files in Base Profiler.

Differential Revision: https://phabricator.services.mozilla.com/D39624

--HG--
extra : moz-landing-system : lando
2019-07-30 12:19:54 +00:00
Gerald Squelart ce8cf3d633 Bug 1567861 - Fix BlocksRingBuffer::ClearBefore() with past-the-end BlockIndex - r=gregtatum
`ClearBefore()` with a past-the-end `BlockIndex` was calling `Clear()`, which
tried to take the lock again! Also we didn't return after that.
Fixed, and added corresponding test.

Also: Removed ambiguous "delete" word, now using more precise "destroy" or
"entry destructor".

Differential Revision: https://phabricator.services.mozilla.com/D38846

--HG--
extra : moz-landing-system : lando
2019-07-30 07:24:20 +00:00
Gerald Squelart f5ca1ba02d Bug 1567465 - Default BlockIndex used as empty value index before any valid entry - r=gregtatum
This is a similar concept as `nullptr` is to a pointer.

`BlocksRingBuffer` now skips the first byte in the buffer, so that no entries
start at 0 (the internal default `BlockIndex` value).
All `BlocksRingBuffer` public APIs handle this default value, and do nothing
and/or return Nothing (as if it pointed at an already-deleted entry).

Added tests for this, and for all BlockIndex operations.

Differential Revision: https://phabricator.services.mozilla.com/D38667

--HG--
extra : moz-landing-system : lando
2019-07-19 16:10:30 +00:00
Gerald Squelart dd5708c6dc Bug 1567461 - Ensure ModuloBuffer can be properly move-constructed - r=gregtatum
Without declaring them, ModuloBuffer had its copy&move constructor&assignments
defaulted. This means it could have been copied, and then both objects would now
own the same resource and attempt to free it on destruction!

So now:
- Copy construction&assignment are now explicitly disallowed.
- Move assignment is disallowed, to keep some members `const`.
- Move construction is allowed (so a function can return a ModuloBuffer), and
  ensures that the moved-from object won't free the resource anymore.

Bonus: `mBuffer` is now `const`, to ensure that it cannot point at something
else, but note the pointed-at bytes are *not* const.
So ModuloBuffer is like an unchanging resource, but it allows to be moved-from
as an xvalue that should not be used after the move.

Differential Revision: https://phabricator.services.mozilla.com/D38665

--HG--
extra : moz-landing-system : lando
2019-07-20 00:13:59 +00:00