Bug 1050009 - Initialize pldhash tables with a length, not a capacity. r=roc.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 06 Aug 2014 06:31:21 -0700
changeset 220125 96a566fa1599b55e019a7172d93a458002300237
parent 220124 5edac09d4b930c3c261007e2fb515938918e8b4a
child 220173 2c56f2d98018034e158391152ffabb798dd15d9a
child 220218 ac00c8a8a7a6aedc219624b14480a38bb70d05c4
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1050009
milestone34.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 1050009 - Initialize pldhash tables with a length, not a capacity. r=roc. * * * imported patch rm-dummy-params
accessible/base/DocManager.cpp
accessible/generic/DocAccessible.cpp
accessible/generic/DocAccessible.h
accessible/windows/msaa/nsWinUtils.cpp
accessible/xul/XULTreeAccessible.cpp
accessible/xul/XULTreeAccessible.h
accessible/xul/XULTreeGridAccessible.cpp
chrome/nsChromeRegistryChrome.cpp
content/base/src/nsContentList.cpp
content/base/src/nsContentUtils.cpp
content/base/src/nsDocument.cpp
content/base/src/nsPropertyTable.cpp
content/html/content/src/HTMLFormControlsCollection.cpp
content/html/content/src/HTMLFormElement.cpp
content/html/content/src/HTMLFormElement.h
content/xul/document/src/XULDocument.cpp
content/xul/templates/src/nsContentSupportMap.cpp
content/xul/templates/src/nsTemplateMap.h
dom/base/nsDOMWindowUtils.cpp
dom/base/nsScriptNameSpaceManager.cpp
dom/indexedDB/Client.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/src/storage/DOMStorageManager.cpp
dom/xbl/nsBindingManager.cpp
dom/xbl/nsXBLPrototypeBinding.cpp
dom/xslt/xslt/txExecutionState.h
dom/xslt/xslt/txKey.h
embedding/components/commandhandler/src/nsCommandParams.cpp
embedding/components/commandhandler/src/nsControllerCommandTable.cpp
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxFT2Fonts.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFontFeatures.cpp
gfx/thebes/gfxFontconfigUtils.cpp
gfx/thebes/gfxGDIFont.cpp
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxPangoFonts.cpp
gfx/thebes/gfxPlatformFontList.cpp
gfx/thebes/gfxPlatformFontList.h
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxWindowsPlatform.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCMaps.h
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/wrappers/WrapperFactory.cpp
layout/base/nsCounterManager.cpp
layout/base/nsFrameManager.cpp
layout/generic/TextOverflow.cpp
layout/generic/nsLineBox.h
layout/style/nsAnimationManager.cpp
layout/style/nsCSSProps.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsRuleNode.cpp
layout/style/nsRuleNode.h
layout/svg/nsSVGEffects.h
layout/svg/nsSVGFilterInstance.cpp
layout/tables/SpanningCellSorter.cpp
layout/xul/nsBoxObject.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
modules/libjar/nsJAR.cpp
modules/libpref/Preferences.cpp
modules/libpref/prefapi.cpp
netwerk/base/src/RedirectChannelRegistrar.cpp
netwerk/base/src/nsLoadGroup.cpp
netwerk/cache/nsCacheEntry.cpp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/dns/nsEffectiveTLDService.cpp
netwerk/protocol/http/SpdyStream3.cpp
netwerk/protocol/http/SpdyStream31.cpp
netwerk/protocol/http/nsHttp.cpp
netwerk/protocol/res/nsResProtocolHandler.cpp
parser/html/nsHtml5TreeOpExecutor.cpp
parser/htmlparser/src/nsHTMLEntities.cpp
rdf/base/nsInMemoryDataSource.cpp
rdf/base/nsRDFService.cpp
security/manager/boot/src/nsSecureBrowserUIImpl.cpp
security/manager/ssl/src/TransportSecurityInfo.cpp
security/manager/ssl/src/nsCertTree.cpp
security/manager/ssl/src/nsNSSIOLayer.cpp
security/manager/ssl/src/nsNSSShutDown.cpp
toolkit/components/places/History.cpp
toolkit/components/places/nsFaviconService.cpp
toolkit/components/places/nsNavBookmarks.cpp
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/nsNavHistoryResult.cpp
toolkit/components/telemetry/Telemetry.cpp
toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
uriloader/base/nsDocLoader.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/base/nsTraceRefcnt.cpp
xpcom/components/nsComponentManager.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsStaticNameTable.cpp
xpcom/ds/nsStaticNameTable.h
xpcom/glue/DeadlockDetector.h
xpcom/glue/nsBaseHashtable.h
xpcom/glue/nsClassHashtable.h
xpcom/glue/nsDataHashtable.h
xpcom/glue/nsInterfaceHashtable.h
xpcom/glue/nsRefPtrHashtable.h
xpcom/glue/nsTHashtable.h
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
xpcom/io/nsDirectoryService.cpp
xpcom/reflect/xptinfo/xptiWorkingSet.cpp
xpcom/tests/TestHashtables.cpp
xpcom/tests/TestPLDHash.cpp
--- a/accessible/base/DocManager.cpp
+++ b/accessible/base/DocManager.cpp
@@ -32,17 +32,17 @@ using namespace mozilla;
 using namespace mozilla::a11y;
 using namespace mozilla::dom;
 
 ////////////////////////////////////////////////////////////////////////////////
 // DocManager
 ////////////////////////////////////////////////////////////////////////////////
 
 DocManager::DocManager()
-  : mDocAccessibleCache(4)
+  : mDocAccessibleCache(2)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // DocManager public
 
 DocAccessible*
 DocManager::GetDocAccessible(nsIDocument* aDocument)
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -73,18 +73,18 @@ static const uint32_t kRelationAttrsLen 
 ////////////////////////////////////////////////////////////////////////////////
 // Constructor/desctructor
 
 DocAccessible::
   DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
                   nsIPresShell* aPresShell) :
   HyperTextAccessibleWrap(aRootContent, this),
   // XXX aaronl should we use an algorithm for the initial cache size?
-  mAccessibleCache(kDefaultCacheSize),
-  mNodeToAccessibleMap(kDefaultCacheSize),
+  mAccessibleCache(kDefaultCacheLength),
+  mNodeToAccessibleMap(kDefaultCacheLength),
   mDocumentNode(aDocument),
   mScrollPositionChangedTicks(0),
   mLoadState(eTreeConstructionPending), mDocFlags(0), mLoadEventType(0),
   mVirtualCursor(nullptr),
   mPresShell(aPresShell)
 {
   mGenericTypes |= eDocument;
   mStateFlags |= eNotNodeMapEntry;
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -21,17 +21,17 @@
 #include "nsIScrollPositionListener.h"
 #include "nsITimer.h"
 #include "nsIWeakReference.h"
 
 class nsAccessiblePivot;
 
 class nsIScrollableView;
 
-const uint32_t kDefaultCacheSize = 256;
+const uint32_t kDefaultCacheLength = 128;
 
 namespace mozilla {
 namespace a11y {
 
 class DocManager;
 class NotificationController;
 class RelatedAccIterator;
 template<class Class, class Arg>
--- a/accessible/windows/msaa/nsWinUtils.cpp
+++ b/accessible/windows/msaa/nsWinUtils.cpp
@@ -56,17 +56,17 @@ bool
 nsWinUtils::MaybeStartWindowEmulation()
 {
   // Register window class that'll be used for document accessibles associated
   // with tabs.
   if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
       Compatibility::IsDolphin() ||
       XRE_GetProcessType() == GeckoProcessType_Content) {
     RegisterNativeWindow(kClassNameTabContent);
-    sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(4);
+    sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(2);
     return true;
   }
 
   return false;
 }
 
 void
 nsWinUtils::ShutdownWindowEmulation()
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -37,17 +37,17 @@ using namespace mozilla::a11y;
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeAccessible::
   XULTreeAccessible(nsIContent* aContent, DocAccessible* aDoc,
                     nsTreeBodyFrame* aTreeFrame) :
   AccessibleWrap(aContent, aDoc),
-  mAccessibleCache(kDefaultTreeCacheSize)
+  mAccessibleCache(kDefaultTreeCacheLength)
 {
   mType = eXULTreeType;
   mGenericTypes |= eSelect;
 
   nsCOMPtr<nsITreeView> view = aTreeFrame->GetExistingView();
   mTreeView = view;
 
   mTree = nsCoreUtils::GetTreeBoxObject(aContent);
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -15,17 +15,17 @@ class nsTreeBodyFrame;
 
 namespace mozilla {
 namespace a11y {
 
 /*
  * A class the represents the XUL Tree widget.
  */
 const uint32_t kMaxTreeColumns = 100;
-const uint32_t kDefaultTreeCacheSize = 256;
+const uint32_t kDefaultTreeCacheLength = 128;
 
 /**
  * Accessible class for XUL tree element.
  */
 
 class XULTreeAccessible : public AccessibleWrap
 {
 public:
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -256,17 +256,17 @@ XULTreeGridAccessible::CreateTreeItemAcc
 // XULTreeGridRowAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeGridRowAccessible::
   XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc,
                            Accessible* aTreeAcc, nsITreeBoxObject* aTree,
                            nsITreeView* aTreeView, int32_t aRow) :
   XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow),
-  mAccessibleCache(kDefaultTreeCacheSize)
+  mAccessibleCache(kDefaultTreeCacheLength)
 {
   mGenericTypes |= eTableRow;
 }
 
 XULTreeGridRowAccessible::~XULTreeGridRowAccessible()
 {
 }
 
--- a/chrome/nsChromeRegistryChrome.cpp
+++ b/chrome/nsChromeRegistryChrome.cpp
@@ -119,18 +119,17 @@ nsChromeRegistryChrome::Init()
 {
   nsresult rv = nsChromeRegistry::Init();
   if (NS_FAILED(rv))
     return rv;
 
   mSelectedLocale = NS_LITERAL_CSTRING("en-US");
   mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");
 
-  PL_DHashTableInit(&mPackagesHash, &kTableOps,
-                    nullptr, sizeof(PackageEntry), 16);
+  PL_DHashTableInit(&mPackagesHash, &kTableOps, nullptr, sizeof(PackageEntry));
 
   bool safeMode = false;
   nsCOMPtr<nsIXULRuntime> xulrun (do_GetService(XULAPPINFO_SERVICE_CONTRACTID));
   if (xulrun)
     xulrun->GetInSafeMode(&safeMode);
 
   nsCOMPtr<nsIPrefService> prefserv (do_GetService(NS_PREFSERVICE_CONTRACTID));
   nsCOMPtr<nsIPrefBranch> prefs;
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -214,20 +214,18 @@ NS_GetContentList(nsINode* aRootNode,
     ContentListHashtableMatchEntry,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
   };
 
   // Initialize the hashtable if needed.
   if (!gContentListHashTable.ops) {
-    PL_DHashTableInit(&gContentListHashTable,
-                      &hash_table_ops, nullptr,
-                      sizeof(ContentListHashEntry),
-                      16);
+    PL_DHashTableInit(&gContentListHashTable, &hash_table_ops, nullptr,
+                      sizeof(ContentListHashEntry));
   }
 
   ContentListHashEntry *entry = nullptr;
   // First we look in our hashtable.  Then we create a content list if needed
   if (gContentListHashTable.ops) {
 
     // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases
     // when the entry is already in the hashtable.
@@ -331,20 +329,18 @@ GetFuncStringContentList(nsINode* aRootN
     FuncStringContentListHashtableMatchEntry,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
   };
 
   // Initialize the hashtable if needed.
   if (!gFuncStringContentListHashTable.ops) {
-    PL_DHashTableInit(&gFuncStringContentListHashTable,
-                      &hash_table_ops, nullptr,
-                      sizeof(FuncStringContentListHashEntry),
-                      16);
+    PL_DHashTableInit(&gFuncStringContentListHashTable, &hash_table_ops,
+                      nullptr, sizeof(FuncStringContentListHashEntry));
   }
 
   FuncStringContentListHashEntry *entry = nullptr;
   // First we look in our hashtable.  Then we create a content list if needed
   if (gFuncStringContentListHashTable.ops) {
     nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString);
 
     // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -481,17 +481,17 @@ nsContentUtils::Init()
       PL_DHashMatchEntryStub,
       PL_DHashMoveEntryStub,
       EventListenerManagerHashClearEntry,
       PL_DHashFinalizeStub,
       EventListenerManagerHashInitEntry
     };
 
     PL_DHashTableInit(&sEventListenerManagersHash, &hash_table_ops,
-                      nullptr, sizeof(EventListenerManagerMapEntry), 16);
+                      nullptr, sizeof(EventListenerManagerMapEntry));
 
     RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter());
   }
 
   sBlockedScriptRunners = new nsTArray< nsCOMPtr<nsIRunnable> >;
 
   Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
                                "dom.allow_XUL_XBL_for_file");
@@ -632,19 +632,19 @@ nsContentUtils::InitializeEventTable() {
 #define NON_IDL_EVENT EVENT
 #include "mozilla/EventNameList.h"
 #undef WINDOW_ONLY_EVENT
 #undef EVENT
     { nullptr }
   };
 
   sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>(
-      int(ArrayLength(eventArray) / 0.75) + 1);
+      ArrayLength(eventArray));
   sStringEventTable = new nsDataHashtable<nsStringHashKey, EventNameMapping>(
-      int(ArrayLength(eventArray) / 0.75) + 1);
+      ArrayLength(eventArray));
   sUserDefinedEvents = new nsCOMArray<nsIAtom>(64);
 
   // Subtract one from the length because of the trailing null
   for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) {
     sAtomEventTable->Put(eventArray[i].mAtom, eventArray[i]);
     sStringEventTable->Put(Substring(nsDependentAtomString(eventArray[i].mAtom), 2),
                            eventArray[i]);
   }
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3736,17 +3736,17 @@ nsDocument::SetSubDocumentFor(Element* a
         PL_DHashMatchEntryStub,
         PL_DHashMoveEntryStub,
         SubDocClearEntry,
         PL_DHashFinalizeStub,
         SubDocInitEntry
       };
 
       mSubDocuments = PL_NewDHashTable(&hash_table_ops, nullptr,
-                                       sizeof(SubDocMapEntry), 16);
+                                       sizeof(SubDocMapEntry));
       if (!mSubDocuments) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
     }
 
     // Add a mapping to the hash table
     SubDocMapEntry *entry =
       static_cast<SubDocMapEntry*>
@@ -6813,17 +6813,17 @@ nsDocument::GetBoxObjectFor(Element* aEl
     mHasWarnedAboutBoxObjects = true;
     nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                     NS_LITERAL_CSTRING("BoxObjects"), this,
                                     nsContentUtils::eDOM_PROPERTIES,
                                     "UseOfGetBoxObjectForWarning");
   }
 
   if (!mBoxObjectTable) {
-    mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>(12);
+    mBoxObjectTable = new nsInterfaceHashtable<nsPtrHashKey<nsIContent>, nsPIBoxObject>(6);
   } else {
     nsCOMPtr<nsPIBoxObject> boxObject = mBoxObjectTable->Get(aElement);
     if (boxObject) {
       return boxObject.forget();
     }
   }
 
   int32_t namespaceID;
--- a/content/base/src/nsPropertyTable.cpp
+++ b/content/base/src/nsPropertyTable.cpp
@@ -289,17 +289,17 @@ nsPropertyTable::PropertyList::PropertyL
                                             bool                aTransfer)
   : mName(aName),
     mDtorFunc(aDtorFunc),
     mDtorData(aDtorData),
     mTransfer(aTransfer),
     mNext(nullptr)
 {
   PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(), this,
-                    sizeof(PropertyListMapEntry), 16);
+                    sizeof(PropertyListMapEntry));
 }
 
 nsPropertyTable::PropertyList::~PropertyList()
 {
   PL_DHashTableFinish(&mObjectValueMap);
 }
 
 
--- a/content/html/content/src/HTMLFormControlsCollection.cpp
+++ b/content/html/content/src/HTMLFormControlsCollection.cpp
@@ -69,17 +69,17 @@ HTMLFormControlsCollection::ShouldBeInEl
   return false;
 }
 
 HTMLFormControlsCollection::HTMLFormControlsCollection(HTMLFormElement* aForm)
   : mForm(aForm)
   // Initialize the elements list to have an initial capacity
   // of 8 to reduce allocations on small forms.
   , mElements(8)
