Bug 1258924 - Reorder DOMIfaceAndProtoJSClass fields to reduce padding. r=bz.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 24 Mar 2016 05:54:38 +1100
changeset 290133 edba1116e87e703f360794e5749279c04a09a3a4
parent 290132 cafb33796c3520b9a0d64340cbd9f3c1974baaae
child 290134 871c95cf3e40f974c4ee2d1e6af76ca6e0d21293
push id30114
push usercbook@mozilla.com
push dateThu, 24 Mar 2016 15:15:54 +0000
treeherdermozilla-central@24c5fbde4488 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1258924
milestone48.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 1258924 - Reorder DOMIfaceAndProtoJSClass fields to reduce padding. r=bz. On 64-bit this reduces sizeof(DOMIfaceAndProtoJSClass) from 336 to 328, saving 20 KiB. On 32-bit it should save half that.
dom/base/WindowNamedPropertiesHandler.cpp
dom/bindings/Codegen.py
dom/bindings/DOMJSClass.h
--- a/dom/base/WindowNamedPropertiesHandler.cpp
+++ b/dom/base/WindowNamedPropertiesHandler.cpp
@@ -270,20 +270,20 @@ const NativePropertyHooks sWindowNamedPr
   constructors::id::_ID_Count,
   nullptr
 } };
 
 static const DOMIfaceAndProtoJSClass WindowNamedPropertiesClass = {
   PROXY_CLASS_DEF("WindowProperties",
                   JSCLASS_IS_DOMIFACEANDPROTOJSCLASS),
   eNamedPropertiesObject,
+  prototypes::id::_ID_Count,
+  0,
   sWindowNamedPropertiesNativePropertyHooks,
   "[object WindowProperties]",
-  prototypes::id::_ID_Count,
-  0,
   EventTargetBinding::GetProtoObject
 };
 
 // static
 JSObject*
 WindowNamedPropertiesHandler::Create(JSContext* aCx,
                                      JS::Handle<JSObject*> aProto)
 {
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -602,20 +602,20 @@ class CGPrototypeJSClass(CGThing):
                 nullptr,               /* hasInstance */
                 nullptr,               /* construct */
                 nullptr,               /* trace */
                 JS_NULL_CLASS_SPEC,
                 JS_NULL_CLASS_EXT,
                 JS_NULL_OBJECT_OPS
               },
               ${type},
+              ${prototypeID},
+              ${depth},
               ${hooks},
               "[object ${name}Prototype]",
-              ${prototypeID},
-              ${depth},
               ${protoGetter}
             };
             """,
             name=self.descriptor.interface.identifier.name,
             slotCount=slotCount,
             type=type,
             hooks=NativePropertyHooks(self.descriptor),
             prototypeID=prototypeID,
@@ -711,20 +711,20 @@ class CGInterfaceObjectJSClass(CGThing):
                   nullptr, /* watch */
                   nullptr, /* unwatch */
                   nullptr, /* getElements */
                   nullptr, /* enumerate */
                   InterfaceObjectToString, /* funToString */
                 }
               },
               eInterface,
+              ${prototypeID},
+              ${depth},
               ${hooks},
               "function ${name}() {\\n    [native code]\\n}",
-              ${prototypeID},
-              ${depth},
               ${protoGetter}
             };
             """,
             slotCount=slotCount,
             ctorname=ctorname,
             hasInstance=hasinstance,
             hooks=NativePropertyHooks(self.descriptor),
             name=self.descriptor.interface.identifier.name,
@@ -12088,17 +12088,17 @@ class CGNamespacedEnum(CGThing):
 
         # Append a Count.
         entries.append('_' + enumName + '_Count')
 
         # Indent.
         entries = ['  ' + e for e in entries]
 
         # Build the enum body.
-        enumstr = comment + 'enum %s\n{\n%s\n};\n' % (enumName, ',\n'.join(entries))
+        enumstr = comment + 'enum %s : uint16_t\n{\n%s\n};\n' % (enumName, ',\n'.join(entries))
         curr = CGGeneric(declare=enumstr)
 
         # Add some whitespace padding.
         curr = CGWrapper(curr, pre='\n', post='\n')
 
         # Add the namespace.
         curr = CGNamespace(namespace, curr)
 
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -207,17 +207,17 @@ struct NativePropertyHooks
   // constructors::id::_ID_Count.
   constructors::ID mConstructorID;
 
   // The NativePropertyHooks instance for the parent interface (for
   // ShimInterfaceInfo).
   const NativePropertyHooks* mProtoHooks;
 };
 
-enum DOMObjectType {
+enum DOMObjectType : uint8_t {
   eInstance,
   eGlobalInstance,
   eInterface,
   eInterfacePrototype,
   eGlobalInterfacePrototype,
   eNamedPropertiesObject
 };
 
@@ -296,25 +296,25 @@ struct DOMIfaceAndProtoJSClass
   // |DOMJSInterfaceAndPrototypeClass = {...};|, since C++ only allows brace
   // initialization for aggregate/POD types.
   const js::Class mBase;
 
   // Either eInterface, eInterfacePrototype, eGlobalInterfacePrototype or
   // eNamedPropertiesObject.
   DOMObjectType mType;
 
+  const prototypes::ID mPrototypeID;
+  const uint32_t mDepth;
+
   const NativePropertyHooks* mNativeHooks;
 
   // The value to return for toString() on this interface or interface prototype
   // object.
   const char* mToString;
 
-  const prototypes::ID mPrototypeID;
-  const uint32_t mDepth;
-
   ProtoGetter mGetParentProto;
 
   static const DOMIfaceAndProtoJSClass* FromJSClass(const JSClass* base) {
     MOZ_ASSERT(base->flags & JSCLASS_IS_DOMIFACEANDPROTOJSCLASS);
     return reinterpret_cast<const DOMIfaceAndProtoJSClass*>(base);
   }
   static const DOMIfaceAndProtoJSClass* FromJSClass(const js::Class* base) {
     return FromJSClass(Jsvalify(base));