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

73 Коммитов

Автор SHA1 Сообщение Дата
Chris Peterson c9530ebe28 Bug 1729598 - Replace MOZ_MUST_USE_TYPE with [[nodiscard]]. r=static-analysis-reviewers,andi
Differential Revision: https://phabricator.services.mozilla.com/D125504
2021-09-15 05:10:51 +00:00
Jan Varga c06f56c861 Bug 1709352 - Allow QMResult errors to use existing stack id and to increase the frame id during error propagation; r=dom-storage-reviewers,asuth,glandium
Differential Revision: https://phabricator.services.mozilla.com/D114243
2021-05-25 07:28:20 +00:00
Simon Giesecke ae75c3faa8 Bug 1601556 - Make Result<V, E> a literal type if V and E are literal types and PackingStrategy is not Variant. r=emilio
Also make CompactPair<A, B> a literal type if A and B are literal types,
and add MaybeStorageBase that ought to be used as a basis of MaybeStorage
in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D55930
2021-03-23 12:35:19 +00:00
Simon Giesecke 8953086494 Bug 1677284 - Move PackingStrategy::Variant implementation to separate header file. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D97075
2020-11-23 15:49:14 +00:00
Simon Giesecke 290b2047d2 Bug 1677284 - Avoid using PackingStrategy::Variant fallback for CPUUsageWatcherError. r=nika,emilio
This also adds an UnusedZeroEnum template to Result.h, which can be used
for specializing UnusedZero for scoped enum types.

Differential Revision: https://phabricator.services.mozilla.com/D97074
2020-11-23 15:49:02 +00:00
Simon Giesecke a1064e29d7 Bug 1677284 - Use std::aligned_storage_t instead of mozilla::AlignedStorage2 in PackingStrategy::NullIsOk implementation. r=emilio
sizeof(mozilla::AlignedStorage2<T>) is always at least sizeof(uint64_t), which
is bad when T is bool, e.g.

Differential Revision: https://phabricator.services.mozilla.com/D97072
2020-11-23 15:48:53 +00:00
Sylvestre Ledru bebb9f9181 Bug 1519636 - Reformat with clang-format-11 to the Google coding style r=andi,sg,geckoview-reviewers,snorp
It is bringing some minor changes

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D90795
2020-11-18 09:05:59 +00:00
Simon Giesecke bd5cfda423 Bug 1669421 - Make andThen accept a function that accepts a rvalue reference. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D92552
2020-10-06 09:03:14 +00:00
Simon Giesecke e003e4d581 Bug 1667019 - Simplify moving of Results for PackingStrategy NullIsOk. r=emilio
No longer reset a moved-from Result to an error state, which required
UnusedZero<E>::GetDefaultValue, which was somewhat confusing, and might
also be inefficient. Leaving Result in a valid state, which might be a
success or error state is sufficient.

Differential Revision: https://phabricator.services.mozilla.com/D91250
2020-09-29 08:09:02 +00:00
Simon Giesecke 8804eb9be3 Bug 1666416 - Allow conversion from Result with convertible error type. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D90960
2020-09-22 11:24:08 +00:00
Simon Giesecke ccdc97d011 Bug 1666422 - Add missing include for cstdint. r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D90963
2020-09-22 08:52:51 +00:00
Simon Giesecke 32f7547296 Bug 1666200 - Support in-place construction of Result success value. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D90839
2020-09-21 13:15:13 +00:00
Simon Giesecke 2b1eb28b6a Bug 1665927 - Use free LSB optimization for empty types with mozilla::Result. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D90699
2020-09-21 13:14:53 +00:00
Simon Giesecke c8ed33ab9d Bug 1665850 - Remove specifics for reference error types from mozilla::Result. r=emilio,jandem
Also update the documentation on optimizations and representation to
better reflect the current situation.

Differential Revision: https://phabricator.services.mozilla.com/D90662
2020-09-21 13:14:28 +00:00
Simon Giesecke eaa00050e4 Bug 1665850 - Switch JS to use non-reference errors with mozilla::Result. r=jandem
Also switch optimizations for HasFreeLSB and existing tests to no longer
use references.

Differential Revision: https://phabricator.services.mozilla.com/D90661
2020-09-21 13:14:10 +00:00
Simon Giesecke 2e065c64d6 Bug 1665614 - Make mozilla::Result work with non-copyable/non-param error types. r=emilio,jandem
Among other things, there were some misuses of std::forward, and
GenericErrorResult was (presumably accidentally) instatiated with
references as the template argument type, e.g. const nsresult&,
which circumvented the check for not calling it with NS_OK in
ResultExtensions.h