-  , mNameLookupTable(HTMLFormElement::FORM_CONTROL_LIST_HASHTABLE_SIZE)
+  , mNameLookupTable(HTMLFormElement::FORM_CONTROL_LIST_HASHTABLE_LENGTH)
 {
   SetIsDOMBinding();
 }
 
 HTMLFormControlsCollection::~HTMLFormControlsCollection()
 {
   mForm = nullptr;
   Clear();
--- a/content/html/content/src/HTMLFormElement.cpp
+++ b/content/html/content/src/HTMLFormElement.cpp
@@ -81,34 +81,34 @@ static const nsAttrValue::EnumTable kFor
 static const nsAttrValue::EnumTable* kFormDefaultAutocomplete = &kFormAutocompleteTable[0];
 
 bool HTMLFormElement::gFirstFormSubmitted = false;
 bool HTMLFormElement::gPasswordManagerInitialized = false;
 
 HTMLFormElement::HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
     mControls(new HTMLFormControlsCollection(MOZ_THIS_IN_INITIALIZER_LIST())),
-    mSelectedRadioButtons(4),
-    mRequiredRadioButtonCounts(4),
-    mValueMissingRadioGroups(4),
+    mSelectedRadioButtons(2),
+    mRequiredRadioButtonCounts(2),
+    mValueMissingRadioGroups(2),
     mGeneratingSubmit(false),
     mGeneratingReset(false),
     mIsSubmitting(false),
     mDeferSubmission(false),
     mNotifiedObservers(false),
     mNotifiedObserversResult(false),
     mSubmitPopupState(openAbused),
     mSubmitInitiatedFromUserInput(false),
     mPendingSubmission(nullptr),
     mSubmittingRequest(nullptr),
     mDefaultSubmitElement(nullptr),
     mFirstSubmitInElements(nullptr),
     mFirstSubmitNotInElements(nullptr),
-    mImageNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_SIZE),
-    mPastNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_SIZE),
+    mImageNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_LENGTH),
+    mPastNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_LENGTH),
     mInvalidElementsCount(0),
     mEverTriedInvalidSubmit(false)
 {
 }
 
 HTMLFormElement::~HTMLFormElement()
 {
   if (mControls) {
--- a/content/html/content/src/HTMLFormElement.h
+++ b/content/html/content/src/HTMLFormElement.h
@@ -40,17 +40,17 @@ class HTMLFormElement MOZ_FINAL : public
                                   public nsIRadioGroupContainer
 {
   friend class HTMLFormControlsCollection;
 
 public:
   HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
 
   enum {
-    FORM_CONTROL_LIST_HASHTABLE_SIZE = 16
+    FORM_CONTROL_LIST_HASHTABLE_LENGTH = 8
   };
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMHTMLFormElement
   NS_DECL_NSIDOMHTMLFORMELEMENT
 
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -792,18 +792,17 @@ XULDocument::AddBroadcastListenerFor(Ele
         PL_DHashMoveEntryStub,
         ClearBroadcasterMapEntry,
         PL_DHashFinalizeStub,
         nullptr
     };
 
     if (! mBroadcasterMap) {
         mBroadcasterMap =
-            PL_NewDHashTable(&gOps, nullptr, sizeof(BroadcasterMapEntry),
-                             PL_DHASH_MIN_SIZE);
+            PL_NewDHashTable(&gOps, nullptr, sizeof(BroadcasterMapEntry));
 
         if (! mBroadcasterMap) {
             aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
             return;
         }
     }
 
     BroadcasterMapEntry* entry =
--- a/content/xul/templates/src/nsContentSupportMap.cpp
+++ b/content/xul/templates/src/nsContentSupportMap.cpp
@@ -4,34 +4,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsContentSupportMap.h"
 #include "nsXULElement.h"
 
 void
 nsContentSupportMap::Init()
 {
-    PL_DHashTableInit(&mMap, PL_DHashGetStubOps(), nullptr,
-                      sizeof(Entry), PL_DHASH_MIN_SIZE);
+    PL_DHashTableInit(&mMap, PL_DHashGetStubOps(), nullptr, sizeof(Entry));
 }
 
 void
 nsContentSupportMap::Finish()
 {
     if (mMap.ops)
         PL_DHashTableFinish(&mMap);
 }
 
 nsresult
 nsContentSupportMap::Remove(nsIContent* aElement)
 {
     if (!mMap.ops)
         return NS_ERROR_NOT_INITIALIZED;
 
-    nsIContent* child = aElement;    
+    nsIContent* child = aElement;
     do {
         PL_DHashTableOperate(&mMap, child, PL_DHASH_REMOVE);
         child = child->GetNextNode(aElement);
     } while(child);
 
     return NS_OK;
 }
 
--- a/content/xul/templates/src/nsTemplateMap.h
+++ b/content/xul/templates/src/nsTemplateMap.h
@@ -15,17 +15,21 @@ protected:
         PLDHashEntryHdr mHdr;
         nsIContent*     mContent;
         nsIContent*     mTemplate;
     };
 
     PLDHashTable mTable;
 
     void
-    Init() { PL_DHashTableInit(&mTable, PL_DHashGetStubOps(), nullptr, sizeof(Entry), PL_DHASH_MIN_SIZE); }
+    Init()
+    {
+        PL_DHashTableInit(&mTable, PL_DHashGetStubOps(), nullptr,
+                          sizeof(Entry));
+    }
 
     void
     Finish() { PL_DHashTableFinish(&mTable); }
 
 public:
     nsTemplateMap() { Init(); }
 
     ~nsTemplateMap() { Finish(); }
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1607,17 +1607,17 @@ nsDOMWindowUtils::GetTranslationNodes(ns
   NS_ENSURE_STATE(root);
   nsCOMPtr<nsIDocument> doc = GetDocument();
   NS_ENSURE_STATE(doc);
 
   if (root->OwnerDoc() != doc) {
     return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
   }
 
-  nsTHashtable<nsPtrHashKey<nsIContent>> translationNodesHash(1000);
+  nsTHashtable<nsPtrHashKey<nsIContent>> translationNodesHash(500);
   nsRefPtr<nsTranslationNodeList> list = new nsTranslationNodeList;
 
   uint32_t limit = 15000;
 
   // We begin iteration with content->GetNextNode because we want to explictly
   // skip the root tag from being a translation node.
   nsIContent* content = root;
   while ((limit > 0) && (content = content->GetNextNode(root))) {
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -309,17 +309,17 @@ nsScriptNameSpaceManager::RegisterInterf
   }
 
   s->mType = nsGlobalNameStruct::eTypeInterface;
   s->mIID = *aIfIID;
 
   return NS_OK;
 }
 
-#define GLOBALNAME_HASHTABLE_INITIAL_SIZE	1024
+#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH   512
 
 nsresult
 nsScriptNameSpaceManager::Init()
 {
   static const PLDHashTableOps hash_table_ops =
   {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
@@ -328,24 +328,24 @@ nsScriptNameSpaceManager::Init()
     PL_DHashMoveEntryStub,
     GlobalNameHashClearEntry,
     PL_DHashFinalizeStub,
     GlobalNameHashInitEntry
   };
 
   mIsInitialized = PL_DHashTableInit(&mGlobalNames, &hash_table_ops,
                                      nullptr, sizeof(GlobalNameMapEntry),
-                                     GLOBALNAME_HASHTABLE_INITIAL_SIZE,
-                                     fallible_t());
+                                     fallible_t(),
+                                     GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
   NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_OUT_OF_MEMORY);
 
   mIsInitialized = PL_DHashTableInit(&mNavigatorNames, &hash_table_ops,
                                      nullptr, sizeof(GlobalNameMapEntry),
-                                     GLOBALNAME_HASHTABLE_INITIAL_SIZE,
-                                     fallible_t());
+                                     fallible_t(),
+                                     GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
   if (!mIsInitialized) {
     PL_DHashTableFinish(&mGlobalNames);
 
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   RegisterWeakMemoryReporter(this);
 
--- a/dom/indexedDB/Client.cpp
+++ b/dom/indexedDB/Client.cpp
@@ -56,17 +56,17 @@ Client::InitOrigin(PersistenceType aPers
     GetDirectory(aPersistenceType, aOrigin, getter_AddRefs(directory));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // We need to see if there are any files in the directory already. If they
   // are database files then we need to cleanup stored files (if it's needed)
   // and also get the usage.
 
   nsAutoTArray<nsString, 20> subdirsToProcess;
-  nsAutoTArray<nsCOMPtr<nsIFile> , 20> unknownFiles;
+  nsAutoTArray<nsCOMPtr<nsIFile>, 20> unknownFiles;
   nsTHashtable<nsStringHashKey> validSubdirs(20);
 
   nsCOMPtr<nsISimpleEnumerator> entries;
   rv = directory->GetDirectoryEntries(getter_AddRefs(entries));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasMore;
   while (NS_SUCCEEDED((rv = entries->HasMoreElements(&hasMore))) &&
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1720,17 +1720,17 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
     NS_ERROR("No npp passed to nsNPObjWrapper::GetNewOrUsed()!");
 
     return nullptr;
   }
 
   if (!sNPObjWrappers.ops) {
     // No hash yet (or any more), initialize it.
     PL_DHashTableInit(&sNPObjWrappers, PL_DHashGetStubOps(), nullptr,
-                      sizeof(NPObjWrapperHashEntry), 16);
+                      sizeof(NPObjWrapperHashEntry));
   }
 
   NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
     (PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_ADD));
 
   if (!entry) {
     // Out of memory
     JS_ReportOutOfMemory(cx);
--- a/dom/src/storage/DOMStorageManager.cpp
+++ b/dom/src/storage/DOMStorageManager.cpp
@@ -93,17 +93,17 @@ PrincipalsEqual(nsIPrincipal* aObjectPri
 
   return aSubjectPrincipal->Equals(aObjectPrincipal);
 }
 
 NS_IMPL_ISUPPORTS(DOMStorageManager,
                   nsIDOMStorageManager)
 
 DOMStorageManager::DOMStorageManager(DOMStorage::StorageType aType)
-  : mCaches(10)
+  : mCaches(8)
   , mType(aType)
   , mLowDiskSpace(false)
 {
   DOMStorageObserver* observer = DOMStorageObserver::Self();
   NS_ASSERTION(observer, "No DOMStorageObserver, cannot observe private data delete notifications!");
 
   if (observer) {
     observer->AddSink(this);
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -485,17 +485,17 @@ nsBindingManager::ExecuteDetachedHandler
 }
 
 nsresult
 nsBindingManager::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
 {
   NS_PRECONDITION(aDocumentInfo, "Must have a non-null documentinfo!");
 
   if (!mDocumentTable) {
-    mDocumentTable = new nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo>(16);
+    mDocumentTable = new nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo>();
   }
 
   mDocumentTable->Put(aDocumentInfo->DocumentURI(), aDocumentInfo);
 
   return NS_OK;
 }
 
 void
@@ -516,17 +516,18 @@ nsBindingManager::GetXBLDocumentInfo(nsI
 }
 
 nsresult
 nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener)
 {
   NS_PRECONDITION(aListener, "Must have a non-null listener!");
 
   if (!mLoadingDocTable) {
-    mLoadingDocTable = new nsInterfaceHashtable<nsURIHashKey,nsIStreamListener>(16);
+    mLoadingDocTable =
+      new nsInterfaceHashtable<nsURIHashKey,nsIStreamListener>();
   }
   mLoadingDocTable->Put(aURL, aListener);
 
   return NS_OK;
 }
 
 nsIStreamListener*
 nsBindingManager::GetLoadingDocListener(nsIURI* aURL)
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -593,28 +593,29 @@ nsXBLPrototypeBinding::GetRuleProcessor(
 
   return nullptr;
 }
 
 void
 nsXBLPrototypeBinding::EnsureAttributeTable()
 {
   if (!mAttributeTable) {
-    mAttributeTable = new nsClassHashtable<nsUint32HashKey, InnerAttributeTable>(4);
+    mAttributeTable =
+        new nsClassHashtable<nsUint32HashKey, InnerAttributeTable>(2);
   }
 }
 
 void
 nsXBLPrototypeBinding::AddToAttributeTable(int32_t aSourceNamespaceID, nsIAtom* aSourceTag,
                                            int32_t aDestNamespaceID, nsIAtom* aDestTag,
                                            nsIContent* aContent)
 {
     InnerAttributeTable* attributesNS = mAttributeTable->Get(aSourceNamespaceID);
     if (!attributesNS) {
-      attributesNS = new InnerAttributeTable(4);
+      attributesNS = new InnerAttributeTable(2);
       mAttributeTable->Put(aSourceNamespaceID, attributesNS);
     }
 
     nsXBLAttributeEntry* xblAttr =
       new nsXBLAttributeEntry(aSourceTag, aDestTag, aDestNamespaceID, aContent);
 
     nsXBLAttributeEntry* entry = attributesNS->Get(aSourceTag);
     if (!entry) {
--- a/dom/xslt/xslt/txExecutionState.h
+++ b/dom/xslt/xslt/txExecutionState.h
@@ -52,17 +52,17 @@ public:
     nsAutoPtr<txXPathNode> mDocument;
     nsresult mLoadResult;
 };
 
 class txLoadedDocumentsHash : public nsTHashtable<txLoadedDocumentEntry>
 {
 public:
     txLoadedDocumentsHash()
-        : nsTHashtable<txLoadedDocumentEntry>(8),
+        : nsTHashtable<txLoadedDocumentEntry>(4),
           mSourceDocument(nullptr)
     {
     }
     ~txLoadedDocumentsHash();
     void init(txXPathNode* aSourceDocument);
 
 private:
     friend class txExecutionState;
--- a/dom/xslt/xslt/txKey.h
+++ b/dom/xslt/xslt/txKey.h
@@ -174,17 +174,17 @@ private:
     txExpandedName mName;
 };
 
 
 class txKeyHash
 {
 public:
     txKeyHash(const txOwningExpandedNameMap<txXSLKey>& aKeys)
-        : mKeyValues(8)
+        : mKeyValues(4)
         , mIndexedKeys(1)
         , mKeys(aKeys)
     {
     }
     
     nsresult init();
 
     nsresult getKeyNodes(const txExpandedName& aKeyName,
--- a/embedding/components/commandhandler/src/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/src/nsCommandParams.cpp
@@ -37,18 +37,18 @@ nsCommandParams::nsCommandParams()
 nsCommandParams::~nsCommandParams()
 {
   PL_DHashTableFinish(&mValuesHash);
 }
 
 nsresult
 nsCommandParams::Init()
 {
-  PL_DHashTableInit(&mValuesHash, &sHashOps, (void *)this, sizeof(HashEntry), 4);
-
+  PL_DHashTableInit(&mValuesHash, &sHashOps, (void *)this,
+                    sizeof(HashEntry), 2);
   return NS_OK;
 }
 
 #if 0
 #pragma mark -
 #endif
 
 /* short getValueType (in string name); */
@@ -258,43 +258,41 @@ nsCommandParams::GetNamedEntry(const cha
   return nullptr;
 }
 
 
 nsCommandParams::HashEntry*
 nsCommandParams::GetIndexedEntry(int32_t index)
 {
   HashEntry*  entry = reinterpret_cast<HashEntry*>(mValuesHash.entryStore);
-  HashEntry*  limit = entry + PL_DHASH_TABLE_SIZE(&mValuesHash);
+  HashEntry*  limit = entry + PL_DHASH_TABLE_CAPACITY(&mValuesHash);
   uint32_t    entryCount = 0;
-  
-  do
-  {  
+
+  do {
     if (!PL_DHASH_ENTRY_IS_LIVE(entry))
       continue;
 
     if ((int32_t)entryCount == index)
       return entry;
-    
+
     entryCount ++;
   } while (++entry < limit);
 
   return nullptr;
 }
 
 
 uint32_t
 nsCommandParams::GetNumEntries()
 {
   HashEntry*  entry = reinterpret_cast<HashEntry*>(mValuesHash.entryStore);
-  HashEntry*  limit = entry + PL_DHASH_TABLE_SIZE(&mValuesHash);
+  HashEntry*  limit = entry + PL_DHASH_TABLE_CAPACITY(&mValuesHash);
   uint32_t    entryCount = 0;
-  
-  do
-  {  
+
+  do {
     if (PL_DHASH_ENTRY_IS_LIVE(entry))
       entryCount ++;
   } while (++entry < limit);
 
   return entryCount;
 }
 
 nsresult
--- a/embedding/components/commandhandler/src/nsControllerCommandTable.cpp
+++ b/embedding/components/commandhandler/src/nsControllerCommandTable.cpp
@@ -8,21 +8,21 @@
 #include "nsControllerCommandTable.h"
 
 // prototype;
 nsresult
 NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
 
 
 // this value is used to size the hash table. Just a sensible upper bound
-#define NUM_COMMANDS_BOUNDS       64
+#define NUM_COMMANDS_LENGTH       32
 
 
 nsControllerCommandTable::nsControllerCommandTable()
-: mCommandsTable(NUM_COMMANDS_BOUNDS)
+: mCommandsTable(NUM_COMMANDS_LENGTH)
 , mMutable(true)
 {
 }
 
 
 nsControllerCommandTable::~nsControllerCommandTable()
 {
 }
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -578,17 +578,17 @@ gfxDWriteFont::ProvidesGlyphWidths() con
     return !mUseSubpixelPositions ||
            (mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD);
 }
 
 int32_t
 gfxDWriteFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
 {
     if (!mGlyphWidths) {
-        mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(200);
+        mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);
     }
 
     int32_t width = -1;
     if (mGlyphWidths->Get(aGID, &width)) {
         return width;
     }
 
     width = NS_lround(MeasureGlyphWidth(aGID) * 65536.0);
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -157,17 +157,17 @@ gfxFT2Font::AddRange(const char16_t *aTe
     }
 }
 
 gfxFT2Font::gfxFT2Font(cairo_scaled_font_t *aCairoFont,
                        FT2FontEntry *aFontEntry,
                        const gfxFontStyle *aFontStyle,
                        bool aNeedsBold)
     : gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle)
-    , mCharGlyphCache(64)
+    , mCharGlyphCache(32)
 {
     NS_ASSERTION(mFontEntry, "Unable to find font entry for font.  Something is whack.");
     mApplySyntheticBold = aNeedsBold;
 }
 
 gfxFT2Font::~gfxFT2Font()
 {
 }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -668,17 +668,17 @@ gfxFontEntry::FontTableHashEntry::GetBlo
 }
 
 bool
 gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t **aBlob)
 {
     if (!mFontTableCache) {
         // we do this here rather than on fontEntry construction
         // because not all shapers will access the table cache at all
-        mFontTableCache = new nsTHashtable<FontTableHashEntry>(10);
+        mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
     }
 
     FontTableHashEntry *entry = mFontTableCache->GetEntry(aTag);
     if (!entry) {
         return false;
     }
 
     *aBlob = entry->GetBlob();
@@ -687,17 +687,17 @@ gfxFontEntry::GetExistingFontTable(uint3
 
 hb_blob_t *
 gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
                                        FallibleTArray<uint8_t>* aBuffer)
 {
     if (MOZ_UNLIKELY(!mFontTableCache)) {
         // we do this here rather than on fontEntry construction
         // because not all shapers will access the table cache at all
-      mFontTableCache = new nsTHashtable<FontTableHashEntry>(10);
+      mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
     }
 
     FontTableHashEntry *entry = mFontTableCache->PutEntry(aTag);
     if (MOZ_UNLIKELY(!entry)) { // OOM
         return nullptr;
     }
 
     if (!aBuffer) {
--- a/gfx/thebes/gfxFontFeatures.cpp
+++ b/gfx/thebes/gfxFontFeatures.cpp
@@ -5,17 +5,17 @@
 
 #include "gfxFontFeatures.h"
 #include "nsUnicharUtils.h"
 #include "nsHashKeys.h"
 
 using namespace mozilla;
 
 gfxFontFeatureValueSet::gfxFontFeatureValueSet()
-    : mFontFeatureValues(10)
+    : mFontFeatureValues(8)
 {
 }
 
 bool
 gfxFontFeatureValueSet::GetFontFeatureValuesFor(const nsAString& aFamily,
                                                 uint32_t aVariantProperty,
                                                 const nsAString& aName,
                                                 nsTArray<uint32_t>& aValues)
--- a/gfx/thebes/gfxFontconfigUtils.cpp
+++ b/gfx/thebes/gfxFontconfigUtils.cpp
@@ -308,19 +308,19 @@ gfxFontconfigUtils::NewPattern(const nsT
             AddWeakString(pattern, FC_FAMILY, family.get());
         }
     }
 
     return pattern.out();
 }
 
 gfxFontconfigUtils::gfxFontconfigUtils()
-    : mFontsByFamily(50)
-    , mFontsByFullname(50)
-    , mLangSupportTable(50)
+    : mFontsByFamily(32)
+    , mFontsByFullname(32)
+    , mLangSupportTable(32)
     , mLastConfig(nullptr)
 #ifdef MOZ_BUNDLED_FONTS
     , mBundledFontsInitialized(false)
 #endif
 {
     UpdateFontListInternal();
 }
 
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -426,17 +426,17 @@ gfxGDIFont::GetGlyph(uint32_t aUnicode, 
     // We don't support variation selector sequences or non-BMP characters
     // in the legacy bitmap, vector or postscript fonts that might use
     // this code path.
     if (aUnicode > 0xffff || aVarSelector) {
         return 0;
     }
 
     if (!mGlyphIDs) {
-        mGlyphIDs = new nsDataHashtable<nsUint32HashKey,uint32_t>(128);
+        mGlyphIDs = new nsDataHashtable<nsUint32HashKey,uint32_t>(64);
     }
 
     uint32_t gid;
     if (mGlyphIDs->Get(aUnicode, &gid)) {
         return gid;
     }
 
     wchar_t ch = aUnicode;
@@ -454,17 +454,17 @@ gfxGDIFont::GetGlyph(uint32_t aUnicode, 
     mGlyphIDs->Put(aUnicode, glyph);
     return glyph;
 }
 
 int32_t
 gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
 {
     if (!mGlyphWidths) {
-        mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(200);
+        mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);
     }
 
     int32_t width;
     if (mGlyphWidths->Get(aGID, &width)) {
         return width;
     }
 
     DCFromContext dc(aCtx);
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -567,17 +567,17 @@ GDIFontFamily::FindStyleVariations(FontI
 
 /***************************************************************
  *
  * gfxGDIFontList
  *
  */
 
 gfxGDIFontList::gfxGDIFontList()
-    : mFontSubstitutes(50)
+    : mFontSubstitutes(32)
 {
 #ifdef MOZ_BUNDLED_FONTS
     ActivateBundledFonts();
 #endif
 }
 
 static void
 RemoveCharsetFromFontSubstitute(nsAString &aName)
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -910,17 +910,17 @@ gfxFcFontSet::SortPreferredFonts(bool &a
 
     // FcDefaultSubstitute() ensures a slant on mSortPattern, but, if that ever
     // doesn't happen, Roman will be used.
     int requestedSlant = FC_SLANT_ROMAN;
     FcPatternGetInteger(mSortPattern, FC_SLANT, 0, &requestedSlant);
     double requestedSize = -1.0;
     FcPatternGetDouble(mSortPattern, FC_PIXEL_SIZE, 0, &requestedSize);
 
-    nsTHashtable<gfxFontconfigUtils::DepFcStrEntry> existingFamilies(50);
+    nsTHashtable<gfxFontconfigUtils::DepFcStrEntry> existingFamilies(32);
     FcChar8 *family;
     for (int v = 0;
          FcPatternGetString(mSortPattern,
                             FC_FAMILY, v, &family) == FcResultMatch; ++v) {
         const nsTArray< nsCountedRef<FcPattern> > *familyFonts = nullptr;
 
         // Is this an @font-face family?
         bool isUserFont = false;
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -162,18 +162,18 @@ gfxPlatformFontList::MemoryReporter::Col
                       NS_LITERAL_CSTRING("Memory used for cached font metrics and layout tables."),
                       aClosure);
     }
 
     return NS_OK;
 }
 
 gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
-    : mFontFamilies(100), mOtherFamilyNames(30),
-      mPrefFonts(10), mBadUnderlineFamilyNames(10), mSharedCmaps(16),
+    : mFontFamilies(64), mOtherFamilyNames(16),
+      mPrefFonts(8), mBadUnderlineFamilyNames(8), mSharedCmaps(8),
       mStartIndex(0), mIncrement(1), mNumFamilies(0)
 {
     mOtherFamilyNamesInitialized = false;
 
     if (aNeedFullnamePostscriptNames) {
         mExtraNames = new ExtraNames();
     }
     mFaceNameListsInitialized = false;
@@ -392,17 +392,17 @@ gfxPlatformFontList::LookupInFaceNameLis
         }
     }
 
     // lookup in name lookup tables, return null if not found
     if (!(lookup = FindFaceName(aFaceName))) {
         // names not completely initialized, so keep track of lookup misses
         if (!mFaceNameListsInitialized) {
             if (!mFaceNamesMissed) {
-                mFaceNamesMissed = new nsTHashtable<nsStringHashKey>(4);
+                mFaceNamesMissed = new nsTHashtable<nsStringHashKey>(2);
             }
             mFaceNamesMissed->PutEntry(aFaceName);
         }
     }
 
     return lookup;
 }
 
@@ -411,17 +411,17 @@ gfxPlatformFontList::PreloadNamesList()
 {
     nsAutoTArray<nsString, 10> preloadFonts;
     gfxFontUtils::GetPrefsFontList("font.preload-names-list", preloadFonts);
 
     uint32_t numFonts = preloadFonts.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
         nsAutoString key;
         GenerateFontListKey(preloadFonts[i], key);
-        
+
         // only search canonical names!
         gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
         if (familyEntry) {
             familyEntry->ReadOtherFamilyNames(this);
         }
     }
 
 }
@@ -755,17 +755,17 @@ gfxPlatformFontList::FindFamily(const ns
     if (!mOtherFamilyNamesInitialized && !IsASCII(aFamily)) {
         InitOtherFamilyNames();
         if ((familyEntry = mOtherFamilyNames.GetWeak(key)) != nullptr) {
             return CheckFamily(familyEntry);
         } else if (!mOtherFamilyNamesInitialized) {
             // localized family names load timed out, add name to list of
             // names to check after localized names are loaded
             if (!mOtherNamesMissed) {
-                mOtherNamesMissed = new nsTHashtable<nsStringHashKey>(4);
+                mOtherNamesMissed = new nsTHashtable<nsStringHashKey>(2);
             }
             mOtherNamesMissed->PutEntry(key);
         }
     }
 
     return nullptr;
 }
 
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -298,17 +298,17 @@ protected:
 
     // flag set after InitOtherFamilyNames is called upon first name lookup miss
     bool mOtherFamilyNamesInitialized;
 
     // flag set after fullname and Postcript name lists are populated
     bool mFaceNameListsInitialized;
 
     struct ExtraNames {
-      ExtraNames() : mFullnames(100), mPostscriptNames(100) {}
+      ExtraNames() : mFullnames(64), mPostscriptNames(64) {}
       // fullname ==> font entry (unique, one name per font entry)
       nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mFullnames;
       // Postscript name ==> font entry (unique, one name per font entry)
       nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mPostscriptNames;
     };
     nsAutoPtr<ExtraNames> mExtraNames;
 
     // face names missed when face name loading takes a long time
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -560,17 +560,17 @@ gfxProxyFontEntry::LoadFont(gfxMixedFont
     // The downloaded data can now be discarded; the font entry is using the
     // sanitized copy
     NS_Free((void*)aFontData);
 
     return fe;
 }
 
 gfxUserFontSet::gfxUserFontSet()
-    : mFontFamilies(5), mLocalRulesUsed(false)
+    : mFontFamilies(4), mLocalRulesUsed(false)
 {
     IncrementGeneration();
     gfxPlatformFontList *fp = gfxPlatformFontList::PlatformFontList();
     if (fp) {
         fp->AddUserFontSet(this);
     }
 }
 
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -287,17 +287,17 @@ public:
         return NS_OK;
     }
 };
 
 NS_IMPL_ISUPPORTS(GPUAdapterReporter, nsIMemoryReporter)
 
 gfxWindowsPlatform::gfxWindowsPlatform()
   : mD3D11DeviceInitialized(false)
