Bug 1272160. Fix XPCWrappedNativeScope::AddSizeOfIncludingThis to not blindly poke at non-DOM globals as if they were DOM globals. r=khuey, a=sylvestre
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 13 May 2016 20:21:40 -0400
changeset 333004 bcac6066d9267ca2ea7b281cfcf2223450435a5e
parent 333003 9fe9c798d44ff40eb793feb857602cce7dff16e8
child 333005 9c28c3b843d9ecfb64dfee69469d01e255a73cff
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sylvestre
bugs1272160
milestone48.0a2
Bug 1272160. Fix XPCWrappedNativeScope::AddSizeOfIncludingThis to not blindly poke at non-DOM globals as if they were DOM globals. r=khuey, a=sylvestre I did audit the XPConnect callers of TraceProtoAndIfaceCache and DestroyProtoAndIfaceCache, and they all check JSCLASS_DOM_GLOBAL.
dom/bindings/BindingUtils.h
dom/bindings/DOMJSClass.h
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -516,28 +516,28 @@ TraceProtoAndIfaceCache(JSTracer* trc, J
        JS::CallbackTracer::TracerKind::VerifyTraceProtoAndIface)) {
     // We don't do anything here, we only want to verify that
     // TraceProtoAndIfaceCache was called.
     static_cast<VerifyTraceProtoAndIfaceCacheCalledTracer*>(trc)->ok = true;
     return;
   }
 #endif
 
-  if (!HasProtoAndIfaceCache(obj))
+  if (!DOMGlobalHasProtoAndIFaceCache(obj))
     return;
   ProtoAndIfaceCache* protoAndIfaceCache = GetProtoAndIfaceCache(obj);
   protoAndIfaceCache->Trace(trc);
 }
 
 inline void
 DestroyProtoAndIfaceCache(JSObject* obj)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
 
-  if (!HasProtoAndIfaceCache(obj)) {
+  if (!DOMGlobalHasProtoAndIFaceCache(obj)) {
     return;
   }
 
   ProtoAndIfaceCache* protoAndIfaceCache = GetProtoAndIfaceCache(obj);
 
   delete protoAndIfaceCache;
 }
 
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -399,23 +399,32 @@ struct DOMIfaceAndProtoJSClass
   }
 
   const JSClass* ToJSClass() const { return Jsvalify(&mBase); }
 };
 
 class ProtoAndIfaceCache;
 
 inline bool
-HasProtoAndIfaceCache(JSObject* global)
+DOMGlobalHasProtoAndIFaceCache(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 bool
+HasProtoAndIfaceCache(JSObject* global)
+{
+  if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
+    return false;
+  }
+  return DOMGlobalHasProtoAndIFaceCache(global);
+}
+
 inline ProtoAndIfaceCache*
 GetProtoAndIfaceCache(JSObject* global)
 {
   MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
   return static_cast<ProtoAndIfaceCache*>(
     js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).toPrivate());
 }