Bug 1591132 - Make hashtable checker use MOZ_RELEASE_ASSERT. r=nika draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 24 Oct 2019 16:38:57 +0000
changeset 2396056 7a3ec68e4d0987616906f1371e4e6f68f7d55d4f
parent 2395845 724c75f9d98fa441703a4e36f294672859e138d7
child 2396057 b7e538bcb2281aa8ae4e43c5abbfb826c728c44a
push id439687
push userreviewbot
push dateThu, 24 Oct 2019 16:39:19 +0000
treeherdertry@55d10b12661f [default view] [failures only]
reviewersnika
bugs1591132
milestone72.0a1
Bug 1591132 - Make hashtable checker use MOZ_RELEASE_ASSERT. r=nika I want to maybe enable some of these checks in DIAGNOSTIC_ASSERT builds. The whole type is compiled out in release builds at the moment. Differential Diff: PHID-DIFF-bphwveahvqk6ofobz5wg
xpcom/ds/PLDHashTable.h
--- a/xpcom/ds/PLDHashTable.h
+++ b/xpcom/ds/PLDHashTable.h
@@ -117,67 +117,67 @@ class Checker {
   // (b) check the old value was reasonable. This ensures we don't have
   // interleaving problems.
   //
   // For |mIsWritable| we don't need to be as careful because it can only in
   // transition in one direction (from writable to non-writable).
 
   void StartReadOp() {
     uint32_t oldState = mState++;  // this is an atomic increment
-    MOZ_ASSERT(IsIdle(oldState) || IsRead(oldState));
-    MOZ_ASSERT(oldState < kReadMax);  // check for overflow
+    MOZ_RELEASE_ASSERT(IsIdle(oldState) || IsRead(oldState));
+    MOZ_RELEASE_ASSERT(oldState < kReadMax);  // check for overflow
   }
 
   void EndReadOp() {
     uint32_t oldState = mState--;  // this is an atomic decrement
-    MOZ_ASSERT(IsRead(oldState));
+    MOZ_RELEASE_ASSERT(IsRead(oldState));
   }
 
   void StartWriteOp() {
-    MOZ_ASSERT(IsWritable());
+    MOZ_RELEASE_ASSERT(IsWritable());
     uint32_t oldState = mState.exchange(kWrite);
-    MOZ_ASSERT(IsIdle(oldState));
+    MOZ_RELEASE_ASSERT(IsIdle(oldState));
   }
 
   void EndWriteOp() {
     // Check again that the table is writable, in case it was marked as
     // non-writable just after the IsWritable() assertion in StartWriteOp()
     // occurred.
-    MOZ_ASSERT(IsWritable());
+    MOZ_RELEASE_ASSERT(IsWritable());
     uint32_t oldState = mState.exchange(kIdle);
-    MOZ_ASSERT(IsWrite(oldState));
+    MOZ_RELEASE_ASSERT(IsWrite(oldState));
   }
 
   void StartIteratorRemovalOp() {
     // When doing removals at the end of iteration, we go from Read1 state to
     // Write and then back.
-    MOZ_ASSERT(IsWritable());
+    MOZ_RELEASE_ASSERT(IsWritable());
     uint32_t oldState = mState.exchange(kWrite);
-    MOZ_ASSERT(IsRead1(oldState));
+    MOZ_RELEASE_ASSERT(IsRead1(oldState));
   }
 
   void EndIteratorRemovalOp() {
     // Check again that the table is writable, in case it was marked as
     // non-writable just after the IsWritable() assertion in
     // StartIteratorRemovalOp() occurred.
-    MOZ_ASSERT(IsWritable());
+    MOZ_RELEASE_ASSERT(IsWritable());
     uint32_t oldState = mState.exchange(kRead1);
-    MOZ_ASSERT(IsWrite(oldState));
+    MOZ_RELEASE_ASSERT(IsWrite(oldState));
   }
 
   void StartDestructorOp() {
     // A destructor op is like a write, but the table doesn't need to be
     // writable.
     uint32_t oldState = mState.exchange(kWrite);
-    MOZ_ASSERT(IsIdle(oldState));
+    MOZ_RELEASE_ASSERT(IsIdle(oldState));
   }
 
   void EndDestructorOp() {
     uint32_t oldState = mState.exchange(kIdle);
-    MOZ_ASSERT(IsWrite(oldState));
+    MOZ_RELEASE_ASSERT(IsWrite(oldState));
   }
 
  private:
   // Things of note about the representation of |mState|.
   // - The values between kRead1..kReadMax represent valid Read(n) values.
   // - kIdle and kRead1 are deliberately chosen so that incrementing the -
   //   former gives the latter.
   // - 9999 concurrent readers should be enough for anybody.