-  , mPrefFonts(50)
+  , mPrefFonts(32)
 {
     mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
     mUseClearTypeAlways = UNINITIALIZED_VALUE;
 
     mUsingGDIFonts = false;
 
     /* 
      * Initialize COM 
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -304,19 +304,19 @@ ReportOnCaller(JSCLContextHelper &helper
     helper.reportErrorAfterPop(buf);
 
     return NS_OK;
 }
 
 mozJSComponentLoader::mozJSComponentLoader()
     : mRuntime(nullptr),
       mContext(nullptr),
-      mModules(32),
-      mImports(32),
-      mInProgressImports(32),
+      mModules(16),
+      mImports(16),
+      mInProgressImports(16),
       mInitialized(false),
       mReuseLoaderGlobal(false)
 {
     MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton");
 
 #ifdef PR_LOGGING
     if (!gJSCLLog) {
         gJSCLLog = PR_NewLogModule("JSComponentLoader");
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -3109,25 +3109,25 @@ static const JSWrapObjectCallbacks WrapO
 
 XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
    : CycleCollectedJSRuntime(nullptr, JS::DefaultHeapMaxBytes, JS::DefaultNurseryBytes),
    mJSContextStack(new XPCJSContextStack(MOZ_THIS_IN_INITIALIZER_LIST())),
    mCallContext(nullptr),
    mAutoRoots(nullptr),
    mResolveName(JSID_VOID),
    mResolvingWrapper(nullptr),
-   mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_SIZE)),
-   mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_SIZE)),
-   mIID2NativeInterfaceMap(IID2NativeInterfaceMap::newMap(XPC_NATIVE_INTERFACE_MAP_SIZE)),
-   mClassInfo2NativeSetMap(ClassInfo2NativeSetMap::newMap(XPC_NATIVE_SET_MAP_SIZE)),
-   mNativeSetMap(NativeSetMap::newMap(XPC_NATIVE_SET_MAP_SIZE)),
-   mThisTranslatorMap(IID2ThisTranslatorMap::newMap(XPC_THIS_TRANSLATOR_MAP_SIZE)),
-   mNativeScriptableSharedMap(XPCNativeScriptableSharedMap::newMap(XPC_NATIVE_JSCLASS_MAP_SIZE)),
-   mDyingWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DYING_NATIVE_PROTO_MAP_SIZE)),
-   mDetachedWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DETACHED_NATIVE_PROTO_MAP_SIZE)),
+   mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_LENGTH)),
+   mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_LENGTH)),
+   mIID2NativeInterfaceMap(IID2NativeInterfaceMap::newMap(XPC_NATIVE_INTERFACE_MAP_LENGTH)),
+   mClassInfo2NativeSetMap(ClassInfo2NativeSetMap::newMap(XPC_NATIVE_SET_MAP_LENGTH)),
+   mNativeSetMap(NativeSetMap::newMap(XPC_NATIVE_SET_MAP_LENGTH)),
+   mThisTranslatorMap(IID2ThisTranslatorMap::newMap(XPC_THIS_TRANSLATOR_MAP_LENGTH)),
+   mNativeScriptableSharedMap(XPCNativeScriptableSharedMap::newMap(XPC_NATIVE_JSCLASS_MAP_LENGTH)),
+   mDyingWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DYING_NATIVE_PROTO_MAP_LENGTH)),
+   mDetachedWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DETACHED_NATIVE_PROTO_MAP_LENGTH)),
    mGCIsRunning(false),
    mWrappedJSToReleaseArray(),
    mNativesToReleaseArray(),
    mDoingFinalization(false),
    mVariantRoots(nullptr),
    mWrappedJSRoots(nullptr),
    mObjectHolderRoots(nullptr),
    mWatchdogManager(new WatchdogManager(MOZ_THIS_IN_INITIALIZER_LIST())),
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -111,33 +111,33 @@ JSObject2WrappedJSMap::ShutdownMarker()
     }
 }
 
 /***************************************************************************/
 // implement Native2WrappedNativeMap...
 
 // static
 Native2WrappedNativeMap*
-Native2WrappedNativeMap::newMap(int size)
+Native2WrappedNativeMap::newMap(int length)
 {
-    Native2WrappedNativeMap* map = new Native2WrappedNativeMap(size);
+    Native2WrappedNativeMap* map = new Native2WrappedNativeMap(length);
     if (map && map->mTable)
         return map;
     // Allocation of the map or the creation of its hash table has
     // failed. This will cause a nullptr deref later when we attempt
     // to use the map, so we abort immediately to provide a more
     // useful crash stack.
     NS_RUNTIMEABORT("Ran out of memory.");
     return nullptr;
 }
 
-Native2WrappedNativeMap::Native2WrappedNativeMap(int size)
+Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr,
-                              sizeof(Entry), size);
+                              sizeof(Entry), length);
 }
 
 Native2WrappedNativeMap::~Native2WrappedNativeMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -168,28 +168,28 @@ const struct PLDHashTableOps IID2Wrapped
     MatchIIDPtrKey,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
 };
 
 // static
 IID2WrappedJSClassMap*
-IID2WrappedJSClassMap::newMap(int size)
+IID2WrappedJSClassMap::newMap(int length)
 {
-    IID2WrappedJSClassMap* map = new IID2WrappedJSClassMap(size);
+    IID2WrappedJSClassMap* map = new IID2WrappedJSClassMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-IID2WrappedJSClassMap::IID2WrappedJSClassMap(int size)
+IID2WrappedJSClassMap::IID2WrappedJSClassMap(int length)
 {
-    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), size);
+    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), length);
 }
 
 IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -205,28 +205,28 @@ const struct PLDHashTableOps IID2NativeI
     MatchIIDPtrKey,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
 };
 
 // static
 IID2NativeInterfaceMap*
-IID2NativeInterfaceMap::newMap(int size)
+IID2NativeInterfaceMap::newMap(int length)
 {
-    IID2NativeInterfaceMap* map = new IID2NativeInterfaceMap(size);
+    IID2NativeInterfaceMap* map = new IID2NativeInterfaceMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-IID2NativeInterfaceMap::IID2NativeInterfaceMap(int size)
+IID2NativeInterfaceMap::IID2NativeInterfaceMap(int length)
 {
-    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), size);
+    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), length);
 }
 
 IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -247,29 +247,29 @@ IID2NativeInterfaceMap::SizeOfEntryExclu
     return iface->SizeOfIncludingThis(mallocSizeOf);
 }
 
 /***************************************************************************/
 // implement ClassInfo2NativeSetMap...
 
 // static
 ClassInfo2NativeSetMap*
-ClassInfo2NativeSetMap::newMap(int size)
+ClassInfo2NativeSetMap::newMap(int length)
 {
-    ClassInfo2NativeSetMap* map = new ClassInfo2NativeSetMap(size);
+    ClassInfo2NativeSetMap* map = new ClassInfo2NativeSetMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int size)
+ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr,
-                              sizeof(Entry), size);
+                              sizeof(Entry), length);
 }
 
 ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -283,33 +283,33 @@ ClassInfo2NativeSetMap::ShallowSizeOfInc
     return n;
 }
 
 /***************************************************************************/
 // implement ClassInfo2WrappedNativeProtoMap...
 
 // static
 ClassInfo2WrappedNativeProtoMap*
-ClassInfo2WrappedNativeProtoMap::newMap(int size)
+ClassInfo2WrappedNativeProtoMap::newMap(int length)
 {
-    ClassInfo2WrappedNativeProtoMap* map = new ClassInfo2WrappedNativeProtoMap(size);
+    ClassInfo2WrappedNativeProtoMap* map = new ClassInfo2WrappedNativeProtoMap(length);
     if (map && map->mTable)
         return map;
     // Allocation of the map or the creation of its hash table has
     // failed. This will cause a nullptr deref later when we attempt
     // to use the map, so we abort immediately to provide a more
     // useful crash stack.
     NS_RUNTIMEABORT("Ran out of memory.");
     return nullptr;
 }
 
-ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int size)
+ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr,
-                              sizeof(Entry), size);
+                              sizeof(Entry), length);
 }
 
 ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -412,28 +412,28 @@ const struct PLDHashTableOps NativeSetMa
     Match,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
 };
 
 // static
 NativeSetMap*
-NativeSetMap::newMap(int size)
+NativeSetMap::newMap(int length)
 {
-    NativeSetMap* map = new NativeSetMap(size);
+    NativeSetMap* map = new NativeSetMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-NativeSetMap::NativeSetMap(int size)
+NativeSetMap::NativeSetMap(int length)
 {
-    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), size);
+    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), length);
 }
 
 NativeSetMap::~NativeSetMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -479,28 +479,28 @@ const struct PLDHashTableOps IID2ThisTra
     Match,
     PL_DHashMoveEntryStub,
     Clear,
     PL_DHashFinalizeStub
 };
 
 // static
 IID2ThisTranslatorMap*
-IID2ThisTranslatorMap::newMap(int size)
+IID2ThisTranslatorMap::newMap(int length)
 {
-    IID2ThisTranslatorMap* map = new IID2ThisTranslatorMap(size);
+    IID2ThisTranslatorMap* map = new IID2ThisTranslatorMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-IID2ThisTranslatorMap::IID2ThisTranslatorMap(int size)
+IID2ThisTranslatorMap::IID2ThisTranslatorMap(int length)
 {
-    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), size);
+    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), length);
 }
 
 IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -559,29 +559,29 @@ const struct PLDHashTableOps XPCNativeSc
     Match,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
 };
 
 // static
 XPCNativeScriptableSharedMap*
-XPCNativeScriptableSharedMap::newMap(int size)
+XPCNativeScriptableSharedMap::newMap(int length)
 {
     XPCNativeScriptableSharedMap* map =
-        new XPCNativeScriptableSharedMap(size);
+        new XPCNativeScriptableSharedMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int size)
+XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int length)
 {
-    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), size);
+    mTable = PL_NewDHashTable(&Entry::sOps, nullptr, sizeof(Entry), length);
 }
 
 XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
@@ -614,29 +614,29 @@ XPCNativeScriptableSharedMap::GetNewOrUs
     return true;
 }
 
 /***************************************************************************/
 // implement XPCWrappedNativeProtoMap...
 
 // static
 XPCWrappedNativeProtoMap*
-XPCWrappedNativeProtoMap::newMap(int size)
+XPCWrappedNativeProtoMap::newMap(int length)
 {
-    XPCWrappedNativeProtoMap* map = new XPCWrappedNativeProtoMap(size);
+    XPCWrappedNativeProtoMap* map = new XPCWrappedNativeProtoMap(length);
     if (map && map->mTable)
         return map;
     delete map;
     return nullptr;
 }
 
-XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int size)
+XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), nullptr,
-                              sizeof(PLDHashEntryStub), size);
+                              sizeof(PLDHashEntryStub), length);
 }
 
 XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
 {
     if (mTable)
         PL_DHashTableDestroy(mTable);
 }
 
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -25,19 +25,19 @@
 /*************************/
 
 class JSObject2WrappedJSMap
 {
     typedef js::HashMap<JSObject*, nsXPCWrappedJS*, js::PointerHasher<JSObject*, 3>,
                         js::SystemAllocPolicy> Map;
 
 public:
-    static JSObject2WrappedJSMap* newMap(int size) {
+    static JSObject2WrappedJSMap* newMap(int length) {
         JSObject2WrappedJSMap* map = new JSObject2WrappedJSMap();
-        if (map && map->mTable.init(size))
+        if (map && map->mTable.init(length))
             return map;
         delete map;
         return nullptr;
     }
 
     inline nsXPCWrappedJS* Find(JSObject* Obj) {
         NS_PRECONDITION(Obj,"bad param");
         Map::Ptr p = mTable.lookup(Obj);
@@ -101,17 +101,17 @@ class Native2WrappedNativeMap
 {
 public:
     struct Entry : public PLDHashEntryHdr
     {
         nsISupports*      key;
         XPCWrappedNative* value;
     };
 
-    static Native2WrappedNativeMap* newMap(int size);
+    static Native2WrappedNativeMap* newMap(int length);
 
     inline XPCWrappedNative* Find(nsISupports* Obj)
     {
         NS_PRECONDITION(Obj,"bad param");
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, Obj, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
@@ -172,17 +172,17 @@ public:
     struct Entry : public PLDHashEntryHdr
     {
         const nsIID*         key;
         nsXPCWrappedJSClass* value;
 
         static const struct PLDHashTableOps sOps;
     };
 
-    static IID2WrappedJSClassMap* newMap(int size);
+    static IID2WrappedJSClassMap* newMap(int length);
 
     inline nsXPCWrappedJSClass* Find(REFNSIID iid)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, &iid, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->value;
@@ -229,17 +229,17 @@ public:
     struct Entry : public PLDHashEntryHdr
     {
         const nsIID*        key;
         XPCNativeInterface* value;
 
         static const struct PLDHashTableOps sOps;
     };
 
-    static IID2NativeInterfaceMap* newMap(int size);
+    static IID2NativeInterfaceMap* newMap(int length);
 
     inline XPCNativeInterface* Find(REFNSIID iid)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, &iid, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->value;
@@ -289,17 +289,17 @@ class ClassInfo2NativeSetMap
 {
 public:
     struct Entry : public PLDHashEntryHdr
     {
         nsIClassInfo* key;
         XPCNativeSet* value;
     };
 
-    static ClassInfo2NativeSetMap* newMap(int size);
+    static ClassInfo2NativeSetMap* newMap(int length);
 
     inline XPCNativeSet* Find(nsIClassInfo* info)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, info, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->value;
@@ -349,17 +349,17 @@ class ClassInfo2WrappedNativeProtoMap
 {
 public:
     struct Entry : public PLDHashEntryHdr
     {
         nsIClassInfo*          key;
         XPCWrappedNativeProto* value;
     };
 
-    static ClassInfo2WrappedNativeProtoMap* newMap(int size);
+    static ClassInfo2WrappedNativeProtoMap* newMap(int length);
 
     inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, info, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->value;
@@ -414,17 +414,17 @@ public:
         static bool
         Match(PLDHashTable *table,
               const PLDHashEntryHdr *entry,
               const void *key);
 
         static const struct PLDHashTableOps sOps;
     };
 
-    static NativeSetMap* newMap(int size);
+    static NativeSetMap* newMap(int length);
 
     inline XPCNativeSet* Find(XPCNativeSetKey* key)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, key, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->key_value;
@@ -491,17 +491,17 @@ public:
               const void *key);
 
         static void
         Clear(PLDHashTable *table, PLDHashEntryHdr *entry);
 
         static const struct PLDHashTableOps sOps;
     };
 
-    static IID2ThisTranslatorMap* newMap(int size);
+    static IID2ThisTranslatorMap* newMap(int length);
 
     inline nsIXPCFunctionThisTranslator* Find(REFNSIID iid)
     {
         Entry* entry = (Entry*)
             PL_DHashTableOperate(mTable, &iid, PL_DHASH_LOOKUP);
         if (PL_DHASH_ENTRY_IS_FREE(entry))
             return nullptr;
         return entry->value;
@@ -552,17 +552,17 @@ public:
         static bool
         Match(PLDHashTable *table,
               const PLDHashEntryHdr *entry,
               const void *key);
 
         static const struct PLDHashTableOps sOps;
     };
 
-    static XPCNativeScriptableSharedMap* newMap(int size);
+    static XPCNativeScriptableSharedMap* newMap(int length);
 
     bool GetNewOrUsed(uint32_t flags, char* name, uint32_t interfacesBitmap,
                       XPCNativeScriptableInfo* si);
 
     inline uint32_t Count() {return mTable->entryCount;}
     inline uint32_t Enumerate(PLDHashEnumerator f, void *arg)
         {return PL_DHashTableEnumerate(mTable, f, arg);}
 
@@ -574,17 +574,17 @@ private:
     PLDHashTable *mTable;
 };
 
 /***************************************************************************/
 
 class XPCWrappedNativeProtoMap
 {
 public:
-    static XPCWrappedNativeProtoMap* newMap(int size);
+    static XPCWrappedNativeProtoMap* newMap(int length);
 
     inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto)
     {
         NS_PRECONDITION(proto,"bad param");
         PLDHashEntryStub* entry = (PLDHashEntryStub*)
             PL_DHashTableOperate(mTable, proto, PL_DHASH_ADD);
         if (!entry)
             return nullptr;
@@ -615,19 +615,19 @@ private:
 /***************************************************************************/
 
 class JSObject2JSObjectMap
 {
     typedef js::HashMap<JSObject *, JS::Heap<JSObject *>, js::PointerHasher<JSObject *, 3>,
                         js::SystemAllocPolicy> Map;
 
 public:
-    static JSObject2JSObjectMap* newMap(int size) {
+    static JSObject2JSObjectMap* newMap(int length) {
         JSObject2JSObjectMap* map = new JSObject2JSObjectMap();
-        if (map && map->mTable.init(size))
+        if (map && map->mTable.init(length))
             return map;
         delete map;
         return nullptr;
     }
 
     inline JSObject* Find(JSObject* key) {
         NS_PRECONDITION(key, "bad param");
         if (Map::Ptr p = mTable.lookup(key))
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -72,18 +72,18 @@ RemoteXULForbidsXBLScope(nsIPrincipal *a
       return false;
 
   // Check the pref to determine how we should behave.
   return !Preferences::GetBool("dom.use_xbl_scopes_for_remote_xul", false);
 }
 
 XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext *cx,
                                              JS::HandleObject aGlobal)
-      : mWrappedNativeMap(Native2WrappedNativeMap::newMap(XPC_NATIVE_MAP_SIZE)),
-        mWrappedNativeProtoMap(ClassInfo2WrappedNativeProtoMap::newMap(XPC_NATIVE_PROTO_MAP_SIZE)),
+      : mWrappedNativeMap(Native2WrappedNativeMap::newMap(XPC_NATIVE_MAP_LENGTH)),
+        mWrappedNativeProtoMap(ClassInfo2WrappedNativeProtoMap::newMap(XPC_NATIVE_PROTO_MAP_LENGTH)),
         mComponents(nullptr),
         mNext(nullptr),
         mGlobalJSObject(aGlobal),
         mIsContentXBLScope(false),
         mIsAddonScope(false)
 {
     // add ourselves to the scopes list
     {
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -170,30 +170,30 @@
 #endif
 #endif /* XP_WIN */
 
 #include "nsINode.h"
 
 /***************************************************************************/
 // default initial sizes for maps (hashtables)
 
-#define XPC_CONTEXT_MAP_SIZE                16
-#define XPC_JS_MAP_SIZE                     64
-#define XPC_JS_CLASS_MAP_SIZE               64
-
-#define XPC_NATIVE_MAP_SIZE                 64
-#define XPC_NATIVE_PROTO_MAP_SIZE           16
-#define XPC_DYING_NATIVE_PROTO_MAP_SIZE     16
-#define XPC_DETACHED_NATIVE_PROTO_MAP_SIZE  32
-#define XPC_NATIVE_INTERFACE_MAP_SIZE       64
-#define XPC_NATIVE_SET_MAP_SIZE             64
-#define XPC_NATIVE_JSCLASS_MAP_SIZE         32
-#define XPC_THIS_TRANSLATOR_MAP_SIZE         8
-#define XPC_NATIVE_WRAPPER_MAP_SIZE         16
-#define XPC_WRAPPER_MAP_SIZE                16
+#define XPC_CONTEXT_MAP_LENGTH                   8
+#define XPC_JS_MAP_LENGTH                       32
+#define XPC_JS_CLASS_MAP_LENGTH                 32
+
+#define XPC_NATIVE_MAP_LENGTH                   32
+#define XPC_NATIVE_PROTO_MAP_LENGTH              8
+#define XPC_DYING_NATIVE_PROTO_MAP_LENGTH        8
+#define XPC_DETACHED_NATIVE_PROTO_MAP_LENGTH    16
+#define XPC_NATIVE_INTERFACE_MAP_LENGTH         32
+#define XPC_NATIVE_SET_MAP_LENGTH               32
+#define XPC_NATIVE_JSCLASS_MAP_LENGTH           16
+#define XPC_THIS_TRANSLATOR_MAP_LENGTH           4
+#define XPC_NATIVE_WRAPPER_MAP_LENGTH            8
+#define XPC_WRAPPER_MAP_LENGTH                   8
 
 /***************************************************************************/
 // data declarations...
 extern const char XPC_CONTEXT_STACK_CONTRACTID[];
 extern const char XPC_RUNTIME_CONTRACTID[];
 extern const char XPC_EXCEPTION_CONTRACTID[];
 extern const char XPC_CONSOLE_CONTRACTID[];
 extern const char XPC_SCRIPT_ERROR_CONTRACTID[];
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -81,17 +81,17 @@ WrapperFactory::CreateXrayWaiver(JSConte
                                     &XrayWaiver);
     if (!waiver)
         return nullptr;
 
     // Add the new waiver to the map. It's important that we only ever have
     // one waiver for the lifetime of the target object.
     if (!scope->mWaiverWrapperMap) {
         scope->mWaiverWrapperMap =
-          JSObject2JSObjectMap::newMap(XPC_WRAPPER_MAP_SIZE);
+          JSObject2JSObjectMap::newMap(XPC_WRAPPER_MAP_LENGTH);
         MOZ_ASSERT(scope->mWaiverWrapperMap);
     }
     if (!scope->mWaiverWrapperMap->Add(cx, obj, waiver))
         return nullptr;
     return waiver;
 }
 
 JSObject *
--- a/layout/base/nsCounterManager.cpp
+++ b/layout/base/nsCounterManager.cpp
@@ -194,17 +194,17 @@ nsCounterList::RecalcAll()
                 useNode->GetText(text);
                 useNode->mText->SetData(text);
             }
         }
     } while ((node = Next(node)) != First());
 }
 
 nsCounterManager::nsCounterManager()
-    : mNames(16)
+    : mNames()
 {
 }
 
 bool
 nsCounterManager::AddCounterResetsAndIncrements(nsIFrame *aFrame)
 {
     const nsStyleContent *styleContent = aFrame->StyleContent();
     if (!styleContent->CounterIncrementCount() &&
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -166,17 +166,17 @@ nsFrameManager::GetPlaceholderFrameFor(c
 nsresult
 nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
 {
   NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
   NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
                   "unexpected frame type");
   if (!mPlaceholderMap.ops) {
     PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps, nullptr,
-                      sizeof(PlaceholderMapEntry), 16);
+                      sizeof(PlaceholderMapEntry));
   }
   PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>(PL_DHashTableOperate(&mPlaceholderMap,
                               aPlaceholderFrame->GetOutOfFlowFrame(),
                               PL_DHASH_ADD));
   if (!entry)
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ASSERTION(!entry->placeholderFrame, "Registering a placeholder for a frame that already has a placeholder!");
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -568,18 +568,18 @@ TextOverflow::ProcessLine(const nsDispla
 {
   NS_ASSERTION(mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
                mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP,
                "TextOverflow with 'clip' for both sides");
   mLeft.Reset();
   mLeft.mActive = mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP;
   mRight.Reset();
   mRight.mActive = mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP;
-  
-  FrameHashtable framesToHide(100);
+
+  FrameHashtable framesToHide(64);
   AlignmentEdges alignmentEdges;
   ExamineLineFrames(aLine, &framesToHide, &alignmentEdges);
   bool needLeft = mLeft.IsNeeded();
   bool needRight = mRight.IsNeeded();
   if (!needLeft && !needRight) {
     return;
   }
   NS_ASSERTION(mLeft.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
--- a/layout/generic/nsLineBox.h
+++ b/layout/generic/nsLineBox.h
@@ -337,19 +337,19 @@ private:
    */
   void NoteFramesMovedFrom(nsLineBox* aFromLine);
 
   void SwitchToHashtable()
   {
     MOZ_ASSERT(!mFlags.mHasHashedFrames);
     uint32_t count = GetChildCount();
     mFlags.mHasHashedFrames = 1;
-    uint32_t minSize =
-      std::max(kMinChildCountForHashtable, uint32_t(PL_DHASH_MIN_SIZE));
-    mFrames = new nsTHashtable< nsPtrHashKey<nsIFrame> >(std::max(count, minSize));
+    uint32_t minLength = std::max(kMinChildCountForHashtable,
+                                  uint32_t(PL_DHASH_DEFAULT_INITIAL_LENGTH));
+    mFrames = new nsTHashtable< nsPtrHashKey<nsIFrame> >(std::max(count, minLength));
     for (nsIFrame* f = mFirstChild; count-- > 0; f = f->GetNextSibling()) {
       mFrames->PutEntry(f);
     }
   }
   void SwitchToCounter() {
     MOZ_ASSERT(mFlags.mHasHashedFrames);
     uint32_t count = GetChildCount();
     delete mFrames;
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -360,17 +360,17 @@ struct KeyframeDataComparator {
   }
   bool LessThan(const KeyframeData& A, const KeyframeData& B) const {
     return A.mKey < B.mKey || (A.mKey == B.mKey && A.mIndex < B.mIndex);
   }
 };
 
 class ResolvedStyleCache {
 public:
-  ResolvedStyleCache() : mCache(16) {}
+  ResolvedStyleCache() : mCache() {}
   nsStyleContext* Get(nsPresContext *aPresContext,
                       nsStyleContext *aParentStyleContext,
                       nsCSSKeyframeRule *aKeyframe);
 
 private:
   nsRefPtrHashtable<nsPtrHashKey<nsCSSKeyframeRule>, nsStyleContext> mCache;
 };
 
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -110,33 +110,33 @@ enum {
 static nsCSSProperty gAliases[eCSSAliasCount != 0 ? eCSSAliasCount : 1] = {
 #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)  \
   eCSSProperty_##propid_ ,
 #include "nsCSSPropAliasList.h"
 #undef CSS_PROP_ALIAS
 };
 
 nsStaticCaseInsensitiveNameTable*
-CreateStaticTable(const char* const aRawTable[], int32_t aSize)
+CreateStaticTable(const char* const aRawTable[], int32_t aLength)
 {
   auto table = new nsStaticCaseInsensitiveNameTable();
   if (table) {
 #ifdef DEBUG
     // let's verify the table...
-    for (int32_t index = 0; index < aSize; ++index) {
+    for (int32_t index = 0; index < aLength; ++index) {
       nsAutoCString temp1(aRawTable[index]);
       nsAutoCString temp2(aRawTable[index]);
       ToLowerCase(temp1);
       NS_ABORT_IF_FALSE(temp1.Equals(temp2),
                         "upper case char in case insensitive name table");
       NS_ABORT_IF_FALSE(-1 == temp1.FindChar('_'),
                         "underscore char in case insensitive name table");
     }
 #endif
-    table->Init(aRawTable, aSize);
+    table->Init(aRawTable, aLength);
   }
   return table;
 }
 
 void
 nsCSSProps::AddRefTable(void)
 {
   if (0 == gPropertyTableRefCount++) {
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -626,49 +626,49 @@ void RuleHash::AppendRule(const RuleSele
   if (selector->IsPseudoElement()) {
     selector = selector->mNext;
   }
   if (nullptr != selector->mIDList) {
     if (!mIdTable.ops) {
       PL_DHashTableInit(&mIdTable,
                         mQuirksMode ? &RuleHash_IdTable_CIOps.ops
                                     : &RuleHash_IdTable_CSOps.ops,
-                        nullptr, sizeof(RuleHashTableEntry), 16);
+                        nullptr, sizeof(RuleHashTableEntry));
     }
     AppendRuleToTable(&mIdTable, selector->mIDList->mAtom, aRuleInfo);
     RULE_HASH_STAT_INCREMENT(mIdSelectors);
   }
   else if (nullptr != selector->mClassList) {
     if (!mClassTable.ops) {
       PL_DHashTableInit(&mClassTable,
                         mQuirksMode ? &RuleHash_ClassTable_CIOps.ops
                                     : &RuleHash_ClassTable_CSOps.ops,
-                        nullptr, sizeof(RuleHashTableEntry), 16);
+                        nullptr, sizeof(RuleHashTableEntry));
     }
     AppendRuleToTable(&mClassTable, selector->mClassList->mAtom, aRuleInfo);
     RULE_HASH_STAT_INCREMENT(mClassSelectors);
   }
   else if (selector->mLowercaseTag) {
     RuleValue ruleValue(aRuleInfo, mRuleCount++, mQuirksMode);
     if (!mTagTable.ops) {
       PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops, nullptr,
-                        sizeof(RuleHashTagTableEntry), 16);
+                        sizeof(RuleHashTagTableEntry));
     }
     AppendRuleToTagTable(&mTagTable, selector->mLowercaseTag, ruleValue);
     RULE_HASH_STAT_INCREMENT(mTagSelectors);
     if (selector->mCasedTag &&
         selector->mCasedTag != selector->mLowercaseTag) {
       AppendRuleToTagTable(&mTagTable, selector->mCasedTag, ruleValue);
       RULE_HASH_STAT_INCREMENT(mTagSelectors);
     }
   }
   else if (kNameSpaceID_Unknown != selector->mNameSpace) {
     if (!mNameSpaceTable.ops) {
       PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops, nullptr,
-                        sizeof(RuleHashTableEntry), 16);
+                        sizeof(RuleHashTableEntry));
     }
     AppendRuleToTable(&mNameSpaceTable,
                       NS_INT32_TO_PTR(selector->mNameSpace), aRuleInfo);
     RULE_HASH_STAT_INCREMENT(mNameSpaceSelectors);
   }
   else {  // universal tag selector
     AppendUniversalRule(aRuleInfo);
     RULE_HASH_STAT_INCREMENT(mUniversalSelectors);
@@ -920,40 +920,40 @@ static const RuleHashTableOps AtomSelect
 
 //--------------------------------
 
 struct RuleCascadeData {
   RuleCascadeData(nsIAtom *aMedium, bool aQuirksMode)
     : mRuleHash(aQuirksMode),
       mStateSelectors(),
       mSelectorDocumentStates(0),
-      mKeyframesRuleTable(16),
-      mCounterStyleRuleTable(16),
+      mKeyframesRuleTable(),
+      mCounterStyleRuleTable(),
       mCacheKey(aMedium),
       mNext(nullptr),
       mQuirksMode(aQuirksMode)
   {
     // mAttributeSelectors is matching on the attribute _name_, not the value,
     // and we case-fold names at parse-time, so this is a case-sensitive match.
     PL_DHashTableInit(&mAttributeSelectors, &AtomSelector_CSOps, nullptr,
-                      sizeof(AtomSelectorEntry), 16);
+                      sizeof(AtomSelectorEntry));
     PL_DHashTableInit(&mAnonBoxRules, &RuleHash_TagTable_Ops, nullptr,
-                      sizeof(RuleHashTagTableEntry), 16);
+                      sizeof(RuleHashTagTableEntry));
     PL_DHashTableInit(&mIdSelectors,
                       aQuirksMode ? &AtomSelector_CIOps.ops :
                                     &AtomSelector_CSOps,
-                      nullptr, sizeof(AtomSelectorEntry), 16);
+                      nullptr, sizeof(AtomSelectorEntry));
     PL_DHashTableInit(&mClassSelectors,
                       aQuirksMode ? &AtomSelector_CIOps.ops :
                                     &AtomSelector_CSOps,
-                      nullptr, sizeof(AtomSelectorEntry), 16);
+                      nullptr, sizeof(AtomSelectorEntry));
     memset(mPseudoElementRuleHashes, 0, sizeof(mPseudoElementRuleHashes));
 #ifdef MOZ_XUL
     PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops, nullptr,
-                      sizeof(RuleHashTagTableEntry), 16);
+                      sizeof(RuleHashTagTableEntry));
 #endif
   }
 
   ~RuleCascadeData()
   {
     PL_DHashTableFinish(&mAttributeSelectors);
     PL_DHashTableFinish(&mAnonBoxRules);
     PL_DHashTableFinish(&mIdSelectors);
@@ -3275,17 +3275,17 @@ struct CascadeEnumData {
       mKeyframesRules(aKeyframesRules),
       mFontFeatureValuesRules(aFontFeatureValuesRules),
       mPageRules(aPageRules),
       mCounterStyleRules(aCounterStyleRules),
       mCacheKey(aKey),
       mSheetType(aSheetType)
   {
     if (!PL_DHashTableInit(&mRulesByWeight, &gRulesByWeightOps, nullptr,
-                           sizeof(RuleByWeightEntry), 64, fallible_t()))
+                           sizeof(RuleByWeightEntry), fallible_t(), 32))
       mRulesByWeight.ops = nullptr;
 
     // Initialize our arena
     PL_INIT_ARENA_POOL(&mArena, "CascadeEnumDataArena",
                        NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE);
   }
 
   ~CascadeEnumData()
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -474,17 +474,17 @@ nsHTMLStyleSheet::SetVisitedLinkColor(ns
   return ImplLinkColorSetter(mVisitedRule, aColor);
 }
 
 already_AddRefed<nsMappedAttributes>
 nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped)
 {
   if (!mMappedAttrTable.ops) {
     PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops,
-                      nullptr, sizeof(MappedAttrTableEntry), 16);
+                      nullptr, sizeof(MappedAttrTableEntry));
   }
   MappedAttrTableEntry *entry = static_cast<MappedAttrTableEntry*>
                                            (PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_ADD));
   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;
@@ -508,17 +508,17 @@ nsHTMLStyleSheet::DropMappedAttributes(n
   NS_ASSERTION(entryCount == mMappedAttrTable.entryCount, "not removed");
 }
 
 nsIStyleRule*
 nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage)
 {
   if (!mLangRuleTable.ops) {
     PL_DHashTableInit(&mLangRuleTable, &LangRuleTable_Ops,
-                      nullptr, sizeof(LangRuleTableEntry), 16);
+                      nullptr, sizeof(LangRuleTableEntry));
   }
   LangRuleTableEntry *entry = static_cast<LangRuleTableEntry*>
     (PL_DHashTableOperate(&mLangRuleTable, &aLanguage, PL_DHASH_ADD));
   if (!entry) {
     NS_ASSERTION(false, "out of memory");
     return nullptr;
   }
   return entry->mRule;
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1506,17 +1506,17 @@ nsRuleNode::Transition(nsIStyleRule* aRu
     nsRuleNode* curr = ChildrenList();
     while (curr && curr->GetKey() != key) {
       curr = curr->mNextSibling;
       ++numKids;
     }
     if (curr)
       next = curr;
     else if (numKids >= kMaxChildrenInList)
-      ConvertChildrenToHash();
+      ConvertChildrenToHash(numKids);
   }
 
   if (ChildrenAreHashed()) {
     ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>
                                           (PL_DHashTableOperate(ChildrenHash(), &key, PL_DHASH_ADD));
     if (!entry) {
       NS_WARNING("out of memory");
       return this;
@@ -1567,23 +1567,23 @@ void nsRuleNode::SetUsedDirectly()
         NS_ASSERTION(data, "unexpected null struct");
         mStyleData.SetStyleData(sid, mPresContext, data);
       }
     }
   }
 }
 
 void
-nsRuleNode::ConvertChildrenToHash()
+nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
 {
   NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
                "must have a non-empty list of children");
   PLDHashTable *hash = PL_NewDHashTable(&ChildrenHashOps, nullptr,
                                         sizeof(ChildrenHashEntry),
-                                        kMaxChildrenInList * 4);
+                                        aNumKids);
   if (!hash)
     return;
   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_DHashTableOperate(hash, curr->mRule, PL_DHASH_ADD));
     NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
     entry->mRuleNode = curr;
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -368,17 +368,17 @@ private:
                  "pointer not 2-byte aligned");
     mChildren.asList = aList;
   }
   void SetChildrenHash(PLDHashTable *aHashtable) {
     NS_ASSERTION(!(intptr_t(aHashtable) & kTypeMask),
                  "pointer not 2-byte aligned");
     mChildren.asHash = (PLDHashTable*)(intptr_t(aHashtable) | kHashType);
   }
