Bug 987457 - rename ProtoAndIfaceArray to ProtoAndIfaceCache; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Sat, 22 Mar 2014 13:04:09 -0400
changeset 175558 892a3da3d9b4aa135b7c98e1e694aab2aa8afb42
parent 175557 5ad1392066742f19a0a9e63976d23378bfcccecb
child 175559 08ec6ef03ae34334cdd03e98097f77796aed662f
push id26492
push userryanvm@gmail.com
push dateThu, 27 Mar 2014 00:57:51 +0000
treeherdermozilla-central@441f5fd256e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs987457
milestone31.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 987457 - rename ProtoAndIfaceArray to ProtoAndIfaceCache; r=bz
dom/bindings/BindingUtils.cpp
dom/bindings/BindingUtils.h
dom/bindings/Codegen.py
dom/bindings/DOMJSClass.h
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/nsXPConnect.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1122,25 +1122,25 @@ XrayResolveProperty(JSContext* cx, JS::H
   }
 
   return true;
 }
 
 static bool
 ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
                               JS::Handle<JSObject*> obj,
-                              size_t protoAndIfaceArrayIndex, unsigned attrs,
+                              size_t protoAndIfaceCacheIndex, unsigned attrs,
                               JS::MutableHandle<JSPropertyDescriptor> desc)
 {
   JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
   {
     JSAutoCompartment ac(cx, global);
-    ProtoAndIfaceArray& protoAndIfaceArray = *GetProtoAndIfaceArray(global);
+    ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     JSObject* protoOrIface =
-      protoAndIfaceArray.EntrySlotIfExists(protoAndIfaceArrayIndex);
+      protoAndIfaceCache.EntrySlotIfExists(protoAndIfaceCacheIndex);
     if (!protoOrIface) {
       return false;
     }
     desc.object().set(wrapper);
     desc.setAttributes(attrs);
     desc.setGetter(JS_PropertyStub);
     desc.setSetter(JS_StrictPropertyStub);
     desc.value().set(JS::ObjectValue(*protoOrIface));
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -280,25 +280,25 @@ IsConvertibleToDictionary(JSContext* cx,
 }
 
 MOZ_ALWAYS_INLINE bool
 IsConvertibleToCallbackInterface(JSContext* cx, JS::Handle<JSObject*> obj)
 {
   return IsNotDateOrRegExp(cx, obj);
 }
 
-// The items in the protoAndIfaceArray are indexed by the prototypes::id::ID and
+// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID and
 // constructors::id::ID enums, in that order. The end of the prototype objects
 // should be the start of the interface objects.
 static_assert((size_t)constructors::id::_ID_Start ==
               (size_t)prototypes::id::_ID_Count,
               "Overlapping or discontiguous indexes.");
 const size_t kProtoAndIfaceCacheCount = constructors::id::_ID_Count;
 
-class ProtoAndIfaceArray
+class ProtoAndIfaceCache
 {
   // The caching strategy we use depends on what sort of global we're dealing
   // with.  For a window-like global, we want everything to be as fast as
   // possible, so we use a flat array, indexed by prototype/constructor ID.
   // For everything else (e.g. globals for JSMs), space is more important than
   // speed, so we use a two-level lookup table.
 
   class ArrayCache : public Array<JS::Heap<JSObject*>, kProtoAndIfaceCacheCount>
@@ -315,17 +315,17 @@ class ProtoAndIfaceArray
     JS::Heap<JSObject*>& EntrySlotMustExist(size_t i) {
       MOZ_ASSERT((*this)[i]);
       return (*this)[i];
     }
 
     void Trace(JSTracer* aTracer) {
       for (size_t i = 0; i < ArrayLength(*this); ++i) {
         if ((*this)[i]) {
-          JS_CallHeapObjectTracer(aTracer, &(*this)[i], "protoAndIfaceArray[i]");
+          JS_CallHeapObjectTracer(aTracer, &(*this)[i], "protoAndIfaceCache[i]");
         }
       }
     }
 
     size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
       return aMallocSizeOf(this);
     }
   };
@@ -376,17 +376,17 @@ class ProtoAndIfaceArray
     }
 
     void Trace(JSTracer* trc) {
       for (size_t i = 0; i < ArrayLength(mPages); ++i) {
         Page* p = mPages[i];
         if (p) {
           for (size_t j = 0; j < ArrayLength(*p); ++j) {
             if ((*p)[j]) {
-              JS_CallHeapObjectTracer(trc, &(*p)[j], "protoAndIfaceArray[i]");
+              JS_CallHeapObjectTracer(trc, &(*p)[j], "protoAndIfaceCache[i]");
             }
           }
         }
       }
     }
 
     size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
       size_t n = aMallocSizeOf(this);
