Bug 1187197 (part 3) - Convert pldhash.{cpp,h} to C++ style comments. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 23 Jul 2015 23:13:11 -0700
changeset 254627 f8a695c239981780c4e5e9d34cbd3c2121d66066
parent 254626 ca5ac85253ff10b6f21ee2120cf1fb9b1c8bea4d
child 254628 1ca5723f69d4af4cd3492c4bb8d3a06bd1fed774
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1187197
milestone42.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 1187197 (part 3) - Convert pldhash.{cpp,h} to C++ style comments. r=froydnj.
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -1,25 +1,21 @@
 /* -*- 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/. */
 
-/*
- * Double hashing implementation.
- */
 #include <new>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "pldhash.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/MathAlgorithms.h"
-#include "nsDebug.h"     /* for PR_ASSERT */
 #include "nsAlgorithm.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ChaosMode.h"
 
 using namespace mozilla;
 
 #ifdef DEBUG
@@ -90,17 +86,17 @@ PL_DHashMatchEntryStub(PLDHashTable* aTa
 
 bool
 PL_DHashMatchStringKey(PLDHashTable* aTable,
                        const PLDHashEntryHdr* aEntry,
                        const void* aKey)
 {
   const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry;
 
-  /* XXX tolerate null keys on account of sloppy Mozilla callers. */
+  // XXX tolerate null keys on account of sloppy Mozilla callers.
   return stub->key == aKey ||
          (stub->key && aKey &&
           strcmp((const char*)stub->key, (const char*)aKey) == 0);
 }
 
 MOZ_ALWAYS_INLINE void
 PLDHashTable::MoveEntryStub(const PLDHashEntryHdr* aFrom,
                             PLDHashEntryHdr* aTo)
@@ -145,23 +141,21 @@ PL_DHashGetStubOps(void)
 static bool
 SizeOfEntryStore(uint32_t aCapacity, uint32_t aEntrySize, uint32_t* aNbytes)
 {
   uint64_t nbytes64 = uint64_t(aCapacity) * uint64_t(aEntrySize);
   *aNbytes = aCapacity * aEntrySize;
   return uint64_t(*aNbytes) == nbytes64;   // returns false on overflow
 }
 
-/*
- * Compute max and min load numbers (entry counts).  We have a secondary max
- * that allows us to overload a table reasonably if it cannot be grown further
- * (i.e. if ChangeTable() fails).  The table slows down drastically if the
- * secondary max is too close to 1, but 0.96875 gives only a slight slowdown
- * while allowing 1.3x more elements.
- */
+// Compute max and min load numbers (entry counts). We have a secondary max
+// that allows us to overload a table reasonably if it cannot be grown further
+// (i.e. if ChangeTable() fails). The table slows down drastically if the
+// secondary max is too close to 1, but 0.96875 gives only a slight slowdown
+// while allowing 1.3x more elements.
 static inline uint32_t
 MaxLoad(uint32_t aCapacity)
 {
   return aCapacity - (aCapacity >> 2);  // == aCapacity * 0.75
 }
 static inline uint32_t
 MaxLoadOnGrowthFailure(uint32_t aCapacity)
 {
@@ -283,24 +277,22 @@ void
 PLDHashTable::Hash2(PLDHashNumber aHash,
                     uint32_t& aHash2Out, uint32_t& aSizeMaskOut)
 {
   uint32_t sizeLog2 = kHashBits - mHashShift;
   aHash2Out = ((aHash << sizeLog2) >> mHashShift) | 1;
   aSizeMaskOut = (PLDHashNumber(1) << sizeLog2) - 1;
 }
 
-/*
- * Reserve mKeyHash 0 for free entries and 1 for removed-entry sentinels.  Note
- * that a removed-entry sentinel need be stored only if the removed entry had
- * a colliding entry added after it.  Therefore we can use 1 as the collision
- * flag in addition to the removed-entry sentinel value.  Multiplicative hash
- * uses the high order bits of mKeyHash, so this least-significant reservation
- * should not hurt the hash function's effectiveness much.
- */
+// Reserve mKeyHash 0 for free entries and 1 for removed-entry sentinels. Note
+// that a removed-entry sentinel need be stored only if the removed entry had
+// a colliding entry added after it. Therefore we can use 1 as the collision
+// flag in addition to the removed-entry sentinel value. Multiplicative hash
+// uses the high order bits of mKeyHash, so this least-significant reservation
+// should not hurt the hash function's effectiveness much.
 
 /* static */ MOZ_ALWAYS_INLINE bool
 PLDHashTable::EntryIsFree(PLDHashEntryHdr* aEntry)
 {
   return aEntry->mKeyHash == 0;
 }
 /* static */ MOZ_ALWAYS_INLINE bool
 PLDHashTable::EntryIsRemoved(PLDHashEntryHdr* aEntry)
@@ -319,52 +311,52 @@ PLDHashTable::MarkEntryFree(PLDHashEntry
   aEntry->mKeyHash = 0;
 }
 /* static */ MOZ_ALWAYS_INLINE void
 PLDHashTable::MarkEntryRemoved(PLDHashEntryHdr* aEntry)
 {
   aEntry->mKeyHash = 1;
 }
 
-/* Match an entry's mKeyHash against an unstored one computed from a key. */
+// Match an entry's mKeyHash against an unstored one computed from a key.
 /* static */ bool
 PLDHashTable::MatchEntryKeyhash(PLDHashEntryHdr* aEntry, PLDHashNumber aKeyHash)
 {
   return (aEntry->mKeyHash & ~kCollisionFlag) == aKeyHash;
 }
 
-/* Compute the address of the indexed entry in table. */
+// Compute the address of the indexed entry in table.
 PLDHashEntryHdr*
 PLDHashTable::AddressEntry(uint32_t aIndex)
 {
   return reinterpret_cast<PLDHashEntryHdr*>(mEntryStore + aIndex * mEntrySize);
 }
 
 PLDHashTable::~PLDHashTable()
 {
 #ifdef DEBUG
   AutoDestructorOp op(mChecker);
 #endif
 
   if (!mEntryStore) {
     return;
   }
 
-  /* Clear any remaining live entries. */
+  // Clear any remaining live entries.
   char* entryAddr = mEntryStore;
   char* entryLimit = entryAddr + Capacity() * mEntrySize;
   while (entryAddr < entryLimit) {
     PLDHashEntryHdr* entry = (PLDHashEntryHdr*)entryAddr;
     if (EntryIsLive(entry)) {
       mOps->clearEntry(this, entry);
     }
     entryAddr += mEntrySize;
   }
 
-  /* Free entry storage last. */
+  // Free entry storage last.
   free(mEntryStore);
   mEntryStore = nullptr;
 }
 
 void
 PLDHashTable::ClearAndPrepareForLength(uint32_t aLength)
 {
   // Get these values before the destructor clobbers them.
@@ -389,41 +381,39 @@ PLDHashTable::Clear()
 template <PLDHashTable::SearchReason Reason>
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PLDHashTable::SearchTable(const void* aKey, PLDHashNumber aKeyHash)
 {
   MOZ_ASSERT(mEntryStore);
   NS_ASSERTION(!(aKeyHash & kCollisionFlag),
                "!(aKeyHash & kCollisionFlag)");
 
-  /* Compute the primary hash address. */
+  // Compute the primary hash address.
   PLDHashNumber hash1 = Hash1(aKeyHash);
   PLDHashEntryHdr* entry = AddressEntry(hash1);
 
-  /* Miss: return space for a new entry. */
+  // Miss: return space for a new entry.
   if (EntryIsFree(entry)) {
     return (Reason == ForAdd) ? entry : nullptr;
   }
 
-  /* Hit: return entry. */
+  // Hit: return entry.
   PLDHashMatchEntry matchEntry = mOps->matchEntry;
   if (MatchEntryKeyhash(entry, aKeyHash) &&
       matchEntry(this, entry, aKey)) {
     return entry;
   }
 
-  /* Collision: double hash. */
+  // Collision: double hash.
   PLDHashNumber hash2;
   uint32_t sizeMask;
   Hash2(aKeyHash, hash2, sizeMask);
 
-  /*
-   * Save the first removed entry pointer so Add() can recycle it. (Only used
-   * if Reason==ForAdd.)
-   */
+  // Save the first removed entry pointer so Add() can recycle it. (Only used
+  // if Reason==ForAdd.)
   PLDHashEntryHdr* firstRemoved = nullptr;
 
   for (;;) {
     if (Reason == ForAdd) {
       if (MOZ_UNLIKELY(EntryIsRemoved(entry))) {
         if (!firstRemoved) {
           firstRemoved = entry;
         }
@@ -442,47 +432,44 @@ PLDHashTable::SearchTable(const void* aK
     }
 
     if (MatchEntryKeyhash(entry, aKeyHash) &&
         matchEntry(this, entry, aKey)) {
       return entry;
     }
   }
 
-  /* NOTREACHED */
+  // NOTREACHED
   return nullptr;
 }
 
-/*
- * This is a copy of SearchTable, used by ChangeTable, hardcoded to
- *   1. assume |aIsAdd| is true,
- *   2. assume that |aKey| will never match an existing entry, and
- *   3. assume that no entries have been removed from the current table
- *      structure.
- * Avoiding the need for |aKey| means we can avoid needing a way to map
- * entries to keys, which means callers can use complex key types more
- * easily.
- */
+// This is a copy of SearchTable(), used by ChangeTable(), hardcoded to
+//   1. assume |aIsAdd| is true,
+//   2. assume that |aKey| will never match an existing entry, and
+//   3. assume that no entries have been removed from the current table
+//      structure.
+// Avoiding the need for |aKey| means we can avoid needing a way to map entries
+// to keys, which means callers can use complex key types more easily.
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PLDHashTable::FindFreeEntry(PLDHashNumber aKeyHash)
 {
   MOZ_ASSERT(mEntryStore);
   NS_ASSERTION(!(aKeyHash & kCollisionFlag),
                "!(aKeyHash & kCollisionFlag)");
 
-  /* Compute the primary hash address. */
+  // Compute the primary hash address.
   PLDHashNumber hash1 = Hash1(aKeyHash);
   PLDHashEntryHdr* entry = AddressEntry(hash1);
 
-  /* Miss: return space for a new entry. */
+  // Miss: return space for a new entry.
   if (EntryIsFree(entry)) {
     return entry;
   }
 
-  /* Collision: double hash. */
+  // Collision: double hash.
   PLDHashNumber hash2;
   uint32_t sizeMask;
   Hash2(aKeyHash, hash2, sizeMask);
 
   for (;;) {
     NS_ASSERTION(!EntryIsRemoved(entry),
                  "!EntryIsRemoved(entry)");
     entry->mKeyHash |= kCollisionFlag;
@@ -491,26 +478,26 @@ PLDHashTable::FindFreeEntry(PLDHashNumbe
     hash1 &= sizeMask;
 
     entry = AddressEntry(hash1);
     if (EntryIsFree(entry)) {
       return entry;
     }
   }
 
-  /* NOTREACHED */
+  // NOTREACHED
   return nullptr;
 }
 
 bool
 PLDHashTable::ChangeTable(int32_t aDeltaLog2)
 {
   MOZ_ASSERT(mEntryStore);
 
-  /* Look, but don't touch, until we succeed in getting new entry store. */
+  // Look, but don't touch, until we succeed in getting new entry store.
   int32_t oldLog2 = kHashBits - mHashShift;
   int32_t newLog2 = oldLog2 + aDeltaLog2;
   uint32_t newCapacity = 1u << newLog2;
   if (newCapacity > kMaxCapacity) {
     return false;
   }
 
   uint32_t nbytes;
@@ -518,30 +505,30 @@ PLDHashTable::ChangeTable(int32_t aDelta
     return false;   // overflowed
   }
 
   char* newEntryStore = (char*)malloc(nbytes);
   if (!newEntryStore) {
     return false;
   }
 
-  /* We can't fail from here on, so update table parameters. */
+  // We can't fail from here on, so update table parameters.
   mHashShift = kHashBits - newLog2;
   mRemovedCount = 0;
   mGeneration++;
 
-  /* Assign the new entry store to table. */
+  // Assign the new entry store to table.
   memset(newEntryStore, 0, nbytes);
   char* oldEntryStore;
   char* oldEntryAddr;
   oldEntryAddr = oldEntryStore = mEntryStore;
   mEntryStore = newEntryStore;
   PLDHashMoveEntry moveEntry = mOps->moveEntry;
 
-  /* Copy only live entries, leaving removed ones behind. */
+  // Copy only live entries, leaving removed ones behind.
   uint32_t oldCapacity = 1u << oldLog2;
   for (uint32_t i = 0; i < oldCapacity; ++i) {
     PLDHashEntryHdr* oldEntry = (PLDHashEntryHdr*)oldEntryAddr;
     if (EntryIsLive(oldEntry)) {
       oldEntry->mKeyHash &= ~kCollisionFlag;
       PLDHashEntryHdr* newEntry = FindFreeEntry(oldEntry->mKeyHash);
       NS_ASSERTION(EntryIsFree(newEntry), "EntryIsFree(newEntry)");
       moveEntry(this, oldEntry, newEntry);
@@ -557,17 +544,17 @@ PLDHashTable::ChangeTable(int32_t aDelta
 MOZ_ALWAYS_INLINE PLDHashNumber
 PLDHashTable::ComputeKeyHash(const void* aKey)
 {
   MOZ_ASSERT(mEntryStore);
 
   PLDHashNumber keyHash = mOps->hashKey(this, aKey);
   keyHash *= kGoldenRatio;
 
-  /* Avoid 0 and 1 hash codes, they indicate free and removed entries. */
+  // Avoid 0 and 1 hash codes, they indicate free and removed entries.
   if (keyHash < 2) {
     keyHash -= 2;
   }
   keyHash &= ~kCollisionFlag;
 
   return keyHash;
 }
 
@@ -600,50 +587,43 @@ PLDHashTable::Add(const void* aKey, cons
                                         &nbytes));
     mEntryStore = (char*)malloc(nbytes);
     if (!mEntryStore) {
       return nullptr;
     }
     memset(mEntryStore, 0, nbytes);
   }
 
-  /*
-   * If alpha is >= .75, grow or compress the table.  If aKey is already
-   * in the table, we may grow once more than necessary, but only if we
-   * are on the edge of being overloaded.
-   */
+  // If alpha is >= .75, grow or compress the table. If aKey is already in the
+  // table, we may grow once more than necessary, but only if we are on the
+  // edge of being overloaded.
   uint32_t capacity = Capacity();
   if (mEntryCount + mRemovedCount >= MaxLoad(capacity)) {
-    /* Compress if a quarter or more of all entries are removed. */
+    // Compress if a quarter or more of all entries are removed.
     int deltaLog2;
     if (mRemovedCount >= capacity >> 2) {
       deltaLog2 = 0;
     } else {
       deltaLog2 = 1;
     }
 
-    /*
-     * Grow or compress the table.  If ChangeTable() fails, allow
-     * overloading up to the secondary max.  Once we hit the secondary
-     * max, return null.
-     */
+    // Grow or compress the table. If ChangeTable() fails, allow overloading up
+    // to the secondary max. Once we hit the secondary max, return null.
     if (!ChangeTable(deltaLog2) &&
         mEntryCount + mRemovedCount >= MaxLoadOnGrowthFailure(capacity)) {
       return nullptr;
     }
   }
 
-  /*
-   * Look for entry after possibly growing, so we don't have to add it,
-   * then skip it while growing the table and re-add it after.
-   */
+  // Look for entry after possibly growing, so we don't have to add it,
+  // then skip it while growing the table and re-add it after.
   PLDHashNumber keyHash = ComputeKeyHash(aKey);
   PLDHashEntryHdr* entry = SearchTable<ForAdd>(aKey, keyHash);
   if (!EntryIsLive(entry)) {
-    /* Initialize the entry, indicating that it's no longer free. */
+    // Initialize the entry, indicating that it's no longer free.
     if (EntryIsRemoved(entry)) {
       mRemovedCount--;
       keyHash |= kCollisionFlag;
     }
     if (mOps->initEntry) {
       mOps->initEntry(entry, aKey);
     }
     entry->mKeyHash = keyHash;
@@ -680,20 +660,20 @@ PLDHashTable::Remove(const void* aKey)
 #ifdef DEBUG
   AutoWriteOp op(mChecker);
 #endif
 
   PLDHashEntryHdr* entry =
     mEntryStore ? SearchTable<ForSearchOrRemove>(aKey, ComputeKeyHash(aKey))
                 : nullptr;
   if (entry) {
-    /* Clear this entry and mark it as "removed". */
+    // Clear this entry and mark it as "removed".
     RawRemove(entry);
 
-    /* Shrink if alpha is <= .25 and the table isn't too small already. */
+    // Shrink if alpha is <= .25 and the table isn't too small already.
     uint32_t capacity = Capacity();
     if (capacity > kMinCapacity &&
         mEntryCount <= MinLoad(capacity)) {
       (void) ChangeTable(-1);
     }
   }
 }
 
@@ -729,17 +709,17 @@ PLDHashTable::RawRemove(PLDHashEntryHdr*
   // RawRemove() can be called legitimately while an Enumerate() call is
   // active, which doesn't fit well into how Checker's mState variable works.
   MOZ_ASSERT(mChecker.IsWritable());
 
   MOZ_ASSERT(mEntryStore);
 
   NS_ASSERTION(EntryIsLive(aEntry), "EntryIsLive(aEntry)");
 
-  /* Load keyHash first in case clearEntry() goofs it. */
+  // Load keyHash first in case clearEntry() goofs it.
   PLDHashNumber keyHash = aEntry->mKeyHash;
   mOps->clearEntry(this, aEntry);
   if (keyHash & kCollisionFlag) {
     MarkEntryRemoved(aEntry);
     mRemovedCount++;
   } else {
     MarkEntryFree(aEntry);
   }
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -1,19 +1,17 @@
 /* -*- 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 pldhash_h___
 #define pldhash_h___
-/*
- * Double hashing, a la Knuth 6.
- */
+
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h" // for MOZ_ALWAYS_INLINE
 #include "mozilla/fallible.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/Types.h"
 #include "nscore.h"
 
@@ -25,34 +23,32 @@
 #define PL_DHASH_FASTCALL
 #endif
 
 typedef uint32_t PLDHashNumber;
 
 class PLDHashTable;
 struct PLDHashTableOps;
 
-/*
- * Table entry header structure.
- *
- * In order to allow in-line allocation of key and value, we do not declare
- * either here.  Instead, the API uses const void *key as a formal parameter.
- * The key need not be stored in the entry; it may be part of the value, but
- * need not be stored at all.
- *
- * Callback types are defined below and grouped into the PLDHashTableOps
- * structure, for single static initialization per hash table sub-type.
- *
- * Each hash table sub-type should make its entry type a subclass of
- * PLDHashEntryHdr. The mKeyHash member contains the result of multiplying the
- * hash code returned from the hashKey callback (see below) by kGoldenRatio,
- * then constraining the result to avoid the magic 0 and 1 values. The stored
- * mKeyHash value is table size invariant, and it is maintained automatically
- * -- users need never access it.
- */
+// Table entry header structure.
+//
+// In order to allow in-line allocation of key and value, we do not declare
+// either here. Instead, the API uses const void *key as a formal parameter.
+// The key need not be stored in the entry; it may be part of the value, but
+// need not be stored at all.
+//
+// Callback types are defined below and grouped into the PLDHashTableOps
+// structure, for single static initialization per hash table sub-type.
+//
+// Each hash table sub-type should make its entry type a subclass of
+// PLDHashEntryHdr. The mKeyHash member contains the result of multiplying the
+// hash code returned from the hashKey callback (see below) by kGoldenRatio,
+// then constraining the result to avoid the magic 0 and 1 values. The stored
+// mKeyHash value is table size invariant, and it is maintained automatically
+// -- users need never access it.
 struct PLDHashEntryHdr
 {
 private:
   friend class PLDHashTable;
 
   PLDHashNumber mKeyHash;
 };
 
@@ -201,41 +197,39 @@ private:
   static const uint32_t kReadMax = 9999;
   static const uint32_t kWrite   = 10000;
 
   mutable mozilla::Atomic<uint32_t> mState;
   mutable mozilla::Atomic<uint32_t> mIsWritable;
 };
 #endif
 
-/*
- * A PLDHashTable may be allocated on the stack or within another structure or
- * class. No entry storage is allocated until the first element is added. This
- * means that empty hash tables are cheap, which is good because they are
- * common.
- *
- * There used to be a long, math-heavy comment here about the merits of
- * double hashing vs. chaining; it was removed in bug 1058335. In short, double
- * hashing is more space-efficient unless the element size gets large (in which
- * case you should keep using double hashing but switch to using pointer
- * elements). Also, with double hashing, you can't safely hold an entry pointer
- * and use it after an ADD or REMOVE operation, unless you sample
- * aTable->mGeneration before adding or removing, and compare the sample after,
- * dereferencing the entry pointer only if aTable->mGeneration has not changed.
- */
+// A PLDHashTable may be allocated on the stack or within another structure or
+// class. No entry storage is allocated until the first element is added. This
+// means that empty hash tables are cheap, which is good because they are
+// common.
+//
+// There used to be a long, math-heavy comment here about the merits of
+// double hashing vs. chaining; it was removed in bug 1058335. In short, double
+// hashing is more space-efficient unless the element size gets large (in which
+// case you should keep using double hashing but switch to using pointer
+// elements). Also, with double hashing, you can't safely hold an entry pointer
+// and use it after an ADD or REMOVE operation, unless you sample
+// aTable->mGeneration before adding or removing, and compare the sample after,
+// dereferencing the entry pointer only if aTable->mGeneration has not changed.
 class PLDHashTable
 {
 private:
-  const PLDHashTableOps* const mOps;  /* Virtual operations; see below. */
-  int16_t             mHashShift;     /* multiplicative hash shift */
-  const uint32_t      mEntrySize;     /* number of bytes in an entry */
-  uint32_t            mEntryCount;    /* number of entries in table */
-  uint32_t            mRemovedCount;  /* removed entry sentinels in table */
-  uint32_t            mGeneration;    /* entry storage generation number */
-  char*               mEntryStore;    /* entry storage; allocated lazily */
+  const PLDHashTableOps* const mOps;  // Virtual operations; see below.
+  int16_t             mHashShift;     // Multiplicative hash shift.
+  const uint32_t      mEntrySize;     // Number of bytes in an entry.
+  uint32_t            mEntryCount;    // Number of entries in table.
+  uint32_t            mRemovedCount;  // Removed entry sentinels in table.
+  uint32_t            mGeneration;    // Entry storage generation number.
+  char*               mEntryStore;    // Entry storage; allocated lazily.
 
 #ifdef DEBUG
   mutable Checker mChecker;
 #endif
 
 public:
   // Table capacity limit; do not exceed. The max capacity used to be 1<<23 but
   // that occasionally that wasn't enough. Making it much bigger than 1<<26
@@ -282,21 +276,19 @@ public:
 
   PLDHashTable& operator=(PLDHashTable&& aOther);
 
   ~PLDHashTable();
 
   // This should be used rarely.
   const PLDHashTableOps* const Ops() { return mOps; }
 
-  /*
-   * Size in entries (gross, not net of free and removed sentinels) for table.
-   * This can be zero if no elements have been added yet, in which case the
-   * entry storage will not have yet been allocated.
-   */
+  // Size in entries (gross, not net of free and removed sentinels) for table.
+  // This can be zero if no elements have been added yet, in which case the
+  // entry storage will not have yet been allocated.
   uint32_t Capacity() const
   {
     return mEntryStore ? CapacityFromHashShift() : 0;
   }
 
   uint32_t EntrySize()  const { return mEntrySize; }
   uint32_t EntryCount() const { return mEntryCount; }
   uint32_t Generation() const { return mGeneration; }
@@ -490,98 +482,84 @@ private:
   bool ChangeTable(int aDeltaLog2);
 
   void ShrinkIfAppropriate();
 
   PLDHashTable(const PLDHashTable& aOther) = delete;
   PLDHashTable& operator=(const PLDHashTable& aOther) = delete;
 };
 
-/*
- * Compute the hash code for a given key to be looked up, added, or removed
- * from aTable.  A hash code may have any PLDHashNumber value.
- */
+// Compute the hash code for a given key to be looked up, added, or removed
+// from aTable. A hash code may have any PLDHashNumber value.
 typedef PLDHashNumber (*PLDHashHashKey)(PLDHashTable* aTable,
                                         const void* aKey);
 
-/*
- * Compare the key identifying aEntry in aTable with the provided key parameter.
- * Return true if keys match, false otherwise.
- */
+// Compare the key identifying aEntry in aTable with the provided key parameter.
+// Return true if keys match, false otherwise.
 typedef bool (*PLDHashMatchEntry)(PLDHashTable* aTable,
                                   const PLDHashEntryHdr* aEntry,
                                   const void* aKey);
 
-/*
- * Copy the data starting at aFrom to the new entry storage at aTo. Do not add
- * reference counts for any strong references in the entry, however, as this
- * is a "move" operation: the old entry storage at from will be freed without
- * any reference-decrementing callback shortly.
- */
+// Copy the data starting at aFrom to the new entry storage at aTo. Do not add
+// reference counts for any strong references in the entry, however, as this
+// is a "move" operation: the old entry storage at from will be freed without
+// any reference-decrementing callback shortly.
 typedef void (*PLDHashMoveEntry)(PLDHashTable* aTable,
                                  const PLDHashEntryHdr* aFrom,
                                  PLDHashEntryHdr* aTo);
 
-/*
- * Clear the entry and drop any strong references it holds.  This callback is
- * invoked by Remove(), but only if the given key is found in the table.
- */
+// Clear the entry and drop any strong references it holds. This callback is
+// invoked by Remove(), but only if the given key is found in the table.
 typedef void (*PLDHashClearEntry)(PLDHashTable* aTable,
                                   PLDHashEntryHdr* aEntry);
 
-/*
- * Initialize a new entry, apart from mKeyHash.  This function is called when
- * Add() finds no existing entry for the given key, and must add a new one.  At
- * that point, |aEntry->mKeyHash| is not set yet, to avoid claiming the last
- * free entry in a severely overloaded table.
- */
+// Initialize a new entry, apart from mKeyHash. This function is called when
+// Add() finds no existing entry for the given key, and must add a new one. At
+// that point, |aEntry->mKeyHash| is not set yet, to avoid claiming the last
+// free entry in a severely overloaded table.
 typedef void (*PLDHashInitEntry)(PLDHashEntryHdr* aEntry, const void* aKey);
 
-/*
- * Finally, the "vtable" structure for PLDHashTable.  The first four hooks
- * must be provided by implementations; they're called unconditionally by the
- * generic pldhash.c code.  Hooks after these may be null.
- *
- * Summary of allocation-related hook usage with C++ placement new emphasis:
- *  initEntry           Call placement new using default key-based ctor.
- *  moveEntry           Call placement new using copy ctor, run dtor on old
- *                      entry storage.
- *  clearEntry          Run dtor on entry.
- *
- * Note the reason why initEntry is optional: the default hooks (stubs) clear
- * entry storage:  On successful Add(tbl, key), the returned entry pointer
- * addresses an entry struct whose mKeyHash member has been set non-zero, but
- * all other entry members are still clear (null). Add() callers can test such
- * members to see whether the entry was newly created by the Add() call that
- * just succeeded.  If placement new or similar initialization is required,
- * define an |initEntry| hook.  Of course, the |clearEntry| hook must zero or
- * null appropriately.
- *
- * XXX assumes 0 is null for pointer types.
- */
+// Finally, the "vtable" structure for PLDHashTable. The first four hooks
+// must be provided by implementations; they're called unconditionally by the
+// generic pldhash.c code. Hooks after these may be null.
+//
+// Summary of allocation-related hook usage with C++ placement new emphasis:
+//  initEntry           Call placement new using default key-based ctor.
+//  moveEntry           Call placement new using copy ctor, run dtor on old
+//                      entry storage.
+//  clearEntry          Run dtor on entry.
+//
+// Note the reason why initEntry is optional: the default hooks (stubs) clear
+// entry storage:  On successful Add(tbl, key), the returned entry pointer
+// addresses an entry struct whose mKeyHash member has been set non-zero, but
+// all other entry members are still clear (null). Add() callers can test such
+// members to see whether the entry was newly created by the Add() call that
+// just succeeded. If placement new or similar initialization is required,
+// define an |initEntry| hook. Of course, the |clearEntry| hook must zero or
+// null appropriately.
+//
+// XXX assumes 0 is null for pointer types.
 struct PLDHashTableOps
 {
-  /* Mandatory hooks.  All implementations must provide these. */
+  // Mandatory hooks. All implementations must provide these.
   PLDHashHashKey      hashKey;
   PLDHashMatchEntry   matchEntry;
   PLDHashMoveEntry    moveEntry;
   PLDHashClearEntry   clearEntry;
 
-  /* Optional hooks start here.  If null, these are not called. */
+  // Optional hooks start here. If null, these are not called.
   PLDHashInitEntry    initEntry;
 };
 
-/*
- * Default implementations for the above mOps.
- */
+// Default implementations for the above mOps.
 
 PLDHashNumber
 PL_DHashStringKey(PLDHashTable* aTable, const void* aKey);
 
-/* A minimal entry is a subclass of PLDHashEntryHdr and has void key pointer. */
+// A minimal entry is a subclass of PLDHashEntryHdr and has void key pointer.
 struct PLDHashEntryStub : public PLDHashEntryHdr
 {
   const void* key;
 };
 
 PLDHashNumber
 PL_DHashVoidPtrKeyStub(PLDHashTable* aTable, const void* aKey);
 
@@ -598,21 +576,19 @@ PL_DHashMatchStringKey(PLDHashTable* aTa
 void
 PL_DHashMoveEntryStub(PLDHashTable* aTable,
                       const PLDHashEntryHdr* aFrom,
                       PLDHashEntryHdr* aTo);
 
 void
 PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
 
-/*
- * If you use PLDHashEntryStub or a subclass of it as your entry struct, and
- * if your entries move via memcpy and clear via memset(0), you can use these
- * stub operations.
- */
+// If you use PLDHashEntryStub or a subclass of it as your entry struct, and
+// if your entries move via memcpy and clear via memset(0), you can use these
+// stub operations.
 const PLDHashTableOps*
 PL_DHashGetStubOps(void);
 
 // The following function are deprecated. Use the equivalent class methods
 // instead: PLDHashTable::Search() instead of PL_DHashTableSearch(), etc.
 
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey);