Bug 1364816 part 1. Store the relevant constructor id in the entries in the WebIDLGlobalNameHash. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 06 Jun 2017 21:21:43 -0400
changeset 413098 68989f96eb93a9f4857b6d2807f2519fee16ef42
parent 413097 b81d51cb596b6ae3e29fc466a567dd8bb2cc727a
child 413099 4b72b120485d9bf593f95da95e6b1d701b74e72d
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1364816
milestone55.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 1364816 part 1. Store the relevant constructor id in the entries in the WebIDLGlobalNameHash. r=qdot
dom/bindings/Codegen.py
dom/bindings/WebIDLGlobalNameHash.cpp
dom/bindings/WebIDLGlobalNameHash.h
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -13763,17 +13763,18 @@ class CGRegisterGlobalNames(CGAbstractMe
             if not desc.isExposedConditionally():
                 return "nullptr"
             return "%sBinding::ConstructorEnabled" % desc.name
 
         define = ""
         currentOffset = 0
         for (name, desc) in getGlobalNames(self.config):
             length = len(name)
-            define += "WebIDLGlobalNameHash::Register(%i, %i, %sBinding::DefineDOMInterface, %s);\n" % (currentOffset, length, desc.name, getCheck(desc))
+            define += "WebIDLGlobalNameHash::Register(%i, %i, %sBinding::DefineDOMInterface, %s, constructors::id::%s);\n" % (
+                currentOffset, length, desc.name, getCheck(desc), desc.name)
             currentOffset += length + 1 # Add trailing null.
         return define
 
 
 def dependencySortObjects(objects, dependencyGetter, nameGetter):
     """
     Sort IDL objects with dependencies on each other such that if A
     depends on B then B will come before A.  This is needed for
@@ -16997,16 +16998,17 @@ class GlobalGenRoots():
         curr = CGWrapper(curr, post='\n')
 
         # Add the includes
         defineIncludes = [CGHeaders.getDeclarationFilename(desc.interface)
                           for desc in config.getDescriptors(hasInterfaceObject=True,
                                                             isExposedInWindow=True,
                                                             register=True)]
         defineIncludes.append('mozilla/dom/WebIDLGlobalNameHash.h')
+        defineIncludes.append('mozilla/dom/PrototypeList.h')
         defineIncludes.extend([CGHeaders.getDeclarationFilename(desc.interface)
                                for desc in config.getDescriptors(isNavigatorProperty=True,
                                                                  register=True)])
         curr = CGHeaders([], [], [], [], [], defineIncludes, 'RegisterBindings',
                          curr)
 
         # Add include guards.
         curr = CGIncludeGuard('RegisterBindings', curr)
--- a/dom/bindings/WebIDLGlobalNameHash.cpp
+++ b/dom/bindings/WebIDLGlobalNameHash.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebIDLGlobalNameHash.h"
 #include "js/GCAPI.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/dom/DOMJSProxyHandler.h"
+#include "mozilla/dom/PrototypeList.h"
 #include "mozilla/dom/RegisterBindings.h"
 #include "nsIMemoryReporter.h"
 #include "nsTHashtable.h"
 
 namespace mozilla {
 namespace dom {
 
 struct MOZ_STACK_CLASS WebIDLNameTableKey
@@ -53,22 +54,24 @@ struct MOZ_STACK_CLASS WebIDLNameTableKe
 struct WebIDLNameTableEntry : public PLDHashEntryHdr
 {
   typedef const WebIDLNameTableKey& KeyType;
   typedef const WebIDLNameTableKey* KeyTypePointer;
 
   explicit WebIDLNameTableEntry(KeyTypePointer aKey)
     : mNameOffset(0),
       mNameLength(0),
+      mConstructorId(constructors::id::_ID_Count),
       mDefine(nullptr),
       mEnabled(nullptr)
   {}
   WebIDLNameTableEntry(WebIDLNameTableEntry&& aEntry)
     : mNameOffset(aEntry.mNameOffset),
       mNameLength(aEntry.mNameLength),
+      mConstructorId(aEntry.mConstructorId),
       mDefine(aEntry.mDefine),
       mEnabled(aEntry.mEnabled)
   {}
   ~WebIDLNameTableEntry()
   {}
 
   bool KeyEquals(KeyTypePointer aKey) const
   {
@@ -95,16 +98,17 @@ struct WebIDLNameTableEntry : public PLD
   {
     return aKey->mHash;
   }
 
   enum { ALLOW_MEMMOVE = true };
 
   uint16_t mNameOffset;
   uint16_t mNameLength;
+  constructors::id::ID mConstructorId;
   WebIDLGlobalNameHash::DefineGlobalName mDefine;
   // May be null if enabled unconditionally
   WebIDLGlobalNameHash::ConstructorEnabled* mEnabled;
 };
 
 static nsTHashtable<WebIDLNameTableEntry>* sWebIDLGlobalNames;
 
 class WebIDLGlobalNamesHashReporter final : public nsIMemoryReporter
@@ -149,25 +153,27 @@ WebIDLGlobalNameHash::Shutdown()
 {
   delete sWebIDLGlobalNames;
 }
 
 /* static */
 void
 WebIDLGlobalNameHash::Register(uint16_t aNameOffset, uint16_t aNameLength,
                                DefineGlobalName aDefine,
-                               ConstructorEnabled* aEnabled)
+                               ConstructorEnabled* aEnabled,
+                               constructors::id::ID aConstructorId)
 {
   const char* name = sNames + aNameOffset;
   WebIDLNameTableKey key(name, aNameLength);
   WebIDLNameTableEntry* entry = sWebIDLGlobalNames->PutEntry(key);
   entry->mNameOffset = aNameOffset;
   entry->mNameLength = aNameLength;
   entry->mDefine = aDefine;
   entry->mEnabled = aEnabled;
+  entry->mConstructorId = aConstructorId;
 }
 
 /* static */
 void
 WebIDLGlobalNameHash::Remove(const char* aName, uint32_t aLength)
 {
   WebIDLNameTableKey key(aName, aLength);
   sWebIDLGlobalNames->RemoveEntry(key);
--- a/dom/bindings/WebIDLGlobalNameHash.h
+++ b/dom/bindings/WebIDLGlobalNameHash.h
@@ -10,16 +10,22 @@
 #include "js/RootingAPI.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace dom {
 
 struct WebIDLNameTableEntry;
 
+namespace constructors {
+namespace id {
+enum ID : uint16_t;
+} // namespace id
+} // namespace constructors
+
 class WebIDLGlobalNameHash
 {
 public:
   static void Init();
   static void Shutdown();
 
   typedef JSObject*
   (*DefineGlobalName)(JSContext* cx, JS::Handle<JSObject*> global,
@@ -30,17 +36,18 @@ public:
   // defining constructors on the underlying object.
   // This is a typedef for the function type itself, not the function
   // pointer, so it's more obvious that pointers to a ConstructorEnabled
   // can be null.
   typedef bool
   (ConstructorEnabled)(JSContext* cx, JS::Handle<JSObject*> obj);
 
   static void Register(uint16_t aNameOffset, uint16_t aNameLength,
-                       DefineGlobalName aDefine, ConstructorEnabled* aEnabled);
+                       DefineGlobalName aDefine, ConstructorEnabled* aEnabled,
+                       constructors::id::ID aConstructorId);
 
   static void Remove(const char* aName, uint32_t aLength);
 
   // Returns false if something failed. aFound is set to true if the name is in
   // the hash, whether it's enabled or not.
   static bool DefineIfEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj,
                               JS::Handle<jsid> aId,
                               JS::MutableHandle<JS::PropertyDescriptor> aDesc,