Bug 1414389 - Remove use of RwAssert in CaptureCommandList. r=lsalzman
authorRyan Hunt <rhunt@eqrion.net>
Tue, 21 Aug 2018 17:54:20 -0500
changeset 488292 62bf59351409430561fb8f8fcef08bdb1a7208cd
parent 488241 e4a245dc212abd00595bb4e4489096c6daefc73c
child 488293 582994eb6fa96e60ce0271d2b2c54a6bed0a7608
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1414389
milestone63.0a1
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
Bug 1414389 - Remove use of RwAssert in CaptureCommandList. r=lsalzman
gfx/2d/CaptureCommandList.h
gfx/2d/RwAssert.h
--- a/gfx/2d/CaptureCommandList.h
+++ b/gfx/2d/CaptureCommandList.h
@@ -8,17 +8,16 @@
 #define mozilla_gfx_2d_CaptureCommandList_h
 
 #include "mozilla/Move.h"
 #include "mozilla/PodOperations.h"
 #include <vector>
 
 #include "DrawCommand.h"
 #include "Logging.h"
-#include "RwAssert.h"
 
 namespace mozilla {
 namespace gfx {
 
 class CaptureCommandList
 {
 public:
   CaptureCommandList()
@@ -28,39 +27,36 @@ public:
     : mStorage(std::move(aOther.mStorage))
     , mLastCommand(aOther.mLastCommand)
   {
     aOther.mLastCommand = nullptr;
   }
   ~CaptureCommandList();
 
   CaptureCommandList& operator=(CaptureCommandList&& aOther) {
-    RwAssert::Writer lock(mAssert);
     mStorage = std::move(aOther.mStorage);
     mLastCommand = aOther.mLastCommand;
     aOther.mLastCommand = nullptr;
     return *this;
   }
 
   template <typename T>
   T* Append() {
-    RwAssert::Writer lock(mAssert);
     size_t oldSize = mStorage.size();
     mStorage.resize(mStorage.size() + sizeof(T) + sizeof(uint32_t));
     uint8_t* nextDrawLocation = &mStorage.front() + oldSize;
     *(uint32_t*)(nextDrawLocation) = sizeof(T) + sizeof(uint32_t);
     T* newCommand = reinterpret_cast<T*>(nextDrawLocation + sizeof(uint32_t));
     mLastCommand = newCommand;
     return newCommand;
   }
 
   template <typename T>
   T* ReuseOrAppend() {
     { // Scope lock
-      RwAssert::Writer lock(mAssert);
       if (mLastCommand != nullptr &&
         mLastCommand->GetType() == T::Type) {
         return reinterpret_cast<T*>(mLastCommand);
       }
     }
     return Append<T>();
   }
 
@@ -82,26 +78,21 @@ public:
   class iterator
   {
   public:
     explicit iterator(CaptureCommandList& aParent)
      : mParent(aParent),
        mCurrent(nullptr),
        mEnd(nullptr)
     {
-      mParent.mAssert.BeginReading();
       if (!mParent.mStorage.empty()) {
         mCurrent = &mParent.mStorage.front();
         mEnd = mCurrent + mParent.mStorage.size();
       }
     }
-    ~iterator()
-    {
-      mParent.mAssert.EndReading();
-    }
 
     bool Done() const {
       return mCurrent >= mEnd;
     }
     void Next() {
       MOZ_ASSERT(!Done());
       mCurrent += *reinterpret_cast<uint32_t*>(mCurrent);
     }
@@ -127,15 +118,14 @@ public:
 
 private:
   CaptureCommandList(const CaptureCommandList& aOther) = delete;
   void operator =(const CaptureCommandList& aOther) = delete;
 
 private:
   std::vector<uint8_t> mStorage;
   DrawingCommand* mLastCommand;
-  RwAssert mAssert;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif // mozilla_gfx_2d_CaptureCommandList_h
deleted file mode 100644
--- a/gfx/2d/RwAssert.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_gfx_2d_RwAssert_h
-#define mozilla_gfx_2d_RwAssert_h
-
-#include "mozilla/Attributes.h"
-#include "mozilla/Mutex.h"
-
-namespace mozilla {
-namespace gfx {
-
-class RwAssert {
-public:
-  RwAssert()
-    : mLock("RwAssert::mLock")
-    , mReaders(0)
-    , mWriting(false)
-  { }
-
-  ~RwAssert()
-  {
-    MOZ_RELEASE_ASSERT(!mReaders && !mWriting);
-  }
-
-  class MOZ_RAII Writer {
-  public:
-    MOZ_IMPLICIT Writer(RwAssert& aAssert)
-      : mAssert(aAssert)
-    {
-      mAssert.BeginWriting();
-    }
-    ~Writer()
-    {
-      mAssert.EndWriting();
-    }
-
-  private:
-    RwAssert& mAssert;
-  };
-
-  class MOZ_RAII Reader {
-  public:
-    MOZ_IMPLICIT Reader(RwAssert& aAssert)
-      : mAssert(aAssert)
-    {
-      mAssert.BeginReading();
-    }
-    ~Reader()
-    {
-      mAssert.EndReading();
-    }
-
-  private:
-    RwAssert& mAssert;
-  };
-
-  void BeginWriting()
-  {
-    MutexAutoLock lock(mLock);
-    MOZ_RELEASE_ASSERT(!mReaders && !mWriting);
-    mWriting = true;
-  }
-
-  void EndWriting()
-  {
-    MutexAutoLock lock(mLock);
-    MOZ_ASSERT(mWriting);
-    mWriting = false;
-  }
-
-  void BeginReading()
-  {
-    MutexAutoLock lock(mLock);
-    MOZ_RELEASE_ASSERT(!mWriting);
-    mReaders += 1;
-  }
-
-  void EndReading()
-  {
-    MutexAutoLock lock(mLock);
-    MOZ_ASSERT(mReaders > 0);
-    mReaders -= 1;
-  }
-
-private:
-  Mutex mLock;
-  uint32_t mReaders;
-  bool mWriting;
-};
-
-} // namespace gfx
-} // namespace mozilla
-
-#endif // mozilla_gfx_2d_RwAssert_h