@@ -405,32 +405,32 @@ class ProtoAndIfaceArray
   };
 
 public:
   enum Kind {
     WindowLike,
     NonWindowLike
   };
 
-  ProtoAndIfaceArray(Kind aKind) : mKind(aKind) {
-    MOZ_COUNT_CTOR(ProtoAndIfaceArray);
+  ProtoAndIfaceCache(Kind aKind) : mKind(aKind) {
+    MOZ_COUNT_CTOR(ProtoAndIfaceCache);
     if (aKind == WindowLike) {
       mArrayCache = new ArrayCache();
     } else {
       mPageTableCache = new PageTableCache();
     }
   }
 
-  ~ProtoAndIfaceArray() {
+  ~ProtoAndIfaceCache() {
     if (mKind == WindowLike) {
       delete mArrayCache;
     } else {
       delete mPageTableCache;
     }
-    MOZ_COUNT_DTOR(ProtoAndIfaceArray);
+    MOZ_COUNT_DTOR(ProtoAndIfaceCache);
   }
 
 #define FORWARD_OPERATION(opName, args)              \
   do {                                               \
     if (mKind == WindowLike) {                       \
       return mArrayCache->opName args;               \
     } else {                                         \
       return mPageTableCache->opName args;           \
@@ -466,46 +466,46 @@ private:
   union {
     ArrayCache *mArrayCache;
     PageTableCache *mPageTableCache;
   };
   Kind mKind;
 };
 
 inline void
-AllocateProtoAndIfaceCache(JSObject* obj, ProtoAndIfaceArray::Kind aKind)
+AllocateProtoAndIfaceCache(JSObject* obj, ProtoAndIfaceCache::Kind aKind)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
   MOZ_ASSERT(js::GetReservedSlot(obj, DOM_PROTOTYPE_SLOT).isUndefined());
 
-  ProtoAndIfaceArray* protoAndIfaceArray = new ProtoAndIfaceArray(aKind);
+  ProtoAndIfaceCache* protoAndIfaceCache = new ProtoAndIfaceCache(aKind);
 
   js::SetReservedSlot(obj, DOM_PROTOTYPE_SLOT,
-                      JS::PrivateValue(protoAndIfaceArray));
+                      JS::PrivateValue(protoAndIfaceCache));
 }
 
 inline void
 TraceProtoAndIfaceCache(JSTracer* trc, JSObject* obj)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
 
-  if (!HasProtoAndIfaceArray(obj))
+  if (!HasProtoAndIfaceCache(obj))
     return;
-  ProtoAndIfaceArray* protoAndIfaceArray = GetProtoAndIfaceArray(obj);
-  protoAndIfaceArray->Trace(trc);
+  ProtoAndIfaceCache* protoAndIfaceCache = GetProtoAndIfaceCache(obj);
+  protoAndIfaceCache->Trace(trc);
 }
 
 inline void
 DestroyProtoAndIfaceCache(JSObject* obj)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
 
-  ProtoAndIfaceArray* protoAndIfaceArray = GetProtoAndIfaceArray(obj);
+  ProtoAndIfaceCache* protoAndIfaceCache = GetProtoAndIfaceCache(obj);
 
-  delete protoAndIfaceArray;
+  delete protoAndIfaceCache;
 }
 
 /**
  * Add constants to an object.
  */
 bool
 DefineConstants(JSContext* cx, JS::Handle<JSObject*> obj,
                 const ConstantSpec* cs);
@@ -2275,18 +2275,18 @@ InterfaceHasInstance(JSContext* cx, int 
 // Helper for lenient getters/setters to report to console.  If this
 // returns false, we couldn't even get a global.
 bool
 ReportLenientThisUnwrappingFailure(JSContext* cx, JSObject* obj);
 
 inline JSObject*
 GetUnforgeableHolder(JSObject* aGlobal, prototypes::ID aId)
 {
-  ProtoAndIfaceArray& protoAndIfaceArray = *GetProtoAndIfaceArray(aGlobal);
-  JSObject* interfaceProto = protoAndIfaceArray.EntrySlotMustExist(aId);
+  ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(aGlobal);
+  JSObject* interfaceProto = protoAndIfaceCache.EntrySlotMustExist(aId);
   return &js::GetReservedSlot(interfaceProto,
                               DOM_INTERFACE_PROTO_SLOTS_BASE).toObject();
 }
 
 // Given a JSObject* that represents the chrome side of a JS-implemented WebIDL
 // interface, get the nsPIDOMWindow corresponding to the content side, if any.
 // A false return means an exception was thrown.
 bool
@@ -2534,17 +2534,17 @@ CreateGlobal(JSContext* aCx, T* aObject,
                        aOptions));
   if (!global) {
     NS_WARNING("Failed to create global");
     return nullptr;
   }
 
   JSAutoCompartment ac(aCx, global);
 
