Bug 1121760 (part 2) - Remove PL_DHashTableAdd(). r=poiru.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 14 Sep 2015 14:23:12 -0700
changeset 295307 16597175b6f3678f38020fdf4c4a7f4debf38d2e
parent 295306 e37d0c2d053a28f4361a495a4ec20d8488406d64
child 295308 108f4bf0585b22a5d5d44c280a8e1c463ae329ef
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspoiru
bugs1121760
milestone43.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 1121760 (part 2) - Remove PL_DHashTableAdd(). r=poiru.
dom/base/nsContentList.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDocument.cpp
dom/base/nsPropertyTable.cpp
dom/base/nsScriptNameSpaceManager.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/xul/XULDocument.cpp
dom/xul/templates/nsContentSupportMap.h
dom/xul/templates/nsTemplateMap.h
embedding/components/commandhandler/nsCommandParams.cpp
gfx/thebes/gfxFT2FontList.cpp
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCMaps.h
layout/base/nsFrameManager.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsRuleNode.cpp
layout/tables/SpanningCellSorter.cpp
modules/libpref/prefapi.cpp
netwerk/base/nsLoadGroup.cpp
netwerk/cache/nsCacheEntry.cpp
netwerk/cache/nsDiskCacheBinding.cpp
netwerk/dns/nsHostResolver.cpp
netwerk/protocol/http/nsHttp.cpp
parser/htmlparser/nsHTMLEntities.cpp
rdf/base/nsInMemoryDataSource.cpp
rdf/base/nsRDFService.cpp
security/manager/ssl/nsCertTree.cpp
security/manager/ssl/nsNSSShutDown.cpp
security/manager/ssl/nsSecureBrowserUIImpl.cpp
uriloader/base/nsDocLoader.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsStaticNameTable.cpp
xpcom/glue/nsTHashtable.h
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
xpcom/tests/gtest/TestPLDHash.cpp
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -215,20 +215,19 @@ NS_GetContentList(nsINode* aRootNode,
   };
 
   // Initialize the hashtable if needed.
   if (!gContentListHashTable) {
     gContentListHashTable =
       new PLDHashTable(&hash_table_ops, sizeof(ContentListHashEntry));
   }
 
-  ContentListHashEntry *entry = nullptr;
   // First we look in our hashtable.  Then we create a content list if needed
