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

2237 Коммитов

Автор SHA1 Сообщение Дата
Narcis Beleuzu 0723378bf7 Backed out 2 changesets (bug 1674221) for SM bustages on PreXULSkeletonUI.cpp
Backed out changeset 3d9b951db0f4 (bug 1674221)
Backed out changeset 5092fde1ebe1 (bug 1674221)
2020-11-05 22:54:10 +02:00
Doug Thayer 21230c3f49 Bug 1674221 - Prefix Skeleton UI reg names with exe path r=agashlin
Differential Revision: https://phabricator.services.mozilla.com/D95541
2020-11-05 20:18:16 +00:00
Alexis Beingessner e75e8e5b98 Bug 1608068 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D95128
2020-11-03 01:02:11 +00:00
Florian Quèze 49855a4e40 Bug 1674234 - Add a profiler marker for creating the skeleton UI, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D95219
2020-11-02 19:45:22 +00:00
Bogdan Tara 6b2d214e53 Backed out 2 changesets (bug 1601632, bug 1608068) for ScriptPreloader related tsan failures CLOSED TREE
Backed out changeset 2f14d44bacf2 (bug 1601632)
Backed out changeset ebd82e2edbdc (bug 1608068)
2020-11-03 02:58:08 +02:00
Alexis Beingessner 2507488d07 Bug 1506812 - Wrap all accesses to URLPreloader's mReaderThread in a mutex. r=decoder,nika
The shutdown code of BackgroundReadFiles races with BeginBackgroundRead.
This is paritally obfuscated by the usage of the initialEvent convenience
of NS_NewNamedThread, so this change also removes that in favour of explicit
dispatch. (xpcom devs want to remove the convenience anyway)

Differential Revision: https://phabricator.services.mozilla.com/D94877
2020-11-02 23:26:05 +00:00
Alexis Beingessner 19c8d885b8 Bug 1601632 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D95129
2020-11-02 23:22:22 +00:00
Alexis Beingessner b2c9198c9c Bug 1608068 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D95128
2020-11-02 23:22:13 +00:00
Gerald Squelart 4fedf5eb76 Bug 1674045 - Remove unused ProfilerStringView::String() - r=gregtatum
The previous patch removed the only two uses of ProfilerStringView::String().
Since it can be potentially expensive (creating a `std::string` object, sometimes allocating a buffer, and copying the string contents), it's best to remove it completely.