-  void ConvertChildrenToHash();
+  void ConvertChildrenToHash(int32_t aNumKids);
 
   nsCachedStyleData mStyleData;   // Any data we cached on the rule node.
 
   uint32_t mDependentBits; // Used to cache the fact that we can look up
                            // cached data under a parent rule.
 
   uint32_t mNoneBits; // Used to cache the fact that the branch to this
                       // node specifies no non-inherited data for a
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -274,17 +274,17 @@ protected:
  * InvalidateAll must be called before this object is destroyed, i.e.
  * before the referenced frame is destroyed. This should normally happen
  * via nsSVGContainerFrame::RemoveFrame, since only frames in the frame
  * tree should be referenced.
  */
 class nsSVGRenderingObserverList {
 public:
   nsSVGRenderingObserverList()
-    : mObservers(5)
+    : mObservers(4)
   {
     MOZ_COUNT_CTOR(nsSVGRenderingObserverList);
   }
 
   ~nsSVGRenderingObserverList() {
     InvalidateAll();
     MOZ_COUNT_DTOR(nsSVGRenderingObserverList);
   }
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -384,17 +384,17 @@ nsSVGFilterInstance::BuildPrimitives(nsT
     nsRefPtr<nsSVGFE> primitive;
     CallQueryInterface(child, (nsSVGFE**)getter_AddRefs(primitive));
     if (primitive) {
       primitives.AppendElement(primitive);
     }
   }
 
   // Maps source image name to source index.
-  nsDataHashtable<nsStringHashKey, int32_t> imageTable(10);
+  nsDataHashtable<nsStringHashKey, int32_t> imageTable(8);
 
   // The principal that we check principals of any loaded images against.
   nsCOMPtr<nsIPrincipal> principal = mTargetFrame->GetContent()->NodePrincipal();
 
   for (uint32_t primitiveElementIndex = 0;
        primitiveElementIndex < primitives.Length();
        ++primitiveElementIndex) {
     nsSVGFE* filter = primitives[primitiveElementIndex];
--- a/layout/tables/SpanningCellSorter.cpp
+++ b/layout/tables/SpanningCellSorter.cpp
@@ -72,17 +72,17 @@ SpanningCellSorter::AddCell(int32_t aCol
 
     if (UseArrayForSpan(aColSpan)) {
         int32_t index = SpanToIndex(aColSpan);
         i->next = mArray[index];
         mArray[index] = i;
     } else {
         if (!mHashTable.entryCount) {
             PL_DHashTableInit(&mHashTable, &HashTableOps, nullptr,
-                              sizeof(HashTableEntry), PL_DHASH_MIN_SIZE);
+                              sizeof(HashTableEntry));
         }
         HashTableEntry *entry = static_cast<HashTableEntry*>
                                            (PL_DHashTableOperate(&mHashTable, NS_INT32_TO_PTR(aColSpan),
                                  PL_DHASH_ADD));
         NS_ENSURE_TRUE(entry, false);
 
         NS_ASSERTION(entry->mColSpan == 0 || entry->mColSpan == aColSpan,
                      "wrong entry");
--- a/layout/xul/nsBoxObject.cpp
+++ b/layout/xul/nsBoxObject.cpp
@@ -266,31 +266,31 @@ nsBoxObject::GetHeight(int32_t* aResult)
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetScreenX(int32_t *_retval)
 {
   nsIntPoint position;
   nsresult rv = GetScreenPosition(position);
   if (NS_FAILED(rv)) return rv;
-  
+
   *_retval = position.x;
-  
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetScreenY(int32_t *_retval)
 {
   nsIntPoint position;
   nsresult rv = GetScreenPosition(position);
   if (NS_FAILED(rv)) return rv;
-  
+
   *_retval = position.y;
-  
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::GetPropertyAsSupports(const char16_t* aPropertyName, nsISupports** aResult)
 {
   NS_ENSURE_ARG(aPropertyName && *aPropertyName);
   if (!mPropertyTable) {
@@ -301,19 +301,19 @@ nsBoxObject::GetPropertyAsSupports(const
   mPropertyTable->Get(propertyName, aResult); // Addref here.
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBoxObject::SetPropertyAsSupports(const char16_t* aPropertyName, nsISupports* aValue)
 {
   NS_ENSURE_ARG(aPropertyName && *aPropertyName);
-  
-  if (!mPropertyTable) {  
-    mPropertyTable = new nsInterfaceHashtable<nsStringHashKey,nsISupports>(8);
+
+  if (!mPropertyTable) {
+    mPropertyTable = new nsInterfaceHashtable<nsStringHashKey,nsISupports>(4);
   }
 
   nsDependentString propertyName(aPropertyName);
   mPropertyTable->Put(propertyName, aValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -324,35 +324,35 @@ nsBoxObject::GetProperty(const char16_t*
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!data) {
     *aResult = nullptr;
     return NS_OK;
   }
 
   nsCOMPtr<nsISupportsString> supportsStr = do_QueryInterface(data);
-  if (!supportsStr) 
+  if (!supportsStr)
     return NS_ERROR_FAILURE;
-  
+
   return supportsStr->ToString(aResult);
 }
 
 NS_IMETHODIMP
 nsBoxObject::SetProperty(const char16_t* aPropertyName, const char16_t* aPropertyValue)
 {
   NS_ENSURE_ARG(aPropertyName && *aPropertyName);
 
   nsDependentString propertyName(aPropertyName);
   nsDependentString propertyValue;
   if (aPropertyValue) {
     propertyValue.Rebind(aPropertyValue);
   } else {
     propertyValue.SetIsVoid(true);
   }
-  
+
   nsCOMPtr<nsISupportsString> supportsStr(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
   NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
   supportsStr->SetData(propertyValue);
 
   return SetPropertyAsSupports(aPropertyName,supportsStr);
 }
 
 NS_IMETHODIMP
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -106,17 +106,17 @@ NS_QUERYFRAME_HEAD(nsTreeBodyFrame)
   NS_QUERYFRAME_ENTRY(nsIScrollbarOwner)
   NS_QUERYFRAME_ENTRY(nsTreeBodyFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame)
 
 // Constructor
 nsTreeBodyFrame::nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 :nsLeafBoxFrame(aPresShell, aContext),
  mSlots(nullptr),
- mImageCache(16),
+ mImageCache(),
  mTopRowIndex(0),
  mPageLength(0),
  mHorzPosition(0),
  mOriginalHorzWidth(-1),
  mHorzWidth(0),
  mAdjustWidth(0),
  mRowHeight(0),
  mIndentation(0),
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -72,17 +72,17 @@ nsJARManifestItem::~nsJARManifestItem()
 }
 
 //----------------------------------------------
 // nsJAR constructor/destructor
 //----------------------------------------------
 
 // The following initialization makes a guess of 10 entries per jarfile.
 nsJAR::nsJAR(): mZip(new nsZipArchive()),
-                mManifestData(10),
+                mManifestData(8),
                 mParsedManifest(false),
                 mGlobalStatus(JAR_MANIFEST_NOT_PARSED),
                 mReleaseTime(PR_INTERVAL_NO_TIMEOUT),
                 mCache(nullptr),
                 mLock("nsJAR::mLock"),
                 mTotalItemsInManifest(0),
                 mOpened(false)
 {
@@ -1023,17 +1023,17 @@ nsJARItem::GetPermissions(uint32_t* aPer
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIZipReaderCache
 
 NS_IMPL_ISUPPORTS(nsZipReaderCache, nsIZipReaderCache, nsIObserver, nsISupportsWeakReference)
 
 nsZipReaderCache::nsZipReaderCache()
   : mLock("nsZipReaderCache.mLock")
-  , mZips(16)
+  , mZips()
   , mMustCacheFd(false)
 #ifdef ZIP_CACHE_HIT_RATE
     ,
     mZipCacheLookups(0),
     mZipCacheHits(0),
     mZipCacheFlushes(0),
     mZipSyncMisses(0)
 #endif
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -740,17 +740,17 @@ Preferences::GetPreference(PrefSetting* 
     return;
 
   pref_GetPrefFromEntry(entry, aPref);
 }
 
 void
 Preferences::GetPreferences(InfallibleTArray<PrefSetting>* aPrefs)
 {
-  aPrefs->SetCapacity(PL_DHASH_TABLE_SIZE(&gHashTable));
+  aPrefs->SetCapacity(PL_DHASH_TABLE_CAPACITY(&gHashTable));
   PL_DHashTableEnumerate(&gHashTable, pref_GetPrefs, aPrefs);
 }
 
 NS_IMETHODIMP
 Preferences::GetBranch(const char *aPrefRoot, nsIPrefBranch **_retval)
 {
   nsresult rv;
 
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -139,24 +139,24 @@ struct CallbackNode {
 static nsresult pref_DoCallback(const char* changed_pref);
 
 enum {
     kPrefSetDefault = 1,
     kPrefForceSet = 2
 };
 static nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags);
 
-#define PREF_HASHTABLE_INITIAL_SIZE	2048
+#define PREF_HASHTABLE_INITIAL_LENGTH   1024
 
 nsresult PREF_Init()
 {
     if (!gHashTable.ops) {
         if (!PL_DHashTableInit(&gHashTable, &pref_HashTableOps, nullptr,
-                               sizeof(PrefHashEntry), PREF_HASHTABLE_INITIAL_SIZE,
-                               fallible_t())) {
+                               sizeof(PrefHashEntry), fallible_t(),
+                               PREF_HASHTABLE_INITIAL_LENGTH)) {
             gHashTable.ops = nullptr;
             return NS_ERROR_OUT_OF_MEMORY;
         }
 
         PL_INIT_ARENA_POOL(&gPrefNameArena, "PrefNameArena",
                            PREFNAME_ARENA_SIZE);
     }
     return NS_OK;
--- a/netwerk/base/src/RedirectChannelRegistrar.cpp
+++ b/netwerk/base/src/RedirectChannelRegistrar.cpp
@@ -5,18 +5,18 @@
 #include "RedirectChannelRegistrar.h"
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ISUPPORTS(RedirectChannelRegistrar, nsIRedirectChannelRegistrar)
 
 RedirectChannelRegistrar::RedirectChannelRegistrar()
-  : mRealChannels(64)
-  , mParentChannels(64)
+  : mRealChannels(32)
+  , mParentChannels(32)
   , mId(1)
 {
 }
 
 NS_IMETHODIMP
 RedirectChannelRegistrar::RegisterChannel(nsIChannel *channel,
                                           uint32_t *_retval)
 {
--- a/netwerk/base/src/nsLoadGroup.cpp
+++ b/netwerk/base/src/nsLoadGroup.cpp
@@ -1166,16 +1166,16 @@ nsresult nsLoadGroup::Init()
         RequestHashMatchEntry,
         PL_DHashMoveEntryStub,
         RequestHashClearEntry,
         PL_DHashFinalizeStub,
         RequestHashInitEntry
     };
 
     PL_DHashTableInit(&mRequests, &hash_table_ops, nullptr,
-                      sizeof(RequestMapEntry), 16);
+                      sizeof(RequestMapEntry));
 
     mConnectionInfo = new nsLoadGroupConnectionInfo();
 
     return NS_OK;
 }
 
 #undef LOG
--- a/netwerk/cache/nsCacheEntry.cpp
+++ b/netwerk/cache/nsCacheEntry.cpp
@@ -403,17 +403,17 @@ nsCacheEntryHashTable::~nsCacheEntryHash
 
 
 nsresult
 nsCacheEntryHashTable::Init()
 {
     nsresult rv = NS_OK;
     initialized = PL_DHashTableInit(&table, &ops, nullptr,
                                     sizeof(nsCacheEntryHashTableEntry),
-                                    512, fallible_t());
+                                    fallible_t(), 256);
 
     if (!initialized) rv = NS_ERROR_OUT_OF_MEMORY;
 
     return rv;
 }
 
 void
 nsCacheEntryHashTable::Shutdown()
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -888,18 +888,18 @@ private:
 NS_IMPL_ISUPPORTS0(nsOfflineCacheDevice)
 
 nsOfflineCacheDevice::nsOfflineCacheDevice()
   : mDB(nullptr)
   , mCacheCapacity(0)
   , mDeltaCounter(0)
   , mAutoShutdown(false)
   , mLock("nsOfflineCacheDevice.lock")
-  , mActiveCaches(5)
-  , mLockedEntries(64)
+  , mActiveCaches(4)
+  , mLockedEntries(32)
 {
 }
 
 nsOfflineCacheDevice::~nsOfflineCacheDevice()
 {}
 
 /* static */
 bool
--- a/netwerk/dns/nsEffectiveTLDService.cpp
+++ b/netwerk/dns/nsEffectiveTLDService.cpp
@@ -57,20 +57,16 @@ nsDomainEntry::FuncForStaticAsserts(void
 #undef ETLD_STR_NUM
 #undef ETLD_STR_NUM1
 
 // ----------------------------------------------------------------------
 
 static nsEffectiveTLDService *gService = nullptr;
 
 nsEffectiveTLDService::nsEffectiveTLDService()
-  // We'll probably have to rehash at least once, since nsTHashtable doesn't
-  // use a perfect hash, but at least we'll save a few rehashes along the way.
-  // Next optimization here is to precompute the hash using something like
-  // gperf, but one step at a time.  :-)
   : mHash(ArrayLength(nsDomainEntry::entries))
 {
 }
 
 nsresult
 nsEffectiveTLDService::Init()
 {
   const ETLDEntry *entries = nsDomainEntry::entries;
--- a/netwerk/protocol/http/SpdyStream3.cpp
+++ b/netwerk/protocol/http/SpdyStream3.cpp
@@ -395,17 +395,17 @@ SpdyStream3::ParseHttpRequestHeaders(con
     versionHeader = NS_LITERAL_CSTRING("HTTP/1.1");
   else
     versionHeader = NS_LITERAL_CSTRING("HTTP/1.0");
 
   // use mRequestHead() to get a sense of how big to make the hash,
   // even though we are parsing the actual text stream because
   // it is legit to append headers.
   nsClassHashtable<nsCStringHashKey, nsCString>
-    hdrHash(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
+    hdrHash(mTransaction->RequestHead()->Headers().Count());
 
   const char *beginBuffer = mFlatHttpRequestHeaders.BeginReading();
 
   // need to hash all the headers together to remove duplicates, special
   // headers, etc..
 
   int32_t crlfIndex = mFlatHttpRequestHeaders.Find("\r\n");
   while (true) {
--- a/netwerk/protocol/http/SpdyStream31.cpp
+++ b/netwerk/protocol/http/SpdyStream31.cpp
@@ -401,17 +401,17 @@ SpdyStream31::ParseHttpRequestHeaders(co
     versionHeader = NS_LITERAL_CSTRING("HTTP/1.1");
   else
     versionHeader = NS_LITERAL_CSTRING("HTTP/1.0");
 
   // use mRequestHead() to get a sense of how big to make the hash,
   // even though we are parsing the actual text stream because
   // it is legit to append headers.
   nsClassHashtable<nsCStringHashKey, nsCString>
-    hdrHash(1 + (mTransaction->RequestHead()->Headers().Count() * 2));
+    hdrHash(mTransaction->RequestHead()->Headers().Count());
 
   const char *beginBuffer = mFlatHttpRequestHeaders.BeginReading();
 
   // need to hash all the headers together to remove duplicates, special
   // headers, etc..
 
   int32_t crlfIndex = mFlatHttpRequestHeaders.Find("\r\n");
   while (true) {
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -100,22 +100,22 @@ nsresult
 nsHttp::CreateAtomTable()
 {
     MOZ_ASSERT(!sAtomTable.ops, "atom table already initialized");
 
     if (!sLock) {
         sLock = new Mutex("nsHttp.sLock");
     }
 
-    // The capacity for this table is initialized to a value greater than the
-    // number of known atoms (NUM_HTTP_ATOMS) because we expect to encounter a
-    // few random headers right off the bat.
+    // The initial length for this table is a value greater than the number of
+    // known atoms (NUM_HTTP_ATOMS) because we expect to encounter a few random
+    // headers right off the bat.
     if (!PL_DHashTableInit(&sAtomTable, &ops, nullptr,
                            sizeof(PLDHashEntryStub),
-                           NUM_HTTP_ATOMS + 10, fallible_t())) {
+                           fallible_t(), NUM_HTTP_ATOMS + 10)) {
         sAtomTable.ops = nullptr;
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     // fill the table with our known atoms
     const char *const atoms[] = {
 #define HTTP_ATOM(_name, _value) nsHttp::_name._val,
 #include "nsHttpAtomList.h"
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp
+++ b/netwerk/protocol/res/nsResProtocolHandler.cpp
@@ -92,17 +92,17 @@ nsResURL::GetClassIDNoAlloc(nsCID *aClas
     return NS_OK;
 }
 
 //----------------------------------------------------------------------------
 // nsResProtocolHandler <public>
 //----------------------------------------------------------------------------
 
 nsResProtocolHandler::nsResProtocolHandler()
-    : mSubstitutions(32)
+    : mSubstitutions(16)
 {
 #if defined(PR_LOGGING)
     gResLog = PR_NewLogModule("nsResProtocol");
 #endif
 
     NS_ASSERTION(!gResHandler, "res handler already created!");
     gResHandler = this;
 }
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -28,17 +28,17 @@
 #include "nsIScriptError.h"
 #include "nsIScriptContext.h"
 #include "mozilla/Preferences.h"
 #include "nsIHTMLDocument.h"
 
 using namespace mozilla;
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHtml5TreeOpExecutor)
-  NS_INTERFACE_TABLE_INHERITED(nsHtml5TreeOpExecutor, 
+  NS_INTERFACE_TABLE_INHERITED(nsHtml5TreeOpExecutor,
                                nsIContentSink)
 NS_INTERFACE_TABLE_TAIL_INHERITING(nsHtml5DocumentBuilder)
 
 NS_IMPL_ADDREF_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
 
 NS_IMPL_RELEASE_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
 
 class nsHtml5ExecutorReflusher : public nsRunnable
--- a/parser/htmlparser/src/nsHTMLEntities.cpp
+++ b/parser/htmlparser/src/nsHTMLEntities.cpp
@@ -81,30 +81,28 @@ static nsrefcnt gTableRefCnt = 0;
 static const EntityNode gEntityArray[] = {
 #include "nsHTMLEntityList.h"
 };
 #undef HTML_ENTITY
 
 #define NS_HTML_ENTITY_COUNT ((int32_t)ArrayLength(gEntityArray))
 
 nsresult
-nsHTMLEntities::AddRefTable(void) 
+nsHTMLEntities::AddRefTable(void)
 {
   if (!gTableRefCnt) {
     if (!PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
                            nullptr, sizeof(EntityNodeEntry),
-                           uint32_t(NS_HTML_ENTITY_COUNT / 0.75),
-                           fallible_t())) {
+                           fallible_t(), NS_HTML_ENTITY_COUNT)) {
       gEntityToUnicode.ops = nullptr;
       return NS_ERROR_OUT_OF_MEMORY;
     }
     if (!PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
                            nullptr, sizeof(EntityNodeEntry),
-                           uint32_t(NS_HTML_ENTITY_COUNT / 0.75),
-                           fallible_t())) {
+                           fallible_t(), NS_HTML_ENTITY_COUNT)) {
       PL_DHashTableFinish(&gEntityToUnicode);
       gEntityToUnicode.ops = gUnicodeToEntity.ops = nullptr;
       return NS_ERROR_OUT_OF_MEMORY;
     }
     for (const EntityNode *node = gEntityArray,
                  *node_end = ArrayEnd(gEntityArray);
          node < node_end; ++node) {
 
--- a/rdf/base/nsInMemoryDataSource.cpp
+++ b/rdf/base/nsInMemoryDataSource.cpp
@@ -158,18 +158,18 @@ Assertion::Assertion(nsIRDFResource* aSo
       mNext(nullptr),
       mRefCnt(0),
       mHashEntry(true)
 {
     MOZ_COUNT_CTOR(RDF_Assertion);
 
     NS_ADDREF(mSource);
 
-    u.hash.mPropertyHash = PL_NewDHashTable(PL_DHashGetStubOps(),
-                      nullptr, sizeof(Entry), PL_DHASH_MIN_SIZE);
+    u.hash.mPropertyHash =
+        PL_NewDHashTable(PL_DHashGetStubOps(), nullptr, sizeof(Entry));
 }
 
 Assertion::Assertion(nsIRDFResource* aSource,
                      nsIRDFResource* aProperty,
                      nsIRDFNode* aTarget,
                      bool aTruthValue)
     : mSource(aSource),
       mNext(nullptr),
@@ -780,24 +780,22 @@ InMemoryDataSource::InMemoryDataSource(n
 
 
 nsresult
 InMemoryDataSource::Init()
 {
     PL_DHashTableInit(&mForwardArcs,
                       PL_DHashGetStubOps(),
                       nullptr,
-                      sizeof(Entry),
-                      PL_DHASH_MIN_SIZE);
+                      sizeof(Entry));
 
     PL_DHashTableInit(&mReverseArcs,
                       PL_DHashGetStubOps(),
                       nullptr,
-                      sizeof(Entry),
-                      PL_DHASH_MIN_SIZE);
+                      sizeof(Entry));
 
 #ifdef PR_LOGGING
     if (! gLog)
         gLog = PR_NewLogModule("InMemoryDataSource");
 #endif
 
     return NS_OK;
 }
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -756,29 +756,29 @@ RDFServiceImpl::Init()
                                         PL_CompareStrings,
                                         PL_CompareValues,
                                         &dataSourceHashAllocOps, nullptr);
 
     if (! mNamedDataSources)
         return NS_ERROR_OUT_OF_MEMORY;
 
     PL_DHashTableInit(&mResources, &gResourceTableOps, nullptr,
-                      sizeof(ResourceHashEntry), PL_DHASH_MIN_SIZE);
+                      sizeof(ResourceHashEntry));
 
     PL_DHashTableInit(&mLiterals, &gLiteralTableOps, nullptr,
-                      sizeof(LiteralHashEntry), PL_DHASH_MIN_SIZE);
+                      sizeof(LiteralHashEntry));
 
     PL_DHashTableInit(&mInts, &gIntTableOps, nullptr,
-                      sizeof(IntHashEntry), PL_DHASH_MIN_SIZE);
+                      sizeof(IntHashEntry));
 
     PL_DHashTableInit(&mDates, &gDateTableOps, nullptr,
-                      sizeof(DateHashEntry), PL_DHASH_MIN_SIZE);
+                      sizeof(DateHashEntry));
 
     PL_DHashTableInit(&mBlobs, &gBlobTableOps, nullptr,
-                      sizeof(BlobHashEntry), PL_DHASH_MIN_SIZE);
+                      sizeof(BlobHashEntry));
 
     mDefaultResourceFactory = do_GetClassObject(kRDFDefaultResourceCID, &rv);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get default resource factory");
     if (NS_FAILED(rv)) return rv;
 
 #ifdef PR_LOGGING
     if (! gLog)
         gLog = PR_NewLogModule("nsRDFService");
--- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
@@ -452,17 +452,17 @@ void nsSecureBrowserUIImpl::ResetStateTr
   ReentrantMonitorAutoEnter lock(mReentrantMonitor);
 
   mDocumentRequestsInProgress = 0;
   if (mTransferringRequests.ops) {
     PL_DHashTableFinish(&mTransferringRequests);
     mTransferringRequests.ops = nullptr;
   }
   PL_DHashTableInit(&mTransferringRequests, &gMapOps, nullptr,
-                    sizeof(RequestHashEntry), 16);
+                    sizeof(RequestHashEntry));
 }
 
 nsresult
 nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest* aRequest,
                                                       nsISupports *info,
                                                       bool withNewLocation,
                                                       bool withNewSink)
 {
--- a/security/manager/ssl/src/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/src/TransportSecurityInfo.cpp
@@ -951,17 +951,17 @@ formatOverridableCertErrorMessage(nsISSL
 }
 
 // RememberCertErrorsTable
 
 /*static*/ RememberCertErrorsTable*
 RememberCertErrorsTable::sInstance = nullptr;
 
 RememberCertErrorsTable::RememberCertErrorsTable()
-  : mErrorHosts(16)
+  : mErrorHosts()
   , mMutex("RememberCertErrorsTable::mMutex")
 {
 }
 
 static nsresult
 GetHostPortKey(TransportSecurityInfo* infoObject, nsAutoCString &result)
 {
   nsresult rv;
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -182,17 +182,17 @@ void nsCertTree::ClearCompareHash()
     mCompareCache.ops = nullptr;
   }
 }
 
 nsresult nsCertTree::InitCompareHash()
 {
   ClearCompareHash();
   if (!PL_DHashTableInit(&mCompareCache, &gMapOps, nullptr,
-                         sizeof(CompareCacheHashEntryPtr), 128, fallible_t())) {
+                         sizeof(CompareCacheHashEntryPtr), fallible_t(), 64)) {
     mCompareCache.ops = nullptr;
     return NS_ERROR_OUT_OF_MEMORY;
   }
   return NS_OK;
 }
 
 nsCertTree::~nsCertTree()
 {
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -1208,17 +1208,17 @@ nsSSLIOLayerPoll(PRFileDesc* fd, int16_t
                                     (void*) fd, (int) result));
   return result;
 }
 
 nsSSLIOLayerHelpers::nsSSLIOLayerHelpers()
   : mRenegoUnrestrictedSites(nullptr)
   , mTreatUnsafeNegotiationAsBroken(false)
   , mWarnLevelMissingRFC5746(1)
-  , mTLSIntoleranceInfo(16)
+  , mTLSIntoleranceInfo()
   , mFalseStartRequireNPN(true)
   , mFalseStartRequireForwardSecrecy(false)
   , mutex("nsSSLIOLayerHelpers.mutex")
 {
 }
 
 static int
 _PSM_InvalidInt(void)
@@ -1513,17 +1513,17 @@ nsSSLIOLayerHelpers::Init()
     nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
     nsSSLIOLayerMethods.poll = nsSSLIOLayerPoll;
 
     nsSSLPlaintextLayerIdentity = PR_GetUniqueIdentity("Plaintxext PSM layer");
     nsSSLPlaintextLayerMethods  = *PR_GetDefaultIOMethods();
     nsSSLPlaintextLayerMethods.recv = PlaintextRecv;
   }
 
-  mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>(16);
+  mRenegoUnrestrictedSites = new nsTHashtable<nsCStringHashKey>();
 
   nsCString unrestricted_hosts;
   Preferences::GetCString("security.ssl.renego_unrestricted_hosts", &unrestricted_hosts);
   if (!unrestricted_hosts.IsEmpty()) {
     setRenegoUnrestrictedSites(unrestricted_hosts);
   }
 
   bool enabled = false;
--- a/security/manager/ssl/src/nsNSSShutDown.cpp
+++ b/security/manager/ssl/src/nsNSSShutDown.cpp
@@ -47,19 +47,19 @@ nsNSSShutDownList *nsNSSShutDownList::si
 
 nsNSSShutDownList::nsNSSShutDownList()
 :mListLock("nsNSSShutDownList.mListLock")
 {
   mActiveSSLSockets = 0;
   mPK11LogoutCancelObjects.ops = nullptr;
   mObjects.ops = nullptr;
   PL_DHashTableInit(&mObjects, &gSetOps, nullptr,
-                    sizeof(ObjectHashEntry), 16);
+                    sizeof(ObjectHashEntry));
   PL_DHashTableInit(&mPK11LogoutCancelObjects, &gSetOps, nullptr,
-                    sizeof(ObjectHashEntry), 16);
+                    sizeof(ObjectHashEntry));
 }
 
 nsNSSShutDownList::~nsNSSShutDownList()
 {
   if (mObjects.ops) {
     PL_DHashTableFinish(&mObjects);
     mObjects.ops = nullptr;
   }
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -33,20 +33,20 @@
 #include "nsContentUtils.h" // for nsAutoScriptBlocker
 #include "nsJSUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "nsPrintfCString.h"
 #include "nsTHashtable.h"
 #include "jsapi.h"
 
 // Initial size for the cache holding visited status observers.
-#define VISIT_OBSERVERS_INITIAL_CACHE_SIZE 128
-
-// Initial size for the visits removal hash.
-#define VISITS_REMOVAL_INITIAL_HASH_SIZE 128
+#define VISIT_OBSERVERS_INITIAL_CACHE_LENGTH 64
+
+// Initial length for the visits removal hash.
+#define VISITS_REMOVAL_INITIAL_HASH_LENGTH 64
 
 using namespace mozilla::dom;
 using namespace mozilla::ipc;
 using mozilla::unused;
 
 namespace mozilla {
 namespace places {
 
@@ -1581,17 +1581,17 @@ static PLDHashOperator NotifyVisitRemova
 /**
  * Notify removed visits to observers.
  */
 class NotifyRemoveVisits : public nsRunnable
 {
 public:
 
   NotifyRemoveVisits(nsTHashtable<PlaceHashKey>& aPlaces)
-    : mPlaces(VISITS_REMOVAL_INITIAL_HASH_SIZE)
+    : mPlaces(VISITS_REMOVAL_INITIAL_HASH_LENGTH)
     , mHistory(History::GetService())
   {
     MOZ_ASSERT(!NS_IsMainThread(),
                "This should not be called on the main thread");
     aPlaces.EnumerateEntries(TransferHashEntries, &mPlaces);
   }
 
   NS_IMETHOD Run()
@@ -1688,17 +1688,17 @@ public:
     MutexAutoLock lockedScope(mHistory->GetShutdownMutex());
     if (mHistory->IsShuttingDown()) {
       // If we were already shutting down, we cannot remove the visits.
       return NS_OK;
     }
 
     // Find all the visits relative to the current filters and whether their
     // pages will be removed or not.
-    nsTHashtable<PlaceHashKey> places(VISITS_REMOVAL_INITIAL_HASH_SIZE);
+    nsTHashtable<PlaceHashKey> places(VISITS_REMOVAL_INITIAL_HASH_LENGTH);
     nsresult rv = FindRemovableVisits(places);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (places.Count() == 0)
       return NS_OK;
 
     mozStorageTransaction transaction(mDBConn, false,
                                       mozIStorageConnection::TRANSACTION_IMMEDIATE);
@@ -1920,17 +1920,17 @@ StoreAndNotifyEmbedVisit(VisitData& aPla
 ////////////////////////////////////////////////////////////////////////////////
 //// History
 
 History* History::gService = nullptr;
 
 History::History()
   : mShuttingDown(false)
   , mShutdownMutex("History::mShutdownMutex")
-  , mObservers(VISIT_OBSERVERS_INITIAL_CACHE_SIZE)
+  , mObservers(VISIT_OBSERVERS_INITIAL_CACHE_LENGTH)
   , mRecentlyVisitedURIsNextIndex(0)
 {
   NS_ASSERTION(!gService, "Ruh-roh!  This service has already been created!");
   gService = this;
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   NS_WARN_IF_FALSE(os, "Observer service was not found!");
   if (os) {
--- a/toolkit/components/places/nsFaviconService.cpp
+++ b/toolkit/components/places/nsFaviconService.cpp
@@ -30,20 +30,20 @@
 
 // For large favicons optimization.
 #include "imgITools.h"
 #include "imgIContainer.h"
 
 // Default value for mOptimizedIconDimension
 #define OPTIMIZED_FAVICON_DIMENSION 16
 
-#define MAX_FAVICON_CACHE_SIZE 256
+#define MAX_FAILED_FAVICONS 256
 #define FAVICON_CACHE_REDUCE_COUNT 64
 
-#define MAX_UNASSOCIATED_FAVICONS 64
+#define UNASSOCIATED_FAVICONS_LENGTH 32
 
 // When replaceFaviconData is called, we store the icons in an in-memory cache
 // instead of in storage. Icons in the cache are expired according to this
 // interval.
 #define UNASSOCIATED_ICON_EXPIRY_INTERVAL 60000
 
 // The MIME type of the default favicon and favicons created by
 // OptimizeFaviconImage.
@@ -72,18 +72,18 @@ NS_IMPL_ISUPPORTS_CI(
 , nsIFaviconService
 , mozIAsyncFavicons
 , nsITimerCallback
 )
 
 nsFaviconService::nsFaviconService()
   : mOptimizedIconDimension(OPTIMIZED_FAVICON_DIMENSION)
   , mFailedFaviconSerial(0)
-  , mFailedFavicons(MAX_FAVICON_CACHE_SIZE)
-  , mUnassociatedIcons(MAX_UNASSOCIATED_FAVICONS)
+  , mFailedFavicons(MAX_FAILED_FAVICONS / 2)
+  , mUnassociatedIcons(UNASSOCIATED_FAVICONS_LENGTH)
 {
   NS_ASSERTION(!gFaviconService,
                "Attempting to create two instances of the service!");
   gFaviconService = this;
 }
 
 
 nsFaviconService::~nsFaviconService()
@@ -430,21 +430,21 @@ nsFaviconService::AddFailedFavicon(nsIUR
 
   nsAutoCString spec;
   nsresult rv = aFaviconURI->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mFailedFavicons.Put(spec, mFailedFaviconSerial);
   mFailedFaviconSerial ++;
 
-  if (mFailedFavicons.Count() > MAX_FAVICON_CACHE_SIZE) {
+  if (mFailedFavicons.Count() > MAX_FAILED_FAVICONS) {
     // need to expire some entries, delete the FAVICON_CACHE_REDUCE_COUNT number
     // of items that are the oldest
     uint32_t threshold = mFailedFaviconSerial -
-                         MAX_FAVICON_CACHE_SIZE + FAVICON_CACHE_REDUCE_COUNT;
+                         MAX_FAILED_FAVICONS + FAVICON_CACHE_REDUCE_COUNT;
     mFailedFavicons.Enumerate(ExpireFailedFaviconsCallback, &threshold);
   }
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsFaviconService::RemoveFailedFavicon(nsIURI* aFaviconURI)
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -14,19 +14,19 @@
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "nsPrintfCString.h"
 #include "prprf.h"
 #include "mozilla/storage.h"
 
 #include "GeckoProfiler.h"
 
-#define BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE 64
-#define RECENT_BOOKMARKS_INITIAL_CACHE_SIZE 10
-// Threashold to expire old bookmarks if the initial cache size is exceeded.
+#define BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_LENGTH 32
+#define RECENT_BOOKMARKS_INITIAL_CACHE_LENGTH 10
+// Threshold to expire old bookmarks if the initial cache size is exceeded.
 #define RECENT_BOOKMARKS_THRESHOLD PRTime((int64_t)1 * 60 * PR_USEC_PER_SEC)
 
 #define BEGIN_CRITICAL_BOOKMARK_CACHE_SECTION(_itemId_) \
   mUncachableBookmarks.PutEntry(_itemId_); \
   mRecentBookmarksCache.RemoveEntry(_itemId_)
 
 #define END_CRITICAL_BOOKMARK_CACHE_SECTION(_itemId_) \
   MOZ_ASSERT(!mRecentBookmarksCache.GetEntry(_itemId_)); \
@@ -164,17 +164,17 @@ ExpireNonrecentBookmarksCallback(Bookmar
     return PL_DHASH_REMOVE;
   }
   return PL_DHASH_NEXT;
 }
 
 static void
 ExpireNonrecentBookmarks(nsTHashtable<BookmarkKeyClass>* hashTable)
 {
-  if (hashTable->Count() > RECENT_BOOKMARKS_INITIAL_CACHE_SIZE) {
+  if (hashTable->Count() > RECENT_BOOKMARKS_INITIAL_CACHE_LENGTH) {
     int64_t threshold = PR_Now() - RECENT_BOOKMARKS_THRESHOLD;
     (void)hashTable->EnumerateEntries(ExpireNonrecentBookmarksCallback,
                                       reinterpret_cast<void*>(&threshold));
   }
 }
 
 static PLDHashOperator
 ExpireRecentBookmarksByParentCallback(BookmarkKeyClass* aKey,
@@ -203,20 +203,20 @@ nsNavBookmarks::nsNavBookmarks()
   , mRoot(0)
   , mMenuRoot(0)
   , mTagsRoot(0)
   , mUnfiledRoot(0)
   , mToolbarRoot(0)
   , mCanNotify(false)
   , mCacheObservers("bookmark-observers")
   , mBatching(false)
-  , mBookmarkToKeywordHash(BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_SIZE)
+  , mBookmarkToKeywordHash(BOOKMARKS_TO_KEYWORDS_INITIAL_CACHE_LENGTH)
   , mBookmarkToKeywordHashInitialized(false)
-  , mRecentBookmarksCache(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE)
-  , mUncachableBookmarks(RECENT_BOOKMARKS_INITIAL_CACHE_SIZE)
+  , mRecentBookmarksCache(RECENT_BOOKMARKS_INITIAL_CACHE_LENGTH)
+  , mUncachableBookmarks(RECENT_BOOKMARKS_INITIAL_CACHE_LENGTH)
 {
   NS_ASSERTION(!gBookmarksService,
                "Attempting to create two instances of the service!");
   gBookmarksService = this;
 }
 
 
 nsNavBookmarks::~nsNavBookmarks()
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -109,23 +109,23 @@ using namespace mozilla::places;
 // These are the day containers and catch-all final container.
 #define HISTORY_ADDITIONAL_DATE_CONT_NUM 3
 // We use a guess of the number of months considering all of them 30 days
 // long, but we split only the last 6 months.
 #define HISTORY_DATE_CONT_NUM(_daysFromOldestVisit) \
   (HISTORY_ADDITIONAL_DATE_CONT_NUM + \
    std::min(6, (int32_t)ceilf((float)_daysFromOldestVisit/30)))
 // Max number of containers, used to initialize the params hash.
-#define HISTORY_DATE_CONT_MAX 10
-
-// Initial size of the embed visits cache.
-#define EMBED_VISITS_INITIAL_CACHE_SIZE 128
-
-// Initial size of the recent events caches.
-#define RECENT_EVENTS_INITIAL_CACHE_SIZE 128
+#define HISTORY_DATE_CONT_LENGTH 8
+
+// Initial length of the embed visits cache.
+#define EMBED_VISITS_INITIAL_CACHE_LENGTH 64
+
+// Initial length of the recent events cache.
+#define RECENT_EVENTS_INITIAL_CACHE_LENGTH 64
 
 // Observed topics.
 #ifdef MOZ_XUL
 #define TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING "autocomplete-will-enter-text"
 #endif
 #define TOPIC_IDLE_DAILY "idle-daily"
 #define TOPIC_PREF_CHANGED "nsPref:changed"
 #define TOPIC_PROFILE_TEARDOWN "profile-change-teardown"
@@ -250,20 +250,20 @@ const int32_t nsNavHistory::kGetInfoInde
 
 PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService)
 
 
 nsNavHistory::nsNavHistory()
   : mBatchLevel(0)
   , mBatchDBTransaction(nullptr)
   , mCachedNow(0)
-  , mRecentTyped(RECENT_EVENTS_INITIAL_CACHE_SIZE)
-  , mRecentLink(RECENT_EVENTS_INITIAL_CACHE_SIZE)
-  , mRecentBookmark(RECENT_EVENTS_INITIAL_CACHE_SIZE)
-  , mEmbedVisits(EMBED_VISITS_INITIAL_CACHE_SIZE)
+  , mRecentTyped(RECENT_EVENTS_INITIAL_CACHE_LENGTH)
+  , mRecentLink(RECENT_EVENTS_INITIAL_CACHE_LENGTH)
+  , mRecentBookmark(RECENT_EVENTS_INITIAL_CACHE_LENGTH)
+  , mEmbedVisits(EMBED_VISITS_INITIAL_CACHE_LENGTH)
   , mHistoryEnabled(true)
   , mNumVisitsForFrecency(10)
   , mTagsFolder(-1)
   , mDaysOfHistory(-1)
   , mLastCachedStartOfDay(INT64_MAX)
   , mLastCachedEndOfDay(0)
   , mCanNotify(true)
   , mCacheObservers("history-observers")
@@ -2185,18 +2185,18 @@ nsNavHistory::GetQueryResults(nsNavHisto
 {
   NS_ENSURE_ARG_POINTER(aOptions);
   NS_ASSERTION(aResults->Count() == 0, "Initial result array must be empty");
   if (! aQueries.Count())
     return NS_ERROR_INVALID_ARG;
 
   nsCString queryString;
   bool paramsPresent = false;
-  nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_MAX);
-  nsresult rv = ConstructQueryString(aQueries, aOptions, queryString, 
+  nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_LENGTH);
+  nsresult rv = ConstructQueryString(aQueries, aOptions, queryString,
                                      paramsPresent, addParams);
   NS_ENSURE_SUCCESS(rv,rv);
 
   // create statement
   nsCOMPtr<mozIStorageStatement> statement = mDB->GetStatement(queryString);
 #ifdef DEBUG
   if (!statement) {
     nsAutoCString lastErrorString;
@@ -2962,17 +2962,17 @@ nsNavHistory::AsyncExecuteLegacyQueries(
   }
   NS_ENSURE_ARG_MIN(queries.Count(), 1);
 
   nsCOMPtr<nsNavHistoryQueryOptions> options = do_QueryInterface(aOptions);
   NS_ENSURE_ARG(options);
 
   nsCString queryString;
   bool paramsPresent = false;
-  nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_MAX);
+  nsNavHistory::StringHash addParams(HISTORY_DATE_CONT_LENGTH);
   nsresult rv = ConstructQueryString(queries, options, queryString,
                                      paramsPresent, addParams);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr<mozIStorageAsyncStatement> statement =
     mDB->GetAsyncStatement(queryString);
   NS_ENSURE_STATE(statement);
 
--- a/toolkit/components/places/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/nsNavHistoryResult.cpp
@@ -4014,17 +4014,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 nsNavHistoryResult::nsNavHistoryResult(nsNavHistoryContainerResultNode* aRoot)
   : mRootNode(aRoot)
   , mNeedsToApplySortingMode(false)
   , mIsHistoryObserver(false)
   , mIsBookmarkFolderObserver(false)
   , mIsAllBookmarksObserver(false)
-  , mBookmarkFolderObservers(128)
+  , mBookmarkFolderObservers(64)
   , mBatchInProgress(false)
   , mSuppressNotifications(false)
 {
   mRootNode->mResult = this;
 }
 
 nsNavHistoryResult::~nsNavHistoryResult()
 {
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -72,31 +72,31 @@ namespace {
 
 using namespace base;
 using namespace mozilla;
 
 template<class EntryType>
 class AutoHashtable : public nsTHashtable<EntryType>
 {
 public:
-  AutoHashtable(uint32_t initSize = PL_DHASH_MIN_SIZE);
+  AutoHashtable(uint32_t initLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
   typedef bool (*ReflectEntryFunc)(EntryType *entry, JSContext *cx, JS::Handle<JSObject*> obj);
   bool ReflectIntoJS(ReflectEntryFunc entryFunc, JSContext *cx, JS::Handle<JSObject*> obj);
 private:
   struct EnumeratorArgs {
     JSContext *cx;
     JS::Handle<JSObject*> obj;
     ReflectEntryFunc entryFunc;
   };
   static PLDHashOperator ReflectEntryStub(EntryType *entry, void *arg);
 };
 
 template<class EntryType>
-AutoHashtable<EntryType>::AutoHashtable(uint32_t initSize)
-  : nsTHashtable<EntryType>(initSize)
+AutoHashtable<EntryType>::AutoHashtable(uint32_t initLength)
+  : nsTHashtable<EntryType>(initLength)
 {
 }
 
 template<typename EntryType>
 PLDHashOperator
 AutoHashtable<EntryType>::ReflectEntryStub(EntryType *entry, void *arg)
 {
   EnumeratorArgs *args = static_cast<EnumeratorArgs *>(arg);
--- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
+++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
@@ -21,17 +21,17 @@
 #include "nsIURI.h"
 
 class nsUnixSystemProxySettings MOZ_FINAL : public nsISystemProxySettings {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISYSTEMPROXYSETTINGS
 
   nsUnixSystemProxySettings()
-    : mSchemeProxySettings(5)
+    : mSchemeProxySettings(4)
   {
   }
   nsresult Init();
 
 private:
   ~nsUnixSystemProxySettings() {}
   
   nsCOMPtr<nsIGConfService> mGConf;
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -120,17 +120,17 @@ nsDocLoader::nsDocLoader()
     PL_DHashMatchEntryStub,
     PL_DHashMoveEntryStub,
     RequestInfoHashClearEntry,
     PL_DHashFinalizeStub,
     RequestInfoHashInitEntry
   };
 
   PL_DHashTableInit(&mRequestInfoHash, &hash_table_ops, nullptr,
-                    sizeof(nsRequestInfo), 16);
+                    sizeof(nsRequestInfo));
 
   ClearInternalProgress();
 
   PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, 
          ("DocLoader:%p: created.\n", this));
 }
 
 nsresult
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -467,17 +467,17 @@ NoteJSChildGrayWrapperShim(void* aData, 
 static const JSZoneParticipant sJSZoneCycleCollectorGlobal;
 
 CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSRuntime* aParentRuntime,
                                                  uint32_t aMaxBytes,
                                                  uint32_t aMaxNurseryBytes)
   : mGCThingCycleCollectorGlobal(sGCThingCycleCollectorGlobal)
   , mJSZoneCycleCollectorGlobal(sJSZoneCycleCollectorGlobal)
   , mJSRuntime(nullptr)
-  , mJSHolders(512)
+  , mJSHolders(256)
   , mOutOfMemoryState(OOMState::OK)
   , mLargeAllocationFailureState(OOMState::OK)
 {
   mozilla::dom::InitScriptSettings();
 
   mJSRuntime = JS_NewRuntime(aMaxBytes, aMaxNurseryBytes, aParentRuntime);
   if (!mJSRuntime) {
     MOZ_CRASH();
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -850,17 +850,17 @@ public:
       PL_DHashTableFinish(&mPtrToNodeMap);
     }
   }
 
   void Init()
   {
     MOZ_ASSERT(IsEmpty(), "Failed to call CCGraph::Clear");
     PL_DHashTableInit(&mPtrToNodeMap, &PtrNodeOps, nullptr,
-                      sizeof(PtrToNodeEntry), 32768);
+                      sizeof(PtrToNodeEntry), 16384);
   }
 
   void Clear()
   {
     mNodes.Clear();
     mEdges.Clear();
     mWeakMaps.Clear();
     mRootCount = 0;
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -209,20 +209,17 @@ static const PLHashAllocOps typesToLogHa
 
 ////////////////////////////////////////////////////////////////////////////////
 
 #ifdef STACKWALKING_AVAILABLE
 
 class CodeAddressServiceStringTable MOZ_FINAL
 {
 public:
-  CodeAddressServiceStringTable()
-    : mSet(64)
-  {
-  }
+  CodeAddressServiceStringTable() : mSet(32) {}
 
   const char* Intern(const char* aString)
   {
     nsCharPtrHashKey* e = mSet.PutEntry(aString);
     return e->GetKey();
   }
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -301,21 +301,21 @@ nsComponentManagerImpl::Create(nsISuppor
 
   if (!gComponentManager) {
     return NS_ERROR_FAILURE;
   }
 
   return gComponentManager->QueryInterface(aIID, aResult);
 }
 
-static const int CONTRACTID_HASHTABLE_INITIAL_SIZE = 2048;
+static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 1024;
 
 nsComponentManagerImpl::nsComponentManagerImpl()
-  : mFactories(CONTRACTID_HASHTABLE_INITIAL_SIZE)
-  , mContractIDs(CONTRACTID_HASHTABLE_INITIAL_SIZE)
+  : mFactories(CONTRACTID_HASHTABLE_INITIAL_LENGTH)
+  , mContractIDs(CONTRACTID_HASHTABLE_INITIAL_LENGTH)
   , mLock("nsComponentManagerImpl.mLock")
   , mStatus(NOT_INITIALIZED)
 {
 }
 
 nsTArray<const mozilla::Module*>* nsComponentManagerImpl::sStaticModules;
 
 NSMODULE_DEFN(start_kPStaticModules);
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -533,24 +533,24 @@ NS_SizeOfAtomTablesIncludingThis(MallocS
 
   // The atoms in the this table are almost certainly stored in static data, so
   // we don't need a SizeOfEntry function.
   *aStatic = gStaticAtomTable
            ? gStaticAtomTable->SizeOfIncludingThis(nullptr, aMallocSizeOf)
            : 0;
 }
 
-#define ATOM_HASHTABLE_INITIAL_SIZE  4096
+#define ATOM_HASHTABLE_INITIAL_LENGTH  2048
 
 static inline void
 EnsureTableExists()
 {
   if (!gAtomTable.ops) {
     PL_DHashTableInit(&gAtomTable, &AtomTableOps, 0,
-                      sizeof(AtomTableEntry), ATOM_HASHTABLE_INITIAL_SIZE);
+                      sizeof(AtomTableEntry), ATOM_HASHTABLE_INITIAL_LENGTH);
   }
 }
 
 static inline AtomTableEntry*
 GetAtomHashEntry(const char* aString, uint32_t aLength, uint32_t* aHashOut)
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   EnsureTableExists();
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -461,17 +461,17 @@ nsPropertiesParser::ParseBuffer(const ch
 }
 
 nsPersistentProperties::nsPersistentProperties()
   : mIn(nullptr)
 {
   mSubclass = static_cast<nsIPersistentProperties*>(this);
 
   PL_DHashTableInit(&mTable, &property_HashTableOps, nullptr,
-                    sizeof(PropertyTableEntry), 20);
+                    sizeof(PropertyTableEntry), 16);
 
   PL_INIT_ARENA_POOL(&mArena, "PersistentPropertyArena", 2048);
 }
 
 nsPersistentProperties::~nsPersistentProperties()
 {
   PL_FinishArenaPool(&mArena);
   if (mTable.ops) {
--- a/xpcom/ds/nsStaticNameTable.cpp
+++ b/xpcom/ds/nsStaticNameTable.cpp
@@ -124,37 +124,37 @@ nsStaticCaseInsensitiveNameTable::~nsSta
   if (mNameTable.ops) {
     PL_DHashTableFinish(&mNameTable);
   }
   MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable);
 }
 
 bool
 nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[],
-                                       int32_t aCount)
+                                       int32_t aLength)
 {
   NS_ASSERTION(!mNameArray, "double Init");
   NS_ASSERTION(!mNameTable.ops, "double Init");
   NS_ASSERTION(aNames, "null name table");
-  NS_ASSERTION(aCount, "0 count");
+  NS_ASSERTION(aLength, "0 length");
 
   mNameArray = (nsDependentCString*)
-    nsMemory::Alloc(aCount * sizeof(nsDependentCString));
+    nsMemory::Alloc(aLength * sizeof(nsDependentCString));
   if (!mNameArray) {
     return false;
   }
 
   if (!PL_DHashTableInit(&mNameTable, &nametable_CaseInsensitiveHashTableOps,
-                         nullptr, sizeof(NameTableEntry), aCount,
-                         fallible_t())) {
+                         nullptr, sizeof(NameTableEntry), fallible_t(),
+                         aLength)) {
     mNameTable.ops = nullptr;
     return false;
   }
 
-  for (int32_t index = 0; index < aCount; ++index) {
+  for (int32_t index = 0; index < aLength; ++index) {
     const char* raw = aNames[index];
 #ifdef DEBUG
     {
       // verify invariants of contents
       nsAutoCString temp1(raw);
       nsDependentCString temp2(raw);
       ToLowerCase(temp1);
       NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
--- a/xpcom/ds/nsStaticNameTable.h
+++ b/xpcom/ds/nsStaticNameTable.h
@@ -28,17 +28,17 @@
  *    as long as this table object - typically a static string array.
  */
 
 class nsStaticCaseInsensitiveNameTable
 {
 public:
   enum { NOT_FOUND = -1 };
 
-  bool             Init(const char* const aNames[], int32_t aCount);
+  bool             Init(const char* const aNames[], int32_t aLength);
   int32_t          Lookup(const nsACString& aName);
   int32_t          Lookup(const nsAString& aName);
   const nsAFlatCString& GetStringValue(int32_t aIndex);
 
   nsStaticCaseInsensitiveNameTable();
   ~nsStaticCaseInsensitiveNameTable();
 
 private:
--- a/xpcom/glue/DeadlockDetector.h
+++ b/xpcom/glue/DeadlockDetector.h
@@ -499,14 +499,14 @@ public:
 private:
   DeadlockDetector(const DeadlockDetector& aDD) MOZ_DELETE;
   DeadlockDetector& operator=(const DeadlockDetector& aDD) MOZ_DELETE;
 };
 
 
 template<typename T>
 // FIXME bug 456272: tune based on average workload
-const uint32_t DeadlockDetector<T>::kDefaultNumBuckets = 64;
+const uint32_t DeadlockDetector<T>::kDefaultNumBuckets = 32;
 
 
 } // namespace mozilla
 
 #endif // ifndef mozilla_DeadlockDetector_h
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -57,18 +57,18 @@ class nsBaseHashtable
 
 public:
   typedef typename KeyClass::KeyType KeyType;
   typedef nsBaseHashtableET<KeyClass, DataType> EntryType;
 
   using nsTHashtable<EntryType>::Contains;
 
   nsBaseHashtable() {}
-  explicit nsBaseHashtable(uint32_t aInitSize)
-    : nsTHashtable<EntryType>(aInitSize)
+  explicit nsBaseHashtable(uint32_t aInitLength)
+    : nsTHashtable<EntryType>(aInitLength)
   {
   }
 
   /**
    * Return the number of entries in the table.
    * @return    number of entries
    */
   uint32_t Count() const { return nsTHashtable<EntryType>::Count(); }
--- a/xpcom/glue/nsClassHashtable.h
+++ b/xpcom/glue/nsClassHashtable.h
@@ -25,18 +25,18 @@ class nsClassHashtable
   : public nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*>
 {
 public:
   typedef typename KeyClass::KeyType KeyType;
   typedef T* UserDataType;
   typedef nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*> base_type;
 
   nsClassHashtable() {}
-  explicit nsClassHashtable(uint32_t aInitSize)
-    : nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*>(aInitSize)
+  explicit nsClassHashtable(uint32_t aInitLength)
+    : nsBaseHashtable<KeyClass, nsAutoPtr<T>, T*>(aInitLength)
   {
   }
 
   /**
    * @copydoc nsBaseHashtable::Get
    * @param aData if the key doesn't exist, pData will be set to nullptr.
    */
   bool Get(KeyType aKey, UserDataType* aData) const;
--- a/xpcom/glue/nsDataHashtable.h
+++ b/xpcom/glue/nsDataHashtable.h
@@ -19,15 +19,15 @@
  * @see nsInterfaceHashtable, nsClassHashtable
  */
 template<class KeyClass, class DataType>
 class nsDataHashtable
   : public nsBaseHashtable<KeyClass, DataType, DataType>
 {
 public:
   nsDataHashtable() {}
-  explicit nsDataHashtable(uint32_t aInitSize)
-    : nsBaseHashtable<KeyClass, DataType, DataType>(aInitSize)
+  explicit nsDataHashtable(uint32_t aInitLength)
+    : nsBaseHashtable<KeyClass, DataType, DataType>(aInitLength)
   {
   }
 };
 
 #endif // nsDataHashtable_h__
--- a/xpcom/glue/nsInterfaceHashtable.h
+++ b/xpcom/glue/nsInterfaceHashtable.h
@@ -24,18 +24,18 @@ class nsInterfaceHashtable
   : public nsBaseHashtable<KeyClass, nsCOMPtr<Interface>, Interface*>
 {
 public:
   typedef typename KeyClass::KeyType KeyType;
   typedef Interface* UserDataType;
   typedef nsBaseHashtable<KeyClass, nsCOMPtr<Interface>, Interface*> base_type;
 
   nsInterfaceHashtable() {}
-  explicit nsInterfaceHashtable(uint32_t aInitSize)
-    : nsBaseHashtable<KeyClass, nsCOMPtr<Interface>, Interface*>(aInitSize)
+  explicit nsInterfaceHashtable(uint32_t aInitLength)
+    : nsBaseHashtable<KeyClass, nsCOMPtr<Interface>, Interface*>(aInitLength)
   {
   }
 
   /**
    * @copydoc nsBaseHashtable::Get
    * @param aData This is an XPCOM getter, so aData is already_addrefed.
    *   If the key doesn't exist, aData will be set to nullptr.
    */
--- a/xpcom/glue/nsRefPtrHashtable.h
+++ b/xpcom/glue/nsRefPtrHashtable.h
@@ -24,18 +24,18 @@ class nsRefPtrHashtable
   : public nsBaseHashtable<KeyClass, nsRefPtr<RefPtr>, RefPtr*>
 {
 public:
   typedef typename KeyClass::KeyType KeyType;
   typedef RefPtr* UserDataType;
   typedef nsBaseHashtable<KeyClass, nsRefPtr<RefPtr>, RefPtr*> base_type;
 
   nsRefPtrHashtable() {}
-  explicit nsRefPtrHashtable(uint32_t aInitSize)
-    : nsBaseHashtable<KeyClass, nsRefPtr<RefPtr>, RefPtr*>(aInitSize)
+  explicit nsRefPtrHashtable(uint32_t aInitLength)
+    : nsBaseHashtable<KeyClass, nsRefPtr<RefPtr>, RefPtr*>(aInitLength)
   {
   }
 
   /**
    * @copydoc nsBaseHashtable::Get
    * @param aData This is an XPCOM getter, so aData is already_addrefed.
    *   If the key doesn't exist, aData will be set to nullptr.
    */
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -78,20 +78,20 @@ NS_COM_GLUE PLDHashOperator PL_DHashStub
  */
 
 template<class EntryType>
 class nsTHashtable
 {
   typedef mozilla::fallible_t fallible_t;
 
 public:
-  // Separate constructors instead of default aInitSize parameter since
+  // Separate constructors instead of default aInitLength parameter since
   // otherwise the default no-arg constructor isn't found.
-  nsTHashtable() { Init(PL_DHASH_MIN_SIZE); }
-  explicit nsTHashtable(uint32_t aInitSize) { Init(aInitSize); }
+  nsTHashtable() { Init(PL_DHASH_DEFAULT_INITIAL_LENGTH); }
+  explicit nsTHashtable(uint32_t aInitLength) { Init(aInitLength); }
 
   /**
    * destructor, cleans up and deallocates
    */
   ~nsTHashtable();
 
   nsTHashtable(nsTHashtable<EntryType>&& aOther);
 
@@ -357,19 +357,19 @@ protected:
                              mozilla::MallocSizeOf aMallocSizeOf, void* aArg);
 
 private:
   // copy constructor, not implemented
   nsTHashtable(nsTHashtable<EntryType>& aToCopy) MOZ_DELETE;
 
   /**
    * Initialize the table.
-   * @param aInitSize the initial number of buckets in the hashtable
+   * @param aInitLength the initial number of buckets in the hashtable
    */
-  void Init(uint32_t aInitSize);
+  void Init(uint32_t aInitLength);
 
   /**
    * An implementation of SizeOfEntryExcludingThisFun that calls SizeOfExcludingThis()
    * on each entry.
    */
   static size_t BasicSizeOfEntryExcludingThisFun(EntryType* aEntry,
                                                  mozilla::MallocSizeOf aMallocSizeOf,
                                                  void*);
@@ -400,31 +400,31 @@ nsTHashtable<EntryType>::~nsTHashtable()
 {
   if (mTable.entrySize) {
     PL_DHashTableFinish(&mTable);
   }
 }
 
 template<class EntryType>
 void
-nsTHashtable<EntryType>::Init(uint32_t aInitSize)
+nsTHashtable<EntryType>::Init(uint32_t aInitLength)
 {
   static const PLDHashTableOps sOps =
   {
     ::PL_DHashAllocTable,
     ::PL_DHashFreeTable,
     s_HashKey,
     s_MatchEntry,
     EntryType::ALLOW_MEMMOVE ? ::PL_DHashMoveEntryStub : s_CopyEntry,
     s_ClearEntry,
     ::PL_DHashFinalizeStub,
     s_InitEntry
   };
 
-  PL_DHashTableInit(&mTable, &sOps, nullptr, sizeof(EntryType), aInitSize);
+  PL_DHashTableInit(&mTable, &sOps, nullptr, sizeof(EntryType), aInitLength);
 }
 
 // static
 template<class EntryType>
 size_t
 nsTHashtable<EntryType>::BasicSizeOfEntryExcludingThisFun(EntryType* aEntry,
                                                           mozilla::MallocSizeOf aMallocSizeOf,
                                                           void*)
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -165,70 +165,105 @@ SizeOfEntryStore(uint32_t aCapacity, uin
 {
   uint64_t nbytes64 = uint64_t(aCapacity) * uint64_t(aEntrySize);
   *aNbytes = aCapacity * aEntrySize;
   return uint64_t(*aNbytes) == nbytes64;   // returns false on overflow
 }
 
 PLDHashTable*
 PL_NewDHashTable(const PLDHashTableOps* aOps, void* aData, uint32_t aEntrySize,
-                 uint32_t aCapacity)
+                 uint32_t aLength)
 {
   PLDHashTable* table = (PLDHashTable*)malloc(sizeof(*table));
   if (!table) {
     return nullptr;
   }
-  if (!PL_DHashTableInit(table, aOps, aData, aEntrySize, aCapacity,
-                         fallible_t())) {
+  if (!PL_DHashTableInit(table, aOps, aData, aEntrySize, fallible_t(),
+                         aLength)) {
     free(table);
     return nullptr;
   }
   return table;
 }
 
 void
 PL_DHashTableDestroy(PLDHashTable* aTable)
 {
   PL_DHashTableFinish(aTable);
   free(aTable);
 }
 
+/*
+ * 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)
+{
+  return aCapacity - (aCapacity >> 5);  // == aCapacity * 0.96875
+}
+static inline uint32_t
+MinLoad(uint32_t aCapacity)
+{
+  return aCapacity >> 2;                // == aCapacity * 0.25
+}
+
+static inline uint32_t
+MinCapacity(uint32_t aLength)
+{
+  return (aLength * 4 + (3 - 1)) / 3;   // == ceil(aLength * 4 / 3)
+}
+
 bool
 PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
-                  void* aData, uint32_t aEntrySize, uint32_t aCapacity,
-                  const fallible_t&)
+                  void* aData, uint32_t aEntrySize, const fallible_t&,
+                  uint32_t aLength)
 {
 #ifdef DEBUG
   if (aEntrySize > 16 * sizeof(void*)) {
     printf_stderr(
       "pldhash: for the aTable at address %p, the given aEntrySize"
       " of %lu definitely favors chaining over double hashing.\n",
       (void*)aTable,
       (unsigned long) aEntrySize);
   }
 #endif
 
-  aTable->ops = aOps;
-  aTable->data = aData;
-  if (aCapacity < PL_DHASH_MIN_SIZE) {
-    aCapacity = PL_DHASH_MIN_SIZE;
+  if (aLength > PL_DHASH_MAX_INITIAL_LENGTH) {
+    return false;
   }
 
-  int log2 = CeilingLog2(aCapacity);
+  aTable->ops = aOps;
+  aTable->data = aData;
 
-  aCapacity = 1u << log2;
-  if (aCapacity > PL_DHASH_MAX_SIZE) {
-    return false;
+  // Compute the smallest capacity allowing |aLength| elements to be inserted
+  // without rehashing.
+  uint32_t capacity = MinCapacity(aLength);
+  if (capacity < PL_DHASH_MIN_CAPACITY) {
+    capacity = PL_DHASH_MIN_CAPACITY;
   }
+
+  int log2 = CeilingLog2(capacity);
+
+  capacity = 1u << log2;
+  MOZ_ASSERT(capacity <= PL_DHASH_MAX_CAPACITY);
   aTable->hashShift = PL_DHASH_BITS - log2;
   aTable->entrySize = aEntrySize;
   aTable->entryCount = aTable->removedCount = 0;
   aTable->generation = 0;
   uint32_t nbytes;
-  if (!SizeOfEntryStore(aCapacity, aEntrySize, &nbytes))
+  if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes))
     return false;   // overflowed
 
   aTable->entryStore = (char*)aOps->allocTable(aTable, nbytes);
   if (!aTable->entryStore) {
     return false;
   }
   memset(aTable->entryStore, 0, nbytes);
   METER(memset(&aTable->stats, 0, sizeof(aTable->stats)));
@@ -236,55 +271,33 @@ PL_DHashTableInit(PLDHashTable* aTable, 
 #ifdef DEBUG
   aTable->recursionLevel = 0;
 #endif
 
   return true;
 }
 
 void
-PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps, void* aData,
-                  uint32_t aEntrySize, uint32_t aCapacity)
+PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
+                  void* aData, uint32_t aEntrySize, uint32_t aLength)
 {
-  if (!PL_DHashTableInit(aTable, aOps, aData, aEntrySize, aCapacity, fallible_t())) {
-    if (aCapacity > PL_DHASH_MAX_SIZE) {
-      MOZ_CRASH();
+  if (!PL_DHashTableInit(aTable, aOps, aData, aEntrySize, fallible_t(),
+                         aLength)) {
+    if (aLength > PL_DHASH_MAX_INITIAL_LENGTH) {
+      MOZ_CRASH();          // the asked-for length was too big
     }
-    uint32_t nbytes;
-    if (!SizeOfEntryStore(aCapacity, aEntrySize, &nbytes)) {
-      MOZ_CRASH();
+    uint32_t capacity = MinCapacity(aLength), nbytes;
+    if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes)) {
+      MOZ_CRASH();          // the required entryStore size was too big
     }
-    NS_ABORT_OOM(nbytes);
+    NS_ABORT_OOM(nbytes);   // allocation failed
   }
 }
 
 /*
- * 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 aSize)
-{
-  return aSize - (aSize >> 2);  // == aSize * 0.75
-}
-static inline uint32_t
-MaxLoadOnGrowthFailure(uint32_t aSize)
-{
-  return aSize - (aSize >> 5);  // == aSize * 0.96875
-}
-static inline uint32_t
-MinLoad(uint32_t aSize)
-{
-  return aSize >> 2;           // == aSize * 0.25
-}
-
-/*
  * Double hashing needs the second hash code to be relatively prime to table
  * size, so we simply make hash2 odd.
  */
 #define HASH1(hash0, shift)         ((hash0) >> (shift))
 #define HASH2(hash0,log2,shift)     ((((hash0) << (log2)) >> (shift)) | 1)
 
 /*
  * Reserve keyHash 0 for free entries and 1 for removed-entry sentinels.  Note
@@ -319,17 +332,17 @@ PL_DHashTableFinish(PLDHashTable* aTable
   INCREMENT_RECURSION_LEVEL(aTable);
 
   /* Call finalize before clearing entries, so it can enumerate them. */
   aTable->ops->finalize(aTable);
 
   /* Clear any remaining live entries. */
   char* entryAddr = aTable->entryStore;
   uint32_t entrySize = aTable->entrySize;
-  char* entryLimit = entryAddr + PL_DHASH_TABLE_SIZE(aTable) * entrySize;
+  char* entryLimit = entryAddr + PL_DHASH_TABLE_CAPACITY(aTable) * entrySize;
   while (entryAddr < entryLimit) {
     PLDHashEntryHdr* entry = (PLDHashEntryHdr*)entryAddr;
     if (ENTRY_IS_LIVE(entry)) {
       METER(aTable->stats.removeEnums++);
       aTable->ops->clearEntry(aTable, entry);
     }
     entryAddr += entrySize;
   }
@@ -463,17 +476,17 @@ FindFreeEntry(PLDHashTable* aTable, PLDH
 
 static bool
 ChangeTable(PLDHashTable* aTable, int aDeltaLog2)
 {
   /* Look, but don't touch, until we succeed in getting new entry store. */
   int oldLog2 = PL_DHASH_BITS - aTable->hashShift;
   int newLog2 = oldLog2 + aDeltaLog2;
   uint32_t newCapacity = 1u << newLog2;
-  if (newCapacity > PL_DHASH_MAX_SIZE) {
+  if (newCapacity > PL_DHASH_MAX_CAPACITY) {
     return false;
   }
 
   uint32_t entrySize = aTable->entrySize;
   uint32_t nbytes;
   if (!SizeOfEntryStore(newCapacity, entrySize, &nbytes)) {
     return false;   // overflowed
   }
@@ -543,36 +556,36 @@ PL_DHashTableOperate(PLDHashTable* aTabl
       break;
 
     case PL_DHASH_ADD: {
       /*
        * 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 size = PL_DHASH_TABLE_SIZE(aTable);
-      if (aTable->entryCount + aTable->removedCount >= MaxLoad(size)) {
+      uint32_t capacity = PL_DHASH_TABLE_CAPACITY(aTable);
+      if (aTable->entryCount + aTable->removedCount >= MaxLoad(capacity)) {
         /* Compress if a quarter or more of all entries are removed. */
         int deltaLog2;
-        if (aTable->removedCount >= size >> 2) {
+        if (aTable->removedCount >= capacity >> 2) {
           METER(aTable->stats.compresses++);
           deltaLog2 = 0;
         } else {
           METER(aTable->stats.grows++);
           deltaLog2 = 1;
         }
 
         /*
          * Grow or compress aTable.  If ChangeTable() fails, allow
          * overloading up to the secondary max.  Once we hit the secondary
          * max, return null.
          */
         if (!ChangeTable(aTable, deltaLog2) &&
             aTable->entryCount + aTable->removedCount >=
-            MaxLoadOnGrowthFailure(size)) {
+            MaxLoadOnGrowthFailure(capacity)) {
           METER(aTable->stats.addFailures++);
           entry = nullptr;
           break;
         }
       }
 
       /*
        * Look for entry after possibly growing, so we don't have to add it,
@@ -606,19 +619,19 @@ PL_DHashTableOperate(PLDHashTable* aTabl
     case PL_DHASH_REMOVE:
       entry = SearchTable(aTable, aKey, keyHash, aOp);
       if (ENTRY_IS_LIVE(entry)) {
         /* Clear this entry and mark it as "removed". */
         METER(aTable->stats.removeHits++);
         PL_DHashTableRawRemove(aTable, entry);
 
         /* Shrink if alpha is <= .25 and aTable isn't too small already. */
-        uint32_t size = PL_DHASH_TABLE_SIZE(aTable);
-        if (size > PL_DHASH_MIN_SIZE &&
-            aTable->entryCount <= MinLoad(size)) {
+        uint32_t capacity = PL_DHASH_TABLE_CAPACITY(aTable);
+        if (capacity > PL_DHASH_MIN_CAPACITY &&
+            aTable->entryCount <= MinLoad(capacity)) {
           METER(aTable->stats.shrinks++);
           (void) ChangeTable(aTable, -1);
         }
       }
       METER(else {
         aTable->stats.removeMisses++;
       });
       entry = nullptr;
@@ -657,17 +670,17 @@ PL_DHashTableRawRemove(PLDHashTable* aTa
 
 uint32_t
 PL_DHashTableEnumerate(PLDHashTable* aTable, PLDHashEnumerator aEtor, void* aArg)
 {
   INCREMENT_RECURSION_LEVEL(aTable);
 
   char* entryAddr = aTable->entryStore;
   uint32_t entrySize = aTable->entrySize;
-  uint32_t capacity = PL_DHASH_TABLE_SIZE(aTable);
+  uint32_t capacity = PL_DHASH_TABLE_CAPACITY(aTable);
   uint32_t tableSize = capacity * entrySize;
   char* entryLimit = entryAddr + tableSize;
   uint32_t i = 0;
   bool didRemove = false;
 
   if (ChaosMode::isActive()) {
     // Start iterating at a random point in the hashtable. It would be
     // even more chaotic to iterate in fully random order, but that's a lot
@@ -703,23 +716,23 @@ PL_DHashTableEnumerate(PLDHashTable* aTa
    * Shrink or compress if a quarter or more of all entries are removed, or
    * if the table is underloaded according to the minimum alpha, and is not
    * minimal-size already.  Do this only if we removed above, so non-removing
    * enumerations can count on stable aTable->entryStore until the next
    * non-lookup-Operate or removing-Enumerate.
    */
   if (didRemove &&
       (aTable->removedCount >= capacity >> 2 ||
-       (capacity > PL_DHASH_MIN_SIZE &&
+       (capacity > PL_DHASH_MIN_CAPACITY &&
         aTable->entryCount <= MinLoad(capacity)))) {
     METER(aTable->stats.enumShrinks++);
     capacity = aTable->entryCount;
     capacity += capacity >> 1;
-    if (capacity < PL_DHASH_MIN_SIZE) {
-      capacity = PL_DHASH_MIN_SIZE;
+    if (capacity < PL_DHASH_MIN_CAPACITY) {
+      capacity = PL_DHASH_MIN_CAPACITY;
     }
 
     uint32_t ceiling = CeilingLog2(capacity);
     ceiling -= PL_DHASH_BITS - aTable->hashShift;
 
     (void) ChangeTable(aTable, ceiling);
   }
 
@@ -792,23 +805,23 @@ PL_DHashTableDumpMeter(PLDHashTable* aTa
   PLDHashNumber hash1, hash2, maxChainHash1, maxChainHash2;
   double sqsum, mean, variance, sigma;
   PLDHashEntryHdr* entry;
 
   char* entryAddr = aTable->entryStore;
   uint32_t entrySize = aTable->entrySize;
   int hashShift = aTable->hashShift;
   int sizeLog2 = PL_DHASH_BITS - hashShift;
-  uint32_t tableSize = PL_DHASH_TABLE_SIZE(aTable);
+  uint32_t capacity = PL_DHASH_TABLE_CAPACITY(aTable);
   uint32_t sizeMask = (1u << sizeLog2) - 1;
   uint32_t chainCount = 0, maxChainLen = 0;
   hash2 = 0;
   sqsum = 0;
 
-  for (uint32_t i = 0; i < tableSize; i++) {
+  for (uint32_t i = 0; i < capacity; i++) {
     entry = (PLDHashEntryHdr*)entryAddr;
     entryAddr += entrySize;
     if (!ENTRY_IS_LIVE(entry)) {
       continue;
     }
     hash1 = HASH1(entry->keyHash & ~COLLISION_FLAG, hashShift);
     PLDHashNumber saveHash1 = hash1;
     PLDHashEntryHdr* probe = ADDRESS_ENTRY(aTable, hash1);
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -18,31 +18,34 @@
 #define PL_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall))
 #elif defined(XP_WIN)
 #define PL_DHASH_FASTCALL __fastcall
 #else
 #define PL_DHASH_FASTCALL
 #endif
 
 /*
- * Table size 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 probably
- * isn't worthwhile -- tables that big are kind of ridiculous.  Also, the
- * growth operation will (deliberately) fail if |capacity * entrySize|
+ * 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
+ * probably isn't worthwhile -- tables that big are kind of ridiculous.  Also,
+ * the growth operation will (deliberately) fail if |capacity * entrySize|
  * overflows a uint32_t, and entrySize is always at least 8 bytes.
  */
-#undef PL_DHASH_MAX_SIZE
-#define PL_DHASH_MAX_SIZE     ((uint32_t)1 << 26)
+#define PL_DHASH_MAX_CAPACITY           ((uint32_t)1 << 26)
+
+#define PL_DHASH_MIN_CAPACITY           16
 
-/* Minimum table size, or gross entry count (net is at most .75 loaded). */
-#ifndef PL_DHASH_MIN_SIZE
-#define PL_DHASH_MIN_SIZE 16
-#elif (PL_DHASH_MIN_SIZE & (PL_DHASH_MIN_SIZE - 1)) != 0
-#error "PL_DHASH_MIN_SIZE must be a power of two!"
-#endif
+/*
+ * Making this half of the max capacity ensures it'll fit. Nobody should need
+ * an initial length anywhere nearly this large, anyway.
+ */
+#define PL_DHASH_MAX_INITIAL_LENGTH     (PL_DHASH_MAX_CAPACITY / 2)
+
+/* This gives a default initial capacity of 16. */
+#define PL_DHASH_DEFAULT_INITIAL_LENGTH 8
 
 /*
  * Multiplicative hash uses an unsigned 32 bit integer and the golden ratio,
  * expressed as a fixed-point 32-bit fraction.
  */
 #define PL_DHASH_BITS           32
 #define PL_DHASH_GOLDEN_RATIO   0x9E3779B9U
 
@@ -157,19 +160,19 @@ PL_DHASH_ENTRY_IS_LIVE(PLDHashEntryHdr* 
  *   alpha < (esize - 1) / (esize + k)
  *
  * Therefore double hashing should keep alpha >= (esize - 1) / (esize + k),
  * assuming esize is not too large (in which case, chaining should probably be
  * used for any alpha).  For esize=2 and k=3, we want alpha >= .2; for esize=3
  * and k=2, we want alpha >= .4.  For k=4, esize could be 6, and alpha >= .5
  * would still obtain.
  *
- * The current implementation uses a configurable lower bound on alpha, which
- * defaults to .25, when deciding to shrink the table (while still respecting
- * PL_DHASH_MIN_SIZE).
+ * The current implementation uses a lower bound of 0.25 for alpha when
+ * deciding whether to shrink the table (while still respecting
+ * PL_DHASH_MIN_CAPACITY).
  *
  * Note a qualitative difference between chaining and double hashing: under
  * chaining, entry addresses are stable across table shrinks and grows.  With
  * double hashing, you can't safely hold an entry pointer and use it after an
  * ADD or REMOVE operation, unless you sample aTable->generation before adding
  * or removing, and compare the sample after, dereferencing the entry pointer
  * only if aTable->generation has not changed.
  *
@@ -218,17 +221,17 @@ struct PLDHashTable
 #endif
 };
 
 /*
  * Size in entries (gross, not net of free and removed sentinels) for table.
  * We store hashShift rather than sizeLog2 to optimize the collision-free case
  * in SearchTable.
  */
-#define PL_DHASH_TABLE_SIZE(table) \
+#define PL_DHASH_TABLE_CAPACITY(table) \
     ((uint32_t)1 << (PL_DHASH_BITS - (table)->hashShift))
 
 /*
  * Table space at entryStore is allocated and freed using these callbacks.
  * The allocator should return null on error only (not if called with aNBytes
  * equal to 0; but note that pldhash.c code will never call with 0 aNBytes).
  */
 typedef void* (*PLDHashAllocTable)(PLDHashTable* aTable, uint32_t aNBytes);
@@ -376,45 +379,47 @@ NS_COM_GLUE void PL_DHashFinalizeStub(PL
 NS_COM_GLUE const PLDHashTableOps* PL_DHashGetStubOps(void);
 
 /*
  * Dynamically allocate a new PLDHashTable using malloc, initialize it using
  * PL_DHashTableInit, and return its address.  Return null on malloc failure.
  * Note that the entry storage at aTable->entryStore will be allocated using
  * the aOps->allocTable callback.
  */
-NS_COM_GLUE PLDHashTable* PL_NewDHashTable(const PLDHashTableOps* aOps,
-                                           void* aData, uint32_t aEntrySize,
-                                           uint32_t aCapacity);
+NS_COM_GLUE PLDHashTable* PL_NewDHashTable(
+  const PLDHashTableOps* aOps, void* aData, uint32_t aEntrySize,
+  uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
 
 /*
  * Finalize aTable's data, free its entry storage (via aTable->ops->freeTable),
  * and return the memory starting at aTable to the malloc heap.
  */
 NS_COM_GLUE void PL_DHashTableDestroy(PLDHashTable* aTable);
 
 /*
- * Initialize aTable with aOps, aData, aEntrySize, and aCapacity. Capacity is
- * a guess for the smallest table size at which the table will usually be less
- * than 75% loaded (the table will grow or shrink as needed; capacity serves
- * only to avoid inevitable early growth from PL_DHASH_MIN_SIZE).  This will
- * crash if it can't allocate enough memory, or if entrySize or capacity are
- * too large.
+ * Initialize aTable with aOps, aData, aEntrySize, and aCapacity. The table's
+ * initial capacity will be chosen such that |aLength| elements can be inserted
+ * without rehashing. If |aLength| is a power-of-two, this capacity will be
+ * |2*length|.
+ *
+ * This function will crash if it can't allocate enough memory, or if
+ * |aEntrySize| and/or |aLength| are too large.
  */
-NS_COM_GLUE void PL_DHashTableInit(PLDHashTable* aTable,
-                                   const PLDHashTableOps* aOps, void* aData,
-                                   uint32_t aEntrySize, uint32_t aCapacity);
+NS_COM_GLUE void PL_DHashTableInit(
+  PLDHashTable* aTable, const PLDHashTableOps* aOps, void* aData,
+  uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
 
 /*
  * Initialize aTable. This is the same as PL_DHashTableInit, except that it
  * returns a boolean indicating success, rather than crashing on failure.
  */
 MOZ_WARN_UNUSED_RESULT NS_COM_GLUE bool PL_DHashTableInit(
   PLDHashTable* aTable, const PLDHashTableOps* aOps, void* aData,
-  uint32_t aEntrySize, uint32_t aCapacity, const mozilla::fallible_t&);
+  uint32_t aEntrySize, const mozilla::fallible_t&,
+  uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
 
 /*
  * Finalize aTable's data, free its entry storage using aTable->ops->freeTable,
  * and leave its members unchanged from their last live values (which leaves
  * pointers dangling).  If you want to burn cycles clearing aTable, it's up to
  * your code to call memset.
  */
 NS_COM_GLUE void PL_DHashTableFinish(PLDHashTable* aTable);
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -195,17 +195,17 @@ nsDirectoryService::GetCurrentProcessDir
 
   NS_ERROR("unable to get current process directory");
   return NS_ERROR_FAILURE;
 } // GetCurrentProcessDirectory()
 
 nsDirectoryService* nsDirectoryService::gService = nullptr;
 
 nsDirectoryService::nsDirectoryService()
-  : mHashtable(256)
+  : mHashtable(128)
 {
 }
 
 nsresult
 nsDirectoryService::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
 {
   if (NS_WARN_IF(!aResult)) {
     return NS_ERROR_INVALID_ARG;
--- a/xpcom/reflect/xptinfo/xptiWorkingSet.cpp
+++ b/xpcom/reflect/xptinfo/xptiWorkingSet.cpp
@@ -8,22 +8,22 @@
 #include "mozilla/XPTInterfaceInfoManager.h"
 
 #include "xptiprivate.h"
 #include "nsString.h"
 
 using namespace mozilla;
 
 #define XPTI_STRUCT_ARENA_BLOCK_SIZE    (1024 * 16)
-#define XPTI_HASHTABLE_SIZE             2048
+#define XPTI_HASHTABLE_LENGTH           1024
 
 XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
     : mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
-    , mIIDTable(XPTI_HASHTABLE_SIZE)
-    , mNameTable(XPTI_HASHTABLE_SIZE)
+    , mIIDTable(XPTI_HASHTABLE_LENGTH)
+    , mNameTable(XPTI_HASHTABLE_LENGTH)
 {
     MOZ_COUNT_CTOR(xptiWorkingSet);
 
     gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
                                     "xptiWorkingSet structs");
 }        
 
 static PLDHashOperator
--- a/xpcom/tests/TestHashtables.cpp
+++ b/xpcom/tests/TestHashtables.cpp
@@ -542,18 +542,17 @@ main(void) {
 
   nsCOMArray<IFoo> fooArray;
 
   for (i = 0; i < ENTITY_COUNT; ++i) {
     printf("  Putting entry %u...", gEntities[i].mUnicode);
     nsCOMPtr<IFoo> foo;
     CreateIFoo(getter_AddRefs(foo));
     foo->SetString(nsDependentCString(gEntities[i].mStr));
-    
-    
+
     fooArray.InsertObjectAt(foo, i);
 
     EntToUniClass2.Put(foo, gEntities[i].mUnicode);
     printf("OK...\n");
   }
 
   printf("Testing Get:\n");
   uint32_t myChar2;
@@ -608,17 +607,17 @@ main(void) {
 
   printf("Filling hash with %u entries.\n", ENTITY_COUNT);
 
   for (i = 0; i < ENTITY_COUNT; ++i) {
     printf("  Putting entry %u...", gEntities[i].mUnicode);
     nsCOMPtr<IFoo> foo;
     CreateIFoo(getter_AddRefs(foo));
     foo->SetString(nsDependentCString(gEntities[i].mStr));
-    
+
     UniToEntClass2.Put(gEntities[i].mUnicode, foo);
     printf("OK...\n");
   }
 
   printf("Testing Get:\n");
 
   for (i = 0; i < ENTITY_COUNT; ++i) {
     printf("  Getting entry %s...", gEntities[i].mStr);
--- a/xpcom/tests/TestPLDHash.cpp
+++ b/xpcom/tests/TestPLDHash.cpp
@@ -11,36 +11,38 @@
 // exposed through normal usage.  Therefore, this test currently focusses on
 // extreme cases relating to maximum table capacity and potential overflows,
 // which are unlikely to be hit during normal execution.
 
 namespace TestPLDHash {
 
 static bool test_pldhash_Init_capacity_ok()
 {
-  // Try the largest allowed capacity.  With PL_DHASH_MAX_SIZE==1<<26, this
+  // Try the largest allowed capacity.  With PL_DHASH_MAX_CAPACITY==1<<26, this
   // will allocate 0.5GB of entry store on 32-bit platforms and 1GB on 64-bit
   // platforms.
   PLDHashTable t;
   bool ok = PL_DHashTableInit(&t, PL_DHashGetStubOps(), nullptr,
-                              sizeof(PLDHashEntryStub), PL_DHASH_MAX_SIZE,
-                              mozilla::fallible_t());
+                              sizeof(PLDHashEntryStub),
+                              mozilla::fallible_t(),
+                              PL_DHASH_MAX_INITIAL_LENGTH);
   if (ok)
     PL_DHashTableFinish(&t);
 
   return ok;
 }
 
 static bool test_pldhash_Init_capacity_too_large()
 {
   // Try the smallest too-large capacity.
   PLDHashTable t;
   bool ok = PL_DHashTableInit(&t, PL_DHashGetStubOps(), nullptr,
-                              sizeof(PLDHashEntryStub), PL_DHASH_MAX_SIZE + 1,
-                              mozilla::fallible_t());
+                              sizeof(PLDHashEntryStub),
+                              mozilla::fallible_t(),
+                              PL_DHASH_MAX_INITIAL_LENGTH + 1);
   // Don't call PL_DHashTableDestroy(), it's not safe after Init failure.
 
   return !ok;   // expected to fail
 }
 
 static bool test_pldhash_Init_overflow()
 {
   // Try an acceptable capacity, but one whose byte size overflows uint32_t.
@@ -53,18 +55,18 @@ static bool test_pldhash_Init_overflow()
   struct OneKBEntry {
       PLDHashEntryHdr hdr;
       char buf[1024 - sizeof(PLDHashEntryHdr)];
   };
 
   // |nullptr| for |ops| is ok because it's unused due to the failure.
   PLDHashTable t;
   bool ok = PL_DHashTableInit(&t, /* ops = */nullptr, nullptr,
-                              sizeof(OneKBEntry), PL_DHASH_MAX_SIZE,
-                              mozilla::fallible_t());
+                              sizeof(OneKBEntry), mozilla::fallible_t(),
+                              PL_DHASH_MAX_INITIAL_LENGTH);
 
   return !ok;   // expected to fail
 }
 
 // See bug 931062, we skip this test on Android due to OOM.
 #ifndef MOZ_WIDGET_ANDROID
 // We insert the integers 0.., so this is has function is (a) as simple as
 // possible, and (b) collision-free.  Both of which are good, because we want
@@ -84,33 +86,33 @@ static bool test_pldhash_grow_to_max_cap
     PL_DHashMatchEntryStub,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub,
     nullptr
   };
 
   PLDHashTable t;
-  bool ok = PL_DHashTableInit(&t, &ops, nullptr, sizeof(PLDHashEntryStub), 256,
-                              mozilla::fallible_t());
+  bool ok = PL_DHashTableInit(&t, &ops, nullptr, sizeof(PLDHashEntryStub),
+                              mozilla::fallible_t(), 128);
   if (!ok)
     return false;
 
   // Keep inserting elements until failure occurs because the table is full.
   size_t numInserted = 0;
   while (true) {
     if (!PL_DHashTableOperate(&t, (const void*)numInserted, PL_DHASH_ADD)) {
       break;
     }
     numInserted++;
   }
 
   // We stop when the element count is 96.875% of PL_DHASH_MAX_SIZE (see
   // MaxLoadOnGrowthFailure()).
-  return numInserted == PL_DHASH_MAX_SIZE - (PL_DHASH_MAX_SIZE >> 5);
+  return numInserted == PL_DHASH_MAX_CAPACITY - (PL_DHASH_MAX_CAPACITY >> 5);
 }
 #endif
 
 //----
 
 typedef bool (*TestFunc)();
 #define DECL_TEST(name) { #name, name }