-  entry = static_cast<ContentListHashEntry *>
-    (PL_DHashTableAdd(gContentListHashTable, &hashKey, fallible));
+  auto entry = static_cast<ContentListHashEntry*>
+                          (gContentListHashTable->Add(&hashKey, fallible));
   if (entry)
     list = entry->mContentList;
 
   if (!list) {
     // We need to create a ContentList and add it to our new entry, if
     // we have an entry
     nsCOMPtr<nsIAtom> xmlAtom = do_GetAtom(aTagname);
     nsCOMPtr<nsIAtom> htmlAtom;
@@ -324,18 +323,18 @@ GetFuncStringContentList(nsINode* aRootN
       new PLDHashTable(&hash_table_ops, sizeof(FuncStringContentListHashEntry));
   }
 
   FuncStringContentListHashEntry *entry = nullptr;
   // First we look in our hashtable.  Then we create a content list if needed
   if (gFuncStringContentListHashTable) {
     nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString);
 
-    entry = static_cast<FuncStringContentListHashEntry *>
-      (PL_DHashTableAdd(gFuncStringContentListHashTable, &hashKey, fallible));
+    entry = static_cast<FuncStringContentListHashEntry*>
+      (gFuncStringContentListHashTable->Add(&hashKey, fallible));
     if (entry) {
       list = entry->mContentList;
 #ifdef DEBUG
       MOZ_ASSERT_IF(list, list->mType == ListType::sType);
 #endif
     }
   }
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4135,19 +4135,19 @@ nsContentUtils::GetListenerManagerForNod
 {
   if (!sEventListenerManagersHash) {
     // We're already shut down, don't bother creating an event listener
     // manager.
 
     return nullptr;
   }
 
-  EventListenerManagerMapEntry *entry =
-    static_cast<EventListenerManagerMapEntry *>
-      (PL_DHashTableAdd(sEventListenerManagersHash, aNode, fallible));
+  auto entry =
+    static_cast<EventListenerManagerMapEntry*>
+               (sEventListenerManagersHash->Add(aNode, fallible));
 
   if (!entry) {
     return nullptr;
   }
 
   if (!entry->mListenerManager) {
     entry->mListenerManager = new EventListenerManager(aNode);
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3962,18 +3962,18 @@ nsDocument::SetSubDocumentFor(Element* a
         SubDocClearEntry,
         SubDocInitEntry
       };
 
       mSubDocuments = new PLDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
     }
 
     // Add a mapping to the hash table
-    SubDocMapEntry *entry = static_cast<SubDocMapEntry*>
-      (PL_DHashTableAdd(mSubDocuments, aElement, fallible));
+    auto entry =
+      static_cast<SubDocMapEntry*>(mSubDocuments->Add(aElement, fallible));
 
     if (!entry) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     if (entry->mSubDocument) {
       entry->mSubDocument->SetParentDocument(nullptr);
 
--- a/dom/base/nsPropertyTable.cpp
+++ b/dom/base/nsPropertyTable.cpp
@@ -201,18 +201,18 @@ nsPropertyTable::SetPropertyInternal(nsP
                                     aPropDtorData, aTransfer);
     propertyList->mNext = mPropertyList;
     mPropertyList = propertyList;
   }
 
   // The current property value (if there is one) is replaced and the current
   // value is destroyed
   nsresult result = NS_OK;
-  PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
-    (PL_DHashTableAdd(&propertyList->mObjectValueMap, aObject, mozilla::fallible));
+  auto entry = static_cast<PropertyListMapEntry*>
+    (propertyList->mObjectValueMap.Add(aObject, mozilla::fallible));
   if (!entry)
     return NS_ERROR_OUT_OF_MEMORY;
   // A nullptr entry->key is the sign that the entry has just been allocated
   // for us.  If it's non-nullptr then we have an existing entry.
   if (entry->key) {
     if (aOldValue)
       *aOldValue = entry->value;
     else if (propertyList->mDtorFunc)
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -127,19 +127,17 @@ nsScriptNameSpaceManager::~nsScriptNameS
   UnregisterWeakMemoryReporter(this);
   MOZ_COUNT_DTOR(nsScriptNameSpaceManager);
 }
 
 nsGlobalNameStruct *
 nsScriptNameSpaceManager::AddToHash(PLDHashTable *aTable, const nsAString *aKey,
                                     const char16_t **aClassName)
 {
-  GlobalNameMapEntry *entry = static_cast<GlobalNameMapEntry *>
-    (PL_DHashTableAdd(aTable, aKey, fallible));
-
+  auto entry = static_cast<GlobalNameMapEntry*>(aTable->Add(aKey, fallible));
   if (!entry) {
     return nullptr;
   }
 
   if (aClassName) {
     *aClassName = entry->mKey.get();
   }
 
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1881,18 +1881,18 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
 
   if (!sNPObjWrappers) {
     // No hash yet (or any more), initialize it.
     if (!CreateNPObjWrapperTable()) {
       return nullptr;
     }
   }
 
-  NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
-    (PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
+  auto entry =
+    static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Add(npobj, fallible));
 
   if (!entry) {
     // Out of memory
     JS_ReportOutOfMemory(cx);
 
     return nullptr;
   }
 
@@ -2039,18 +2039,18 @@ nsJSNPRuntime::OnPluginDestroyPending(NP
 static NPP
 LookupNPP(NPObject *npobj)
 {
   if (npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass) {
     nsJSObjWrapper* o = static_cast<nsJSObjWrapper*>(npobj);
     return o->mNpp;
   }
 
-  NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
-    (PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
+  auto entry =
+    static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Add(npobj, fallible));
 
   if (!entry) {
     return nullptr;
   }
 
   NS_ASSERTION(entry->mNpp, "Live NPObject entry w/o an NPP!");
 
   return entry->mNpp;
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -762,17 +762,17 @@ XULDocument::AddBroadcastListenerFor(Ele
     if (! mBroadcasterMap) {
         mBroadcasterMap = new PLDHashTable(&gOps, sizeof(BroadcasterMapEntry));
     }
 
     auto entry = static_cast<BroadcasterMapEntry*>
                             (mBroadcasterMap->Search(&aBroadcaster));
     if (!entry) {
         entry = static_cast<BroadcasterMapEntry*>
-            (PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible));
+                           (mBroadcasterMap->Add(&aBroadcaster, fallible));
 
         if (! entry) {
             aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
             return;
         }
 
         entry->mBroadcaster = &aBroadcaster;
 
--- a/dom/xul/templates/nsContentSupportMap.h
+++ b/dom/xul/templates/nsContentSupportMap.h
@@ -20,18 +20,17 @@
  * and rule information).
  */
 class nsContentSupportMap {
 public:
     nsContentSupportMap() : mMap(PL_DHashGetStubOps(), sizeof(Entry)) { }
     ~nsContentSupportMap() { }
 
     nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) {
-        PLDHashEntryHdr* hdr =
-            PL_DHashTableAdd(&mMap, aElement, mozilla::fallible);
+        PLDHashEntryHdr* hdr = mMap.Add(aElement, mozilla::fallible);
         if (!hdr)
             return NS_ERROR_OUT_OF_MEMORY;
 
         Entry* entry = static_cast<Entry*>(hdr);
         NS_ASSERTION(entry->mMatch == nullptr, "over-writing entry");
         entry->mContent = aElement;
         entry->mMatch   = aMatch;
         return NS_OK;
--- a/dom/xul/templates/nsTemplateMap.h
+++ b/dom/xul/templates/nsTemplateMap.h
@@ -22,18 +22,17 @@ public:
     nsTemplateMap() : mTable(PL_DHashGetStubOps(), sizeof(Entry)) { }
 
     ~nsTemplateMap() { }
 
     void
     Put(nsIContent* aContent, nsIContent* aTemplate) {
         NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
 
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(&mTable, aContent, fallible));
+        auto entry = static_cast<Entry*>(mTable.Add(aContent, fallible));
 
         if (entry) {
             entry->mContent = aContent;
             entry->mTemplate = aTemplate;
         }
     }
 
     void
--- a/embedding/components/commandhandler/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/nsCommandParams.cpp
@@ -214,18 +214,17 @@ nsCommandParams::HashEntry*
 nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
 {
   auto foundEntry = static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
   if (foundEntry) { // reuse existing entry
     foundEntry->Reset(aEntryType);
     return foundEntry;
   }
 
-  foundEntry = static_cast<HashEntry*>(
-    PL_DHashTableAdd(&mValuesHash, (void*)aName, fallible));
+  foundEntry = static_cast<HashEntry*>(mValuesHash.Add((void*)aName, fallible));
   if (!foundEntry) {
     return nullptr;
   }
 
   // Use placement new. Our ctor does not clobber keyHash, which is important.
   new (foundEntry) HashEntry(aEntryType, aName);
   return foundEntry;
 }
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -695,18 +695,18 @@ public:
             }
             uint32_t timestamp = strtoul(beginning, nullptr, 10);
             beginning = end + 1;
             if (!(end = strchr(beginning, ';'))) {
                 break;
             }
             uint32_t filesize = strtoul(beginning, nullptr, 10);
 
-            FNCMapEntry* mapEntry = static_cast<FNCMapEntry*>
-                (PL_DHashTableAdd(&mMap, filename.get(), fallible));
+            auto mapEntry =
+                static_cast<FNCMapEntry*>(mMap.Add(filename.get(), fallible));
             if (mapEntry) {
                 mapEntry->mFilename.Assign(filename);
                 mapEntry->mTimestamp = timestamp;
                 mapEntry->mFilesize = filesize;
                 mapEntry->mFaces.Assign(faceList);
                 // entries from the startupcache are marked "non-existing"
                 // until we have confirmed that the file still exists
                 mapEntry->mFileExists = false;
@@ -735,18 +735,18 @@ public:
             entry->mFileExists = true;
         }
     }
 
     virtual void
     CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList,
                   uint32_t aTimestamp, uint32_t aFilesize)
     {
-        FNCMapEntry* entry = static_cast<FNCMapEntry*>
-            (PL_DHashTableAdd(&mMap, aFileName.get(), fallible));
+        auto entry =
+            static_cast<FNCMapEntry*>(mMap.Add(aFileName.get(), fallible));
         if (entry) {
             entry->mFilename.Assign(aFileName);
             entry->mTimestamp = aTimestamp;
             entry->mFilesize = aFilesize;
             entry->mFaces.Assign(aFaceList);
             entry->mFileExists = true;
         }
         mWriteNeeded = true;
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -552,18 +552,17 @@ bool
 XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
                                            char* name,
                                            XPCNativeScriptableInfo* si)
 {
     NS_PRECONDITION(name,"bad param");
     NS_PRECONDITION(si,"bad param");
 
     XPCNativeScriptableShared key(flags, name);
-    Entry* entry = static_cast<Entry*>
-        (PL_DHashTableAdd(mTable, &key, fallible));
+    auto entry = static_cast<Entry*>(mTable->Add(&key, fallible));
     if (!entry)
         return false;
 
     XPCNativeScriptableShared* shared = entry->key;
 
     if (!shared) {
         entry->key = shared =
             new XPCNativeScriptableShared(flags, key.TransferNameOwnership());
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -118,18 +118,17 @@ public:
         return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNative* Add(XPCWrappedNative* wrapper)
     {
         NS_PRECONDITION(wrapper,"bad param");
         nsISupports* obj = wrapper->GetIdentityObject();
         MOZ_ASSERT(!Find(obj), "wrapper already in new scope!");
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, obj, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(obj, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = obj;
         entry->value = wrapper;
         return wrapper;
     }
@@ -181,18 +180,17 @@ public:
         auto entry = static_cast<Entry*>(mTable->Search(&iid));
         return entry ? entry->value : nullptr;
     }
 
     inline nsXPCWrappedJSClass* Add(nsXPCWrappedJSClass* clazz)
     {
         NS_PRECONDITION(clazz,"bad param");
         const nsIID* iid = &clazz->GetIID();
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, iid, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(iid, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = iid;
         entry->value = clazz;
         return clazz;
     }
@@ -235,18 +233,17 @@ public:
         auto entry = static_cast<Entry*>(mTable->Search(&iid));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeInterface* Add(XPCNativeInterface* iface)
     {
         NS_PRECONDITION(iface,"bad param");
         const nsIID* iid = iface->GetIID();
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, iid, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(iid, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = iid;
         entry->value = iface;
         return iface;
     }
@@ -289,18 +286,17 @@ public:
     {
         auto entry = static_cast<Entry*>(mTable->Search(info));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set)
     {
         NS_PRECONDITION(info,"bad param");
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, info, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(info, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = info;
         entry->value = set;
         return set;
     }
@@ -346,18 +342,17 @@ public:
     {
         auto entry = static_cast<Entry*>(mTable->Search(info));
         return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto)
     {
         NS_PRECONDITION(info,"bad param");
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, info, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(info, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return entry->value;
         entry->key = info;
         entry->value = proto;
         return proto;
     }
@@ -408,18 +403,17 @@ public:
         auto entry = static_cast<Entry*>(mTable->Search(key));
         return entry ? entry->key_value : nullptr;
     }
 
     inline XPCNativeSet* Add(const XPCNativeSetKey* key, XPCNativeSet* set)
     {
         NS_PRECONDITION(key,"bad param");
         NS_PRECONDITION(set,"bad param");
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, key, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(key, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key_value)
             return entry->key_value;
         entry->key_value = set;
         return set;
     }
 
@@ -480,18 +474,17 @@ public:
     {
         auto entry = static_cast<Entry*>(mTable->Search(&iid));
         return entry ? entry->value : nullptr;
     }
 
     inline nsIXPCFunctionThisTranslator* Add(REFNSIID iid,
                                              nsIXPCFunctionThisTranslator* obj)
     {
-        Entry* entry = static_cast<Entry*>
-            (PL_DHashTableAdd(mTable, &iid, mozilla::fallible));
+        auto entry = static_cast<Entry*>(mTable->Add(&iid, mozilla::fallible));
         if (!entry)
             return nullptr;
         entry->value = obj;
         entry->key = iid;
         return obj;
     }
 
     inline void Remove(REFNSIID iid)
@@ -552,18 +545,18 @@ class XPCWrappedNativeProtoMap
 public:
     typedef PLDHashEntryStub Entry;
 
     static XPCWrappedNativeProtoMap* newMap(int length);
 
     inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto)
     {
         NS_PRECONDITION(proto,"bad param");
-        PLDHashEntryStub* entry = static_cast<PLDHashEntryStub*>
-            (PL_DHashTableAdd(mTable, proto, mozilla::fallible));
+        auto entry = static_cast<PLDHashEntryStub*>
+                                (mTable->Add(proto, mozilla::fallible));
         if (!entry)
             return nullptr;
         if (entry->key)
             return (XPCWrappedNativeProto*) entry->key;
         entry->key = proto;
         return proto;
     }
 
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -174,19 +174,18 @@ nsFrameManager::GetPlaceholderFrameFor(c
 }
 
 nsresult
 nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
 {
   NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
   NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
                   "unexpected frame type");
-  PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
-    (PL_DHashTableAdd(&mPlaceholderMap,
-                      aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
+  auto entry = static_cast<PlaceholderMapEntry*>
+    (mPlaceholderMap.Add(aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
   if (!entry)
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ASSERTION(!entry->placeholderFrame, "Registering a placeholder for a frame that already has a placeholder!");
   entry->placeholderFrame = aPlaceholderFrame;
 
   return NS_OK;
 }
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -560,30 +560,28 @@ RuleHash::~RuleHash()
     delete [] mEnumList;
   }
 }
 
 void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
                                  const RuleSelectorPair& aRuleInfo)
 {
   // Get a new or existing entry.
-  RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
-    (PL_DHashTableAdd(aTable, aKey, fallible));
+  auto entry = static_cast<RuleHashTableEntry*>(aTable->Add(aKey, fallible));
   if (!entry)
     return;
   entry->mRules.AppendElement(RuleValue(aRuleInfo, mRuleCount++, mQuirksMode));
 }
 
 static void
 AppendRuleToTagTable(PLDHashTable* aTable, nsIAtom* aKey,
                      const RuleValue& aRuleInfo)
 {
   // Get a new or exisiting entry
-  RuleHashTagTableEntry *entry = static_cast<RuleHashTagTableEntry*>
-    (PL_DHashTableAdd(aTable, aKey, fallible));
+  auto entry = static_cast<RuleHashTagTableEntry*>(aTable->Add(aKey, fallible));
   if (!entry)
     return;
 
   entry->mRules.AppendElement(aRuleInfo);
 }
 
 void RuleHash::AppendUniversalRule(const RuleSelectorPair& aRuleInfo)
 {
@@ -998,19 +996,18 @@ RuleCascadeData::SizeOfIncludingThis(Mal
   }
 
   return n;
 }
 
 nsTArray<SelectorPair>*
 RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
 {
-  AtomSelectorEntry *entry =
-    static_cast<AtomSelectorEntry*>
-               (PL_DHashTableAdd(&mAttributeSelectors, aAttribute, fallible));
+  auto entry = static_cast<AtomSelectorEntry*>
+                          (mAttributeSelectors.Add(aAttribute, fallible));
   if (!entry)
     return nullptr;
   return &entry->mSelectors;
 }
 
 // -------------------------------
 // CSS Style rule processor implementation
 //
@@ -3315,34 +3312,33 @@ AddSelector(RuleCascadeData* aCascade,
         nsCSSRuleProcessor::StateSelector(dependentStates,
                                           aSelectorInTopLevel));
     }
 
     // Build mIDSelectors
     if (negation == aSelectorInTopLevel) {
       for (nsAtomList* curID = negation->mIDList; curID;
            curID = curID->mNext) {
-        AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>
-          (PL_DHashTableAdd(&aCascade->mIdSelectors, curID->mAtom, fallible));
+        auto entry = static_cast<AtomSelectorEntry*>
+          (aCascade->mIdSelectors.Add(curID->mAtom, fallible));
         if (entry) {
           entry->mSelectors.AppendElement(SelectorPair(aSelectorInTopLevel,
                                                        aRightmostSelector));
         }
       }
     } else if (negation->mIDList) {
       aCascade->mPossiblyNegatedIDSelectors.AppendElement(aSelectorInTopLevel);
     }
 
     // Build mClassSelectors
     if (negation == aSelectorInTopLevel) {
       for (nsAtomList* curClass = negation->mClassList; curClass;
            curClass = curClass->mNext) {
-        AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>
-          (PL_DHashTableAdd(&aCascade->mClassSelectors, curClass->mAtom,
-                            fallible));
+        auto entry = static_cast<AtomSelectorEntry*>
+          (aCascade->mClassSelectors.Add(curClass->mAtom, fallible));
         if (entry) {
           entry->mSelectors.AppendElement(SelectorPair(aSelectorInTopLevel,
                                                        aRightmostSelector));
         }
       }
     } else if (negation->mClassList) {
       aCascade->mPossiblyNegatedClassSelectors.AppendElement(aSelectorInTopLevel);
     }
@@ -3656,19 +3652,18 @@ CascadeRuleEnumFunc(css::Rule* aRule, vo
   int32_t type = aRule->GetType();
 
   if (css::Rule::STYLE_RULE == type) {
     css::StyleRule* styleRule = static_cast<css::StyleRule*>(aRule);
 
     for (nsCSSSelectorList *sel = styleRule->Selector();
          sel; sel = sel->mNext) {
       int32_t weight = sel->mWeight;
-      RuleByWeightEntry *entry = static_cast<RuleByWeightEntry*>(
-        PL_DHashTableAdd(&data->mRulesByWeight, NS_INT32_TO_PTR(weight),
-                         fallible));
+      auto entry = static_cast<RuleByWeightEntry*>
+        (data->mRulesByWeight.Add(NS_INT32_TO_PTR(weight), fallible));
       if (!entry)
         return false;
       entry->data.mWeight = weight;
       // entry->data.mRuleSelectorPairs should be linked in forward order;
       // entry->data.mTail is the slot to write to.
       PerWeightDataListItem *newItem =
         new (data->mArena) PerWeightDataListItem(styleRule, sel->mSelectors);
       if (newItem) {
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -466,19 +466,18 @@ nsresult
 nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor)
 {
   return ImplLinkColorSetter(mVisitedRule, aColor);
 }
 
 already_AddRefed<nsMappedAttributes>
 nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped)
 {
-  MappedAttrTableEntry *entry =
-    static_cast<MappedAttrTableEntry*>
-               (PL_DHashTableAdd(&mMappedAttrTable, aMapped, fallible));
+  auto entry = static_cast<MappedAttrTableEntry*>
+                          (mMappedAttrTable.Add(aMapped, fallible));
   if (!entry)
     return nullptr;
   if (!entry->mAttributes) {
     // We added a new entry to the hashtable, so we have a new unique set.
     entry->mAttributes = aMapped;
   }
   nsRefPtr<nsMappedAttributes> ret = entry->mAttributes;
   return ret.forget();
@@ -496,18 +495,18 @@ nsHTMLStyleSheet::DropMappedAttributes(n
   PL_DHashTableRemove(&mMappedAttrTable, aMapped);
 
   NS_ASSERTION(entryCount == mMappedAttrTable.EntryCount(), "not removed");
 }
 
 nsIStyleRule*
 nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage)
 {
-  LangRuleTableEntry *entry = static_cast<LangRuleTableEntry*>
-    (PL_DHashTableAdd(&mLangRuleTable, &aLanguage, fallible));
+  auto entry =
+    static_cast<LangRuleTableEntry*>(mLangRuleTable.Add(&aLanguage, fallible));
   if (!entry) {
     NS_ASSERTION(false, "out of memory");
     return nullptr;
   }
   return entry->mRule;
 }
 
 size_t
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1534,18 +1534,18 @@ nsRuleNode::Transition(nsIStyleRule* aRu
     }
     if (curr)
       next = curr;
     else if (numKids >= kMaxChildrenInList)
       ConvertChildrenToHash(numKids);
   }
 
   if (ChildrenAreHashed()) {
-    ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>
-      (PL_DHashTableAdd(ChildrenHash(), &key, fallible));
+    auto entry =
+      static_cast<ChildrenHashEntry*>(ChildrenHash()->Add(&key, fallible));
     if (!entry) {
       NS_WARNING("out of memory");
       return this;
     }
     if (entry->mRuleNode)
       next = entry->mRuleNode;
     else {
       next = entry->mRuleNode = new (mPresContext)
@@ -1601,18 +1601,18 @@ nsRuleNode::ConvertChildrenToHash(int32_
 {
   NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
                "must have a non-empty list of children");
   PLDHashTable *hash = new PLDHashTable(&ChildrenHashOps,
                                         sizeof(ChildrenHashEntry),
                                         aNumKids);
   for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
     // This will never fail because of the initial size we gave the table.
-    ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>(
-      PL_DHashTableAdd(hash, curr->mRule, fallible));
+    auto entry =
+      static_cast<ChildrenHashEntry*>(hash->Add(curr->mRule, fallible));
     NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
     entry->mRuleNode = curr;
   }
   SetChildrenHash(hash);
 }
 
 inline void
 nsRuleNode::PropagateNoneBit(uint32_t aBit, nsRuleNode* aHighestNode)
--- a/layout/tables/SpanningCellSorter.cpp
+++ b/layout/tables/SpanningCellSorter.cpp
@@ -63,19 +63,18 @@ SpanningCellSorter::AddCell(int32_t aCol
     i->row = aRow;
     i->col = aCol;
 
     if (UseArrayForSpan(aColSpan)) {
         int32_t index = SpanToIndex(aColSpan);
         i->next = mArray[index];
         mArray[index] = i;
     } else {
-        HashTableEntry *entry = static_cast<HashTableEntry*>
-            (PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan),
-                              fallible));
+        auto entry = static_cast<HashTableEntry*>
+            (mHashTable.Add(NS_INT32_TO_PTR(aColSpan), fallible));
         NS_ENSURE_TRUE(entry, false);
 
         NS_ASSERTION(entry->mColSpan == 0 || entry->mColSpan == aColSpan,
                      "wrong entry");
         NS_ASSERTION((entry->mColSpan == 0) == (entry->mItems == nullptr),
                      "entry should be either new or properly initialized");
         entry->mColSpan = aColSpan;
 
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -705,19 +705,17 @@ nsresult pref_HashPref(const char *key, 
 {
 #ifndef MOZ_B2G
     MOZ_ASSERT(NS_IsMainThread());
 #endif
 
     if (!gHashTable)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    PrefHashEntry* pref = static_cast<PrefHashEntry*>
-        (PL_DHashTableAdd(gHashTable, key, fallible));
-
+    auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(key, fallible));
     if (!pref)
         return NS_ERROR_OUT_OF_MEMORY;
 
     // new entry, better initialize
     if (!pref->key) {
 
         // initialize the pref entry
         pref->flags = type;
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -486,19 +486,18 @@ nsLoadGroup::AddRequest(nsIRequest *requ
         rv = MergeLoadFlags(request, flags);
     }
     if (NS_FAILED(rv)) return rv;
     
     //
     // Add the request to the list of active requests...
     //
 
-    RequestMapEntry *entry = static_cast<RequestMapEntry *>
-        (PL_DHashTableAdd(&mRequests, request, fallible));
-
+    auto entry =
+        static_cast<RequestMapEntry*>(mRequests.Add(request, fallible));
     if (!entry) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     if (mPriority != 0)
         RescheduleRequest(request, mPriority);
 
     nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(request);
--- a/netwerk/cache/nsCacheEntry.cpp
+++ b/netwerk/cache/nsCacheEntry.cpp
@@ -430,17 +430,17 @@ nsresult
 nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry)
 {
     PLDHashEntryHdr    *hashEntry;
 
     NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
     if (!initialized)  return NS_ERROR_NOT_INITIALIZED;
     if (!cacheEntry)   return NS_ERROR_NULL_POINTER;
 
-    hashEntry = PL_DHashTableAdd(&table, &(cacheEntry->mKey), fallible);
+    hashEntry = table.Add(&(cacheEntry->mKey), fallible);
 #ifndef DEBUG_dougt
     NS_ASSERTION(((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry == 0,
                  "### nsCacheEntryHashTable::AddEntry - entry already used");
 #endif
     ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry = cacheEntry;
 
     return NS_OK;
 }
--- a/netwerk/cache/nsDiskCacheBinding.cpp
+++ b/netwerk/cache/nsDiskCacheBinding.cpp
@@ -224,22 +224,20 @@ nsDiskCacheBindery::FindActiveBinding(ui
  */
 nsresult
 nsDiskCacheBindery::AddBinding(nsDiskCacheBinding * binding)
 {
     NS_ENSURE_ARG_POINTER(binding);
     NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
 
     // find hash entry for key
-    HashTableEntry * hashEntry;
-    hashEntry = (HashTableEntry *)
-      PL_DHashTableAdd(&table,
-                       (void *)(uintptr_t) binding->mRecord.HashNumber(),
-                       fallible);
-    if (!hashEntry) return NS_ERROR_OUT_OF_MEMORY;
+    auto hashEntry = static_cast<HashTableEntry*>
+        (table.Add((void*)(uintptr_t)binding->mRecord.HashNumber(), fallible));
+    if (!hashEntry)
+        return NS_ERROR_OUT_OF_MEMORY;
     
     if (hashEntry->mBinding == nullptr) {
         hashEntry->mBinding = binding;
         if (binding->mGeneration == 0)
             binding->mGeneration = 1;   // if generation uninitialized, set it to 1
             
         return NS_OK;
     }
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -754,18 +754,17 @@ nsHostResolver::ResolveHost(const char  
             // check to see if there is already an entry for this |host|
             // in the hash table.  if so, then check to see if we can't
             // just reuse the lookup result.  otherwise, if there are
             // any pending callbacks, then add to pending callbacks queue,
             // and return.  otherwise, add ourselves as first pending
             // callback, and proceed to do the lookup.
 
             nsHostKey key = { host, flags, af, netInterface };
-            nsHostDBEnt *he = static_cast<nsHostDBEnt *>
-                (PL_DHashTableAdd(&mDB, &key, fallible));
+            auto he = static_cast<nsHostDBEnt*>(mDB.Add(&key, fallible));
 
             // if the record is null, the hash table OOM'd.
             if (!he) {
                 LOG(("  Out of memory: no cache entry for host [%s%s%s].\n",
                      LOG_HOST(host, netInterface)));
                 rv = NS_ERROR_OUT_OF_MEMORY;
             }
             // do we have a cached result that we can reuse?
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -110,18 +110,18 @@ nsHttp::CreateAtomTable()
     const char *const atoms[] = {
 #define HTTP_ATOM(_name, _value) nsHttp::_name._val,
 #include "nsHttpAtomList.h"
 #undef HTTP_ATOM
         nullptr
     };
 
     for (int i = 0; atoms[i]; ++i) {
-        PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
-            (PL_DHashTableAdd(sAtomTable, atoms[i], fallible));
+        auto stub = static_cast<PLDHashEntryStub*>
+                               (sAtomTable->Add(atoms[i], fallible));
         if (!stub)
             return NS_ERROR_OUT_OF_MEMORY;
 
         MOZ_ASSERT(!stub->key, "duplicate static atom");
         stub->key = atoms[i];
     }
 
     return NS_OK;
@@ -155,18 +155,17 @@ nsHttp::ResolveAtom(const char *str)
 {
     nsHttpAtom atom = { nullptr };
 
     if (!str || !sAtomTable)
         return atom;
 
     MutexAutoLock lock(*sLock);
 
-    PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
-        (PL_DHashTableAdd(sAtomTable, str, fallible));
+    auto stub = static_cast<PLDHashEntryStub*>(sAtomTable->Add(str, fallible));
     if (!stub)
         return atom;  // out of memory
 
     if (stub->key) {
         atom._val = reinterpret_cast<const char *>(stub->key);
         return atom;
     }
 
--- a/parser/htmlparser/nsHTMLEntities.cpp
+++ b/parser/htmlparser/nsHTMLEntities.cpp
@@ -87,29 +87,27 @@ nsHTMLEntities::AddRefTable(void)
     gUnicodeToEntity = new PLDHashTable(&UnicodeToEntityOps,
                                         sizeof(EntityNodeEntry),
                                         NS_HTML_ENTITY_COUNT);
     for (const EntityNode *node = gEntityArray,
                  *node_end = ArrayEnd(gEntityArray);
          node < node_end; ++node) {
 
       // add to Entity->Unicode table
-      EntityNodeEntry* entry =
-        static_cast<EntityNodeEntry*>
-                   (PL_DHashTableAdd(gEntityToUnicode, node->mStr, fallible));
+      auto entry = static_cast<EntityNodeEntry*>
+                              (gEntityToUnicode->Add(node->mStr, fallible));
       NS_ASSERTION(entry, "Error adding an entry");
       // Prefer earlier entries when we have duplication.
       if (!entry->node)
         entry->node = node;
 
       // add to Unicode->Entity table
       entry = static_cast<EntityNodeEntry*>
-                         (PL_DHashTableAdd(gUnicodeToEntity,
-                                           NS_INT32_TO_PTR(node->mUnicode),
-                                           fallible));
+                         (gUnicodeToEntity->Add(NS_INT32_TO_PTR(node->mUnicode),
+                                                fallible));
       NS_ASSERTION(entry, "Error adding an entry");
       // Prefer earlier entries when we have duplication.
       if (!entry->node)
         entry->node = node;
     }
 #ifdef DEBUG
     PL_DHashMarkTableImmutable(gUnicodeToEntity);
     PL_DHashMarkTableImmutable(gEntityToUnicode);
--- a/rdf/base/nsInMemoryDataSource.cpp
+++ b/rdf/base/nsInMemoryDataSource.cpp
@@ -310,33 +310,33 @@ public:
     GetReverseArcs(nsIRDFNode* v) {
         PLDHashEntryHdr* hdr = mReverseArcs.Search(v);
         return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
     }
 
     void
     SetForwardArcs(nsIRDFResource* u, Assertion* as) {
         if (as) {
-            Entry* entry = static_cast<Entry*>
-                (PL_DHashTableAdd(&mForwardArcs, u, mozilla::fallible));
+            auto entry =
+                static_cast<Entry*>(mForwardArcs.Add(u, mozilla::fallible));
             if (entry) {
                 entry->mNode = u;
                 entry->mAssertions = as;
             }
         }
         else {
             PL_DHashTableRemove(&mForwardArcs, u);
         }
     }
 
     void
     SetReverseArcs(nsIRDFNode* v, Assertion* as) {
         if (as) {
-            Entry* entry = static_cast<Entry*>
-                (PL_DHashTableAdd(&mReverseArcs, v, mozilla::fallible));
+            auto entry =
+                static_cast<Entry*>(mReverseArcs.Add(v, mozilla::fallible));
             if (entry) {
                 entry->mNode = v;
                 entry->mAssertions = as;
             }
         }
         else {
             PL_DHashTableRemove(&mReverseArcs, v);
         }
@@ -1113,18 +1113,17 @@ InMemoryDataSource::LockedAssert(nsIRDFR
             hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         if (asRef)
         {
             as->mNext = asRef->mNext;
             asRef->mNext = as;
         }
         else
         {
-            hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty,
-                                   mozilla::fallible);
+            hdr = next->u.hash.mPropertyHash->Add(aProperty, mozilla::fallible);
             if (hdr)
             {
                 Entry* entry = static_cast<Entry*>(hdr);
                 entry->mNode = aProperty;
                 entry->mAssertions = as;
             }
         }
     }
@@ -1223,18 +1222,18 @@ InMemoryDataSource::LockedUnassert(nsIRD
 
         as = next;
 
         if (first) {
             PL_DHashTableRawRemove(root->u.hash.mPropertyHash, hdr);
 
             if (next && next->mNext) {
                 PLDHashEntryHdr* hdr =
-                    PL_DHashTableAdd(root->u.hash.mPropertyHash, aProperty,
-                                     mozilla::fallible);
+                    root->u.hash.mPropertyHash->Add(aProperty,
+                                                    mozilla::fallible);
                 if (hdr) {
                     Entry* entry = static_cast<Entry*>(hdr);
                     entry->mNode = aProperty;
                     entry->mAssertions = next->mNext;
                 }
             }
             else {
                 // If this second-level hash empties out, clean it up.
@@ -1659,18 +1658,17 @@ InMemoryDataSource::EnsureFastContainmen
 
         PLDHashEntryHdr* hdr = table->Search(prop);
         Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         if (val) {
             first->mNext = val->mNext;
             val->mNext = first;
         }
         else {
-            PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop,
-                                                    mozilla::fallible);
+            PLDHashEntryHdr* hdr = table->Add(prop, mozilla::fallible);
             if (hdr) {
                 Entry* entry = static_cast<Entry*>(hdr);
                 entry->mNode = prop;
                 entry->mAssertions = first;
                 first->mNext = nullptr;
             }
         }
         first = nextRef;
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -1135,17 +1135,17 @@ RDFServiceImpl::RegisterResource(nsIRDFR
         // it.
 
         MOZ_LOG(gLog, LogLevel::Debug,
                ("rdfserv   replace-resource [%p] <-- [%p] %s",
                 static_cast<ResourceHashEntry *>(hdr)->mResource,
                 aResource, (const char*) uri));
     }
     else {
-        hdr = PL_DHashTableAdd(&mResources, uri, fallible);
+        hdr = mResources.Add(uri, fallible);
         if (! hdr)
             return NS_ERROR_OUT_OF_MEMORY;
 
         MOZ_LOG(gLog, LogLevel::Debug,
                ("rdfserv   register-resource [%p] %s",
                 aResource, (const char*) uri));
     }
 
@@ -1371,17 +1371,17 @@ RDFServiceImpl::GetDataSource(const char
 nsresult
 RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral)
 {
     const char16_t* value;
     aLiteral->GetValueConst(&value);
 
     NS_ASSERTION(!mLiterals.Search(value), "literal already registered");
 
-    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value, fallible);
+    PLDHashEntryHdr *hdr = mLiterals.Add(value, fallible);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateLiteral() call
@@ -1421,17 +1421,17 @@ RDFServiceImpl::UnregisterLiteral(nsIRDF
 nsresult
 RDFServiceImpl::RegisterInt(nsIRDFInt* aInt)
 {
     int32_t value;
     aInt->GetValue(&value);
 
     NS_ASSERTION(!mInts.Search(&value), "int already registered");
 
-    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value, fallible);
+    PLDHashEntryHdr *hdr = mInts.Add(&value, fallible);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     IntHashEntry *entry = static_cast<IntHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateInt() call
@@ -1471,17 +1471,17 @@ RDFServiceImpl::UnregisterInt(nsIRDFInt*
 nsresult
 RDFServiceImpl::RegisterDate(nsIRDFDate* aDate)
 {
     PRTime value;
     aDate->GetValue(&value);
 
     NS_ASSERTION(!mDates.Search(&value), "date already registered");
 
-    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value, fallible);
+    PLDHashEntryHdr *hdr = mDates.Add(&value, fallible);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     DateHashEntry *entry = static_cast<DateHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateDate() call
@@ -1516,17 +1516,17 @@ RDFServiceImpl::UnregisterDate(nsIRDFDat
     return NS_OK;
 }
 
 nsresult
 RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
 {
     NS_ASSERTION(!mBlobs.Search(&aBlob->mData), "blob already registered");
 
-    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData, fallible);
+    PLDHashEntryHdr *hdr = mBlobs.Add(&aBlob->mData, fallible);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     BlobHashEntry *entry = static_cast<BlobHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateInt() call
--- a/security/manager/ssl/nsCertTree.cpp
+++ b/security/manager/ssl/nsCertTree.cpp
@@ -181,18 +181,18 @@ nsCertTree::FreeCertArray()
 {
   mDispInfo.Clear();
 }
 
 CompareCacheHashEntry *
 nsCertTree::getCacheEntry(void *cache, void *aCert)
 {
   PLDHashTable &aCompareCache = *reinterpret_cast<PLDHashTable*>(cache);
-  CompareCacheHashEntryPtr *entryPtr = static_cast<CompareCacheHashEntryPtr*>
-    (PL_DHashTableAdd(&aCompareCache, aCert, fallible));
+  auto entryPtr = static_cast<CompareCacheHashEntryPtr*>
+                             (aCompareCache.Add(aCert, fallible));
   return entryPtr ? entryPtr->entry : nullptr;
 }
 
 void nsCertTree::RemoveCacheEntry(void *key)
 {
   PL_DHashTableRemove(&mCompareCache, key);
 }
 
--- a/security/manager/ssl/nsNSSShutDown.cpp
+++ b/security/manager/ssl/nsNSSShutDown.cpp
@@ -54,17 +54,17 @@ nsNSSShutDownList::~nsNSSShutDownList()
 
 void nsNSSShutDownList::remember(nsNSSShutDownObject *o)
 {
   if (!singleton)
     return;
   
   PR_ASSERT(o);
   MutexAutoLock lock(singleton->mListLock);
-  PL_DHashTableAdd(&singleton->mObjects, o, fallible);
+  singleton->mObjects.Add(o, fallible);
 }
 
 void nsNSSShutDownList::forget(nsNSSShutDownObject *o)
 {
   if (!singleton)
     return;
   
   PR_ASSERT(o);
@@ -74,17 +74,17 @@ void nsNSSShutDownList::forget(nsNSSShut
 
 void nsNSSShutDownList::remember(nsOnPK11LogoutCancelObject *o)
 {
   if (!singleton)
     return;
   
   PR_ASSERT(o);
   MutexAutoLock lock(singleton->mListLock);
-  PL_DHashTableAdd(&singleton->mPK11LogoutCancelObjects, o, fallible);
+  singleton->mPK11LogoutCancelObjects.Add(o, fallible);
 }
 
 void nsNSSShutDownList::forget(nsOnPK11LogoutCancelObject *o)
 {
   if (!singleton)
     return;
   
   PR_ASSERT(o);
--- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp
@@ -854,17 +854,17 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
   if (aProgressStateFlags & STATE_TRANSFERRING
       &&
       aProgressStateFlags & STATE_IS_REQUEST)
   {
     // The listing of a request in mTransferringRequests
     // means, there has already been data transfered.
 
     ReentrantMonitorAutoEnter lock(mReentrantMonitor);
-    PL_DHashTableAdd(&mTransferringRequests, aRequest, fallible);
+    mTransferringRequests.Add(aRequest, fallible);
 
     return NS_OK;
   }
 
   bool requestHasTransferedData = false;
 
   if (aProgressStateFlags & STATE_STOP
       &&
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -1320,17 +1320,17 @@ nsDocLoader::RefreshAttempted(nsIWebProg
       mParent->RefreshAttempted(aWebProgress, aURI, aDelay, aSameURI);
   }
 
   return allowRefresh;
 }
 
 nsresult nsDocLoader::AddRequestInfo(nsIRequest *aRequest)
 {
-  if (!PL_DHashTableAdd(&mRequestInfoHash, aRequest, mozilla::fallible)) {
+  if (!mRequestInfoHash.Add(aRequest, mozilla::fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
 void nsDocLoader::RemoveRequestInfo(nsIRequest *aRequest)
 {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -912,18 +912,17 @@ CCGraph::FindNode(void* aPtr)
 PtrToNodeEntry*
 CCGraph::AddNodeToMap(void* aPtr)
 {
   JS::AutoSuppressGCAnalysis suppress;
   if (mOutOfMemory) {
     return nullptr;
   }
 
-  PtrToNodeEntry* e = static_cast<PtrToNodeEntry*>
-    (PL_DHashTableAdd(&mPtrToNodeMap, aPtr, fallible));
+  auto e = static_cast<PtrToNodeEntry*>(mPtrToNodeMap.Add(aPtr, fallible));
   if (!e) {
     mOutOfMemory = true;
     MOZ_ASSERT(false, "Ran out of memory while building cycle collector graph");
     return nullptr;
   }
   return e;
 }
 
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -536,27 +536,27 @@ EnsureTableExists()
 
 static inline AtomTableEntry*
 GetAtomHashEntry(const char* aString, uint32_t aLength, uint32_t* aHashOut)
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   EnsureTableExists();
   AtomTableKey key(aString, aLength, aHashOut);
   // This is an infallible add.
-  return static_cast<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
+  return static_cast<AtomTableEntry*>(gAtomTable->Add(&key));
 }
 
 static inline AtomTableEntry*
 GetAtomHashEntry(const char16_t* aString, uint32_t aLength, uint32_t* aHashOut)
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   EnsureTableExists();
   AtomTableKey key(aString, aLength, aHashOut);
   // This is an infallible add.
-  return static_cast<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
+  return static_cast<AtomTableEntry*>(gAtomTable->Add(&key));
 }
 
 class CheckStaticAtomSizes
 {
   CheckStaticAtomSizes()
   {
     static_assert((sizeof(nsFakeStringBuffer<1>().mRefCnt) ==
                    sizeof(nsStringBuffer().mRefCount)) &&
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -518,18 +518,18 @@ nsPersistentProperties::Load(nsIInputStr
 }
 
 NS_IMETHODIMP
 nsPersistentProperties::SetStringProperty(const nsACString& aKey,
                                           const nsAString& aNewValue,
                                           nsAString& aOldValue)
 {
   const nsAFlatCString&  flatKey = PromiseFlatCString(aKey);
-  PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
-    PL_DHashTableAdd(&mTable, flatKey.get(), mozilla::fallible));
+  auto entry = static_cast<PropertyTableEntry*>
+                          (mTable.Add(flatKey.get(), mozilla::fallible));
 
   if (entry->mKey) {
     aOldValue = entry->mValue;
     NS_WARNING(nsPrintfCString("the property %s already exists\n",
                                flatKey.get()).get());
   } else {
     aOldValue.Truncate();
   }
--- a/xpcom/ds/nsStaticNameTable.cpp
+++ b/xpcom/ds/nsStaticNameTable.cpp
@@ -131,18 +131,17 @@ nsStaticCaseInsensitiveNameTable::nsStat
     }
 #endif
     // use placement-new to initialize the string object
     nsDependentCString* strPtr = &mNameArray[index];
     new (strPtr) nsDependentCString(raw);
 
     NameTableKey key(strPtr);
 
-    NameTableEntry* entry = static_cast<NameTableEntry*>
-      (PL_DHashTableAdd(&mNameTable, &key, fallible));
+    auto entry = static_cast<NameTableEntry*>(mNameTable.Add(&key, fallible));
     if (!entry) {
       continue;
     }
 
     NS_ASSERTION(entry->mString == 0, "Entry already exists!");
 
     entry->mString = strPtr;      // not owned!
     entry->mIndex = index;
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -138,26 +138,25 @@ public:
   /**
    * Get the entry associated with a key, or create a new entry,
    * @param     aKey the key to retrieve
    * @return    pointer to the entry class retreived; nullptr only if memory
                 can't be allocated
    */
   EntryType* PutEntry(KeyType aKey)
   {
-    return static_cast<EntryType*>  // infallible add
-      (PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey)));
+    // infallible add
+    return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey)));
   }
 
   MOZ_WARN_UNUSED_RESULT
   EntryType* PutEntry(KeyType aKey, const fallible_t&)
   {
-    return static_cast<EntryType*>
-      (PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey),
-                        mozilla::fallible));
+    return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey),
+                                              mozilla::fallible));
   }
 
   /**
    * Remove the entry associated with a key.
    * @param     aKey of the entry to remove
    */
   void RemoveEntry(KeyType aKey)
   {
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -563,17 +563,17 @@ PLDHashTable::Search(const void* aKey)
 
   PLDHashEntryHdr* entry = mEntryStore.Get()
                          ? SearchTable<ForSearchOrRemove>(aKey,
                                                           ComputeKeyHash(aKey))
                          : nullptr;
   return entry;
 }
 
-MOZ_ALWAYS_INLINE PLDHashEntryHdr*
+PLDHashEntryHdr*
 PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&)
 {
 #ifdef DEBUG
   AutoWriteOp op(mChecker);
 #endif
 
   // Allocate the entry storage if it hasn't already been allocated.
   if (!mEntryStore.Get()) {
@@ -624,17 +624,17 @@ PLDHashTable::Add(const void* aKey, cons
     }
     entry->mKeyHash = keyHash;
     mEntryCount++;
   }
 
   return entry;
 }
 
-MOZ_ALWAYS_INLINE PLDHashEntryHdr*
+PLDHashEntryHdr*
 PLDHashTable::Add(const void* aKey)
 {
   PLDHashEntryHdr* entry = Add(aKey, fallible);
   if (!entry) {
     if (!mEntryStore.Get()) {
       // We OOM'd while allocating the initial entry storage.
       uint32_t nbytes;
       (void) SizeOfEntryStore(CapacityFromHashShift(), mEntrySize, &nbytes);
@@ -673,29 +673,16 @@ PLDHashTable::RemoveEntry(PLDHashEntryHd
 #ifdef DEBUG
   AutoWriteOp op(mChecker);
 #endif
 
   RawRemove(aEntry);
   ShrinkIfAppropriate();
 }
 
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
-                 const fallible_t& aFallible)
-{
-  return aTable->Add(aKey, aFallible);
-}
-
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey)
-{
-  return aTable->Add(aKey);
-}
-
 void PL_DHASH_FASTCALL
 PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey)
 {
   aTable->Remove(aKey);
 }
 
 MOZ_ALWAYS_INLINE void
 PLDHashTable::RawRemove(PLDHashEntryHdr* aEntry)
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -615,23 +615,16 @@ 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.
 const PLDHashTableOps*
 PL_DHashGetStubOps(void);
 
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
-                 const mozilla::fallible_t&);
-
-PLDHashEntryHdr* PL_DHASH_FASTCALL
-PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey);
-
 void PL_DHASH_FASTCALL
 PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey);
 
 void
 PL_DHashTableRawRemove(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
 
 #ifdef DEBUG
 void
--- a/xpcom/tests/gtest/TestPLDHash.cpp
+++ b/xpcom/tests/gtest/TestPLDHash.cpp
@@ -162,67 +162,67 @@ static const PLDHashTableOps trivialOps 
   PL_DHashMoveEntryStub,
   PL_DHashClearEntryStub,
   TrivialInitEntry
 };
 
 TEST(PLDHashTableTest, MoveSemantics)
 {
   PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub));
-  PL_DHashTableAdd(&t1, (const void*)88);
+  t1.Add((const void*)88);
   PLDHashTable t2(&trivialOps, sizeof(PLDHashEntryStub));
-  PL_DHashTableAdd(&t2, (const void*)99);
+  t2.Add((const void*)99);
 
   t1 = mozilla::Move(t1);   // self-move
 
   t1 = mozilla::Move(t2);   // empty overwritten with empty
 
   PLDHashTable t3(&trivialOps, sizeof(PLDHashEntryStub));
   PLDHashTable t4(&trivialOps, sizeof(PLDHashEntryStub));
-  PL_DHashTableAdd(&t3, (const void*)88);
+  t3.Add((const void*)88);
 
   t3 = mozilla::Move(t4);   // non-empty overwritten with empty
 
   PLDHashTable t5(&trivialOps, sizeof(PLDHashEntryStub));
   PLDHashTable t6(&trivialOps, sizeof(PLDHashEntryStub));
-  PL_DHashTableAdd(&t6, (const void*)88);
+  t6.Add((const void*)88);
 
   t5 = mozilla::Move(t6);   // empty overwritten with non-empty
 
   PLDHashTable t7(&trivialOps, sizeof(PLDHashEntryStub));
   PLDHashTable t8(mozilla::Move(t7));  // new table constructed with uninited
 
   PLDHashTable t9(&trivialOps, sizeof(PLDHashEntryStub));
-  PL_DHashTableAdd(&t9, (const void*)88);
+  t9.Add((const void*)88);
   PLDHashTable t10(mozilla::Move(t9));  // new table constructed with inited
 }
 
 TEST(PLDHashTableTest, Clear)
 {
   PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub));
 
   t1.Clear();
   ASSERT_EQ(t1.EntryCount(), 0u);
 
   t1.ClearAndPrepareForLength(100);
   ASSERT_EQ(t1.EntryCount(), 0u);
 
-  PL_DHashTableAdd(&t1, (const void*)77);
-  PL_DHashTableAdd(&t1, (const void*)88);
-  PL_DHashTableAdd(&t1, (const void*)99);
+  t1.Add((const void*)77);
+  t1.Add((const void*)88);
+  t1.Add((const void*)99);
   ASSERT_EQ(t1.EntryCount(), 3u);
 
   t1.Clear();
   ASSERT_EQ(t1.EntryCount(), 0u);
 
-  PL_DHashTableAdd(&t1, (const void*)55);
-  PL_DHashTableAdd(&t1, (const void*)66);
-  PL_DHashTableAdd(&t1, (const void*)77);
-  PL_DHashTableAdd(&t1, (const void*)88);
-  PL_DHashTableAdd(&t1, (const void*)99);
+  t1.Add((const void*)55);
+  t1.Add((const void*)66);
+  t1.Add((const void*)77);
+  t1.Add((const void*)88);
+  t1.Add((const void*)99);
   ASSERT_EQ(t1.EntryCount(), 5u);
 
   t1.ClearAndPrepareForLength(8192);
   ASSERT_EQ(t1.EntryCount(), 0u);
 }
 
 TEST(PLDHashTableTest, Iterator)
 {
@@ -238,19 +238,19 @@ TEST(PLDHashTableTest, Iterator)
 
   // Iterate through the empty table.
   for (PLDHashTable::Iterator iter(&t); !iter.Done(); iter.Next()) {
     (void) iter.Get();
     ASSERT_TRUE(false); // shouldn't hit this
   }
 
   // Add three entries.
-  PL_DHashTableAdd(&t, (const void*)77);
-  PL_DHashTableAdd(&t, (const void*)88);
-  PL_DHashTableAdd(&t, (const void*)99);
+  t.Add((const void*)77);
+  t.Add((const void*)88);
+  t.Add((const void*)99);
 
   // Check the iterator goes through each entry once.
   bool saw77 = false, saw88 = false, saw99 = false;
   int n = 0;
   for (auto iter(t.Iter()); !iter.Done(); iter.Next()) {
     auto entry = static_cast<PLDHashEntryStub*>(iter.Get());
     if (entry->key == (const void*)77) {
       saw77 = true;
@@ -265,17 +265,17 @@ TEST(PLDHashTableTest, Iterator)
   }
   ASSERT_TRUE(saw77 && saw88 && saw99 && n == 3);
 
   t.Clear();
 
   // First, we insert 64 items, which results in a capacity of 128, and a load
   // factor of 50%.
   for (intptr_t i = 0; i < 64; i++) {
-    PL_DHashTableAdd(&t, (const void*)i);
+    t.Add((const void*)i);
   }
   ASSERT_EQ(t.EntryCount(), 64u);
   ASSERT_EQ(t.Capacity(), 128u);
 
   // The first removing iterator does no removing; capacity and entry count are
   // unchanged.
   for (PLDHashTable::Iterator iter(&t); !iter.Done(); iter.Next()) {
     (void) iter.Get();
@@ -321,17 +321,17 @@ TEST(PLDHashTableTest, GrowToMaxCapacity
 {
   // This is infallible.
   PLDHashTable* t =
     new PLDHashTable(&trivialOps, sizeof(PLDHashEntryStub), 128);
 
   // Keep inserting elements until failure occurs because the table is full.
   size_t numInserted = 0;
   while (true) {
-    if (!PL_DHashTableAdd(t, (const void*)numInserted, mozilla::fallible)) {
+    if (!t->Add((const void*)numInserted, mozilla::fallible)) {
       break;
     }
     numInserted++;
   }
 
   // We stop when the element count is 96.875% of PL_DHASH_MAX_SIZE (see
   // MaxLoadOnGrowthFailure()).
   if (numInserted !=