Differential Revision: https://phabricator.services.mozilla.com/D95116
2020-11-02 13:56:14 +00:00
Gerald Squelart 9acb23c062 Bug 1674045 - UniqueJSONStrings takes string spans instead of pointers - r=gregtatum
For consistency with `JSONWriter` (which UniqueJSONStrings' functions use), and for added safety and some efficiency, UniqueJSONStrings now takes `Span<const char`> arguments instead of raw pointers to null-terminated strings.

Differential Revision: https://phabricator.services.mozilla.com/D95114
2020-11-02 13:55:16 +00:00
Gerald Squelart c68a3c6b21 Bug 1674045 - Add documentation to UniqueJSONStrings, and clean up - r=gregtatum
Document the class and methods.
`GetOrAddIndex` is only used internally, so it can be private.
`SpliceStringTableElements` can now only work on rvalue UniqueJSONStrings, this emphasizes that it shouldn't be used anymore after this call.

Differential Revision: https://phabricator.services.mozilla.com/D95113
2020-11-02 13:54:43 +00:00
Gerald Squelart 7e610c2025 Bug 1674045 - Deduplicate UniqueJSONStrings - r=gregtatum
The two identical copies are `UniqueJSONStrings` are combined and moved almost verbatim to BaseProfilerJSONWriter.h.

Differential Revision: https://phabricator.services.mozilla.com/D95112
2020-11-02 13:54:20 +00:00
Doug Thayer 9fbd3ff6c4 Bug 1674540 - Remove unused prthread.h include r=agashlin
This snuck in after I forgot to delete this upon realizing I couldn't
use nspr stuff in mozglue.

Differential Revision: https://phabricator.services.mozilla.com/D95530
2020-11-02 16:03:04 +00:00
Alexis Beingessner bd3c1f855c Bug 1601286 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D95130
2020-11-02 15:05:56 +00:00
Alexis Beingessner 0d1f97e1a4 Bug 1615265 - Backed out changeset 6e297cea9592 and applied proper change. r=decoder
I accidentally got these two mixed up!!

Differential Revision: https://phabricator.services.mozilla.com/D95132
2020-11-02 15:07:02 +00:00
Narcis Beleuzu 115a0628bb Backed out 2 changesets (bug 1674234) for SM bustages on PreXULSkeletonUI.cpp . CLOSED TREE
Backed out changeset 093306c14ca2 (bug 1674234)
Backed out changeset 2684003a37f9 (bug 1674234)
2020-10-31 01:01:33 +02:00
Alexis Beingessner 05c2cbb42e Bug 1607138 - Backed out changeset fb3f09394f1d. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D95410
2020-10-30 21:10:08 +00:00
Florian Quèze 313e538484 Bug 1674234 - Add a profiler marker for creating the skeleton UI, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D95219
2020-10-30 20:58:14 +00:00
Gabriele Svelto 863c8dfec7 Bug 1665411 - Use first-fit mutexes on macOS r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D93319
2020-10-30 13:10:29 +00:00
Doug Thayer 30478629cf Bug 1666874 - Support maximized windows for skeleton UI r=agashlin
Most of this patch is a dance to avoid size flickering of the skeleton UI
window. We change all Resize/Move/SetSizeMode calls from before the first
nsWindow::Show call. Normally those have no effect, since the window isn't
shown yet, and if the window is not maximized, they typically match the
sizes we've gotten out of the registry anyway. However, if we are maximized,
then they produce a lot of visual noise. We can however achieve the desired
effect by just calling SetWindowPlacement.

Similarly, we switch the window styles of the skeleton UI window to match those
of the toplevel Windows window, and adjust the client rect from our window proc
in a way that matches the adjustments in nsWindow in the WM_NCCALCSIZE handler.
We do this because otherwise we get a flicker as soon as we change the styles
and nonclient margins as the fake chrome pops up and then back down.

Lastly we also change the extended window styles so that they match. We
historically added WS_EX_TOOLWINDOW here to hide the toolbar entry, because it
would otherwise switch out to a new toolbar entry when we changed the window
styles. However since our new styles match, we no longer need to do this. It
was also causing the maximized window to paint over the Windows taskbar.

Differential Revision: https://phabricator.services.mozilla.com/D93534
2020-10-29 19:04:02 +00:00
Doug Thayer 620dfb6899 Bug 1665455 - Animate the Skeleton UI r=agashlin
For a better user experience during slow startups (and to match the design
by Markus Jaritz), we want to animate the placeholder elements (the grey
rectangles which hold the place of text and icons) with a light moving
gradient.

A question may arise regarding whether the performance cost of running this
animation is worth the improved user experience. My claim is yes, hinging
mostly on the observation that the performance cost is small.

On my machine, one frame of the animation takes at most 0.15ms, and runs
every 16.15ms. This means we eat less than 1% CPU time on one core of the
system. It should also be noted that this animation runs primarily during
the window wherein we are prefetching dlls, AKA while we are blocked on IO
and the CPU is more likely to be idle.

On slower systems, one frame may take longer - however, on slower systems
we should also be blocked *more* by IO, making the trade favorable.

For further anecdotal evidence of this being okay, when I run this on slow
reference hardware shortly after OS startup, I do not see any dropped frames,
indicating that this has very little trouble completing, and is thus quite
cheap.

Regarding testing, I will invoke the same logic as for the rest of the
skeleton UI patches - it would involve quite a bit of work to test this in
automation given our existing frameworks. It may be worth it at some point,
but certainly not while this is a feature that we are just experimenting
with and which is not enabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D91453
2020-10-29 19:03:59 +00:00
Toshihito Kikuchi f0d4e3e5eb Bug 1672357 - Do not reserve all regions in the 32bit virtual space. r=mhowell
One of the scenarios in TestMMPolicy.exe is to reserve all regions but one free
region, and then FindRegion can find that free region.  However, it intermittently
failed to find a free region on 32bit.  Probably a different thread invoked by
the system reserved it before the main thread does.  A proposed fix is to limit
the address range to reserve.

Differential Revision: https://phabricator.services.mozilla.com/D95188
2020-10-29 18:35:32 +00:00
Butkovits Atila 304bfab038 Backed out 2 changesets (bug 1666874, bug 1665455) for causing bustage on PreXULSkeletonUI.cpp. CLOSED TREE
Backed out changeset 967c4cf56fd2 (bug 1666874)
Backed out changeset e46238e6aabf (bug 1665455)
2020-10-29 16:57:35 +02:00
Doug Thayer 38c0351ae3 Bug 1666874 - Support maximized windows for skeleton UI r=agashlin
Most of this patch is a dance to avoid size flickering of the skeleton UI
window. We change all Resize/Move/SetSizeMode calls from before the first
nsWindow::Show call. Normally those have no effect, since the window isn't
shown yet, and if the window is not maximized, they typically match the
sizes we've gotten out of the registry anyway. However, if we are maximized,
then they produce a lot of visual noise. We can however achieve the desired
effect by just calling SetWindowPlacement.

Similarly, we switch the window styles of the skeleton UI window to match those
of the toplevel Windows window, and adjust the client rect from our window proc
in a way that matches the adjustments in nsWindow in the WM_NCCALCSIZE handler.
We do this because otherwise we get a flicker as soon as we change the styles
and nonclient margins as the fake chrome pops up and then back down.

Lastly we also change the extended window styles so that they match. We
historically added WS_EX_TOOLWINDOW here to hide the toolbar entry, because it
would otherwise switch out to a new toolbar entry when we changed the window
styles. However since our new styles match, we no longer need to do this. It
was also causing the maximized window to paint over the Windows taskbar.

Differential Revision: https://phabricator.services.mozilla.com/D93534
2020-10-29 14:09:54 +00:00
Doug Thayer 220a9763bb Bug 1665455 - Animate the Skeleton UI r=agashlin
For a better user experience during slow startups (and to match the design
by Markus Jaritz), we want to animate the placeholder elements (the grey
rectangles which hold the place of text and icons) with a light moving
gradient.

A question may arise regarding whether the performance cost of running this
animation is worth the improved user experience. My claim is yes, hinging
mostly on the observation that the performance cost is small.

On my machine, one frame of the animation takes at most 0.15ms, and runs
every 16.15ms. This means we eat less than 1% CPU time on one core of the
system. It should also be noted that this animation runs primarily during
the window wherein we are prefetching dlls, AKA while we are blocked on IO
and the CPU is more likely to be idle.

On slower systems, one frame may take longer - however, on slower systems
we should also be blocked *more* by IO, making the trade favorable.

For further anecdotal evidence of this being okay, when I run this on slow
reference hardware shortly after OS startup, I do not see any dropped frames,
indicating that this has very little trouble completing, and is thus quite
cheap.

Regarding testing, I will invoke the same logic as for the rest of the
skeleton UI patches - it would involve quite a bit of work to test this in
automation given our existing frameworks. It may be worth it at some point,
but certainly not while this is a feature that we are just experimenting
with and which is not enabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D91453
2020-10-28 19:22:54 +00:00
Alexis Beingessner 7399cf2078 Bug 1607449 - Backed out changeset c5d8b4f34c06 r=decoder
Still an issue, just rare.

Differential Revision: https://phabricator.services.mozilla.com/D95084
2020-10-29 11:50:48 +00:00
Alexis Beingessner f045afd928 Bug 1506910 - Initialize the poison page with a static initializer. r=glandium,decoder
Poison was setup at the start of xpcom init when that was assumed to be early enough.
Since then, Poison was added to Maybe, and Maybe has been used everywhere, including in
our channel implementation. As a result, poison was being used before it was initialized.

This basically meant our poison pointers were being replaced with null instead, which
dances into some more UB than accessing a page we have actually allocated. Also, tsan
noticed that accesses to the value were racing with the initializer actually being
called!

A (dynamic) static initializer forces the poison initialization as we can reasonably
hope without getting CallOnce or singleton patterns involved.

Other changes:
  * Cleaned up the outdated documentation for mozWritePoison (the alignment
    restriction was removed in Bug 1414901)
  * Removed the poison supression from TSan

Differential Revision: https://phabricator.services.mozilla.com/D94251
2020-10-28 20:38:42 +00:00
Alexis Beingessner e70a174ef5 Bug 1608357 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94856
2020-10-28 15:07:24 +00:00
Alexis Beingessner 9e58a2784e Bug 1607706 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94855
2020-10-28 13:53:55 +00:00
Alexis Beingessner 7701381612 Bug 1607704 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94854
2020-10-28 13:53:47 +00:00
Alexis Beingessner be4f23fa57 Bug 1607588 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94853
2020-10-28 13:53:40 +00:00
Alexis Beingessner b91c79179f Bug 1607138 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94852
2020-10-28 13:53:38 +00:00
Sebastian Hengst ac330b4b09 Backed out changeset 81c5f8fff63e (bug 1665411) for causing deadlock on older OS X versions (e.g. OS X 10.12), see bug 1673826 2020-10-28 13:37:58 +01:00
Byron Campen [:bwc] bbf349e952 Bug 1657739: Remove temporary suppression. r=decoder
Depends on D94155

Differential Revision: https://phabricator.services.mozilla.com/D94478
2020-10-27 16:37:01 +00:00
Alexis Beingessner 64f2dc8c60 Bug 1615265 - Remove supression for seemingly fixed issue. r=decoder
Depends on D94856

Differential Revision: https://phabricator.services.mozilla.com/D94857
2020-10-27 16:15:46 +00:00
Alexis Beingessner 16866ed6a1 Bug 1607449 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94859
2020-10-27 16:05:40 +00:00
Alexis Beingessner 2d883db13d Bug 1607762 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94860
2020-10-27 16:09:21 +00:00
Alexis Beingessner 93528f31fb Bug 1606803 - Remove supression for seemingly fixed issue. r=decoder
Depends on D94493

Differential Revision: https://phabricator.services.mozilla.com/D94494
2020-10-27 16:07:17 +00:00
Alexis Beingessner eaa89f3d67 Bug 1600594 - Remove supression for seemingly fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D94493
2020-10-27 16:07:34 +00:00
Emma Malysz 7529feec30 Bug 1665460: save urlbar position to registry and display in skeleton UI r=dthayer,smaug
If the urlbar is zoomed (defined by attribute breakout-extend), then we
scale it down to the unfocused coordinate values.

Differential Revision: https://phabricator.services.mozilla.com/D92303
2020-10-27 15:53:38 +00:00
Toshihito Kikuchi 5cabaa29f2 Bug 1671316 - Part2. Pass CrossExecTransferManager to FuncHookCrossProcess and Kernel32ExportsSolver. r=mhowell
The latest launcher process showed one of the top failures was `WriteProcessMemory` in
`CopyStubToChildProcess` failed with `ERROR_INVALID_ADDRESS` or `ERROR_NOACCESS`, that
is to store a trampoline address to the global variable of firefox.exe failed.  Its root
cause should be the same as bug 1662560, the executable was loaded onto a different
address from the browser process.

The fix is to to expand the usage of `CrossExecTransferManager` to `FuncHookCrossProcess`
and `Kernel32ExportsSolver`.

Depends on D94652

Differential Revision: https://phabricator.services.mozilla.com/D94653
2020-10-27 14:08:49 +00:00
Toshihito Kikuchi 83d95e2106 Bug 1671316 - Part1. Introduce CrossExecTransferManager. r=mhowell
This patch introduces a class `CrossExecTransferManager` to manage the data
transfer from the current process to a remote process via `WriteProcessMemory`.
The class also encapsulates a logic to bridge the gap between two executable's
imagebase.

Differential Revision: https://phabricator.services.mozilla.com/D94652
2020-10-27 14:09:00 +00:00
Greg Tatum 6451405048 Bug 1671701 - Migrated FileIO markers to the Markers 2.0 API; r=gerald,julienw
This commit uses the new Markers 2.0 API for FileIO Markers. I had to
create another option for the MarkerStack class in order to conditionally
capture a backtrace inside of the Macro. Otherwise the macro invocation
failed.

Differential Revision: https://phabricator.services.mozilla.com/D93848
2020-10-27 14:04:04 +00:00
Gerald Squelart 204efca960 Bug 1672310 - Output marker backtraces from other threads - r=gregtatum
The new Markers 2.0 code had missed one detail:
Backtraces in markers were serialized as just the `ProfileChunkedBuffer`, which doesn't expose the original thread id like `ProfilerBacktrace` did.
Then when outputting the profile, the marker code would use the marker's thread id (where the marker should be displayed in the frontend, which *could* be different from where the backtrace came) to deserialize and stream the attached marker, and a special check in the streaming code meant that the mismatched id would ignore the stored sample, and the displayed marker would show no stack.

With this patch, when streaming stacks from markers, the given thread id is 0 (an impossible thread id), which indicates that whatever sample is present should be streamed.
`ProfilerBacktrace` doesn't need to store the thread id anymore.
This solves the above problem.

As a bonus, the streaming code now reports the original thread of the sample(s) it found. This could be used in the future, to better show in the frontend that some stacks may come from other threads.

Differential Revision: https://phabricator.services.mozilla.com/D94264
2020-10-27 03:16:12 +00:00
Butkovits Atila f31945adb0 Backed out 3 changesets (bug 1671701) for causing failure at browser_startup_mainthreadio.js. CLOSED TREE
Backed out changeset b4b6ec163792 (bug 1671701)
Backed out changeset a343865ccfe0 (bug 1671701)
Backed out changeset e6f882892fea (bug 1671701)
2020-10-27 02:40:13 +02:00
Greg Tatum 4cc2187968 Bug 1671701 - Migrated FileIO markers to the Markers 2.0 API; r=gerald,julienw
This commit uses the new Markers 2.0 API for FileIO Markers. I had to
create another option for the MarkerStack class in order to conditionally
capture a backtrace inside of the Macro. Otherwise the macro invocation
failed.

Differential Revision: https://phabricator.services.mozilla.com/D93848
2020-10-26 20:12:22 +00:00
Ricky Stewart 02a7b4ebdf Bug 1654103: Standardize on Black for Python code in `mozilla-central`.
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-26 18:34:53 +00:00
Bogdan Tara da1098d4aa Backed out 10 changesets (bug 1654103, bug 1672023, bug 1518999) for PanZoomControllerTest.touchEventForResult gv-junit failures CLOSED TREE
Backed out changeset ff3fb0b4a512 (bug 1672023)
Backed out changeset e7834b600201 (bug 1654103)
Backed out changeset 807893ca8069 (bug 1518999)
Backed out changeset 13e6b92440e9 (bug 1518999)
Backed out changeset 8b2ac5a6c98a (bug 1518999)
Backed out changeset 575748295752 (bug 1518999)
Backed out changeset 65f07ce7b39b (bug 1518999)
Backed out changeset 4bb80556158d (bug 1518999)
Backed out changeset 8ac8461d7bd7 (bug 1518999)
Backed out changeset e8ba13ee17f5 (bug 1518999)
2020-10-24 03:36:18 +03:00
Ricky Stewart c0cea3b0fa Bug 1654103: Standardize on Black for Python code in `mozilla-central`. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-23 20:40:42 +00:00
sanketh 35cd8eb504 Bug 1655482 - Bump MinGW to fix the STATUS_HEAP_CORRUPTION define r=tjr
- Bump MinGW version
- Add patch to workaround MinGW's dwrite_3.h
- Remove MinGW workaround for STATUS_HEAP_CORRUPTION define
- Remove MinGW workaround in MMPolicies.h.

Differential Revision: https://phabricator.services.mozilla.com/D91157
2020-10-22 15:58:54 +00:00
Gerald Squelart 15d07d6c5b Bug 1672501 - Initialize scProfilerMainThreadId from profiler_init - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D94419
2020-10-22 12:55:13 +00:00
Dorel Luca 1ff59cb7a3 Backed out changeset 7558c8821a07 (bug 1654103) for multiple failures. CLOSED TREE 2020-10-22 03:51:06 +03:00
Ricky Stewart 50762dacab Bug 1654103: Standardize on Black for Python code in `mozilla-central`. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-21 21:27:27 +00:00
Alexis Beingessner d9fb1ffd72 Bug 1587510 - Remove supression for seemingly fixed issue. r=decoder
Doesn't show up in a try run anymore.

Differential Revision: https://phabricator.services.mozilla.com/D94144
2020-10-21 17:01:40 +00:00
Alexis Beingessner ccc093cd6c Bug 1367344 - Remove supression for seemingly fixed issue. r=decoder
Doesn't show up in a try run anymore.

Differential Revision: https://phabricator.services.mozilla.com/D94143
2020-10-21 17:01:29 +00:00
Christian Holler 771a4eac15 Bug 1672230 - Add temporary suppression. r=Gankro
Depends on D94288

Differential Revision: https://phabricator.services.mozilla.com/D94289
2020-10-21 13:41:54 +00:00
Christian Holler 0c5c78e328 Bug 1671601 - Add temporary suppression. r=Gankro
Depends on D94287

Differential Revision: https://phabricator.services.mozilla.com/D94288
2020-10-21 13:42:59 +00:00
Christian Holler c6f46008ad Bug 1671574 - Add temporary suppression for StartupCache thread leak. r=Gankro
Depends on D94286

Differential Revision: https://phabricator.services.mozilla.com/D94287
2020-10-21 13:43:48 +00:00
Christian Holler a45b846848 Bug 1671572 - Add temporary suppression. r=Gankro
Depends on D94285

Differential Revision: https://phabricator.services.mozilla.com/D94286
2020-10-21 14:37:35 +00:00
Toshihito Kikuchi e61c0c2555 Bug 1671314 - Expand the region to be scanned for a trampoline. r=mhowell
The latest launcher process ping showed one of the reasons why we failed to
detour `NtMapViewOfSection` is that `MMPolicyBase::FindRegion` failed to find
a free region.  Inspecting the function carefully, there were three problems.

Firstly, `FindRegion` did not fully scan the given range.  To randomize
the address of a free region we use, we start scanning from a random address
within the given range.  The problem is we scan only addresses bigger than
that random address, without scanning smaller addresses.  Probably this is
the reason why `FindRegion` fails.

Secondly, `FindRegion` may return an address not aligned with the allocation
granularity because `VirtualQueryEx` returns such an address.  If that happens,
the subsequent mapping API fails with the alignment error.

Lastly, when we randomize an address to start scanning from, we divide a random
number by `maxOffset`, but with that, we never start scanning from the last
region.  It does not affect the product's behavior, but to have fair randomization,
a divisor should be `maxOffset + 1`.

This patch fixes all of these three problems along with a new test program.

Differential Revision: https://phabricator.services.mozilla.com/D94110
2020-10-20 22:51:00 +00:00
Alexis Beingessner c40e440aff Bug 1671692 - Organize and properly label things in the TSan supression list. r=decoder
This is going to cause some merge conflicts for everyone working on the
supressions, sorry!

Differential Revision: https://phabricator.services.mozilla.com/D93835
2020-10-20 16:45:00 +00:00
Gabriele Svelto 2352a082d4 Bug 1665411 - Use first-fit mutexes on macOS r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D93319
2020-10-20 12:07:30 +00:00
Narcis Beleuzu 1e7d4b5b37 Backed out changeset b75ab3fd88c9 (bug 1665411) for SM bustages on ProtectedData.h 2020-10-20 01:27:40 +03:00
Gabriele Svelto b74208fdb6 Bug 1665411 - Use first-fit mutexes on macOS r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D93319
2020-10-19 20:52:24 +00:00
Gerald Squelart a37e92d240 Bug 1671536 - Remove BaseProfilerMarkerPayload.h and dependents - r=gregtatum
Everything related to Base Profiler legacy markers can now be removed, only the new API from BaseProfilerMarkers.h should now be used.

Depends on D93737

Differential Revision: https://phabricator.services.mozilla.com/D93738
2020-10-16 22:10:36 +00:00
Gerald Squelart 2c7e587da0 Bug 1671536 - Stop using baseprofiler::TextMarkerPayload - r=gregtatum
TextMarkerPayload is the only legacy marker type that is still used in the Base Profiler. We're converting it to the new BASE_PROFILER_MARKER_TEXT.

Depends on D93736

Differential Revision: https://phabricator.services.mozilla.com/D93737
2020-10-16 14:09:24 +00:00
Gerald Squelart 500ebb3b30 Bug 1670954 - MarkerThreadId::MainThread() - r=gregtatum
Since the main thread is almost always being profiled, this makes it easy to direct important markers there (e.g., FileIO markers from unregistered threads).

Tech note: The `#include "BaseProfiler.h"` line was moved to BaseProfilerMarkersPrerequesites.h so that `MarkerThreadId::MainThread()` there can access `profiler_main_thread_id()`.

Depends on D93735

Differential Revision: https://phabricator.services.mozilla.com/D93736
2020-10-16 22:07:20 +00:00
Gerald Squelart 334aa92a37 Bug 1670954 - profiler_main_thread_id() and profiler_is_main_thread() - r=gregtatum
These functions will be useful to get the main thread id, or check if we're in it, in some public code (e.g., markers).

Differential Revision: https://phabricator.services.mozilla.com/D93735
2020-10-16 22:06:53 +00:00
Christian Holler 251b26aaf0 Bug 1656068 - Add temporary suppression. r=bwc
Depends on D93509

Differential Revision: https://phabricator.services.mozilla.com/D93510
2020-10-15 09:54:11 +00:00
Christian Holler ab8fa5ff8b Bug 1657739 - Add temporary suppression. r=bwc
Depends on D93508

Differential Revision: https://phabricator.services.mozilla.com/D93509
2020-10-15 09:54:21 +00:00
Christian Holler 5ea665d9a7 Bug 1664803 - Add temporary suppression. r=Gankro
Depends on D93507

Differential Revision: https://phabricator.services.mozilla.com/D93508
2020-10-14 19:34:38 +00:00
Christian Holler 962d75d4f2 Bug 1664535 - Temporary suppression for GC race. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D93507
2020-10-15 09:53:23 +00:00
Christian Holler 02d1bd0904 Bug 1600572 - Remove suppression for fixed bug. r=Gankro
Differential Revision: https://phabricator.services.mozilla.com/D93505
2020-10-15 05:05:45 +00:00
Christian Holler 21004d88dc Bug 1606804 - Permanently suppress false positive deadlock in rkv. r=Gankro
Differential Revision: https://phabricator.services.mozilla.com/D93500
2020-10-14 19:39:57 +00:00
Gerald Squelart 871634702e Bug 1665265 - Prevent chunks from being marked done with the same timestamps in quick tests - r=gregtatum
These unit tests were going through chunks very quickly in tight loops, which on some platforms could cause successive chunks to be marked "done" with the same timestamps.
Distinct timestamps are needed to uniquely identify chunks (in each process), and related assertions caught that. In real Firefox code, chunks are much bigger (around 1MB), and fill at a slower rate, so timestamps are always different as expected there.
To fix this artificial issue in our unit tests, delays are introduced before each `MarkDone()`, to ensure that they'll get a different timestamp every time.

Differential Revision: https://phabricator.services.mozilla.com/D93479
2020-10-14 21:23:31 +00:00
Gerald Squelart ddcc13f424 Bug 1640999 - Output meta.markerSchema for all used marker types in the process - r=gregtatum
Using the stored marker functions, stream all marker schema to JSON.

Added tests for all common marker types.

Differential Revision: https://phabricator.services.mozilla.com/D90660
2020-10-14 02:12:29 +00:00
Gerald Squelart d83d5d3c6b Bug 1640999 - Store name and schema functions for each marker type - r=gregtatum
Along with the deserializer, we now also store other marker functions (that output the marker type name and schema).
These will be used in the following patch to output the combined schema list for all used marker types.

Differential Revision: https://phabricator.services.mozilla.com/D90659
2020-10-14 02:11:49 +00:00
Gerald Squelart 2621d4cbf0 Bug 1640999 - Add `MarkerTypeDisplay` to all marker type definitions - r=gregtatum
Add `static mozilla::MarkerSchemaWriter MarkerTypeDisplay()` for each existing marker type.

Because all markers of a given type now must have the same payload and display schema, the DOM event marker has changed from type=tracing with category=DOMEvent, to its own type=DOMEvent, which is now accepted on the front-end.

Based on c9692715f2/src/profile-logic/marker-schema.js

Differential Revision: https://phabricator.services.mozilla.com/D90658
2020-10-14 02:11:25 +00:00
Gerald Squelart 984f996f1b Bug 1640999 - MarkerSchema schema-writer class - r=gregtatum
This class collects all the information necessary to stream the JSON schema that informs the front-end how to display a type of markers.
It will be created and populated in `MarkerTypeDisplay()`, functions in each marker type definition, with Add/Set functions (see following patch).

Based on c9692715f2/src/profile-logic/marker-schema.js

Differential Revision: https://phabricator.services.mozilla.com/D90657
2020-10-14 02:10:50 +00:00
Gerald Squelart e62f237161 Bug 1670547 - Made AutoArraySchemaWriter safer and more efficient - r=canaltinova
`AutoArraySchemaWriter::FreeFormElement()` is never used, we can remove it.

When constructed, `AutoArraySchemaWriter` was optionally taking a `UniqueStrings` reference, which was stored as a pointer.
Then `AutoArraySchemaWriter::StringElement()` would do a dangerous `MOZ_RELEASE_ASSERT(mStrings);`.

The class is now split in two:
- `AutoArraySchemaWriter`, which does not deal with strings at all, so we don't need a pointer to `UniqueStrings`.
- `AutoArraySchemaWithStringsWriter` that can also deal with strings, in which we store a (non-null) `UniqueStrings` reference.

This is both:
- Safer, because it's not possible to instantiate the non-string writer and try to write a string.
- More efficient, because we don't need to pass&store a `UniqueStrings` reference/pointer when we don't deal with strings.

Differential Revision: https://phabricator.services.mozilla.com/D93191
2020-10-12 23:26:10 +00:00
Toshihito Kikuchi 8b206d0aad Bug 1588245 - More values to DetourResultCode. r=mhowell
This is the third attempt to investigate the launcher failure of our detour.
The previous commits d8315e4ed18d and 1b81ea85c43d added the assembly bytes
of a detour target and a special error code `DetourResultCode` to the launcher
failure ping.

In the latest telemetry data, however, the most common value of `hresult`
is still `ERROR_UNIDENTIFIED_ERROR`, meaning the previous commit missed to
set an error code in the common fallible codepath we wanted to know.
Besides `ERROR_UNIDENTIFIED_ERROR`, we're seeing `DETOUR_PATCHER_DO_RESERVE_ERROR`
in the telemetry, but having that code is not enough to pinpoint a falling
operation.

For further investigation, this patch adds ten more values to `DetourResultCode`.
`FUNCHOOKCROSSPROCESS_COPYSTUB_ERROR` is the last codepath we forgot to cover
in the previous commit.  The values of `MMPOLICY_RESERVE_*` are to investigate
`DETOUR_PATCHER_DO_RESERVE_ERROR` in the MMPolicy level.  In both cases, we add
the last Windows error code to `DetourError::mOrigBytes`.

Differential Revision: https://phabricator.services.mozilla.com/D92974
2020-10-12 18:25:47 +00:00
Andreea Pavel e921b46c56 Backed out changeset 0a114b5e07eb (bug 1588245) on suspicion of crashing Firefox on startup (bug 1670546 etc.) a=backout 2020-10-12 14:31:40 +03:00
Toshihito Kikuchi 09dbd09134 Bug 1468250 - Block all versions of database.dll to stop the crash. r=aklotz
We blocked the older versions of database.dll as Bug 1566109 in 2019,
but the same crash is still happening with the newer versions.
We decided to block all versions because crashing in the middle of printing
or file uploading is not acceptable.

Differential Revision: https://phabricator.services.mozilla.com/D92988
2020-10-09 20:39:58 +00:00
Gerald Squelart db3689ee3d Bug 1670046 - If NoPayload marker has a stack and/or inner window id, convert to NoPayloadUserData - r=gregtatum
It is possible to add options to a NoPayload marker, but stack and inner window ids would be lost because they are normally stored in the payload 'data' JSON object, which doesn't exist for NoPayload markers.
So in this case, we automatically change the marker to a new (internal) "NoPayloadUserData" type, which has a payload in which we can store options.

This is temporary, until bug 1646714 moves these options into the top-level marker JSON object.

Differential Revision: https://phabricator.services.mozilla.com/D93059
2020-10-09 13:00:48 +00:00
Toshihito Kikuchi 481aa7905b Bug 1588245 - More values to DetourResultCode. r=mhowell
This is the third attempt to investigate the launcher failure of our detour.
The previous commits d8315e4ed18d and 1b81ea85c43d added the assembly bytes
of a detour target and a special error code `DetourResultCode` to the launcher
failure ping.

In the latest telemetry data, however, the most common value of `hresult`
is still `ERROR_UNIDENTIFIED_ERROR`, meaning the previous commit missed to
set an error code in the common fallible codepath we wanted to know.
Besides `ERROR_UNIDENTIFIED_ERROR`, we're seeing `DETOUR_PATCHER_DO_RESERVE_ERROR`
in the telemetry, but having that code is not enough to pinpoint a falling
operation.

For further investigation, this patch adds ten more values to `DetourResultCode`.
`FUNCHOOKCROSSPROCESS_COPYSTUB_ERROR` is the last codepath we forgot to cover
in the previous commit.  The values of `MMPOLICY_RESERVE_*` are to investigate
`DETOUR_PATCHER_DO_RESERVE_ERROR` in the MMPolicy level.  In both cases, we add
the last Windows error code to `DetourError::mOrigBytes`.

Differential Revision: https://phabricator.services.mozilla.com/D92974
2020-10-08 19:00:22 +00:00
David Parks c6ffb4b0a9 Bug 1668057: Allow DLL interceptor to patch 64-bit immediate MOVs r=tkikuchi
The latest Windows Insider Preview (version 20226.1000) changes the machine code for BaseThreadInitThunk to have a preamble like the following:

00007FFDBF244C40 48 83 EC 28          sub         rsp,28h
00007FFDBF244C44 85 C9                test        ecx,ecx
00007FFDBF244C46 75 25                jne         00007FFDBF244C6D
00007FFDBF244C48 49 BA 70 A2 DC 12 6A 97 99 B0 mov         r10,0B099976A12DCA270h

This patch adds "MOV r64, imm64" capability to the DLL interceptor so that we can hook this.

Differential Revision: https://phabricator.services.mozilla.com/D92146
2020-10-05 22:25:44 +00:00
Florian Quèze 01d197240a Bug 1524625 - DLL loads during early startup should show profiler markers, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D92340
2020-10-05 13:47:27 +00:00
Alexis Beingessner ab37cbed76 Bug 1601980 - use MOZ_ATOMIC_BITFIELDS in imagelib to avoid races on flags. r=aosmond,decoder
Differential Revision: https://phabricator.services.mozilla.com/D91633
2020-10-01 13:22:49 +00:00
Gerald Squelart 79c0e0c0ef Bug 1667915 - Marker type is now given as a reified empty argument instead of a template argument - r=gregtatum
This makes it clearer where marker-type-specific payload arguments start, just after the marker type object.

Also improved the main API documentation.

Differential Revision: https://phabricator.services.mozilla.com/D91681
2020-10-01 11:02:54 +00:00
Gerald Squelart ee701f64d7 Bug 1667915 - Separate marker category from marker options - r=gregtatum
The `category.WithOptions(...)` syntax was a bit strange and difficult to explain.

Now the category and options are separate parameters. Default options can be specified with `MarkerOptions{}` or just `{}`.

As a special case, defaulted-NoPayload functions don't need `<>`, and defaulted-NoPayload functions and macros don't even need `{}` for default options, e.g.:
`profiler_add_marker("name", OTHER); PROFILER_MARKER_UNTYPED("name", OTHER);`

Differential Revision: https://phabricator.services.mozilla.com/D91680
2020-10-01 11:02:23 +00:00
Bogdan Tara ababae891b Backed out 2 changesets (bug 1667915) for platform related bustage CLOSED TREE
Backed out changeset e7a0788a1741 (bug 1667915)
Backed out changeset d34505b2d81b (bug 1667915)
2020-10-01 12:34:39 +03:00
Gerald Squelart 58ca6739aa Bug 1667915 - Marker type is now given as a reified empty argument instead of a template argument - r=gregtatum
This makes it clearer where marker-type-specific payload arguments start, just after the marker type object.

Also improved the main API documentation.

Differential Revision: https://phabricator.services.mozilla.com/D91681
2020-10-01 01:45:20 +00:00
Gerald Squelart e07ae06a1d Bug 1667915 - Separate marker category from marker options - r=gregtatum
The `category.WithOptions(...)` syntax was a bit strange and difficult to explain.

Now the category and options are separate parameters. Default options can be specified with `MarkerOptions{}` or just `{}`.

As a special case, defaulted-NoPayload functions don't need `<>`, and defaulted-NoPayload functions and macros don't even need `{}` for default options, e.g.:
`profiler_add_marker("name", OTHER); PROFILER_MARKER_UNTYPED("name", OTHER);`

Differential Revision: https://phabricator.services.mozilla.com/D91680
2020-10-01 01:44:47 +00:00
Toshihito Kikuchi 7034355c29 Bug 1588245 - Introduce an extra errorcode inside WindowsDllInterceptor. r=mhowell
The previous commit d8315e4ed18d introduced a new telemetry field
in the launcher process ping to collect the assembly pattern of
a target function on detour failure, but most of the crash instances
do not have a value in the field.  This means the failure happens
before or after `CreateTrampoline`.

To narrow down the root cause, this patch puts a fine-grained error value
in the "hresult" field instead of the hardcoded ERROR_UNIDENTIFIED_ERROR.

This patch also adds `IsPageAccessible` check before fetching data from
a different process because fetching data from an invalid address hits
`MOZ_RELEASE_ASSERT` in `EnsureLimit`, resulting in crash without sending
the launcher process failure.

Differential Revision: https://phabricator.services.mozilla.com/D91881
2020-09-30 20:09:22 +00:00
Florian Quèze 9c87b313a1 Bug 1668056 - Bailout profiler markers should be text markers. r=jandem,gerald
Differential Revision: https://phabricator.services.mozilla.com/D91775
2020-09-30 12:19:54 +00:00
Toshihito Kikuchi abfd030f16 Bug 1666571 - Part 2. Support CALL [disp32] for Avast. r=handyman
The last Avast Antivirus's hook function contains `CALL [disp32]` instruction.
Our detour needs to be able to handle that pattern.

Differential Revision: https://phabricator.services.mozilla.com/D91155
2020-09-25 23:18:02 +00:00
Toshihito Kikuchi 05e886ea80 Bug 1666571 - Part 1. Support more patterns of OpCode 0xFF. r=handyman
This patch optimizes our detour's code handling Opcode 0xFF, expanding
its coverage to INC and DEC reg64 as well as PUSH and CALL.
Testcases for these scenarios are of course included.

Differential Revision: https://phabricator.services.mozilla.com/D91154
2020-09-25 23:18:15 +00:00
Markus Stange f366fca45a Bug 1666617 - Allow creating MarkerInnerWindowId with a Maybe<uint64_t>. r=gerald
Depends on D91078

Differential Revision: https://phabricator.services.mozilla.com/D91079
2020-09-23 00:04:17 +00:00
Doug Thayer c0eae2f201 Bug 1665453 - Poll for native events in between prefetching early dlls r=agashlin
In the initial patches for bug 1656526, mhowell noticed that for startups which
take a very long time, if the user interacts with the skeleton UI window, the OS
will flag us as not responsive, which could be a poorer user experience than
seeing nothing. Since our UI is designed to look non-interactive anyway, we
assume that a better experience would be to simply squash the not responsive
response from the OS by trivially processing native events. It's not perfect in,
say, the event that startup is hung for some reason, but it's arguably preferable
to our old model of startup being hung, which was just nothing being displayed at
all.

Differential Revision: https://phabricator.services.mozilla.com/D91005
2020-09-24 23:51:42 +00:00
Doug Thayer 53dd0a0de2 Bug 1666030 - Fix floor missing on some builds r=dmajor
Depends on D91004

Differential Revision: https://phabricator.services.mozilla.com/D91284
2020-09-24 14:43:55 +00:00
Doug Thayer acd22d7041 Bug 1665453 - Rename EarlyBlankWindow to PreXULSkeletonUI r=agashlin
This is just a more correct name for what's going on.

Differential Revision: https://phabricator.services.mozilla.com/D91004
2020-09-24 14:25:56 +00:00
Gerald Squelart 6b05ae158e Bug 1666708 - Only store category pair in MarkerCategory - r=gregtatum
This saves 1 byte when serializing each marker (and removes all the code that was related to the 2nd byte).
Also it will be easier to use it in legacy code that only knows about the category pair.

Added unit tests for the whole of MarkerCategory.

Differential Revision: https://phabricator.services.mozilla.com/D91110
2020-09-24 03:23:28 +00:00
Alexis Beingessner 6d1f7fdce9 Bug 1656266 - Remove fixed TSAN supression. r=decoder
This supression was setup for Bug 1607712, but it was the same underlying issue as this bug.

Depends on D91036

Differential Revision: https://phabricator.services.mozilla.com/D91037
2020-09-22 18:45:36 +00:00
Alexis Beingessner 5ea0bbd246 Bug 1652300 - Remove supression for fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D90770
2020-09-22 12:51:27 +00:00
Alexis Beingessner 43cd5538c7 Bug 1607426 - Remove supression for fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D90775
2020-09-22 12:51:40 +00:00
Alexis Beingessner fedd8a3482 Bug 1606860 - Remove supression for fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D90777
2020-09-19 08:13:49 +00:00
Jon Coppeard 6bb01d4a27 Bug 1665338 - Make GC cell header word atomic to avoid race in compacting GC r=sfink,decoder
Differential Revision: https://phabricator.services.mozilla.com/D90389
2020-09-22 12:49:40 +00:00
Doug Thayer d61ea08ebb Bug 1665459 - Control pre-xul skele UI registry value via prefs r=mhowell
This patch uses the prefs relevant to the pre-xul skeleton UI to control the
registry value. There are three prefs:

- A new pref intended to be the global toggle once all themes can be handled.
- browser.startup.blankWindow - we currently depend on the code in BrowserGlue.jsm,
  gated on this pref, which immediately specifies the width and height of the
  window and ultimately causes XUL to consume and take ownership of our pre-xul
  window. Without this, we resize to fit a small content area, and then resize
  again back to the correct size.
- extensions.activeThemeID - Given that we have hardcoded layout and colors, we
  need to ensure that we're only presenting the skeleton UI for the default theme.

We're hoping to not need to gate on any prefs other than the new pref that we're
adding, but this allows us to provide a simple direction for users who may want
to dogfood our changes in the mean time: use the default theme, ensure the
browser.startup.blankWindow pref is set, and turn our new pref on.

Differential Revision: https://phabricator.services.mozilla.com/D90884
2020-09-21 19:24:56 +00:00
Alexis Beingessner d99fd95ed5 Bug 1612054 - Remove supression for fixed issue. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D90759
2020-09-18 22:52:16 +00:00
Toshihito Kikuchi 7ff1c84dc1 Bug 1665734 - Fix -Wunused-lambda-capture warnings in non-Nightly build. r=mhowell
This patch bypasses `-Wunused-lambda-capture` warnings by using `Unused` as
Bug 1375386 did.  Having two definitions with `#ifdef` confuses clang-format.
Using `Unused` seems like the easiest approach.

Differential Revision: https://phabricator.services.mozilla.com/D90610
2020-09-18 16:47:41 +00:00
Toshihito Kikuchi 4c58dba463 Bug 1588245 - Collect the assembly pattern of a target function on detour failure. r=mhowell
Many instances of the launcher failure ping indicate hooking NtMapViewOfSection
or LdrLoadDll failed.  This is most likely caused by a third-party application
applying a hook onto the same target earlier than we do.

This patch is to add a new field "detour_orig_bytes" in the laucnher failure ping
to collect the first sixteen bytes of a detour target function.  With this,
we can know whether those detour failures were caused by a third-party hook or not,
and if yes, what was the actual binary pattern.

Differential Revision: https://phabricator.services.mozilla.com/D89836
2020-09-17 01:42:26 +00:00
Doug Thayer 37cb06da7e Bug 1665357 - Ensure DPI_AWARENESS_CONTEXT is defined r=mhowell
This is currently failing the tier 2 MinGW-Clang builds, complaining
that DPI_AWARENESS_CONTEXT is not defined. Accordingly I pulled out the
logic from WinUtils.h which ensures it is defined into a shared header.

Differential Revision: https://phabricator.services.mozilla.com/D90467
2020-09-16 20:14:40 +00:00
Dorel Luca aadcb9bfbc Backed out changeset d5725a81ffd7 (bug 1588245) for Windows build bustages. CLOSED TREE 2020-09-17 00:56:25 +03:00
Toshihito Kikuchi b45fd9fde1 Bug 1588245 - Collect the assembly pattern of a target function on detour failure. r=mhowell
Many instances of the launcher failure ping indicate hooking NtMapViewOfSection
or LdrLoadDll failed.  This is most likely caused by a third-party application
applying a hook onto the same target earlier than we do.

This patch is to add a new field "detour_orig_bytes" in the laucnher failure ping
to collect the first sixteen bytes of a detour target function.  With this,
we can know whether those detour failures were caused by a third-party hook or not,
and if yes, what was the actual binary pattern.

Differential Revision: https://phabricator.services.mozilla.com/D89836
2020-09-16 20:12:08 +00:00
Toshihito Kikuchi d77b5bdf35 Bug 1662560 - Always retrieve the imagebase of the child process's executable from a process handle. r=mhowell
The earlier fix ea452bb92e6a proved the executable's imagebase in a child
process is not always the same as the local imagebase.  This patch applies
the new approach to retieve the imagebase from a handle to all channels.

Interestingly, we observed the launcher failures at `VirtualProtectEx` only
when launching a sandboxed process, not when launching the browser process.
In the long term, we may need to take care of all `WriteProcessMemory` calls
for a child process for greater safety, but given that observation, this
patch only updates `RestoreImportDirectory` and `InitializeDllBlocklistOOP`.

Differential Revision: https://phabricator.services.mozilla.com/D90316
2020-09-15 21:10:06 +00:00
Doug Thayer 2e5dcd024d Bug 1656526 - Lazily load user32 and gdi32 for skeleton UI r=mhowell
We need this because otherwise we load user32, which fails the check in
WindowsDllBlocklist.cpp (line 649). It sounds like this check is non-
negotiable, so this is the only solution I can come up with. Obviously
please let me know if there is some reason we cannot do this, but it
seems to function fine.

Depends on D89670

Differential Revision: https://phabricator.services.mozilla.com/D90271
2020-09-15 16:23:16 +00:00
Doug Thayer 57e80f531d Bug 1656526 - Draw app skeleton UI r=Gijs,mhowell
Hopefully the comments in the actual code are enough to explain what is going
on here.

NOTE: this patch does not represent a finished skeleton UI. There are some
questions in comments within the code, and generally I'm seeking feedback on
whether the overall approach seems sane or not. Gijs, I'm including you for
feedback on whether you think this is maintainable by more frontend-oriented
folks, and Molly, I'm including you for feedback on whether the justification
for writing to a raw pixel buffer seems sound or not, and a general review of
the approach.

Differential Revision: https://phabricator.services.mozilla.com/D86447
2020-09-15 14:50:21 +00:00
Doug Thayer fa7b10106a Bug 1656526 - Show blank window prior to loading xul on Windows r=mhowell
See bug for justification. This patch aims to display a blank window prior to
loading/prefetching xul.dll. It also has a placeholder for drawing a
skeleton UI into that window. Note that this is disabled by default based on
a registry value, as there are still kinks to work out (for instance, what
happens if we aren't actually going to display a window, because, say, Firefox
is already running.) This just gives a basic implementation to dogfood, and
facilitates distributing work across multiple contributors.

Onto the details. The patch achieves its goal by creating a window and
assigning its handle to a static variable, which will be consumed inside
nsWindow::Create by the first toplevel window we want to make. nsWindow::Create
will take ownership of the window handle, restyle it to its own liking, and
then proceed as if everything is normal and it had created the window itself.

Differential Revision: https://phabricator.services.mozilla.com/D86263
2020-09-15 14:50:19 +00:00
Gerald Squelart 782cf5d3ad Bug 1657033 - Use Span<const char> in JSONWriter - r=froydnj
In most situations, JSONWriter users already know string lengths (either directly, or through `nsCString` and friends), so we should keep this information through JSONWriter and not recompute it again.
This also allows using JSONWriter with sub-strings (e.g., from a bigger buffer), without having to create null-terminated strings.

Public JSONWriter functions have overloads that accept literal strings.

Differential Revision: https://phabricator.services.mozilla.com/D86192
2020-09-14 02:33:20 +00:00
Dorel Luca 634b687351 Backed out 4 changesets (bug 1656526) for Browser-chrome failures in toolkit/xre/test/browser_checkdllblockliststate.js. CLOSED TREE
Backed out changeset 24648c48a49c (bug 1656526)
Backed out changeset 472b724994eb (bug 1656526)
Backed out changeset 6fbb7e7ac121 (bug 1656526)
Backed out changeset 88ff36a4bcfb (bug 1656526)
2020-09-11 23:17:23 +03:00
Doug Thayer c893a9a0c2 Bug 1656526 - Draw app skeleton UI r=Gijs,mhowell
Hopefully the comments in the actual code are enough to explain what is going
on here.

NOTE: this patch does not represent a finished skeleton UI. There are some
questions in comments within the code, and generally I'm seeking feedback on
whether the overall approach seems sane or not. Gijs, I'm including you for
feedback on whether you think this is maintainable by more frontend-oriented
folks, and Molly, I'm including you for feedback on whether the justification
for writing to a raw pixel buffer seems sound or not, and a general review of
the approach.

Differential Revision: https://phabricator.services.mozilla.com/D86447
2020-09-11 14:12:15 +00:00
Doug Thayer efe700e222 Bug 1656526 - Show blank window prior to loading xul on Windows r=mhowell
See bug for justification. This patch aims to display a blank window prior to
loading/prefetching xul.dll. It also has a placeholder for drawing a
skeleton UI into that window. Note that this is disabled by default based on
a registry value, as there are still kinks to work out (for instance, what
happens if we aren't actually going to display a window, because, say, Firefox
is already running.) This just gives a basic implementation to dogfood, and
facilitates distributing work across multiple contributors.

Onto the details. The patch achieves its goal by creating a window and
assigning its handle to a static variable, which will be consumed inside
nsWindow::Create by the first toplevel window we want to make. nsWindow::Create
will take ownership of the window handle, restyle it to its own liking, and
then proceed as if everything is normal and it had created the window itself.

Differential Revision: https://phabricator.services.mozilla.com/D86263
2020-09-11 14:12:00 +00:00
Gerald Squelart 2ac895ec86 Bug 1664122 - Clearer MarkerOptions accessors - r=gregtatum
`MarkerOptions::Set()` returns the same reference type as the object it's invoked on, i.e.: & -> &, and && -> &&.

`MarkerOptions::NAME()` now always returns a reference to a `const` member, so it's clear it cannot be modified (even if the object at hand is not `const`).
`MarkerOptions::NAMERef()` must be used when non-`const` access is needed.

Differential Revision: https://phabricator.services.mozilla.com/D89715
2020-09-11 00:44:18 +00:00
Gerald Squelart a087b2df35 Bug 1663554 - Convert AUTO_PROFILER_TEXT_MARKER_... to new AUTO_PROFILER_MARKER_TEXT - r=gregtatum
The name `AUTO_PROFILER_MARKER_TEXT` is more consistent with the equivalent non-`AUTO` macro, and similarly arguments have been re-ordered to be the same, i.e.: Name, category&options, text.

The different macros with different argument sets can now be collapsed into one macro, and the optional arguments (timing, inner window id, backtrace) can easily be added to the `MarkerOptions` where needed.

As a bonus, a specific start time can optionally be provided at construction time.

Differential Revision: https://phabricator.services.mozilla.com/D89588
2020-09-11 00:42:51 +00:00
Gerald Squelart b0bf2c2172 Bug 1663554 - Convert PROFILER_ADD_TEXT_MARKER and friends to PROFILER_MARKER_TEXT - r=gregtatum
Mostly mechanical changes, with some work needed to convert the different payloads (with optional timestamps, inner window id, and/or backtrace) to the equivalent MarkerOptions.

Differential Revision: https://phabricator.services.mozilla.com/D89587
2020-09-11 00:41:27 +00:00
Gerald Squelart 5f9ff13253 Bug 1663543 - Convert PROFILER_ADD_MARKER and 2-arg profiler_add_marker to PROFILER_MARKER_UNTYPED - r=gregtatum
Mostly mechanical change, with some extra work where non-literal names are provided.
Also, when this is the only profiler call in a file, `#include "GeckoProfiler.h"` can be changed to `#include "mozilla/ProfilerMarkers.h"`.

Differential Revision: https://phabricator.services.mozilla.com/D89415
2020-09-10 03:02:36 +00:00
Gerald Squelart 6c2997d6a8 Bug 1663543 - Make MarkerCategory and MarkerOptions usable in macros - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D89414
2020-09-10 03:00:54 +00:00
Toshihito Kikuchi f14b766f30 Bug 1662560 - Retrieve the imagebase of the child process's executable from a process handle. r=mhowell
Our data indicates when the browser process populates a newly-created child process,
`VirtualProtectEx` may fail with `ERROR_INVALID_ADDRESS` for some unknown reason.

One possible cause is the parameter `aRemoteExeImage` of `RestoreImportDirectory`
was wrong i.e. pointing to an invalid address.  We simply pass the local process's
imagebase as `aRemoteExeImage` based on the assumption that the same executable is
mapped onto the same address in a different process, but it may not be guaranteed.

To deal with that potential case, we could retrieve a correct imagebase from the handle
of a remote process as we do for the plugin process.  Since we're not so sure about
the root cause or the effectiveness of this fix, we run it only when the first
attempt to `VirtualProtectEx` failed in Nightly.  Once it's confirmed, we promote this
to a permanent fix.

Differential Revision: https://phabricator.services.mozilla.com/D89502
2020-09-08 22:13:27 +00:00
Gerald Squelart 87d2667590 Bug 1662994 - Fix non-MOZ_GECKO_PROFILER_BUILD - r=canaltinova
`ProfileChunkedBuffer` needed to be fully defined, because its destructor is needed to define `UniquePtr<ProfileChunkedBuffer>`.
It can just be empty, because it won't actually be used anyway.

Added non-`MOZ_GECKO_PROFILER` tests around this.

Differential Revision: https://phabricator.services.mozilla.com/D89351
2020-09-07 10:11:16 +00:00
Gerald Squelart b1c2892ebb Bug 1646266 - Profiler Markers 2.0 tests - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D87260
2020-09-02 04:03:32 +00:00
Gerald Squelart ff8b12cb5c Bug 1646266 - {,Base}ProfilerMarkerTypes.h - r=gregtatum
This patch ports existing ProfilerMarkerPayload types to draft struct definitions that may be used with the new markers API.
This is just a starting point, they may be changed later on as needed, see meta-bug 1661394.

Differential Revision: https://phabricator.services.mozilla.com/D87259
2020-09-02 04:03:22 +00:00
Gerald Squelart e6bd850ec0 Bug 1646266 - {BASE_,}PROFILER_MARKER{,_TEXT} - r=gregtatum
This is the main public marker API:
- `AddMarkerToBuffer` can be used to store a marker to any buffer. This could be useful to code that wants to store markers outside of the default profiler buffers.
- `baseprofiler::AddMarker`/`profiler_add_marker` store a marker in the appropriate profiler buffer.
- BASE_PROFILER_MARKER and PROFILER_MARKER do the same, but are also defined (and empty) when MOZ_GECKO_PROFILER is not #defined.
All these take a name, marker options, a marker type, and the type's expected arguments if any (as expected by the `StreamJSONMarkerData` function).

Extra helpers for the most common types:
- BASE_PROFILER_MARKER_UNTYPED and PROFILER_MARKER_UNTYPED store a marker with no data payload.
- BASE_PROFILER_MARKER_TEXT and PROFILER_MARKER_TEXT store a text marker. `baseprofiler::markers::Text` is an example of how new marker types can be defined.

Differential Revision: https://phabricator.services.mozilla.com/D87257
2020-09-02 04:03:20 +00:00
Gerald Squelart 061abe0d50 Bug 1646266 - AddMarkerToBuffer - r=gregtatum
Main marker serialization function, which accepts the same arguments (with implicit conversions) as the marker type's `StreamJSONMarkerData(JSONWriter&, ...)` function, and stores them in a ProfileChunkedBuffer after the marker name and options.

Differential Revision: https://phabricator.services.mozilla.com/D87255
2020-09-02 04:02:06 +00:00
Gerald Squelart 0000b4f25a Bug 1646266 - Marker Deserialization - r=gregtatum
`DeserializeAfterKindAndStream()` is the main function that extracts all the marker data (past the already-read entry kind), and streams it to JSON using the user-provided `Stream(JSONWriter&, ...)` function in the appropriate marker type definition.

It currently requires two external functions to stream the name and the optional backtrace, because these are different between the two profilers. This may change in the future.

(Deserialization is implemented before serialization, because the `Deserialize()` function is needed during serialization to get a marker type tag.)

Differential Revision: https://phabricator.services.mozilla.com/D87254
2020-09-02 04:01:48 +00:00
Gerald Squelart f304c42c99 Bug 1646266 - ProfileBufferEntryKind::Marker - r=gregtatum
A new entry kind is needed to serialize the new markers, because they are not encoded the same way.

Differential Revision: https://phabricator.services.mozilla.com/D87253
2020-09-02 04:01:20 +00:00
Gerald Squelart 2c20225e23 Bug 1646266 - NoPayload default type, with specialized empty helper - r=gregtatum
`NoPayload` will be mostly used internally when adding markers without payload data.
It has an empty specialization of the MarkerTypeHelper (mainly to catch misuses), and the add-marker code will need to have different compile-time paths to handle it.

Differential Revision: https://phabricator.services.mozilla.com/D87252
2020-09-02 04:01:02 +00:00
Gerald Squelart 77bdcef80c Bug 1646266 - MarkerType::Stream function helpers - r=gregtatum
Marker types will be defined with a simple struct that contains (amongst other things) one `StreamJSONMarkerData(JSONWriter&, ...)` function.
This patch introduces a type-traits-like helper to examine that function. This will be used to check the arguments given to the upcoming add-marker function, to serialize and deserialize them.

Differential Revision: https://phabricator.services.mozilla.com/D87251
2020-09-02 04:00:34 +00:00
Gerald Squelart 4ce2239212 Bug 1646266 - Deserializers and Tags - r=gregtatum
This is similar to the existing deserializer table in ProfilerMarkerPayload.*:
Each type of marker (except the `NoPayload` one) has its corresponding deserializer in a table, and the index is used as a tag in the serialization buffer.

Differential Revision: https://phabricator.services.mozilla.com/D87250
2020-09-02 04:00:16 +00:00
Gerald Squelart 9e07f05d90 Bug 1646266 - MarkerOptions - r=gregtatum
A `MarkerOptions` must be constructed from a MarkerCategory, e.g.: `mozilla::baseprofiler::category::OTHER`. This will be required for all markers.
`MarkerOptions` also contains defaulted `MarkerThreadId`, `MarkerTiming`, `MarkerStack`, and `MarkerInnerWindowId`. They may be set by calling `WithOptions()` on the MarkerCategory, e.g.:
`PROFILER_MARKER<...>("name", OTHER.WithOptions(MarkerThreadId(otherThread), MarkerStack::Capture()), ...);`

Differential Revision: https://phabricator.services.mozilla.com/D87249
2020-09-02 03:59:53 +00:00
Gerald Squelart 092e6ca746 Bug 1646266 - Marker option: MarkerInnerWindowId - r=gregtatum
This option can take an inner window id.

Differential Revision: https://phabricator.services.mozilla.com/D87248
2020-09-02 03:59:30 +00:00
Gerald Squelart e31033f92d Bug 1646266 - Marker option: MarkerStack - r=gregtatum
This marker option allows three cases:
- By default, no stacks are captured.
- The caller can request a stack capture, and the add-marker code will take care of it in the most efficient way.
- The caller can still provide an existing backtrace, for cases where a marker reports something that happened elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D87247
2020-09-02 03:59:13 +00:00
Gerald Squelart 6daee06496 Bug 1646266 - Rework backtrace-capture functions - r=gregtatum
`profiler_capture_backtrace(ProfileChunkedBuffer&)` renamed to `profiler_capture_backtrace_into(ProfileChunkedBuffer&)` (notice "_into"), which is clearer.

New function `profiler_capture_backtrace()` creates a buffer, uses `profiler_capture_backtrace_into()`, and returns a `UniquePtr<ProfileChunkedBuffer>`, which can later be given to `MarkerStack::TakeBacktrace`.

`profiler_get_backtrace()` (returning a `UniqueProfilerBacktrace`) now uses `profiler_capture_backtrace()`.

This patch reduces most duplicate code between these functions.

Differential Revision: https://phabricator.services.mozilla.com/D88280
2020-09-02 03:58:50 +00:00
Gerald Squelart c3ffba3e5c Bug 1646266 - ProfileChunkedBuffer::IsEmpty() and Serializer<ProfileChunkedBuffer*> - r=gregtatum
`IsEmpty()` makes it easier for users to determine if there is anything stored in the `ProfileChunkedBuffer`.

And `ProfileChunkedBuffer` can now be serialized from a raw pointer, which will be useful when adding markers with an optional stack.
Deserialization should be done to a `UniquePtr<ProfileChunkedBuffer>`, which is already implemented.

Differential Revision: https://phabricator.services.mozilla.com/D87246
2020-09-02 03:58:17 +00:00
Gerald Squelart 043c34629b Bug 1646266 - Marker option: MarkerTiming - r=gregtatum
This moves the existing MarkerTiming class introduced in bug 1640969 to the BaseProfilerMarkersPrerequesites.h header, and can be used as a marker option.

Some minor clarifying changes:
- `Instant()` is split into two functions: `InstantNow()` and `InstantAt(TimeStamp)`.
- `Interval(TimeStamp, TimeStamp)` must be given both start and end, otherwise `IntervalUntilNowFrom(TimeStamp)` takes the start only and ends "now".

Also the default construction is now reserved for internal marker usage, the private member function `IsUnspecified()` will be used by the add-marker code will replace it with `InstantNow()`.

The serialization contains the phase, and only one or two timestamps as needed, to save space for non-interval timings.

Differential Revision: https://phabricator.services.mozilla.com/D87245
2020-09-02 03:57:59 +00:00
Gerald Squelart 1d767d3fbb Bug 1646266 - Marker option: MarkerThreadId - r=gregtatum
This marker option captures a given thread id.
If left unspecified (by default construction) during the add-marker call, the current thread id will be used then.

Differential Revision: https://phabricator.services.mozilla.com/D87244
2020-09-02 03:57:31 +00:00
Gerald Squelart a021a0ef4e Bug 1646266 - Marker option: MarkerCategory - r=gregtatum
The main, and only compulsory, marker option is the `MarkerCategory`, which captures the "category pair", as well as the parent category.

Differential Revision: https://phabricator.services.mozilla.com/D88154
2020-09-02 03:57:24 +00:00
Gerald Squelart 7fc90b5c27 Bug 1646266 - CorePS buffer access - r=gregtatum
The upcoming profiler-specific add-marker function will need to know which `ProfileChunkedBuffer` to serialize to, `profiler_get_core_buffer()` give access to the profiler's buffer, and `CachedCoreBuffer()` keeps it stored in a function-static object.

Differential Revision: https://phabricator.services.mozilla.com/D87256
2020-09-02 03:57:19 +00:00
Gerald Squelart f55e5c3957 Bug 1646266 - ProfilerString{,8,16}View - r=gregtatum
These string views are similar to `std::string_view`, but they are optimized to be serialized in the profiler buffer, and later deserialized and streamed to JSON.
They accept literal strings, and keep them as unowned raw pointers and sizes.
They also accept any substring reference, assuming that they will only be used as parameters during function calls, and therefore the dependent string will live during that call where these `StringView`'s are used.

Internally, they also allow optional string ownership, which is only used during deserialization and streaming.
This is hidden, so that users are not tempted to use potentially expensive string allocations during profiling; it's only used *after* profiling, so it's less of an impact to allocate strings then. (But it could still be optimized later on, as part of bug 1577656.)

Differential Revision: https://phabricator.services.mozilla.com/D87242
2020-09-02 03:57:17 +00:00
Gerald Squelart e91236469e Bug 1646266 - ProfilerMarkers skeleton files - r=gregtatum
This patch introduces all new files that contain the new markers C++ API and implementation.
They are mostly empty at this time, only including each other as eventually needed, and with `#ifdef MOZ_GECKO_PROFILER` guards.

Rough inclusion diagram: (header <-- includer)

    BaseProfilerMarkerPrerequesites.h <-- ProfilerMarkerPrerequesites.h  (Useful types: Input string view, marker options)
                  ^                                    ^
       BaseProfilerMarkerDetail.h     <--    ProfilerMarkerDetail.h      (Implementation details)
                  ^                                    ^
         BaseProfilerMarkers.h        <--      ProfilerMarkers.h         (Main API)
                  ^      ^---------                    ^   ^---------
       BaseProfilerMarkerTypes.h  |   <--    ProfilerMarkerTypes.h   |   (Common marker types)
                  ^         BaseProfiler.h        <--         GeckoProfiler.h  (Existing main profiler headers)

Differential Revision: https://phabricator.services.mozilla.com/D87241
2020-09-02 03:55:43 +00:00
Cristina Coroiu 91699791f8 Backed out 20 changesets (bug 1646266) for build bustage at baseprofiler/core/ProfilerMarkers.cpp on a CLOSED TREE
Backed out changeset a2734d73264c (bug 1646266)
Backed out changeset a0c2db6f73c7 (bug 1646266)
Backed out changeset 6b71d7b09641 (bug 1646266)
Backed out changeset fcf3c271d0fc (bug 1646266)
Backed out changeset b4a39ef38261 (bug 1646266)
Backed out changeset 6c2b59568703 (bug 1646266)
Backed out changeset 5e7a28a727a1 (bug 1646266)
Backed out changeset b51bc775d1e3 (bug 1646266)
Backed out changeset a01a466e464c (bug 1646266)
Backed out changeset 2c8828fab7a0 (bug 1646266)
Backed out changeset 9fd6a871374f (bug 1646266)
Backed out changeset 3b88d838b252 (bug 1646266)
Backed out changeset bde14a8b0660 (bug 1646266)
Backed out changeset dfd7e13e9e0b (bug 1646266)
Backed out changeset 22bdc0172356 (bug 1646266)
Backed out changeset 4ea14ca3d492 (bug 1646266)
Backed out changeset 25f8e4b67b32 (bug 1646266)
Backed out changeset 3d0160207591 (bug 1646266)
Backed out changeset 790ed86c1a6c (bug 1646266)
Backed out changeset 4c38607ea1ba (bug 1646266)
2020-09-01 11:01:57 +03:00
Paul Bone a7ab41b822 Bug 1661888 - pt 2. Move a field to avoid padding r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D88709
2020-09-01 04:50:52 +00:00
Gerald Squelart fa20d50c45 Bug 1646266 - Profiler Markers 2.0 tests - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D87260
2020-09-01 04:02:11 +00:00
Gerald Squelart 7440a01e37 Bug 1646266 - {,Base}ProfilerMarkerTypes.h - r=gregtatum
This patch ports existing ProfilerMarkerPayload types to draft struct definitions that may be used with the new markers API.
This is just a starting point, they may be changed later on as needed, see meta-bug 1661394.

Differential Revision: https://phabricator.services.mozilla.com/D87259
2020-09-01 04:01:06 +00:00
Gerald Squelart bf1b496989 Bug 1646266 - {BASE_,}PROFILER_MARKER{,_TEXT} - r=gregtatum
This is the main public marker API:
- `AddMarkerToBuffer` can be used to store a marker to any buffer. This could be useful to code that wants to store markers outside of the default profiler buffers.
- `baseprofiler::AddMarker`/`profiler_add_marker` store a marker in the appropriate profiler buffer.
- BASE_PROFILER_MARKER and PROFILER_MARKER do the same, but are also defined (and empty) when MOZ_GECKO_PROFILER is not #defined.
All these take a name, marker options, a marker type, and the type's expected arguments if any (as expected by the `StreamJSONMarkerData` function).

Extra helpers for the most common types:
- BASE_PROFILER_MARKER_UNTYPED and PROFILER_MARKER_UNTYPED store a marker with no data payload.
- BASE_PROFILER_MARKER_TEXT and PROFILER_MARKER_TEXT store a text marker. `baseprofiler::markers::Text` is an example of how new marker types can be defined.

Differential Revision: https://phabricator.services.mozilla.com/D87257
2020-09-01 04:00:33 +00:00
Gerald Squelart d80777b3e8 Bug 1646266 - AddMarkerToBuffer - r=gregtatum
Main marker serialization function, which accepts the same arguments (with implicit conversions) as the marker type's `StreamJSONMarkerData(JSONWriter&, ...)` function, and stores them in a ProfileChunkedBuffer after the marker name and options.

Differential Revision: https://phabricator.services.mozilla.com/D87255
2020-09-01 04:00:13 +00:00
Gerald Squelart a23a149def Bug 1646266 - Marker Deserialization - r=gregtatum
`DeserializeAfterKindAndStream()` is the main function that extracts all the marker data (past the already-read entry kind), and streams it to JSON using the user-provided `Stream(JSONWriter&, ...)` function in the appropriate marker type definition.

It currently requires two external functions to stream the name and the optional backtrace, because these are different between the two profilers. This may change in the future.

(Deserialization is implemented before serialization, because the `Deserialize()` function is needed during serialization to get a marker type tag.)

Differential Revision: https://phabricator.services.mozilla.com/D87254
2020-09-01 03:59:55 +00:00
Gerald Squelart 068e99dfee Bug 1646266 - ProfileBufferEntryKind::Marker - r=gregtatum
A new entry kind is needed to serialize the new markers, because they are not encoded the same way.

Differential Revision: https://phabricator.services.mozilla.com/D87253
2020-09-01 03:59:27 +00:00
Gerald Squelart 208176a140 Bug 1646266 - NoPayload default type, with specialized empty helper - r=gregtatum
`NoPayload` will be mostly used internally when adding markers without payload data.
It has an empty specialization of the MarkerTypeHelper (mainly to catch misuses), and the add-marker code will need to have different compile-time paths to handle it.

Differential Revision: https://phabricator.services.mozilla.com/D87252
2020-09-01 03:59:09 +00:00
Gerald Squelart 16b97c2388 Bug 1646266 - MarkerType::Stream function helpers - r=gregtatum
Marker types will be defined with a simple struct that contains (amongst other things) one `StreamJSONMarkerData(JSONWriter&, ...)` function.
This patch introduces a type-traits-like helper to examine that function. This will be used to check the arguments given to the upcoming add-marker function, to serialize and deserialize them.

Differential Revision: https://phabricator.services.mozilla.com/D87251
2020-09-01 03:58:41 +00:00
Gerald Squelart 0ac5e8dfd6 Bug 1646266 - Deserializers and Tags - r=gregtatum
This is similar to the existing deserializer table in ProfilerMarkerPayload.*:
Each type of marker (except the `NoPayload` one) has its corresponding deserializer in a table, and the index is used as a tag in the serialization buffer.

Differential Revision: https://phabricator.services.mozilla.com/D87250
2020-09-01 03:58:24 +00:00
Gerald Squelart 7aa5fd002d Bug 1646266 - MarkerOptions - r=gregtatum
A `MarkerOptions` must be constructed from a MarkerCategory, e.g.: `mozilla::baseprofiler::category::OTHER`. This will be required for all markers.
`MarkerOptions` also contains defaulted `MarkerThreadId`, `MarkerTiming`, `MarkerStack`, and `MarkerInnerWindowId`. They may be set by calling `WithOptions()` on the MarkerCategory, e.g.:
`PROFILER_MARKER<...>("name", OTHER.WithOptions(MarkerThreadId(otherThread), MarkerStack::Capture()), ...);`

Differential Revision: https://phabricator.services.mozilla.com/D87249
2020-09-01 03:58:01 +00:00
Gerald Squelart ecbd9b7fdd Bug 1646266 - Marker option: MarkerInnerWindowId - r=gregtatum
This option can take an inner window id.

Differential Revision: https://phabricator.services.mozilla.com/D87248
2020-09-01 03:57:38 +00:00
Gerald Squelart 9007588251 Bug 1646266 - Marker option: MarkerStack - r=gregtatum
This marker option allows three cases:
- By default, no stacks are captured.
- The caller can request a stack capture, and the add-marker code will take care of it in the most efficient way.
- The caller can still provide an existing backtrace, for cases where a marker reports something that happened elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D87247
2020-09-01 03:57:20 +00:00
Gerald Squelart 74d1ab4ad6 Bug 1646266 - Rework backtrace-capture functions - r=gregtatum
`profiler_capture_backtrace(ProfileChunkedBuffer&)` renamed to `profiler_capture_backtrace_into(ProfileChunkedBuffer&)` (notice "_into"), which is clearer.

New function `profiler_capture_backtrace()` creates a buffer, uses `profiler_capture_backtrace_into()`, and returns a `UniquePtr<ProfileChunkedBuffer>`, which can later be given to `MarkerStack::TakeBacktrace`.

`profiler_get_backtrace()` (returning a `UniqueProfilerBacktrace`) now uses `profiler_capture_backtrace()`.

This patch reduces most duplicate code between these functions.

Differential Revision: https://phabricator.services.mozilla.com/D88280
2020-09-01 03:57:02 +00:00
Gerald Squelart 8c8ec601ad Bug 1646266 - ProfileChunkedBuffer::IsEmpty() and Serializer<ProfileChunkedBuffer*> - r=gregtatum
`IsEmpty()` makes it easier for users to determine if there is anything stored in the `ProfileChunkedBuffer`.

And `ProfileChunkedBuffer` can now be serialized from a raw pointer, which will be useful when adding markers with an optional stack.
Deserialization should be done to a `UniquePtr<ProfileChunkedBuffer>`, which is already implemented.

Differential Revision: https://phabricator.services.mozilla.com/D87246
2020-09-01 03:56:29 +00:00
Gerald Squelart 5068c84cfe Bug 1646266 - Marker option: MarkerTiming - r=gregtatum
This moves the existing MarkerTiming class introduced in bug 1640969 to the BaseProfilerMarkersPrerequesites.h header, and can be used as a marker option.

Some minor clarifying changes:
- `Instant()` is split into two functions: `InstantNow()` and `InstantAt(TimeStamp)`.
- `Interval(TimeStamp, TimeStamp)` must be given both start and end, otherwise `IntervalUntilNowFrom(TimeStamp)` takes the start only and ends "now".

Also the default construction is now reserved for internal marker usage, the private member function `IsUnspecified()` will be used by the add-marker code will replace it with `InstantNow()`.

The serialization contains the phase, and only one or two timestamps as needed, to save space for non-interval timings.

Differential Revision: https://phabricator.services.mozilla.com/D87245
2020-09-01 03:56:16 +00:00
Gerald Squelart 85ae866745 Bug 1646266 - Marker option: MarkerThreadId - r=gregtatum
This marker option captures a given thread id.
If left unspecified (by default construction) during the add-marker call, the current thread id will be used then.

Differential Revision: https://phabricator.services.mozilla.com/D87244
2020-09-01 03:56:09 +00:00
Gerald Squelart e6811f9c29 Bug 1646266 - Marker option: MarkerCategory - r=gregtatum
The main, and only compulsory, marker option is the `MarkerCategory`, which captures the "category pair", as well as the parent category.

Differential Revision: https://phabricator.services.mozilla.com/D88154
2020-09-01 03:56:06 +00:00
Gerald Squelart c9adf082b0 Bug 1646266 - CorePS buffer access - r=gregtatum
The upcoming profiler-specific add-marker function will need to know which `ProfileChunkedBuffer` to serialize to, `profiler_get_core_buffer()` give access to the profiler's buffer, and `CachedCoreBuffer()` keeps it stored in a function-static object.

Differential Revision: https://phabricator.services.mozilla.com/D87256
2020-09-01 03:55:00 +00:00
Gerald Squelart f458e68ddc Bug 1646266 - ProfilerString{,8,16}View - r=gregtatum
These string views are similar to `std::string_view`, but they are optimized to be serialized in the profiler buffer, and later deserialized and streamed to JSON.
They accept literal strings, and keep them as unowned raw pointers and sizes.
They also accept any substring reference, assuming that they will only be used as parameters during function calls, and therefore the dependent string will live during that call where these `StringView`'s are used.

Internally, they also allow optional string ownership, which is only used during deserialization and streaming.
This is hidden, so that users are not tempted to use potentially expensive string allocations during profiling; it's only used *after* profiling, so it's less of an impact to allocate strings then. (But it could still be optimized later on, as part of bug 1577656.)

Differential Revision: https://phabricator.services.mozilla.com/D87242
2020-09-01 03:54:26 +00:00
Gerald Squelart 6ec5853647 Bug 1646266 - ProfilerMarkers skeleton files - r=gregtatum
This patch introduces all new files that contain the new markers C++ API and implementation.
They are mostly empty at this time, only including each other as eventually needed, and with `#ifdef MOZ_GECKO_PROFILER` guards.

Rough inclusion diagram: (header <-- includer)

    BaseProfilerMarkerPrerequesites.h <-- ProfilerMarkerPrerequesites.h  (Useful types: Input string view, marker options)
                  ^                                    ^
       BaseProfilerMarkerDetail.h     <--    ProfilerMarkerDetail.h      (Implementation details)
                  ^                                    ^
         BaseProfilerMarkers.h        <--      ProfilerMarkers.h         (Main API)
                  ^      ^---------                    ^   ^---------
       BaseProfilerMarkerTypes.h  |   <--    ProfilerMarkerTypes.h   |   (Common marker types)
                  ^         BaseProfiler.h        <--         GeckoProfiler.h  (Existing main profiler headers)

Differential Revision: https://phabricator.services.mozilla.com/D87241
2020-09-01 03:53:59 +00:00
Brindusan Cristian 891f3554a7 Backed out 20 changesets (bug 1646266) for build bustages at TestBaseProfiler.cpp. CLOSED TREE
Backed out changeset e2e161965ad3 (bug 1646266)
Backed out changeset 5d8691cb0edb (bug 1646266)
Backed out changeset 119344e72ed8 (bug 1646266)
Backed out changeset da8ae4c7615c (bug 1646266)
Backed out changeset d5a7d5139d59 (bug 1646266)
Backed out changeset 1eba69baac1f (bug 1646266)
Backed out changeset 33da5fe6d185 (bug 1646266)
Backed out changeset 60a54b5d7bad (bug 1646266)
Backed out changeset 8e65fa28b768 (bug 1646266)
Backed out changeset 678a7c5d8a83 (bug 1646266)
Backed out changeset 3c1f350a07d5 (bug 1646266)
Backed out changeset d091750b1b14 (bug 1646266)
Backed out changeset de4d9ab1a6e1 (bug 1646266)
Backed out changeset 9eff1a8c358e (bug 1646266)
Backed out changeset db3bdff5e4d7 (bug 1646266)
Backed out changeset be8fd5f6d335 (bug 1646266)
Backed out changeset 220f96d1e3a2 (bug 1646266)
Backed out changeset 092c89f164ba (bug 1646266)
Backed out changeset ddec14555d7e (bug 1646266)
Backed out changeset 8c9ceb8f8dc8 (bug 1646266)
2020-09-01 05:24:52 +03:00
Gerald Squelart 7b632d04a8 Bug 1646266 - Profiler Markers 2.0 tests - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D87260
2020-09-01 01:38:49 +00:00
Gerald Squelart 3980c1d522 Bug 1646266 - {,Base}ProfilerMarkerTypes.h - r=gregtatum
This patch ports existing ProfilerMarkerPayload types to draft struct definitions that may be used with the new markers API.
This is just a starting point, they may be changed later on as needed, see meta-bug 1661394.

Differential Revision: https://phabricator.services.mozilla.com/D87259
2020-09-01 01:38:26 +00:00
Gerald Squelart 5e53131645 Bug 1646266 - {BASE_,}PROFILER_MARKER{,_TEXT} - r=gregtatum
This is the main public marker API:
- `AddMarkerToBuffer` can be used to store a marker to any buffer. This could be useful to code that wants to store markers outside of the default profiler buffers.
- `baseprofiler::AddMarker`/`profiler_add_marker` store a marker in the appropriate profiler buffer.
- BASE_PROFILER_MARKER and PROFILER_MARKER do the same, but are also defined (and empty) when MOZ_GECKO_PROFILER is not #defined.
All these take a name, marker options, a marker type, and the type's expected arguments if any (as expected by the `StreamJSONMarkerData` function).

Extra helpers for the most common types:
- BASE_PROFILER_MARKER_UNTYPED and PROFILER_MARKER_UNTYPED store a marker with no data payload.
- BASE_PROFILER_MARKER_TEXT and PROFILER_MARKER_TEXT store a text marker. `baseprofiler::markers::Text` is an example of how new marker types can be defined.

Differential Revision: https://phabricator.services.mozilla.com/D87257
2020-09-01 01:37:53 +00:00
Gerald Squelart 0e73eb1657 Bug 1646266 - AddMarkerToBuffer - r=gregtatum
Main marker serialization function, which accepts the same arguments (with implicit conversions) as the marker type's `StreamJSONMarkerData(JSONWriter&, ...)` function, and stores them in a ProfileChunkedBuffer after the marker name and options.

Differential Revision: https://phabricator.services.mozilla.com/D87255
2020-09-01 01:37:32 +00:00
Gerald Squelart 75bfba7dd8 Bug 1646266 - Marker Deserialization - r=gregtatum
`DeserializeAfterKindAndStream()` is the main function that extracts all the marker data (past the already-read entry kind), and streams it to JSON using the user-provided `Stream(JSONWriter&, ...)` function in the appropriate marker type definition.

It currently requires two external functions to stream the name and the optional backtrace, because these are different between the two profilers. This may change in the future.

(Deserialization is implemented before serialization, because the `Deserialize()` function is needed during serialization to get a marker type tag.)

Differential Revision: https://phabricator.services.mozilla.com/D87254
2020-09-01 01:37:25 +00:00
Gerald Squelart f2bb5042b4 Bug 1646266 - ProfileBufferEntryKind::Marker - r=gregtatum
A new entry kind is needed to serialize the new markers, because they are not encoded the same way.

Differential Revision: https://phabricator.services.mozilla.com/D87253
2020-09-01 01:37:23 +00:00
Gerald Squelart f3ea5dc029 Bug 1646266 - NoPayload default type, with specialized empty helper - r=gregtatum
`NoPayload` will be mostly used internally when adding markers without payload data.
It has an empty specialization of the MarkerTypeHelper (mainly to catch misuses), and the add-marker code will need to have different compile-time paths to handle it.

Differential Revision: https://phabricator.services.mozilla.com/D87252
2020-09-01 01:37:20 +00:00
Gerald Squelart 3b560590cb Bug 1646266 - MarkerType::Stream function helpers - r=gregtatum
Marker types will be defined with a simple struct that contains (amongst other things) one `StreamJSONMarkerData(JSONWriter&, ...)` function.
This patch introduces a type-traits-like helper to examine that function. This will be used to check the arguments given to the upcoming add-marker function, to serialize and deserialize them.

Differential Revision: https://phabricator.services.mozilla.com/D87251
2020-09-01 01:36:01 +00:00
Gerald Squelart 460b249d40 Bug 1646266 - Deserializers and Tags - r=gregtatum
This is similar to the existing deserializer table in ProfilerMarkerPayload.*:
Each type of marker (except the `NoPayload` one) has its corresponding deserializer in a table, and the index is used as a tag in the serialization buffer.

Differential Revision: https://phabricator.services.mozilla.com/D87250
2020-09-01 01:35:43 +00:00
Gerald Squelart f3e4e60d25 Bug 1646266 - MarkerOptions - r=gregtatum
A `MarkerOptions` must be constructed from a MarkerCategory, e.g.: `mozilla::baseprofiler::category::OTHER`. This will be required for all markers.
`MarkerOptions` also contains defaulted `MarkerThreadId`, `MarkerTiming`, `MarkerStack`, and `MarkerInnerWindowId`. They may be set by calling `WithOptions()` on the MarkerCategory, e.g.:
`PROFILER_MARKER<...>("name", OTHER.WithOptions(MarkerThreadId(otherThread), MarkerStack::Capture()), ...);`

Differential Revision: https://phabricator.services.mozilla.com/D87249
2020-09-01 01:35:21 +00:00
Gerald Squelart 1935200d9b Bug 1646266 - Marker option: MarkerInnerWindowId - r=gregtatum
This option can take an inner window id.

Differential Revision: https://phabricator.services.mozilla.com/D87248
2020-09-01 01:34:58 +00:00
Gerald Squelart 4ddaa53a92 Bug 1646266 - Marker option: MarkerStack - r=gregtatum
This marker option allows three cases:
- By default, no stacks are captured.
- The caller can request a stack capture, and the add-marker code will take care of it in the most efficient way.
- The caller can still provide an existing backtrace, for cases where a marker reports something that happened elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D87247
2020-09-01 01:34:40 +00:00
Gerald Squelart 0338f0c407 Bug 1646266 - Rework backtrace-capture functions - r=gregtatum
`profiler_capture_backtrace(ProfileChunkedBuffer&)` renamed to `profiler_capture_backtrace_into(ProfileChunkedBuffer&)` (notice "_into"), which is clearer.

New function `profiler_capture_backtrace()` creates a buffer, uses `profiler_capture_backtrace_into()`, and returns a `UniquePtr<ProfileChunkedBuffer>`, which can later be given to `MarkerStack::TakeBacktrace`.

`profiler_get_backtrace()` (returning a `UniqueProfilerBacktrace`) now uses `profiler_capture_backtrace()`.

This patch reduces most duplicate code between these functions.

Differential Revision: https://phabricator.services.mozilla.com/D88280
2020-09-01 01:34:17 +00:00
Gerald Squelart b44f966142 Bug 1646266 - ProfileChunkedBuffer::IsEmpty() and Serializer<ProfileChunkedBuffer*> - r=gregtatum
`IsEmpty()` makes it easier for users to determine if there is anything stored in the `ProfileChunkedBuffer`.

And `ProfileChunkedBuffer` can now be serialized from a raw pointer, which will be useful when adding markers with an optional stack.
Deserialization should be done to a `UniquePtr<ProfileChunkedBuffer>`, which is already implemented.

Differential Revision: https://phabricator.services.mozilla.com/D87246
2020-09-01 01:33:44 +00:00
Gerald Squelart 718ef431b3 Bug 1646266 - Marker option: MarkerTiming - r=gregtatum
This moves the existing MarkerTiming class introduced in bug 1640969 to the BaseProfilerMarkersPrerequesites.h header, and can be used as a marker option.

Some minor clarifying changes:
- `Instant()` is split into two functions: `InstantNow()` and `InstantAt(TimeStamp)`.
- `Interval(TimeStamp, TimeStamp)` must be given both start and end, otherwise `IntervalUntilNowFrom(TimeStamp)` takes the start only and ends "now".

Also the default construction is now reserved for internal marker usage, the private member function `IsUnspecified()` will be used by the add-marker code will replace it with `InstantNow()`.

The serialization contains the phase, and only one or two timestamps as needed, to save space for non-interval timings.

Differential Revision: https://phabricator.services.mozilla.com/D87245
2020-09-01 01:33:26 +00:00
Gerald Squelart bd1aaa5796 Bug 1646266 - Marker option: MarkerThreadId - r=gregtatum
This marker option captures a given thread id.
If left unspecified (by default construction) during the add-marker call, the current thread id will be used then.

Differential Revision: https://phabricator.services.mozilla.com/D87244
2020-09-01 01:32:53 +00:00
Gerald Squelart f1e3a40788 Bug 1646266 - Marker option: MarkerCategory - r=gregtatum
The main, and only compulsory, marker option is the `MarkerCategory`, which captures the "category pair", as well as the parent category.

Differential Revision: https://phabricator.services.mozilla.com/D88154
2020-09-01 01:32:35 +00:00
Gerald Squelart 56dc2f7c14 Bug 1646266 - CorePS buffer access - r=gregtatum
The upcoming profiler-specific add-marker function will need to know which `ProfileChunkedBuffer` to serialize to, `profiler_get_core_buffer()` give access to the profiler's buffer, and `CachedCoreBuffer()` keeps it stored in a function-static object.

Differential Revision: https://phabricator.services.mozilla.com/D87256
2020-09-01 01:32:13 +00:00
Gerald Squelart 80e6ec3baf Bug 1646266 - ProfilerString{,8,16}View - r=gregtatum
These string views are similar to `std::string_view`, but they are optimized to be serialized in the profiler buffer, and later deserialized and streamed to JSON.
They accept literal strings, and keep them as unowned raw pointers and sizes.
They also accept any substring reference, assuming that they will only be used as parameters during function calls, and therefore the dependent string will live during that call where these `StringView`'s are used.

Internally, they also allow optional string ownership, which is only used during deserialization and streaming.
This is hidden, so that users are not tempted to use potentially expensive string allocations during profiling; it's only used *after* profiling, so it's less of an impact to allocate strings then. (But it could still be optimized later on, as part of bug 1577656.)

Differential Revision: https://phabricator.services.mozilla.com/D87242
2020-09-01 01:31:45 +00:00
Gerald Squelart 5dd7e84aa2 Bug 1646266 - ProfilerMarkers skeleton files - r=gregtatum
This patch introduces all new files that contain the new markers C++ API and implementation.
They are mostly empty at this time, only including each other as eventually needed, and with `#ifdef MOZ_GECKO_PROFILER` guards.

Rough inclusion diagram: (header <-- includer)

    BaseProfilerMarkerPrerequesites.h <-- ProfilerMarkerPrerequesites.h  (Useful types: Input string view, marker options)
                  ^                                    ^
       BaseProfilerMarkerDetail.h     <--    ProfilerMarkerDetail.h      (Implementation details)
                  ^                                    ^
         BaseProfilerMarkers.h        <--      ProfilerMarkers.h         (Main API)
                  ^      ^---------                    ^   ^---------
       BaseProfilerMarkerTypes.h  |   <--    ProfilerMarkerTypes.h   |   (Common marker types)
                  ^         BaseProfiler.h        <--         GeckoProfiler.h  (Existing main profiler headers)

Differential Revision: https://phabricator.services.mozilla.com/D87241
2020-09-01 01:31:17 +00:00
Narcis Beleuzu 6d1bdc6124 Backed out 20 changesets (bug 1646266) for bustages on TestBaseProfiler.cpp . CLOSED TREE
Backed out changeset 0871a6eb61bb (bug 1646266)
Backed out changeset c797da0d5b1b (bug 1646266)
Backed out changeset 5e8954913748 (bug 1646266)
Backed out changeset 9bc0276c9260 (bug 1646266)
Backed out changeset fa6a89f9eba2 (bug 1646266)
Backed out changeset 9a1cd7b6c1ca (bug 1646266)
Backed out changeset d193a9f84702 (bug 1646266)
Backed out changeset ecfc47fc2444 (bug 1646266)
Backed out changeset 7ecc9ee961b6 (bug 1646266)
Backed out changeset e482a2568f27 (bug 1646266)
Backed out changeset 1a17cf6e6b4d (bug 1646266)
Backed out changeset 08dd6220f0dd (bug 1646266)
Backed out changeset 4189499ea599 (bug 1646266)
Backed out changeset df82ad015f84 (bug 1646266)
Backed out changeset 1c1501cfa02b (bug 1646266)
Backed out changeset 9001175e7475 (bug 1646266)
Backed out changeset c25cdf173894 (bug 1646266)
Backed out changeset e01bc772d669 (bug 1646266)
Backed out changeset 35166588a684 (bug 1646266)
Backed out changeset f05f6a52bd7e (bug 1646266)
2020-09-01 03:31:28 +03:00
Gerald Squelart 12fefb1ee0 Bug 1646266 - Profiler Markers 2.0 tests - r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D87260
2020-08-31 23:36:11 +00:00
Gerald Squelart c626d815bc Bug 1646266 - {,Base}ProfilerMarkerTypes.h - r=gregtatum
This patch ports existing ProfilerMarkerPayload types to draft struct definitions that may be used with the new markers API.
This is just a starting point, they may be changed later on as needed, see meta-bug 1661394.

Differential Revision: https://phabricator.services.mozilla.com/D87259
2020-08-31 23:35:05 +00:00
Gerald Squelart 680bd83298 Bug 1646266 - {BASE_,}PROFILER_MARKER{,_TEXT} - r=gregtatum
This is the main public marker API:
- `AddMarkerToBuffer` can be used to store a marker to any buffer. This could be useful to code that wants to store markers outside of the default profiler buffers.
- `baseprofiler::AddMarker`/`profiler_add_marker` store a marker in the appropriate profiler buffer.
- BASE_PROFILER_MARKER and PROFILER_MARKER do the same, but are also defined (and empty) when MOZ_GECKO_PROFILER is not #defined.
All these take a name, marker options, a marker type, and the type's expected arguments if any (as expected by the `StreamJSONMarkerData` function).

Extra helpers for the most common types:
- BASE_PROFILER_MARKER_UNTYPED and PROFILER_MARKER_UNTYPED store a marker with no data payload.
- BASE_PROFILER_MARKER_TEXT and PROFILER_MARKER_TEXT store a text marker. `baseprofiler::markers::Text` is an example of how new marker types can be defined.

Differential Revision: https://phabricator.services.mozilla.com/D87257
2020-08-31 23:34:33 +00:00
Gerald Squelart 8b8b5cd070 Bug 1646266 - AddMarkerToBuffer - r=gregtatum
Main marker serialization function, which accepts the same arguments (with implicit conversions) as the marker type's `StreamJSONMarkerData(JSONWriter&, ...)` function, and stores them in a ProfileChunkedBuffer after the marker name and options.

Differential Revision: https://phabricator.services.mozilla.com/D87255
2020-08-31 23:34:11 +00:00
Gerald Squelart 8d3604614a Bug 1646266 - Marker Deserialization - r=gregtatum
`DeserializeAfterKindAndStream()` is the main function that extracts all the marker data (past the already-read entry kind), and streams it to JSON using the user-provided `Stream(JSONWriter&, ...)` function in the appropriate marker type definition.

It currently requires two external functions to stream the name and the optional backtrace, because these are different between the two profilers. This may change in the future.

(Deserialization is implemented before serialization, because the `Deserialize()` function is needed during serialization to get a marker type tag.)

Differential Revision: https://phabricator.services.mozilla.com/D87254
2020-08-31 23:33:53 +00:00
Gerald Squelart a6a68c6141 Bug 1646266 - ProfileBufferEntryKind::Marker - r=gregtatum
A new entry kind is needed to serialize the new markers, because they are not encoded the same way.

Differential Revision: https://phabricator.services.mozilla.com/D87253
2020-08-31 23:33:25 +00:00
Gerald Squelart 95eb9ec051 Bug 1646266 - NoPayload default type, with specialized empty helper - r=gregtatum
`NoPayload` will be mostly used internally when adding markers without payload data.
It has an empty specialization of the MarkerTypeHelper (mainly to catch misuses), and the add-marker code will need to have different compile-time paths to handle it.

Differential Revision: https://phabricator.services.mozilla.com/D87252
2020-08-31 23:33:07 +00:00
Gerald Squelart 54c35aa7f1 Bug 1646266 - MarkerType::Stream function helpers - r=gregtatum
Marker types will be defined with a simple struct that contains (amongst other things) one `StreamJSONMarkerData(JSONWriter&, ...)` function.
This patch introduces a type-traits-like helper to examine that function. This will be used to check the arguments given to the upcoming add-marker function, to serialize and deserialize them.

Differential Revision: https://phabricator.services.mozilla.com/D87251
2020-08-31 23:32:39 +00:00
Gerald Squelart 3ef4a84159 Bug 1646266 - Deserializers and Tags - r=gregtatum
This is similar to the existing deserializer table in ProfilerMarkerPayload.*:
Each type of marker (except the `NoPayload` one) has its corresponding deserializer in a table, and the index is used as a tag in the serialization buffer.

Differential Revision: https://phabricator.services.mozilla.com/D87250
2020-08-31 23:32:22 +00:00
Gerald Squelart d0d7950fb3 Bug 1646266 - MarkerOptions - r=gregtatum
A `MarkerOptions` must be constructed from a MarkerCategory, e.g.: `mozilla::baseprofiler::category::OTHER`. This will be required for all markers.
`MarkerOptions` also contains defaulted `MarkerThreadId`, `MarkerTiming`, `MarkerStack`, and `MarkerInnerWindowId`. They may be set by calling `WithOptions()` on the MarkerCategory, e.g.:
`PROFILER_MARKER<...>("name", OTHER.WithOptions(MarkerThreadId(otherThread), MarkerStack::Capture()), ...);`

Differential Revision: https://phabricator.services.mozilla.com/D87249
2020-08-31 23:31:59 +00:00
Gerald Squelart fd497a7bf1 Bug 1646266 - Marker option: MarkerInnerWindowId - r=gregtatum
This option can take an inner window id.

Differential Revision: https://phabricator.services.mozilla.com/D87248
2020-08-31 23:31:36 +00:00
Gerald Squelart aee45f966e Bug 1646266 - Marker option: MarkerStack - r=gregtatum
This marker option allows three cases:
- By default, no stacks are captured.
- The caller can request a stack capture, and the add-marker code will take care of it in the most efficient way.
- The caller can still provide an existing backtrace, for cases where a marker reports something that happened elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D87247
2020-08-31 23:31:18 +00:00
Gerald Squelart 71abce20e5 Bug 1646266 - Rework backtrace-capture functions - r=gregtatum
`profiler_capture_backtrace(ProfileChunkedBuffer&)` renamed to `profiler_capture_backtrace_into(ProfileChunkedBuffer&)` (notice "_into"), which is clearer.

New function `profiler_capture_backtrace()` creates a buffer, uses `profiler_capture_backtrace_into()`, and returns a `UniquePtr<ProfileChunkedBuffer>`, which can later be given to `MarkerStack::TakeBacktrace`.

`profiler_get_backtrace()` (returning a `UniqueProfilerBacktrace`) now uses `profiler_capture_backtrace()`.

This patch reduces most duplicate code between these functions.

Differential Revision: https://phabricator.services.mozilla.com/D88280
2020-08-31 23:30:53 +00:00
Gerald Squelart ff5ebd5a6f Bug 1646266 - ProfileChunkedBuffer::IsEmpty() and Serializer<ProfileChunkedBuffer*> - r=gregtatum
`IsEmpty()` makes it easier for users to determine if there is anything stored in the `ProfileChunkedBuffer`.

And `ProfileChunkedBuffer` can now be serialized from a raw pointer, which will be useful when adding markers with an optional stack.
Deserialization should be done to a `UniquePtr<ProfileChunkedBuffer>`, which is already implemented.

Differential Revision: https://phabricator.services.mozilla.com/D87246
2020-08-31 23:30:28 +00:00
Gerald Squelart 8670e62694 Bug 1646266 - Marker option: MarkerTiming - r=gregtatum
This moves the existing MarkerTiming class introduced in bug 1640969 to the BaseProfilerMarkersPrerequesites.h header, and can be used as a marker option.

Some minor clarifying changes:
- `Instant()` is split into two functions: `InstantNow()` and `InstantAt(TimeStamp)`.
- `Interval(TimeStamp, TimeStamp)` must be given both start and end, otherwise `IntervalUntilNowFrom(TimeStamp)` takes the start only and ends "now".

Also the default construction is now reserved for internal marker usage, the private member function `IsUnspecified()` will be used by the add-marker code will replace it with `InstantNow()`.

The serialization contains the phase, and only one or two timestamps as needed, to save space for non-interval timings.

Differential Revision: https://phabricator.services.mozilla.com/D87245
2020-08-31 23:30:17 +00:00
Gerald Squelart c2665d4e9d Bug 1646266 - Marker option: MarkerThreadId - r=gregtatum
This marker option captures a given thread id.
If left unspecified (by default construction) during the add-marker call, the current thread id will be used then.

Differential Revision: https://phabricator.services.mozilla.com/D87244
2020-08-31 23:30:12 +00:00
Gerald Squelart 959178815b Bug 1646266 - Marker option: MarkerCategory - r=gregtatum
The main, and only compulsory, marker option is the `MarkerCategory`, which captures the "category pair", as well as the parent category.

Differential Revision: https://phabricator.services.mozilla.com/D88154
2020-08-31 23:30:07 +00:00
Gerald Squelart 8ff41618d2 Bug 1646266 - CorePS buffer access - r=gregtatum
The upcoming profiler-specific add-marker function will need to know which `ProfileChunkedBuffer` to serialize to, `profiler_get_core_buffer()` give access to the profiler's buffer, and `CachedCoreBuffer()` keeps it stored in a function-static object.

Differential Revision: https://phabricator.services.mozilla.com/D87256
2020-08-31 23:28:56 +00:00
Gerald Squelart 4e9b0b4d1f Bug 1646266 - ProfilerString{,8,16}View - r=gregtatum
These string views are similar to `std::string_view`, but they are optimized to be serialized in the profiler buffer, and later deserialized and streamed to JSON.
They accept literal strings, and keep them as unowned raw pointers and sizes.
They also accept any substring reference, assuming that they will only be used as parameters during function calls, and therefore the dependent string will live during that call where these `StringView`'s are used.

Internally, they also allow optional string ownership, which is only used during deserialization and streaming.
This is hidden, so that users are not tempted to use potentially expensive string allocations during profiling; it's only used *after* profiling, so it's less of an impact to allocate strings then. (But it could still be optimized later on, as part of bug 1577656.)

Differential Revision: https://phabricator.services.mozilla.com/D87242
2020-08-31 23:28:22 +00:00
Gerald Squelart 3cb4ee0995 Bug 1646266 - ProfilerMarkers skeleton files - r=gregtatum
This patch introduces all new files that contain the new markers C++ API and implementation.
They are mostly empty at this time, only including each other as eventually needed, and with `#ifdef MOZ_GECKO_PROFILER` guards.

Rough inclusion diagram: (header <-- includer)

    BaseProfilerMarkerPrerequesites.h <-- ProfilerMarkerPrerequesites.h  (Useful types: Input string view, marker options)
                  ^                                    ^
       BaseProfilerMarkerDetail.h     <--    ProfilerMarkerDetail.h      (Implementation details)
                  ^                                    ^
         BaseProfilerMarkers.h        <--      ProfilerMarkers.h         (Main API)
                  ^      ^---------                    ^   ^---------
       BaseProfilerMarkerTypes.h  |   <--    ProfilerMarkerTypes.h   |   (Common marker types)
                  ^         BaseProfiler.h        <--         GeckoProfiler.h  (Existing main profiler headers)

Differential Revision: https://phabricator.services.mozilla.com/D87241
2020-08-31 23:27:54 +00:00
Sylvestre Ledru 9c192aa9ca Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D88713
2020-08-31 09:23:02 +00:00
Mihai Alexandru Michis 261d01524b Backed out changeset d0f173a90792 (bug 1519636) for causing bustages.
CLOSED TREE
2020-08-31 10:14:58 +03:00
Sylvestre Ledru 939dd426e6 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D88713
2020-08-31 06:51:21 +00:00
Gerald Squelart 3cbc9b5572 Bug 1659404 - Fix non-MOZ_GECKO_PROFILER build - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D88375
2020-08-27 14:41:46 +00:00
Toshihito Kikuchi 65642af4cd Bug 1659398 - Don't resolve redirecion of JMP for DuplicateHandle. r=handyman
In Win7 and later, some exported functions in kernel32.dll are just a stub
jumping to a function in kernelbase.dll.  After the fix for Bug 1642626,
our detour resolves such a stub in kernel32.dll and detours a corresponding function in
kernelbase.dll.  This new behavior caused a problem in Win8 when we detour
`DuplicateHandle` because our detour cannot handle the assembly pattern of
`KERNELBASE!DuplicateHandle`.

Win8's `KERNELBASE!DuplicateHandle` has jump instructions whose destination is
within the region where we move instructions to a trampoline.

In the example below, the address `000007f954ad271c` is a destination of the
`JMP` instructions, but when we detour `KERNELBASE!DuplicateHandle`, we move
the original instructions to a trampoline, and that address will point to
an invalid instruction, jumping to which address causes a crash.

A proposed fix is to detour `KERNEL32!DuplicateHandle` without resolving redirection,
that is the behavior before bug 1642626.

```
KERNEL32!DuplicateHandle:
000007f9`54cd2d5c ff2556b61100    jmp     qword ptr [KERNEL32!_imp_DuplicateHandle] --> KERNELBASE!DuplicateHandle
```

```
KERNELBASE!DuplicateHandle:
000007f9`54ad2710 4883ec48        sub     rsp,48h
000007f9`54ad2714 4c8bd1          mov     r10,rcx
000007f9`54ad2717 83faf4          cmp     edx,0FFFFFFF4h
000007f9`54ad271a 733b            jae     KERNELBASE!DuplicateHandle+0x43 (000007f9`54ad2757)
000007f9`54ad271c 8b842480000000  mov     eax,dword ptr [rsp+80h]
...
000007f9`54b8f0de 65488b042560000000 mov   rax,qword ptr gs:[60h]
000007f9`54b8f0e7 488b5020        mov     rdx,qword ptr [rax+20h]
000007f9`54b8f0eb 488b5220        mov     rdx,qword ptr [rdx+20h]
000007f9`54b8f0ef e92836f4ff      jmp     KERNELBASE!DuplicateHandle+0xc (000007f9`54ad271c)
000007f9`54b8f0f4 65488b042560000000 mov   rax,qword ptr gs:[60h]
000007f9`54b8f0fd 488b5020        mov     rdx,qword ptr [rax+20h]
000007f9`54b8f101 488b5228        mov     rdx,qword ptr [rdx+28h]
000007f9`54b8f105 e91236f4ff      jmp     KERNELBASE!DuplicateHandle+0xc (000007f9`54ad271c)
000007f9`54b8f10a 65488b042560000000 mov   rax,qword ptr gs:[60h]
000007f9`54b8f113 488b5020        mov     rdx,qword ptr [rax+20h]
000007f9`54b8f117 488b5230        mov     rdx,qword ptr [rdx+30h]
000007f9`54b8f11b e9fc35f4ff      jmp     KERNELBASE!DuplicateHandle+0xc (000007f9`54ad271c)
```

Differential Revision: https://phabricator.services.mozilla.com/D88136
2020-08-26 20:26:36 +00:00
Toshihito Kikuchi eaaa31291a Bug 1630444: Part3 - Send the launcher process failure ping from the browser process. r=aklotz
This patch adds a new property `process_type` to the launcher process failure
ping, indicating which process type the browser process failed to initialize
as a sandboxed process.

Depends on D83639

Differential Revision: https://phabricator.services.mozilla.com/D83640
2020-08-26 19:01:27 +00:00
Toshihito Kikuchi dd20162db0 Bug 1630444: Part2 - Add HandleLauncherError to DllServices. r=aklotz
This patch adds winlauncher's HandleLauncherError to DllServices
along with InitializeDllBlocklistOOPInternal so that SandboxBroker
can call HandleLauncherError.

Differential Revision: https://phabricator.services.mozilla.com/D83639
2020-08-26 19:01:40 +00:00
Gerald Squelart 23277409cf Bug 1660177 - Fold GetTotalLength into its only caller CopyDataIntoLazilyAllocatedBuffer - r=canaltinova
Normally I believe it's good to keep functionally-distinct code in separate functions when appropriate.
However in this case, this `ChunkedJSONWriteFunc::GetTotalLength()` function was only used internally, so it's easy to hide it. It is not very big, so it's less important to keep it separate. And its code (going through all chunks to collect sizes) is similar to the code that follows (going through all chunks to collect their content), so it makes some sense to have these similar things in the same place; if one day this chunking change, both loops would probably have to be modified at the same time.

More importantly to justify this change: It was including the final null terminator, which was a bit inconsistent with the usual `Length()` functions in string containers.
Now that code is only used where absolutely necessary (before allocating an output buffer), so it rightly accounts for the null terminator that is added at the end of the contents.

And in upcoming bug 1612799, `ChunkedJSONWriteFunc` will have a new "retired" state (e.g., after an internal memory allocation failed) in which case a public `GetTotalLength()` function could give misleading results -- should it be 0 (nothing to output), 1 (only the null terminator), 5 ("null"), or the length of some error message? So I think it's better not to expose such an ambiguous function.
It could of course be re-introduced if new needs arise in the future.

Differential Revision: https://phabricator.services.mozilla.com/D87833
2020-08-26 08:03:24 +00:00
Gerald Squelart 1628f9ba8d Bug 1660177 - Replace SpliceableJSONWriter::Splice(const char*) with better calls where possible - r=canaltinova
In most calls to `SpliceableJSONWriter::Splice(const char*)`:
- The data comes from a `ChunkedJSONWriteFunc` and is copied to a new buffer, which is then copied again through `Write()`. Instead we can copy the data directly from the `ChunkedJSONWriteFunc`; and this is a nice complement to `TakeAndSplice()` below.
- Or the length is already known, so we can pass it to a new `Splice(const char*, size_t)`, which forwards it to `Write(const char*, size_t)`, saving one `strlen` call.

Differential Revision: https://phabricator.services.mozilla.com/D87703
2020-08-26 08:03:20 +00:00
Gerald Squelart af0143531b Bug 1660177 - Clarify accesses to SpliceableChunkedJSONWriter's WriteFunc - r=canaltinova
`SpliceableChunkedJSONWriter::ChunkedWriteFunc` returns a `ChunkedJSONWriteFunc*`, which is never null and is either used to:
1. Copy data.
2. Or take ownership of the chunks.

In the first case, `ChunkedWriteFunc()` now returns a `const ChunkedJSONWriteFunc&` (notice "const &"), so only const members may be used to copy the data.

In the second case, a new function `TakeChunkedWriteFunc()` returns `ChunkedJSONWriteFunc&&` (notice "&&"), so it's clear that its chunks can be taken away. Some `DEBUG` assertions help ensure that it's not used anymore after that.
`TakeAndSplice()` now takes a `ChunkedJSONWriteFunc&&`.

All callers have been updated to the more appropriate functions.

Differential Revision: https://phabricator.services.mozilla.com/D87702
2020-08-26 08:03:17 +00:00
Gerald Squelart 12aded23d4 Bug 1659382 - Remove dependency on BaseProfiler.h from BaseProfilingCategory.h - r=gregtatum
It is just not needed here.

Differential Revision: https://phabricator.services.mozilla.com/D87239
2020-08-24 08:39:22 +00:00
Gerald Squelart 9d09d80097 Bug 1659382 - Remove dependency on BaseProfiler.h from BaseProfilerDetail.h - r=gregtatum
Instead of including all of BaseProfiler.h, we only need to declare the one function that we need in this header.

Differential Revision: https://phabricator.services.mozilla.com/D87238
2020-08-24 08:39:18 +00:00
Gerald Squelart d939f1d95f Bug 1659382 - Generic std::basic_string<CHAR> (de)serialization - r=gregtatum
This patch makes it possible to serialize and deserialize std::basic_string's of different character types, not just std::string. This will be useful when dealing with char16_t from nsString and others.

We also expose the internal read-contents functions, to allow the user to read a sequence of characters of already-known length.

Differential Revision: https://phabricator.services.mozilla.com/D87237
2020-08-24 08:34:24 +00:00
Christian Holler 90a0b83838 Bug 1621786 - Fix an incomplete skia suppression. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D87741
2020-08-23 09:42:02 +00:00
Christian Holler ec8a8733c1 Bug 1658013 - Add missing suppression for JS GC race. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D87738
2020-08-20 12:42:21 +00:00
Razvan Maries 6742cf83d7 Backed out 2 changesets (bug 1656526) for build bustages on EarlyBlankWindow.cpp. CLOSED TREE
Backed out changeset b6d3b254ae8c (bug 1656526)
Backed out changeset abdc9c22078c (bug 1656526)
2020-08-18 19:10:37 +03:00
Doug Thayer 817b30e212 Bug 1656526 - Draw app skeleton UI r=Gijs,mhowell
Hopefully the comments in the actual code are enough to explain what is going
on here.

NOTE: this patch does not represent a finished skeleton UI. There are some
questions in comments within the code, and generally I'm seeking feedback on
whether the overall approach seems sane or not. Gijs, I'm including you for
feedback on whether you think this is maintainable by more frontend-oriented
folks, and Molly, I'm including you for feedback on whether the justification
for writing to a raw pixel buffer seems sound or not, and a general review of
the approach.

Differential Revision: https://phabricator.services.mozilla.com/D86447
2020-08-18 15:31:32 +00:00
Doug Thayer b5e46bb95c Bug 1656526 - Show blank window prior to loading xul on Windows r=mhowell
See bug for justification. This patch aims to display a blank window prior to
loading/prefetching xul.dll. It also has a placeholder for drawing a
skeleton UI into that window. Note that this is disabled by default based on
a registry value, as there are still kinks to work out (for instance, what
happens if we aren't actually going to display a window, because, say, Firefox
is already running.) This just gives a basic implementation to dogfood, and
facilitates distributing work across multiple contributors.

Onto the details. The patch achieves its goal by creating a window and
assigning its handle to a static variable, which will be consumed inside
nsWindow::Create by the first toplevel window we want to make. nsWindow::Create
will take ownership of the window handle, restyle it to its own liking, and
then proceed as if everything is normal and it had created the window itself.

Differential Revision: https://phabricator.services.mozilla.com/D86263
2020-08-18 15:31:28 +00:00
Nathan Froyd 548da43ebd Bug 1658374 - add spinning hint for aarch64 in Darwin mutexes; r=glandium
This change makes everything compile and presumably has some tiny effect on
performance.  We also take the opportunity to ensure that the compiler won't
optimize out our inline asm by making the asm volatile and indicating that
it touches memory.

Differential Revision: https://phabricator.services.mozilla.com/D86594
2020-08-13 11:36:08 +00:00
Gerald Squelart 2ae86bbfac Bug 1658232 - profiler_capture_backtrace(ProfileChunkedBuffer&) - r=canaltinova
The stack sampling can be abstracted to only use a reference to a `ProfileBuffer`, and the existing `locked_profiler_get_backtrace` can provide its stack-based `ProfileBuffer` that points at a heap-based `ProfileChunkedBuffer` (the one that will be stored in the returned `ProfilerBacktrace`).

And we can now add a public `profiler_capture_backtrace` that only takes a reference to a `ProfileChunkedBuffer`, and fills it with a backtrace.
This will be used by the new marker API, to optionally capture a backtrace in stack-based buffers at the user's request.

Differential Revision: https://phabricator.services.mozilla.com/D86514
2020-08-13 03:30:58 +00:00
Gerald Squelart d9705556b1 Bug 1658232 - Use a temporary ProfileBuffer in locked_profiler_get_backtrace - r=gregtatum
A heap-allocate ProfileBuffer is not really needed, so it's more efficient to have one on the stack during capture, and we don't need to keep it in the `ProfilerBacktrace`.

Differential Revision: https://phabricator.services.mozilla.com/D86513
2020-08-13 03:30:30 +00:00
Gerald Squelart b2df384fc7 Bug 1658232 - ProfilerBacktrace can reference or own a ProfileBuffer and/or ProfileChunkedBuffer - r=canaltinova,gregtatum
Instead of always taking ownership of both heap-allocated `ProfileBuffer` and `ProfileChunkedBuffer`, `ProfilerBacktrace` can now accept:
- Unique pointers to both or either, similar to what it was before, so a ProfilerBacktrace can be kept for later use.
- Non-owning pointers to both or either, to allow callers to use stack-based buffer(s); null pointers are allowed for totally empty backtraces.

Only the `ProfileChunkedBuffer` contains the actual data, we can create a `ProfileBuffer` on the spot if not provided.

Differential Revision: https://phabricator.services.mozilla.com/D86512
2020-08-13 03:30:02 +00:00
Gerald Squelart d4fa7a1fda Bug 1658232 - Use std::string for ProfilerBacktrace::mName - r=gregtatum
Instead of keeping a pointer to a null-terminated string, it's simpler to keep a proper `std::string`, and it helps to keep the length ready for streaming.

Differential Revision: https://phabricator.services.mozilla.com/D86511
2020-08-13 03:29:34 +00:00
Gerald Squelart ab7dd1effd Bug 1658232 - ProfileBuffer::UnderlyingChunkedBuffer() - r=gregtatum
Let `ProfilerBuffer` expose its underlying `ProfileChunkedBuffer`, this will be useful when `ProfilerBacktrace` will only be given a `ProfileBuffer`, and to perform some safety checks.

As a bonus from this change, `StoreMarker()` can be made non-generic -- It was relying on both `ProfileBuffer` and `ProfileChunkedBuffer` to have the same function `PutObjects()`. Consequently, we don't need `ProfileBuffer::PutObjects()` anymore, this removes this clunky pass-through (but useful and the best solution at the time).

Differential Revision: https://phabricator.services.mozilla.com/D86510
2020-08-13 03:29:06 +00:00
Gerald Squelart accd288dcf Bug 1658232 - Don't make ~ProfileBuffer() erase the ProfileChunkedBuffer - r=gregtatum
Until now the `ProfileBuffer` would erase its attached `ProfileChunkedBuffer` upon destruction.
However:
- The main `ProfileChunkedBuffer` is erased anyway in the `ActivePS`,
- Other `ProfileChunkedBuffer`s are short-lived and don't really need to be erased.
- The upcoming changes to `ProfilerBacktrace` and its users means that we will only keep the `ProfileChunkedBuffer` as backtrace storage, a `ProfileBuffer` will only be needed during capture and then when streaming to JSON; so we don't want the `ProfileChunkedBuffer` to be erased when detached from its capturing `ProfileBuffer`.
- Also, the erasing was done by `ResetChunkManager()` in `~ProfileBuffer()`, which was asymetric with what the constructor does (nothing!). So it's better to leave whoever did the `SetChunkManager()` to deal with the corresponding `ResetChunkManager()` (in the main case `ActivePS`, otherwise short-lived buffers being destroyed at the end of their scope).

Both `ProfileBuffer` destructors were only doing this operation, so we can just remove them completely.

Differential Revision: https://phabricator.services.mozilla.com/D86509
2020-08-13 03:28:38 +00:00
Gerald Squelart 3f131cf7b3 Bug 1658232 - ProfileBufferEntryKinds.h - r=gregtatum
Backtraces and other marker data will be stored directly into a ProfileChunkedBuffer from public code in both profilers, so we will need to have the entry "kinds" available outside of the profiler directories.
This also helps with de-duplicating, since the kinds will now be in one spot and shared by both profilers.

Differential Revision: https://phabricator.services.mozilla.com/D86508
2020-08-13 03:28:11 +00:00
Gerald Squelart 9ee7ca79ba Bug 1658232 - Disable native stack-walking in baseprofiler on linux - r=gregtatum
The upcoming changes will make it easier to try and capture backtraces from the baseprofiler. Unfortunately, the support is not there on Linux (including Android, and BSD), and trying to capture a backtrace would just crash in Registers::SyncPopulate() : https://searchfox.org/mozilla-central/rev/e07d5eb5646b40b10df3164e315d4a3108cf9101/mozglue/baseprofiler/core/platform-linux-android.cpp#542

So until this support is added, I will just prevent any stack-tracing there.

Differential Revision: https://phabricator.services.mozilla.com/D86506
2020-08-13 03:27:25 +00:00
Nathan Froyd 3c32012822 Bug 1658375 - add support for arm64 macOS to profiler sampling and unwinding; r=mstange
The registers referenced in this patch and the assembly have been tested to
compile; the code changes have not been tested to actually work.

Differential Revision: https://phabricator.services.mozilla.com/D86612
2020-08-11 14:09:20 +00:00
Nathan Froyd 7951ffdf2e Bug 1658375 - define platform macros for arm64 macOS in the profiler; r=mstange
This change doesn't resolve some of the issues in profiler code that have
x86-64-isms in them, but this is at least a start.

Differential Revision: https://phabricator.services.mozilla.com/D86595
2020-08-10 22:02:27 +00:00
Gerald Squelart 9aec647e21 Bug 1658230 - Renamed SpliceableChunkedJSONWriter::WriteFunc to ChunkedWriteFunc - r=gregtatum
SpliceableChunkedJSONWriter::WriteFunc was hiding base-class non-virtual JSONWriter::WriteFunc(), which made it less than ideal (for me) to reason with.

Also made a few subclasses final, to help with possible devirtualization.

Differential Revision: https://phabricator.services.mozilla.com/D86505
2020-08-11 03:51:33 +00:00
Gerald Squelart cc6cde66ad Bug 1658230 - Deduplicate ProfileJSONWriter classes - r=gregtatum
The main change is removing ProfileJSONWriter.cpp, making ProfileJSONWriter.h point at BaseProfileJSONWriter.h, and exposing `mozilla::baseprofiler::` classes in the top namespace as expected by users of ProfileJSONWriter.h (to minimize changes).

These two headers are now always present in the "mozilla" include directory, independent of MOZ_GECKO_PROFILER settings.

The rest is just needed tweaks to match the above changes.

Differential Revision: https://phabricator.services.mozilla.com/D86504
2020-08-11 03:50:54 +00:00
Gerald Squelart 11bd8d8e4a Bug 1658230 - Make BaseProfileJSONWriter.h header-only - r=gregtatum
Because this header will be used across libraries (mozglue and xul), it is simpler and more efficient to make it fully self-contained instead of using MFBT_API.

It may lead to slightly longer build times, but since it's only used inside the profilers, it won't impact other components.
The compiler can better optimize it in context, and decide what to inline.

Differential Revision: https://phabricator.services.mozilla.com/D86503
2020-08-11 03:49:00 +00:00
Mike Hommey 748bff0a39 Bug 1658434 - Replace replace_malloc.mk with a mozbuild file. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D86639
2020-08-11 00:05:38 +00:00
Simon Giesecke 1e02318b49 Bug 1653335 - Replace MakeSpan uses by constructor calls. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D83817
2020-08-07 07:49:47 +00:00
Simon Giesecke dea5b543db Bug 1653335 - Remove uses of MakeSpan in return statements. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D83812
2020-08-07 07:42:50 +00:00
Mike Hommey 0853045118 Bug 1656141 - Remove rc include files that only add a manifest. r=firefox-build-system-reviewers,rstewart
That was redundant with the manifest being added with MT (although useful
for mingw builds, that don't use MT), but is also now handled by the
automatic creation of rc files.

Differential Revision: https://phabricator.services.mozilla.com/D86156
2020-08-06 22:51:54 +00:00
Mike Hommey 5a5a1edd0e Bug 1656141 - Remove RESFILE. r=firefox-build-system-reviewers,rstewart
The resource file is always generated so being able to configure its name
is not useful. On the other hand, the way things are currently implemented,
the lack of RESFILE also makes RCFILE ignored, which we fix at the same
time.

And remove a spurious RESFILE in widget/windows/moz.build, where no binary
is produced, which means RESFILE had no meaning.

Differential Revision: https://phabricator.services.mozilla.com/D86154
2020-08-06 22:51:59 +00:00
Mihai Alexandru Michis c4e805857f Backed out 9 changesets (bug 1656141) for causing multiple failures.
CLOSED TREE

Backed out changeset 9033b0400339 (bug 1656141)
Backed out changeset e43dd57dc61a (bug 1656141)
Backed out changeset eb450457a9b7 (bug 1656141)
Backed out changeset 194a994cf9c9 (bug 1656141)
Backed out changeset ce6831acb5e3 (bug 1656141)
Backed out changeset 29653ea85d49 (bug 1656141)
Backed out changeset 704f28486bda (bug 1656141)
Backed out changeset de8899453150 (bug 1656141)
Backed out changeset 4b133eda46aa (bug 1656141)
2020-08-07 01:48:45 +03:00
Mike Hommey 9145b89e14 Bug 1656141 - Remove rc include files that only add a manifest. r=firefox-build-system-reviewers,rstewart
That was redundant with the manifest being added with MT (although useful
for mingw builds, that don't use MT), but is also now handled by the
automatic creation of rc files.

Differential Revision: https://phabricator.services.mozilla.com/D86156
2020-08-06 15:56:41 +00:00
Mike Hommey afe0ac845a Bug 1656141 - Remove RESFILE. r=firefox-build-system-reviewers,rstewart
The resource file is always generated so being able to configure its name
is not useful. On the other hand, the way things are currently implemented,
the lack of RESFILE also makes RCFILE ignored, which we fix at the same
time.

And remove a spurious RESFILE in widget/windows/moz.build, where no binary
is produced, which means RESFILE had no meaning.

Differential Revision: https://phabricator.services.mozilla.com/D86154
2020-08-06 15:59:02 +00:00
Jon Coppeard 8b07bac69a Bug 1657122 - Compact ObjectGroups r=sfink,decoder
Previously we didn't compact ObjectGroups, but doing this would hopfully unlock more memory savings in bug 1654853.

Most of the trickiness here comes from accessing objects whose object group is forwarded, so require special-case handling to get their class, compartment etc.

Differential Revision: https://phabricator.services.mozilla.com/D86033
2020-08-06 14:01:20 +00:00
Csoregi Natalia 3264618a4c Backed out changeset 664faa6f72ad (bug 1657122) for tsan failures on Cell.h. CLOSED TREE 2020-08-06 14:34:25 +03:00
Jon Coppeard 7abae42c44 Bug 1657122 - Compact ObjectGroups r=sfink,decoder
Previously we didn't compact ObjectGroups, but doing this would hopfully unlock more memory savings in bug 1654853.

Most of the trickiness here comes from accessing objects whose object group is forwarded, so require special-case handling to get their class, compartment etc.

Differential Revision: https://phabricator.services.mozilla.com/D86033
2020-08-05 20:52:10 +00:00
Toshihito Kikuchi ae04ca7814 Bug 1655680 - Support JAE rel32 in our detour. r=handyman
After the fix for bug 1642626, we need to detour `KERNELBASE!CloseHandle`
instead of K32's stub, which contains `JAE rel32`.

I also found a mistake in the fix for bug 1642626.  When we put a conditional
jump in a trampoline, we need to reverse a condition, but the JAE case mistakenly
filled JAE straight.  This patch corrects it to filling JB.

Differential Revision: https://phabricator.services.mozilla.com/D85477
2020-08-05 07:21:00 +00:00
Yoshi Cheng-Hao Huang 86ab9d6661 Bug 1653914 - Add profiler GC subcategories. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D85379
2020-08-03 09:24:50 +00:00
Sylvestre Ledru 843f943758 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D85678
2020-08-02 15:29:15 +00:00
Nathan Froyd e3ebda1914 Bug 1223932 - delete guard object uses from the tree; r=jwalden
CLOSED TREE

We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Mihai Alexandru Michis a911a108d0 Backed out changeset ac9c811bc427 (bug 1223932) for causing spidermonkey rust failures.
CLOSED TREE
2020-07-30 18:23:21 +03:00
Nathan Froyd bec9f9b93a Bug 1223932 - delete guard object uses from the tree; r=jwalden
We don't need these macros anymore, for two reasons:

1. We have static analysis to provide the same sort of checks via `MOZ_RAII`
   and friends.
2. clang now warns for the "temporary that should have been a declaration" case.

The extra requirements on class construction also show up during debug tests
as performance problems.

This change was automated by using the following sed script:

```
# Remove declarations in classes.
/MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER/d
/MOZ_GUARD_OBJECT_NOTIFIER_INIT/d

# Remove individual macros, carefully.
{
  # We don't have to worry about substrings here because the closing
  # parenthesis "anchors" the match.
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)/)/g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)/)/g;

  # Remove the longer identifier first.
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT//g;
  s/MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM//g;
}

# Remove the actual include.
\@# *include "mozilla/GuardObjects.h"@d
```

and running:

```
find . -name \*.cpp -o -name \*.h | grep -v 'GuardObjects.h' |xargs sed -i -f script 2>/dev/null
mach clang-format
```

Differential Revision: https://phabricator.services.mozilla.com/D85168
2020-07-30 14:22:38 +00:00
Byron Campen [:bwc] 40627a94b3 Bug 1652530: Suppress error due to libX11 not being instrumented. r=decoder
Depends on D84391

Differential Revision: https://phabricator.services.mozilla.com/D84404
2020-07-27 22:53:25 +00:00
Byron Campen [:bwc] 2dcd19dfc0 Bug 1651770: Suppress lock-order-inversion warning in CamerasChild. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D84391
2020-07-22 15:35:08 +00:00
Byron Campen [:bwc] e33a4d457a Bug 1653618: Suppression for racy flags field access in libusrsctp timer code. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D84367
2020-07-23 17:46:53 +00:00
Byron Campen [:bwc] 4f8381bd1f Bug 1648606: Suppress flag-checking race in libusrsctp's sctp_close. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D84366
2020-07-22 15:21:41 +00:00
Byron Campen [:bwc] 167e0884f5 Bug 1648604: Suppress benign race in libusrsctp's system_base_info. r=decoder
Differential Revision: https://phabricator.services.mozilla.com/D84364
2020-07-22 15:20:39 +00:00
Aaron Klotz 010f090320 Bug 1601792: Remove VMSharingPolicyShared's template parameters and use inline variables instead; r=handyman
Differential Revision: https://phabricator.services.mozilla.com/D83573
2020-07-15 17:43:30 +00:00
Gerald Squelart 36b452b4ba Bug 1654128 - Added missing #includes in baseprofiler/lul - r=canaltinova
The build would fail in non-unified mode and/or when adding/removing other files.

Differential Revision: https://phabricator.services.mozilla.com/D84272
2020-07-21 08:20:20 +00:00
Tyson Smith d478a0fb18 Bug 1651446 - Suppress TSan FFMpeg false positives. r=bryce
Differential Revision: https://phabricator.services.mozilla.com/D84048
2020-07-20 22:34:45 +00:00
Gerald Squelart 126afc3ab4 Bug 1653181 - Profiler feature 'audiocallbacktracing' controls Start/StopAudioCallbackTracing(), off by default - r=canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D83749
2020-07-17 11:22:23 +00:00
Byron Campen [:bwc] d1af59c9fe Bug 1652174: Suppress TSan race error in libevent's event_debug_mode_too_late r=dminor
See https://github.com/libevent/libevent/issues/777

Depends on D83794

Differential Revision: https://phabricator.services.mozilla.com/D83825
2020-07-16 18:22:49 +00:00
Byron Campen [:bwc] 9b9dac6d1c Bug 1652499: Suppress TSan race detection in webrtc.org's Loggable. r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D83794
2020-07-16 18:23:09 +00:00
Randell Jesup fa153eb95d Bug 1642772: name processes in the profiler with eTLD+1 r=gerald,dveditz
Differential Revision: https://phabricator.services.mozilla.com/D77926
2020-07-15 18:00:54 +00:00
Sylvestre Ledru 1dbb63db2b Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D83258
2020-07-14 09:34:19 +00:00
Gerald Squelart 8049dc9c3e Bug 1651086 - Allow profiler_register_thread from thread with already-registered id - r=canaltinova
It is possible that some threads fail/forget to unregister themselves, in which case a registered thread id could get recycled by a later thread, which was not allowed before this patch.

Note: The thread name cannot currently be changed. We record a special marker with the new name, so the frontend could process it to split the thread track at that point.

We also record a marker when profiler_unregister_thread is called from an already-unregistered thread, this could help find reg/unreg mismatches or nesting in Firefox threads.

Differential Revision: https://phabricator.services.mozilla.com/D83293
2020-07-13 13:18:29 +00:00
Gerald Squelart 7610ff4326 Bug 1651086 - Handle tgkill failure - r=canaltinova
On Linux (including Android), it was assumed that a registered thread could always be suspended through `tgkill`.
However in some cases a thread may not be correctly unregistered, in which case this would trigger `MOZ_ASSERT` or wait forever in the following loop.

This will especially be needed when `profiler_{,un}register_thread()` are made less strict in the following patch.

Windows and Mac already handle suspension failures.

Differential Revision: https://phabricator.services.mozilla.com/D83292
2020-07-13 13:14:32 +00:00
Dana Keeler 24db0c88fc Bug 1629002 - unblock asepkcs.dll r=tkikuchi
When the osclientcerts module attempts to use client certificates and keys from
certain tokens, the Windows APIs will attempt to load asepkcs.dll. If Firefox
blocks this library, the keys won't be available. Thus, it needs to be
unblocked.

Due to the architecture of osclientcerts (namely, its dedicated single thread),
using asepkcs.dll via the Windows APIs shouldn't cause the crashes that led to
this module being blocked.

Differential Revision: https://phabricator.services.mozilla.com/D82788
2020-07-10 22:39:38 +00:00
Mike Hommey e2151e9228 Bug 1651903 - Stop preprocessing mozglue.def. r=froydnj
The file defines symbol renames to perform when linking. The list of
symbols to rename varies between an empty list and a full list depending
whether MOZ_MEMORY is set. Practically speaking, the variant with an
empty list is equivalent to not using a def-file at all.

This means we don't need to preprocess it any more, and we can just not
use a def-file when MOZ_MEMORY is not set.

As a side effect, this removes a rule from a Makefile.in.

Differential Revision: https://phabricator.services.mozilla.com/D83034
2020-07-10 15:27:10 +00:00
Csoregi Natalia c275f8f4bb Backed out changeset e106c60b7be4 (bug 1607212) for tsan fails on CacheEntry.cpp. CLOSED TREE 2020-07-09 20:43:30 +03:00
Christian Holler 2c66728ad6 Bug 1642906 - Updating TSan suppressions for performance counter fix. r=perry
Differential Revision: https://phabricator.services.mozilla.com/D82898
2020-07-09 15:06:45 +00:00
Christian Holler baf7486d56 Bug 1607212 - Update TSan suppressions for fixed Necko cache race. r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D82899
2020-07-09 14:13:27 +00:00
Nick Alexander 1b75555dc7 Bug 1651136 - Part 1: Allow (and mark) certain xpcom/ headers as non-XPCOM. r=froydnj,bytesized
`nscore.h` includes `xpcom-config.h` which need not be generated for
non-XPCOM consumers.  In additon, `nullptr` and `bool` are C++
keywords, so at least some of the comments were dated.

The added include lines address transitive consumers of `nscore.h`.

Differential Revision: https://phabricator.services.mozilla.com/D82640
2020-07-08 22:57:26 +00:00
Mike Hommey 69fef46cab Bug 1651079 - Add necessary LOCAL_INCLUDES for StackWalk.cpp in memory/replace/logalloc/replay. r=rstewart
This requires a workaround for the use of __wrap_dladdr, which can't be
used in logalloc-replay. The workaround involves making __wrap_dladdr
expand to dladdr, but that makes the definition ElfLinker.h conflict
with the one in the Android system headers, so we change it to match,
and adjust ElfLinker.cpp accordingly.

And while here, fix the condition in mozglue/misc to match the condition
around including Linker.h in StackWalk.cpp itself.

Differential Revision: https://phabricator.services.mozilla.com/D82648
2020-07-08 21:37:24 +00:00
Gerald Squelart f9612141f1 Bug 1649776 - Use a separate mutex to access ProfileBufferChunkManagerWithLocalLimit::mUpdateCallback - r=canaltinova
To avoid deadlocks between the buffer main mutex and the externally-provided update callback code, the callback storage is now using a separate mutex, and both mutexes are never held at the same time.

Differential Revision: https://phabricator.services.mozilla.com/D82141
2020-07-06 12:38:06 +00:00
Mike Hommey 6b2fc90663 Bug 689178 - Remove crash-reporter hooks to externally provide library mappings. r=gsvelto
This is a rebase of a 7-year-old patch that was r=ted. The hooks are not
used as of bug 725231.

Differential Revision: https://phabricator.services.mozilla.com/D81026
2020-06-25 08:43:23 +00:00
Mike Hommey 200194bccd Bug 725231 - Stop reporting library mappings to the crash reporter. r=snorp
This is a rebase of a 7-year-old patch that was r=taras. Back then it
was waiting for breakpad changes that never were reviewed. However,
since then, bug 1486524 made the linker always map uncompressed files
directly, making it less necessary to report the library mappings to
the crash reporter, and bug 1291377 disabled the linker altogether on
Android 6.0+, which makes report_mapping unused at all in that case.

Differential Revision: https://phabricator.services.mozilla.com/D81025
2020-07-06 14:38:29 +00:00
Sylvestre Ledru caf785c695 Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D82178
2020-07-04 09:38:43 +00:00
Toshihito Kikuchi b80c6d24b1 Bug 1642626 - Part3: Handle a detour pattern of multple jumps. r=handyman
AVG AntiVirus hooks ntdll!NtMapViewOfSection by planting two JMP instructions,
jumping to a trampoline area first, then jumping to aswhook.dll.

```
ntdll!NtMapViewOfSection:
00007ffa`6d77c560 e9d33cfebf      jmp     00007ffa`2d760238

00007ffa`2d760238 ff25f2ffffff    jmp     qword ptr [00007ffa`2d760230] --> 00007ffa`541e2ad0

aswhook+0x2ad0:
00007ffa`541e2ad0 4055            push    rbp
00007ffa`541e2ad2 53              push    rbx
00007ffa`541e2ad3 56              push    rsi
```

With this patch, our detour can detour on top of that pattern.  The first part is
to remove the MEM_IMAGE check from IsPageAccessible.  The second part is to introduce
a loop in ResolveRedirectedAddress to resolve a chain of jumps.

Differential Revision: https://phabricator.services.mozilla.com/D81582
2020-07-02 16:43:14 +00:00
Toshihito Kikuchi fd9eb542c9 Bug 1642626 - Part2: Handle JAE and Opcode83 on x64 without REX Prefix. r=handyman
Depends on D81580

Differential Revision: https://phabricator.services.mozilla.com/D81581
2020-07-02 16:43:01 +00:00
Toshihito Kikuchi 31a3cc0614 Bug 1642626 - Part1: Take out jump detection from ReadOnlyTargetFunction. r=handyman
This patch moves the logics of jump detection from ResolveRedirectedAddress to
ReadOnlyTargetFunction to simplify ReadOnlyTargetFunction.

Differential Revision: https://phabricator.services.mozilla.com/D81580
2020-07-02 16:42:54 +00:00
Gerald Squelart 56736f31c3 Bug 1648507 - Distinguish pausing sampling only from pausing the whole profiler - r=canaltinova,perftest-reviewers,geckoview-reviewers,agi
The profiler can be "paused", which stops sampling, and since bug 1578329 stops markers as well.

Some test suites use pausing between tests (to better differentiate the tests, to keep the profiler ready to run, and to lower the amount of recorded data). But this causes problems with some tracing markers, as their matching ends have not been recorded (e.g., an end marker is missing), which show up as very loooong markers.
To solve this, we need to be able to pause sampling only, but keep recording markers.
But we still need to be able to pause the whole profiler, in particular before capturing, to avoid recording anything around that time.

This big patch is mostly mechanical changes: Wherever there are "Pause" and "Unpause/Resume" profiler functions, we add matching "PauseSampling" and "UnpauseSampling/ResumeSampling" functions that only impact the periodic sampling loop; And existing "Pause/Unpause/Resume" imply pausing sampling as well.
Exceptions and extra work:
- nsIProfiler (the JS API) already had `Pause/ResumeSampling()`, which misleadingly paused everything! Now they do the right thing, and we have `Pause/Resume()` as well.
- All tests using `Pause/ResumeSampling()` now use `Pause/Resume()`, except for Talos tests that only pause sampling between tests; Added some extra `Pause()` calls to pause everything before capturing profiles.
- GeckoJavaSampler doesn't handle pausing/resuming everything, this should be done in a follow-up bug.
- Sampling-only pauses are not streamed into JSON. If needed, we should follow-up, with potential work on the front-end to deal with these.

Differential Revision: https://phabricator.services.mozilla.com/D81492
2020-07-02 01:36:27 +00:00
Nathan Froyd 7c8d2e7c35 Bug 1649261 - stop cargo-culting mfbt headers in MmapFaultHandler.h; r=glandium
This header is using `MOZ_RAII` and `MFBT_ABI` from `Attributes.h` and
`Types.h`, respectively, so it should include those headers.

Differential Revision: https://phabricator.services.mozilla.com/D81600
2020-07-01 13:39:34 +00:00
Simon Giesecke 9364b353d4 Bug 1648010 - Remove NS_NAMED_LITERAL_CSTRING and NS_NAMED_LITERAL_STRING macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80631
2020-07-01 08:42:31 +00:00
Simon Giesecke cd8b8939b9 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Cameron Kaiser 1c860a4d74 Bug 1649653 - fix compilation on non-profiler platforms. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D81803
2020-07-01 03:03:56 +00:00
Jon Coppeard 15c4eee6dc Bug 1647702 - Broaden the race supression for compacting race between updating ObjectGroups and Shapes r=sfink
This is a data race, but I don't think it is causing problems at the moment.  It will go away when we get rid of ObjectGroups and is not trivial to fix, hence the decision to suppress it.

Differential Revision: https://phabricator.services.mozilla.com/D81327
2020-06-26 16:25:03 +00:00
Mike Hommey 77976c2cc1 Bug 1463035 - Remove MOZ_SIGNAL_TRAMPOLINE. r=gerald
This was previously r=jchen and landed, but was backed out because some
Android tests were running on an unrealistically old Linux kernel. These
tests have been retired, so this can reland.

Differential Revision: https://phabricator.services.mozilla.com/D81278
2020-06-26 03:48:49 +00:00
Mike Hommey 219d10e7ce Bug 1648654 - Remove AutoObjectMapperFaultyLib. r=gerald
Bug 1486524 disabled the features from the custom linker that required
AutoObjectMapperFaultyLib. We can now rely on AutoObjectMapperPOSIX
instead.

Differential Revision: https://phabricator.services.mozilla.com/D81264
2020-06-26 01:26:56 +00:00
Mike Hommey 3a241e8832 Bug 1648340 - Only call GetAndroidSDKVersion() on Android. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D81024
2020-06-25 10:59:19 +00:00