Bug 1378586 P3 Reorder Timeout members to improve binary packing. No functional change. r=farre
authorBen Kelly <ben@wanderview.com>
Tue, 25 Jul 2017 08:35:12 -0700
changeset 421998 9d1d8507fc97fde906fff564a29e85981526f246
parent 421997 adc6dc3c8c4e99dc7d50174df4a6b40b5cade227
child 421999 fbccc5bd7c145968efd0903e087172be38a0e8ae
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1378586
milestone56.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 1378586 P3 Reorder Timeout members to improve binary packing. No functional change. r=farre
dom/base/Timeout.cpp
dom/base/Timeout.h
--- a/dom/base/Timeout.cpp
+++ b/dom/base/Timeout.cpp
@@ -7,26 +7,25 @@
 #include "Timeout.h"
 
 #include "mozilla/dom/TimeoutManager.h"
 
 namespace mozilla {
 namespace dom {
 
 Timeout::Timeout()
-  : mCleared(false),
+  : mTimeoutId(0),
+    mFiringId(TimeoutManager::InvalidFiringId),
+    mPopupState(openAllowed),
+    mReason(Reason::eTimeoutOrInterval),
+    mNestingLevel(0),
+    mCleared(false),
     mRunning(false),
     mIsInterval(false),
-    mIsTracking(false),
-    mReason(Reason::eTimeoutOrInterval),
-    mTimeoutId(0),
-    mInterval(0),
-    mFiringId(TimeoutManager::InvalidFiringId),
-    mNestingLevel(0),
-    mPopupState(openAllowed)
+    mIsTracking(false)
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Timeout)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Timeout)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mScriptHandler)
--- a/dom/base/Timeout.h
+++ b/dom/base/Timeout.h
@@ -30,80 +30,86 @@ class Timeout final
   : public LinkedListElement<RefPtr<Timeout>>
 {
 public:
   Timeout();
 
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(Timeout)
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Timeout)
 
-  enum class Reason
+  enum class Reason : uint8_t
   {
     eTimeoutOrInterval,
     eIdleCallbackTimeout,
   };
 
   void SetWhenOrTimeRemaining(const TimeStamp& aBaseTime,
                               const TimeDuration& aDelay);
 
   // Can only be called when not frozen.
   const TimeStamp& When() const;
 
   // Can only be called when frozen.
   const TimeDuration& TimeRemaining() const;
 
+private:
+  // mWhen and mTimeRemaining can't be in a union, sadly, because they
+  // have constructors.
+  // Nominal time to run this timeout.  Use only when timeouts are not
+  // frozen.
+  TimeStamp mWhen;
+
+  // Remaining time to wait.  Used only when timeouts are frozen.
+  TimeDuration mTimeRemaining;
+
+  ~Timeout() = default;
+
+public:
+  // Public member variables in this section.  Please don't add to this list
+  // or mix methods with these.  The interleaving public/private sections
+  // is necessary as we migrate members to private while still trying to
+  // keep decent binary packing.
+
   // Window for which this timeout fires
   RefPtr<nsGlobalWindow> mWindow;
 
+  // The language-specific information about the callback.
+  nsCOMPtr<nsITimeoutHandler> mScriptHandler;
+
+  // Interval
+  TimeDuration mInterval;
+
+  // Returned as value of setTimeout()
+  uint32_t mTimeoutId;
+
+  // Identifies which firing level this Timeout is being processed in
+  // when sync loops trigger nested firing.
+  uint32_t mFiringId;
+
+  // The popup state at timeout creation time if not created from
+  // another timeout
+  PopupControlState mPopupState;
+
+  // Used to allow several reasons for setting a timeout, where each
+  // 'Reason' value is using a possibly overlapping set of id:s.
+  Reason mReason;
+
+  // Between 0 and DOM_CLAMP_TIMEOUT_NESTING_LEVEL.  Currently we don't
+  // care about nesting levels beyond that value.
+  uint8_t mNestingLevel;
+
   // True if the timeout was cleared
   bool mCleared;
 
   // True if this is one of the timeouts that are currently running
   bool mRunning;
 
   // True if this is a repeating/interval timer
   bool mIsInterval;
 
   // True if this is a timeout coming from a tracking script
   bool mIsTracking;
-
-  // Used to allow several reasons for setting a timeout, where each
-  // 'Reason' value is using a possibly overlapping set of id:s.
-  Reason mReason;
-
-  // Returned as value of setTimeout()
-  uint32_t mTimeoutId;
-
-  // Interval
-  TimeDuration mInterval;
-
-  // Identifies which firing level this Timeout is being processed in
-  // when sync loops trigger nested firing.
-  uint32_t mFiringId;
-
-  // Between 0 and DOM_CLAMP_TIMEOUT_NESTING_LEVEL.  Currently we don't
-  // care about nesting levels beyond that value.
-  uint8_t mNestingLevel;
-
-  // The popup state at timeout creation time if not created from
-  // another timeout
-  PopupControlState mPopupState;
-
-  // The language-specific information about the callback.
-  nsCOMPtr<nsITimeoutHandler> mScriptHandler;
-
-private:
-  // mWhen and mTimeRemaining can't be in a union, sadly, because they
-  // have constructors.
-  // Nominal time to run this timeout.  Use only when timeouts are not
-  // frozen.
-  TimeStamp mWhen;
-
-  // Remaining time to wait.  Used only when timeouts are frozen.
-  TimeDuration mTimeRemaining;
-
-  ~Timeout() = default;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_timeout_h