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

1905 Коммитов

Автор SHA1 Сообщение Дата
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