Bug 1461182 reduce nsHostRecord overhead by about 40 bytes r=bagder draft
authorPatrick McManus <mcmanus@ducksong.com>
Sat, 12 May 2018 14:36:26 -0700
changeset 794574 8d7d427ed40f68404640b915296e5b2808561ee2
parent 794547 df5dae2daa1b920a3c94e2647a7bd8c2b4a3d48e
push id109717
push userbmo:mcmanus@ducksong.com
push dateSun, 13 May 2018 12:42:18 +0000
reviewersbagder
bugs1461182
milestone62.0a1
Bug 1461182 reduce nsHostRecord overhead by about 40 bytes r=bagder MozReview-Commit-ID: DvmJE5LcDwQ
netwerk/dns/nsHostResolver.cpp
netwerk/dns/nsHostResolver.h
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -185,32 +185,31 @@ nsHostKey::SizeOfExcludingThis(mozilla::
 nsHostRecord::nsHostRecord(const nsHostKey& key)
     : nsHostKey(key)
     , addr_info_lock("nsHostRecord.addr_info_lock")
     , addr_info_gencnt(0)
     , addr_info(nullptr)
     , addr(nullptr)
     , negative(false)
     , mResolving(0)
+    , mTRRSuccess(0)
+    , mNativeSuccess(0)
     , mNative(false)
-    , mTRRSuccess(0)
     , mTRRUsed(false)
     , mNativeUsed(false)
-    , mNativeSuccess(false)
-    , mFirstTRR(nullptr)
     , onQueue(false)
     , usingAnyThread(false)
     , mDoomed(false)
     , mDidCallbacks(false)
     , mGetTtl(false)
+    , mResolveAgain(false)
     , mTrrAUsed(INIT)
     , mTrrAAAAUsed(INIT)
     , mTrrLock("nsHostRecord.mTrrLock")
     , mBlacklistedCount(0)
-    , mResolveAgain(false)
 {
 }
 
 void
 nsHostRecord::Cancel()
 {
     MutexAutoLock trrlock(mTrrLock);
     if (mTrrA) {
--- a/netwerk/dns/nsHostResolver.h
+++ b/netwerk/dns/nsHostResolver.h
@@ -171,48 +171,49 @@ public:
 
     mozilla::net::ResolverMode mResolverMode;
 
 private:
     friend class nsHostResolver;
 
     explicit nsHostRecord(const nsHostKey& key);
     mozilla::LinkedList<RefPtr<nsResolveHostCallback>> mCallbacks;
+    nsAutoPtr<mozilla::net::AddrInfo> mFirstTRR; // partial TRR storage
 
-    int     mResolving;  // counter of outstanding resolving calls
-    bool    mNative;     // true if this record is being resolved "natively",
-                         // which means that it is either on the pending queue
-                         // or owned by one of the worker threads. */
-    int     mTRRSuccess; // number of successful TRR responses
-    bool    mTRRUsed;    // TRR was used on this record
-    bool    mNativeUsed;
-    int     mNativeSuccess; // number of native lookup responses
-    nsAutoPtr<mozilla::net::AddrInfo> mFirstTRR; // partial TRR storage
-    bool    onQueue; // true if pending and on the queue (not yet given to getaddrinfo())
-    bool    usingAnyThread; // true if off queue and contributing to mActiveAnyThreadCount
-    bool    mDoomed; // explicitly expired
-    bool    mDidCallbacks;
-    bool    mGetTtl;
+    uint16_t  mResolving;  // counter of outstanding resolving calls
+    uint8_t   mTRRSuccess; // number of successful TRR responses
+    uint8_t   mNativeSuccess; // number of native lookup responses
+
+    uint16_t    mNative : 1;     // true if this record is being resolved "natively",
+                                 // which means that it is either on the pending queue
+                                 // or owned by one of the worker threads. */
+    uint16_t    mTRRUsed : 1;    // TRR was used on this record
+    uint16_t    mNativeUsed : 1;
+    uint16_t    onQueue : 1;    // true if pending and on the queue (not yet given to getaddrinfo())
+    uint16_t    usingAnyThread : 1; // true if off queue and contributing to mActiveAnyThreadCount
+    uint16_t    mDoomed : 1;    // explicitly expired
+    uint16_t    mDidCallbacks : 1;
+    uint16_t    mGetTtl : 1;
+
+    // when the results from this resolve is returned, it is not to be
+    // trusted, but instead a new resolve must be made!
+    uint16_t    mResolveAgain : 1;
 
     enum {
         INIT, STARTED, OK, FAILED
     } mTrrAUsed, mTrrAAAAUsed;
 
     Mutex mTrrLock; // lock when accessing the mTrrA[AAA] pointers
     RefPtr<mozilla::net::TRR> mTrrA;
     RefPtr<mozilla::net::TRR> mTrrAAAA;
 
     // The number of times ReportUnusable() has been called in the record's
     // lifetime.
     uint32_t mBlacklistedCount;
 
-    // when the results from this resolve is returned, it is not to be
-    // trusted, but instead a new resolve must be made!
-    bool    mResolveAgain;
-
     // a list of addresses associated with this record that have been reported
     // as unusable. the list is kept as a set of strings to make it independent
     // of gencnt.
     nsTArray<nsCString> mBlacklistedItems;
 
    ~nsHostRecord();
 };