Bug 1443252 Make nsGlobalWindowInner/Outer final to reduce build times r?mystor draft
authorTom Ritter <tom@mozilla.com>
Fri, 02 Mar 2018 09:30:03 -0600
changeset 763346 5c838a148e9782676de201c7a85d3ecba728885c
parent 763022 1b2e6b2148ef609108a2ec0d0da0e87d71c49045
push id101420
push userbmo:tom@mozilla.com
push dateMon, 05 Mar 2018 20:42:35 +0000
reviewersmystor
bugs1443252, 1332680
milestone60.0a1
Bug 1443252 Make nsGlobalWindowInner/Outer final to reduce build times r?mystor In Bug 1332680 we got a list of classes and methods we could mark 'final', as suggested by an LTO build of gcc. One of the items on that list was nsGlobalWindowInner and nsGlobalWindowOuter, with quite a lot of virtual calls: > dom/base/nsGlobalWindowInner.h:206:7: warning: Declaring type 'struct nsGlobalWindowInner' final would enable devirtualization of 483 calls > dom/base/nsGlobalWindowOuter.h:164:7: warning: Declaring type 'struct nsGlobalWindowOuter' final would enable devirtualization of 143 calls After trying it out, we saw a modest improvement to a single Talos tes (displaylist mutate got 4-8.5% better). That's not the interesting thing though. For Linux and OSX (and some flavors of Android) build times were reduced by half across the board. They're a bit variable of course, but 30-70% improvements are shown by Talos. Windows and other flavors of Android show 10-15% improvements. MozReview-Commit-ID: GlEGBt2JOTt
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.h
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -199,28 +199,29 @@ ImplCycleCollectionTraverse(nsCycleColle
 // windows still in memory for any given outer window. This list is needed to
 // ensure that mOuterWindow doesn't end up dangling. The nature of PRCList means
 // that the window itself is always in the list, and an outer window's list will
 // also contain all inner window objects that are still in memory (and in
 // reality all inner window object's lists also contain its outer and all other
 // inner windows belonging to the same outer window, but that's an unimportant
 // side effect of inheriting PRCList).
 
-class nsGlobalWindowInner : public mozilla::dom::EventTarget,
-                            public nsPIDOMWindowInner,
-                            private nsIDOMWindow,
-                            // NOTE: This interface is private, as it's only
-                            // implemented on chrome windows.
-                            private nsIDOMChromeWindow,
-                            public nsIScriptGlobalObject,
-                            public nsIScriptObjectPrincipal,
-                            public nsSupportsWeakReference,
-                            public nsIInterfaceRequestor,
-                            public PRCListStr,
-                            public nsAPostRefreshObserver
+class nsGlobalWindowInner final
+  : public mozilla::dom::EventTarget
+  , public nsPIDOMWindowInner
+  , private nsIDOMWindow
+  // NOTE: This interface is private, as it's only
+  // implemented on chrome windows.
+  , private nsIDOMChromeWindow
+  , public nsIScriptGlobalObject
+  , public nsIScriptObjectPrincipal
+  , public nsSupportsWeakReference
+  , public nsIInterfaceRequestor
+  , public PRCListStr
+  , public nsAPostRefreshObserver
 {
 public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
 
   typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowInner*> InnerWindowByIdTable;
 
   static void
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -156,27 +156,28 @@ extern const js::Class OuterWindowProxyC
 // windows still in memory for any given outer window. This list is needed to
 // ensure that mOuterWindow doesn't end up dangling. The nature of PRCList means
 // that the window itself is always in the list, and an outer window's list will
 // also contain all inner window objects that are still in memory (and in
 // reality all inner window object's lists also contain its outer and all other
 // inner windows belonging to the same outer window, but that's an unimportant
 // side effect of inheriting PRCList).
 
-class nsGlobalWindowOuter : public mozilla::dom::EventTarget,
-                            public nsPIDOMWindowOuter,
-                            private nsIDOMWindow,
-                            // NOTE: This interface is private, as it's only
-                            // implemented on chrome windows.
-                            private nsIDOMChromeWindow,
-                            public nsIScriptGlobalObject,
-                            public nsIScriptObjectPrincipal,
-                            public nsSupportsWeakReference,
-                            public nsIInterfaceRequestor,
-                            public PRCListStr
+class nsGlobalWindowOuter final
+  : public mozilla::dom::EventTarget
+  , public nsPIDOMWindowOuter
+  , private nsIDOMWindow
+    // NOTE: This interface is private, as it's only
+    // implemented on chrome windows.
+  , private nsIDOMChromeWindow
+  , public nsIScriptGlobalObject
+  , public nsIScriptObjectPrincipal
+  , public nsSupportsWeakReference
+  , public nsIInterfaceRequestor
+  , public PRCListStr
 {
 public:
   typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*> OuterWindowByIdTable;
 
   static void
   AssertIsOnMainThread()
 #ifdef DEBUG
   ;