Differential Revision: https://phabricator.services.mozilla.com/D90561
2020-09-21 13:12:48 +00:00
Bogdan Tara 395ecea593 Backed out changeset a1e4531f2091 (bug 1666200) for TestResult.cpp related bustage CLOSED TREE 2020-09-21 15:55:42 +03:00
Simon Giesecke 2cf66d3f89 Bug 1666200 - Support in-place construction of Result success value. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D90839
2020-09-21 11:47:47 +00:00
Butkovits Atila 270e7e2200 Backed out 5 changesets (bug 1665927, bug 1665614, bug 1665850) for causing bustage on Result.h. CLOSED TREE
Backed out changeset 1467e76399e8 (bug 1665927)
Backed out changeset ebd4dfbc0a88 (bug 1665850)
Backed out changeset 5e23340e3b39 (bug 1665850)
Backed out changeset 5bc547e7a773 (bug 1665850)
Backed out changeset 8d88afb85a78 (bug 1665614)
2020-09-21 15:25:16 +03:00
Simon Giesecke 6b3d1793e7 Bug 1665927 - Use free LSB optimization for empty types with mozilla::Result. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D90699
2020-09-21 11:09:31 +00:00
Simon Giesecke f193981fb7 Bug 1665850 - Remove specifics for reference error types from mozilla::Result. r=emilio,jandem
Also update the documentation on optimizations and representation to
better reflect the current situation.

Differential Revision: https://phabricator.services.mozilla.com/D90662
2020-09-21 11:09:09 +00:00
Simon Giesecke 70bda1ef61 Bug 1665850 - Switch JS to use non-reference errors with mozilla::Result. r=jandem
Also switch optimizations for HasFreeLSB and existing tests to no longer
use references.

Differential Revision: https://phabricator.services.mozilla.com/D90661
2020-09-21 11:11:02 +00:00
Simon Giesecke 3b0420646e Bug 1665614 - Make mozilla::Result work with non-copyable/non-param error types. r=emilio,jandem
Among other things, there were some misuses of std::forward, and
GenericErrorResult was (presumably accidentally) instatiated with
references as the template argument type, e.g. const nsresult&,
which circumvented the check for not calling it with NS_OK in
ResultExtensions.h

Differential Revision: https://phabricator.services.mozilla.com/D90561
2020-09-21 10:38:19 +00:00
Simon Giesecke 59cd4601d7 Bug 1663902 - Avoid gcc emitting lots of static constructors for UnusedZero<T&>::defaultValue. r=dmajor
Differential Revision: https://phabricator.services.mozilla.com/D90359
2020-09-16 13:58:49 +00:00
Jan Varga d4d58eddc9 Bug 1663648 - Fix mozilla::Result::map's return type definition; r=dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D89457
2020-09-08 14:39:41 +00:00
Simon Giesecke 2d21df0e59 Bug 1661428 - Support PackingVariant::NullIsOk also with non-trivially-default-constructible V. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D88444
2020-09-03 14:14:41 +00:00
Simon Giesecke 5cacc3e1dc Bug 1661502 - Make Result move-only. r=froydnj,jandem
Differential Revision: https://phabricator.services.mozilla.com/D88443
2020-09-02 17:56:23 +00:00
Simon Giesecke bd28698eb3 Bug 1661428 - Use CompactPair instead of Variant for trivially default-constructible V and UnusedZero E. r=froydnj
It seems that the clang toolchain has trouble optimizing away the tag access in
a `mozilla::Variant`. Use of a `CompactPair` seems to be better when `E` is
small (all cases where `UnusedZero<E>` is true are small right now anyway).
While this doesn't change `sizeof(Result<V, E>)` in most cases, it makes
the generated code simpler/smaller: As of now, this reduce the overall VM size
of libxul.so by ca. 59K.

Without additional effort, this requires and leads to default-construction of
a `V` even in cases where it is never accessed, so this is restricted to
trivially default-constructible `V` for now.

This could be avoided by replacing  `CompactPair<V, E>` by
`CompactPair<AlignedStorage2<V>, E>`.

Differential Revision: https://phabricator.services.mozilla.com/D88393
2020-09-02 17:55:55 +00:00
Razvan Maries eae150a880 Backed out 5 changesets (bug 1661457, bug 1661428, bug 1661497, bug 1661502) for build bustages on Result.h. CLOSED TREE
Backed out changeset fbf42b3b51f3 (bug 1661428)
Backed out changeset 83f3f36d540f (bug 1661457)
Backed out changeset 8a9dce0d08ce (bug 1661502)
Backed out changeset 733df139089a (bug 1661497)
Backed out changeset fca770fc0956 (bug 1661428)
2020-09-02 19:44:47 +03:00
Simon Giesecke 261cda7f20 Bug 1661428 - Support PackingVariant::NullIsOk also with non-trivially-default-constructible V. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D88444
2020-09-02 16:31:43 +00:00
Simon Giesecke d4179392a0 Bug 1661502 - Make Result move-only. r=froydnj,jandem
Differential Revision: https://phabricator.services.mozilla.com/D88443
2020-09-02 16:23:01 +00:00
Simon Giesecke d5f6d76c5a Bug 1661428 - Use CompactPair instead of Variant for trivially default-constructible V and UnusedZero E. r=froydnj
It seems that the clang toolchain has trouble optimizing away the tag access in
a `mozilla::Variant`. Use of a `CompactPair` seems to be better when `E` is
small (all cases where `UnusedZero<E>` is true are small right now anyway).
While this doesn't change `sizeof(Result<V, E>)` in most cases, it makes
the generated code simpler/smaller: As of now, this reduce the overall VM size
of libxul.so by ca. 59K.