-  dom::AllocateProtoAndIfaceCache(global, ProtoAndIfaceArray::WindowLike);
+  dom::AllocateProtoAndIfaceCache(global, ProtoAndIfaceCache::WindowLike);
 
   js::SetReservedSlot(global, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL(aObject));
   NS_ADDREF(aObject);
 
   aCache->SetIsDOMBinding();
   aCache->SetWrapper(global);
 
   /* Intl API is broken and makes this fail intermittently, see bug 934889.
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1944,17 +1944,17 @@ class CGCreateInterfaceObjectsMethod(CGA
     """
     Generate the CreateInterfaceObjects method for an interface descriptor.
 
     properties should be a PropertyArrays instance.
     """
     def __init__(self, descriptor, properties):
         args = [Argument('JSContext*', 'aCx'),
                 Argument('JS::Handle<JSObject*>', 'aGlobal'),
-                Argument('ProtoAndIfaceArray&', 'aProtoAndIfaceArray'),
+                Argument('ProtoAndIfaceCache&', 'aProtoAndIfaceCache'),
                 Argument('bool', 'aDefineOnGlobal')]
         CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'void', args)
         self.properties = properties
     def definition_body(self):
         if len(self.descriptor.prototypeChain) == 1:
             parentProtoType = "Rooted"
             if self.descriptor.interface.getExtendedAttribute("ArrayClass"):
                 getParentProto = "aCx, JS_GetArrayPrototype(aCx, aGlobal)"
@@ -2069,23 +2069,23 @@ if (!unforgeableHolder) {
             constructArgs = 0
         if len(self.descriptor.interface.namedConstructors) > 0:
             namedConstructors = "namedConstructors"
         else:
             namedConstructors = "nullptr"
 
         if needInterfacePrototypeObject:
             protoClass = "&PrototypeClass.mBase"
-            protoCache = "&aProtoAndIfaceArray.EntrySlotOrCreate(prototypes::id::%s)" % self.descriptor.name
+            protoCache = "&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::%s)" % self.descriptor.name
         else:
             protoClass = "nullptr"
             protoCache = "nullptr"
         if needInterfaceObject:
             interfaceClass = "&InterfaceObjectClass.mBase"
-            interfaceCache = "&aProtoAndIfaceArray.EntrySlotOrCreate(constructors::id::%s)" % self.descriptor.name
+            interfaceCache = "&aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::%s)" % self.descriptor.name
         else:
             # We don't have slots to store the named constructors.
             assert len(self.descriptor.interface.namedConstructors) == 0
             interfaceClass = "nullptr"
             interfaceCache = "nullptr"
 
         if self.descriptor.concrete:
             domClass = "&Class.mClass"
@@ -2115,17 +2115,17 @@ if (!unforgeableHolder) {
             interfaceCache,
             domClass,
             properties,
             chromeProperties,
             '"' + self.descriptor.interface.identifier.name + '"' if needInterfaceObject else "nullptr"))
         if UseHolderForUnforgeable(self.descriptor):
             assert needInterfacePrototypeObject
             setUnforgeableHolder = CGGeneric(
-                "JSObject* proto = aProtoAndIfaceArray.EntrySlotOrCreate(prototypes::id::%s);\n"
+                "JSObject* proto = aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::%s);\n"
                 "if (proto) {\n"
                 "  js::SetReservedSlot(proto, DOM_INTERFACE_PROTO_SLOTS_BASE,\n"
                 "                      JS::ObjectValue(*unforgeableHolder));\n"
                 "}" % self.descriptor.name)
         else:
             setUnforgeableHolder = None
         functionBody = CGList(
             [CGGeneric(getParentProto), CGGeneric(getConstructorProto), initIds,
@@ -2147,29 +2147,29 @@ class CGGetPerInterfaceObject(CGAbstract
     def definition_body(self):
         return ("""
 
   /* Make sure our global is sane.  Hopefully we can remove this sometime */
   if (!(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL)) {
     return JS::NullPtr();
   }
   /* Check to see whether the interface objects are already installed */
