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

66 Коммитов

Автор SHA1 Сообщение Дата
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
Tooru Fujisawa afa6435815 Bug 1585585 - Add {MOZ_LIKELY,MOZ_UNLIKELY} to Result::{isOk,isErr} consumers. r=jwalden
Differential Revision: https://phabricator.services.mozilla.com/D48136

--HG--
extra : moz-landing-system : lando
2019-10-10 23:46:42 +00:00
Doug Thayer 1678c5e378 Bug 1550108 - Add mapErr method to Result r=froydnj
Adds an explicit error mapping function to Result, to simplify
using MOZ_TRY... macros.

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

--HG--
extra : moz-landing-system : lando
2019-10-04 20:44:50 +00:00
Cosmin Sabou 14938bad3b Backed out 10 changesets (bug 1550108) for causing build bustages on StartupCache.cpp.
Backed out changeset cbadfa2bbd7e (bug 1550108)
Backed out changeset 2560f0ab6ebf (bug 1550108)
Backed out changeset 0a1fa8d8bb3c (bug 1550108)
Backed out changeset 62416909cf67 (bug 1550108)
Backed out changeset 60991713b1e2 (bug 1550108)
Backed out changeset f950e30afd90 (bug 1550108)
Backed out changeset e63d0a1fec38 (bug 1550108)
Backed out changeset 7a009d42e7e7 (bug 1550108)
Backed out changeset 395affa4c205 (bug 1550108)
Backed out changeset 0fd41e9dbd2a (bug 1550108)

--HG--
rename : mfbt/lz4/lz4.c => mfbt/lz4.c
rename : mfbt/lz4/lz4.h => mfbt/lz4.h
2019-09-29 01:14:31 +03:00
Doug Thayer d27f7199e1 Bug 1550108 - Add mapErr method to Result r=froydnj
Adds an explicit error mapping function to Result, to simplify
using MOZ_TRY... macros.

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

--HG--
extra : moz-landing-system : lando
2019-09-27 22:15:35 +00:00
Emilio Cobos Álvarez 5c4d9db375 Bug 1582358 - Fix move semantics for Result where the error is non-copiable. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D46428

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

We could try to use stuff like:

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

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

--HG--
extra : moz-landing-system : lando
2019-08-13 08:26:18 +00:00
Jim Blandy 45737ac244 Bug 1563065: Use const& in mozilla::Result constructors. r=froydnj
Change the `ResultImplementation` and `Result` constructors to accept success
values by `const` reference. This makes it possible for `Result` to carry
`MOZ_NON_PARAM` types as success values.

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

--HG--
extra : moz-landing-system : lando
2019-07-05 23:50:16 +00:00