Backout 15b89e515c94 (bug 1410186) for causing too many crashes on Nightly.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 13 Nov 2017 12:14:02 +1100
changeset 391463 adfd4d3245467c54507316b9be82b86424585031
parent 391462 67ee292b841a969ec678968aefe5492406e6f2f8
child 391466 9205c22fde5f197c2e02ca0b6edc599b49a0cacc
push id97270
push usernnethercote@mozilla.com
push dateMon, 13 Nov 2017 01:22:18 +0000
treeherdermozilla-inbound@adfd4d324546 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1410186
milestone58.0a1
backs out15b89e515c94cb05bfdebdf7fc37a347234547c8
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 15b89e515c94 (bug 1410186) for causing too many crashes on Nightly.
mfbt/Maybe.h
--- a/mfbt/Maybe.h
+++ b/mfbt/Maybe.h
@@ -220,17 +220,21 @@ public:
   }
 
   /* Methods that check whether this Maybe contains a value */
   explicit operator bool() const { return isSome(); }
   bool isSome() const { return mIsSome; }
   bool isNothing() const { return !mIsSome; }
 
   /* Returns the contents of this Maybe<T> by value. Unsafe unless |isSome()|. */
-  T value() const;
+  T value() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
 
   /*
    * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns
    * the default value provided.
    */
   template<typename V>
   T valueOr(V&& aDefault) const
   {
@@ -249,18 +253,27 @@ public:
   {
     if (isSome()) {
       return ref();
     }
     return aFunc();
   }
 
   /* Returns the contents of this Maybe<T> by pointer. Unsafe unless |isSome()|. */
-  T* ptr();
-  const T* ptr() const;
+  T* ptr()
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
+
+  const T* ptr() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
 
   /*
    * Returns the contents of this Maybe<T> by pointer. If |isNothing()|,
    * returns the default value provided.
    */
   T* ptrOr(T* aDefault)
   {
     if (isSome()) {
@@ -294,22 +307,40 @@ public:
   const T* ptrOrFrom(F&& aFunc) const
   {
     if (isSome()) {
       return ptr();
     }
     return aFunc();
   }
 
-  T* operator->();
-  const T* operator->() const;
+  T* operator->()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
+
+  const T* operator->() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
 
   /* Returns the contents of this Maybe<T> by ref. Unsafe unless |isSome()|. */
-  T& ref();
-  const T& ref() const;
+  T& ref()
+  {
+    MOZ_ASSERT(mIsSome);
+    return *static_cast<T*>(data());
+  }
+
+  const T& ref() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return *static_cast<const T*>(data());
+  }
 
   /*
    * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns
    * the default value provided.
    */
   T& refOr(T& aDefault)
   {
     if (isSome()) {
@@ -343,18 +374,27 @@ public:
   const T& refOrFrom(F&& aFunc) const
   {
     if (isSome()) {
       return ref();
     }
     return aFunc();
   }
 
-  T& operator*();
-  const T& operator*() const;
+  T& operator*()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
+
+  const T& operator*() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
 
   /* If |isSome()|, runs the provided function or functor on the contents of
    * this Maybe. */
   template<typename Func>
   Maybe& apply(Func aFunc)
   {
     if (isSome()) {
       aFunc(ref());
@@ -408,112 +448,35 @@ public:
     }
   }
 
   /*
    * Constructs a T value in-place in this empty Maybe<T>'s storage. The
    * arguments to |emplace()| are the parameters to T's constructor.
    */
   template<typename... Args>
-  void emplace(Args&&... aArgs);
+  void emplace(Args&&... aArgs)
+  {
+    MOZ_ASSERT(!mIsSome);
+    ::new (KnownNotNull, data()) T(Forward<Args>(aArgs)...);
+    mIsSome = true;
+  }
 
   friend std::ostream&
   operator<<(std::ostream& aStream, const Maybe<T>& aMaybe)
   {
     if (aMaybe) {
       aStream << aMaybe.ref();
     } else {
       aStream << "<Nothing>";
     }
     return aStream;
   }
 };
 
-template<typename T>
-T
-Maybe<T>::value() const
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-T*
-Maybe<T>::ptr()
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return &ref();
-}
-
-template<typename T>
-const T*
-Maybe<T>::ptr() const
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return &ref();
-}
-
-template<typename T>
-T*
-Maybe<T>::operator->()
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return ptr();
-}
-
-template<typename T>
-const T*
-Maybe<T>::operator->() const
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return ptr();
-}
-
-template<typename T>
-T&
-Maybe<T>::ref()
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return *static_cast<T*>(data());
-}
-
-template<typename T>
-const T&
-Maybe<T>::ref() const
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return *static_cast<const T*>(data());
-}
-
-template<typename T>
-T&
-Maybe<T>::operator*()
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-const T&
-Maybe<T>::operator*() const
-{
-  MOZ_RELEASE_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-template<typename... Args>
-void
-Maybe<T>::emplace(Args&&... aArgs)
-{
-  MOZ_RELEASE_ASSERT(!mIsSome);
-  ::new (KnownNotNull, data()) T(Forward<Args>(aArgs)...);
-  mIsSome = true;
-}
-
 /*
  * Some() creates a Maybe<T> value containing the provided T value. If T has a
  * move constructor, it's used to make this as efficient as possible.
  *
  * Some() selects the type of Maybe it returns by removing any const, volatile,
  * or reference qualifiers from the type of the value you pass to it. This gives
  * it more intuitive behavior when used in expressions, but it also means that
  * if you need to construct a Maybe value that holds a const, volatile, or