-  ProtoAndIfaceArray& protoAndIfaceArray = *GetProtoAndIfaceArray(aGlobal);
-  if (!protoAndIfaceArray.EntrySlotIfExists(%s)) {
-    CreateInterfaceObjects(aCx, aGlobal, protoAndIfaceArray, aDefineOnGlobal);
+  ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(aGlobal);
+  if (!protoAndIfaceCache.EntrySlotIfExists(%s)) {
+    CreateInterfaceObjects(aCx, aGlobal, protoAndIfaceCache, aDefineOnGlobal);
   }
 
   /*
    * The object might _still_ be null, but that's OK.
    *
-   * Calling fromMarkedLocation() is safe because protoAndIfaceArray is
+   * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    * traced by TraceProtoAndIfaceCache() and its contents are never
    * changed after they have been set.
    */
-  return JS::Handle<JSObject*>::fromMarkedLocation(protoAndIfaceArray.EntrySlotMustExist(%s).address());""" % (self.id, self.id))
+  return JS::Handle<JSObject*>::fromMarkedLocation(protoAndIfaceCache.EntrySlotMustExist(%s).address());""" % (self.id, self.id))
 
 class CGGetProtoObjectMethod(CGGetPerInterfaceObject):
     """
     A method for getting the interface prototype object.
     """
     def __init__(self, descriptor):
         CGGetPerInterfaceObject.__init__(self, descriptor, "GetProtoObject",
                                          "prototypes::")
@@ -9889,17 +9889,17 @@ class CGForwardDeclarations(CGWrapper):
             # There may be some other cases we are missing.
 
         # Needed for at least Wrap.
         for d in descriptors:
             builder.add(d.nativeType)
 
         # We just about always need NativePropertyHooks
         builder.addInMozillaDom("NativePropertyHooks")
-        builder.addInMozillaDom("ProtoAndIfaceArray")
+        builder.addInMozillaDom("ProtoAndIfaceCache")
 
         for callback in mainCallbacks:
             forwardDeclareForType(callback)
             for t in getTypesFromCallback(callback):
                 forwardDeclareForType(t, workerness='mainthreadonly')
 
         for callback in workerCallbacks:
             forwardDeclareForType(callback)
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -230,30 +230,30 @@ struct DOMIfaceAndProtoJSClass
   }
   static const DOMIfaceAndProtoJSClass* FromJSClass(const js::Class* base) {
     return FromJSClass(Jsvalify(base));
   }
 
   const JSClass* ToJSClass() const { return &mBase; }
 };
 
-class ProtoAndIfaceArray;
+class ProtoAndIfaceCache;
 
 inline bool
-HasProtoAndIfaceArray(JSObject* global)
+HasProtoAndIfaceCache(JSObject* global)
 {
   MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
   // This can be undefined if we GC while creating the global
   return !js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).isUndefined();
 }
 
-inline ProtoAndIfaceArray*
-GetProtoAndIfaceArray(JSObject* global)
+inline ProtoAndIfaceCache*
+GetProtoAndIfaceCache(JSObject* global)
 {
   MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
-  return static_cast<ProtoAndIfaceArray*>(
+  return static_cast<ProtoAndIfaceCache*>(
     js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).toPrivate());
 }
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_DOMJSClass_h */
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -710,18 +710,18 @@ void
 XPCWrappedNativeScope::AddSizeOfIncludingThis(ScopeSizeInfo* scopeSizeInfo)
 {
     scopeSizeInfo->mScopeAndMapSize += scopeSizeInfo->mMallocSizeOf(this);
     scopeSizeInfo->mScopeAndMapSize +=
         mWrappedNativeMap->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
     scopeSizeInfo->mScopeAndMapSize +=
         mWrappedNativeProtoMap->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
 
-    if (dom::HasProtoAndIfaceArray(mGlobalJSObject)) {
-        dom::ProtoAndIfaceArray* cache = dom::GetProtoAndIfaceArray(mGlobalJSObject);
+    if (dom::HasProtoAndIfaceCache(mGlobalJSObject)) {
+        dom::ProtoAndIfaceCache* cache = dom::GetProtoAndIfaceCache(mGlobalJSObject);
         scopeSizeInfo->mProtoAndIfaceCacheSize +=
             cache->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
     }
 
     // There are other XPCWrappedNativeScope members that could be measured;
     // the above ones have been seen by DMD to be worth measuring.  More stuff
     // may be added later.
 }
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -388,18 +388,18 @@ CreateGlobalObject(JSContext *cx, const 
     }
 #endif
 
     if (clasp->flags & JSCLASS_DOM_GLOBAL) {
         const char* className = clasp->name;
         AllocateProtoAndIfaceCache(global,
                                    (strcmp(className, "Window") == 0 ||
                                     strcmp(className, "ChromeWindow") == 0)
-                                   ? ProtoAndIfaceArray::WindowLike
-                                   : ProtoAndIfaceArray::NonWindowLike);
+                                   ? ProtoAndIfaceCache::WindowLike
+                                   : ProtoAndIfaceCache::NonWindowLike);
     }
 
     return global;
 }
 
 } // namespace xpc
 
 NS_IMETHODIMP