Without additional effort, this requires and leads to default-construction of
a `V` even in cases where it is never accessed, so this is restricted to
trivially default-constructible `V` for now.

This could be avoided by replacing  `CompactPair<V, E>` by
`CompactPair<AlignedStorage2<V>, E>`.

Differential Revision: https://phabricator.services.mozilla.com/D88393
2020-09-02 16:22:25 +00:00
Simon Giesecke ff85972891 Bug 1661476 - Prevent Result<const V, E> or Result<V, const E> from being instantiated. r=froydnj
Also, remove the existing uses of Result<const nsCString, nsresult> in URLPreloader
and Result<CryptoScheme, const nsCString> in SampleIterator.

Differential Revision: https://phabricator.services.mozilla.com/D88419
2020-08-28 14:16:35 +00:00
Jan Varga ecaff7daea Bug 1659673 - Add the `mozilla::Result::orElse` method; r=froydnj,dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D87418
2020-08-24 14:44:50 +00:00
Jan Varga d749be0c59 Bug 1659660 - Improve documentation and testing for mozilla::Result::map and mozilla::Result::mapErr; r=froydnj,dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D87414
2020-08-20 11:04:12 +00:00
Butkovits Atila 850817430e Backed out 3 changesets (bug 1658874, bug 1658324, bug 1659660) for bustage at ActorsParent.cpp. CLOSED TREE
Backed out changeset b69e256013a3 (bug 1659660)
Backed out changeset 4939692a9047 (bug 1658874)
Backed out changeset e27fb7cd29fe (bug 1658324)
2020-08-20 13:57:20 +03:00
Jan Varga f66e9112b5 Bug 1659660 - Improve documentation and testing for mozilla::Result::map and mozilla::Result::mapErr; r=froydnj,dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D87414
2020-08-20 09:22:09 +00:00
Simon Giesecke 18d9c43178 Bug 1654564 - Fix documentation of requirements on target in MOZ_TRY_VAR. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D84531
2020-08-04 08:50:26 +00:00
Simon Giesecke f29e73f1c3 Bug 1637599 - Rephrase documentation referring to copies of errors. r=froydnj
The phrase "copy the error" is misleading, as the error type might not be
copyable, and it is never copied but moved. "Propagate" the error seems to
be a good term to describe this.

Differential Revision: https://phabricator.services.mozilla.com/D75093
2020-05-13 15:44:31 +00:00
Simon Giesecke 4a309d690e Bug 1637599 - Simplify propagation of error results. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D75090
2020-05-13 15:44:31 +00:00
Simon Giesecke 94fa08db9c Bug 1626267 - Added transformation algorithms with error handling. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68994

--HG--
extra : moz-landing-system : lando
2020-04-01 15:53:58 +00:00
André Bargull 14ca007916 Bug 1625138 - Part 41: Remove no longer needed includes for mozilla/TypeTraits. r=froydnj
Also adds missing includes in some files, these were previously only transivitely
included through mozilla/TypeTraits.h.

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

--HG--
extra : moz-landing-system : lando
2020-03-28 16:00:09 +00:00
André Bargull 2712714d84 Bug 1625138 - Part 35: Replace mozilla::TrueType with std::true_type. r=froydnj,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D68554

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:20 +00:00
André Bargull f8eb4c162e Bug 1625138 - Part 34: Replace mozilla::FalseType with std::false_type. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68553

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:20 +00:00
André Bargull cae4e1fdbc Bug 1606962: Replace mozilla::EnableIf with std::enable_if. r=froydnj,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D68401

--HG--
extra : moz-landing-system : lando
2020-03-28 13:35:31 +00:00
André Bargull 1be056677a Bug 1625138 - Part 26: Replace mozilla::Conditional with std::conditional. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68381

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:18 +00:00
André Bargull 08a8c3fc78 Bug 1625138 - Part 24: Replace mozilla::IsConvertible with std::is_convertible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68379

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:17 +00:00
André Bargull e7d63cc0a3 Bug 1625138 - Part 5: Replace mozilla::IsDefaultConstructible with std::is_default_constructible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68359

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:12 +00:00
André Bargull 526c7e70fc Bug 1625138 - Part 3: Replace mozilla::IsEmpty with std::is_empty. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68357

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:11 +00:00
Simon Giesecke c7bd77d920 Bug 1612135 - Allow Result<V, E> to be used with a MOZ_NON_PARAM_TYPE E. r=emilio,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D61214

--HG--
extra : moz-landing-system : lando
2020-01-29 21:22:39 +00:00