Bug 1503659 - Back out some debugging instrumentation from Firefox 64, now that it's in beta. r=mccr8, a=RyanVM
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 31 Oct 2018 14:34:12 -0400
changeset 498273 0a7792cc133f00007c69cd8e5200a977f801d876
parent 498272 fa0dfb7abb5e0cc2466860580082c620e7819c86
child 498274 a15c1d469c7593816633b1f9b9d579e5e2851a7e
push id10087
push userryanvm@gmail.com
push dateThu, 01 Nov 2018 13:32:13 +0000
treeherdermozilla-beta@8a28169fa91d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, RyanVM
bugs1503659
milestone64.0
Bug 1503659 - Back out some debugging instrumentation from Firefox 64, now that it's in beta. r=mccr8, a=RyanVM
dom/base/nsGlobalWindowInner.cpp
dom/base/nsINode.cpp
dom/bindings/BindingUtils.cpp
dom/bindings/Codegen.py
dom/html/ImageDocument.cpp
dom/html/nsHTMLDocument.cpp
dom/xml/XMLDocument.cpp
dom/xul/XULDocument.cpp
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -7517,20 +7517,16 @@ nsGlobalWindowInner::GetSidebar(OwningEx
 #else
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
 #endif
 }
 
 void
 nsGlobalWindowInner::ClearDocumentDependentSlots(JSContext* aCx)
 {
-  if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(GetWrapperPreserveColor())) {
-    MOZ_CRASH("Looks like bug 1488480/1405521, with ClearDocumentDependentSlots in a bogus compartment");
-  }
-
   // If JSAPI OOMs here, there is basically nothing we can do to recover safely.
   if (!Window_Binding::ClearCachedDocumentValue(aCx, this) ||
       !Window_Binding::ClearCachedPerformanceValue(aCx, this)) {
     MOZ_CRASH("Unhandlable OOM while clearing document dependent slots.");
   }
 }
 
 /* static */
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2894,30 +2894,24 @@ nsINode::WrapObject(JSContext *aCx, JS::
   // Event handling is possible only if (1). If (2) event handling is
   // prevented.
   // If the document has never had a script handling object, untrusted
   // scripts (3) shouldn't touch it!
   bool hasHadScriptHandlingObject = false;
   if (!OwnerDoc()->GetScriptHandlingObject(hasHadScriptHandlingObject) &&
       !hasHadScriptHandlingObject &&
       !nsContentUtils::IsSystemCaller(aCx)) {
-    if (IsDocument()) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with a document that lost its script handling object");
-    }
     Throw(aCx, NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   JS::Rooted<JSObject*> obj(aCx, WrapNode(aCx, aGivenProto));
   MOZ_ASSERT_IF(obj && ChromeOnlyAccess(),
                 xpc::IsInContentXBLScope(obj) ||
                 !xpc::UseContentXBLScope(JS::GetObjectRealmOrNull(obj)));
-  if (!obj && IsDocument()) {
-    MOZ_CRASH("Looks like bug 1488480/1405521, with WrapNode on a document returning null");
-  }
   return obj;
 }
 
 already_AddRefed<nsINode>
 nsINode::CloneNode(bool aDeep, ErrorResult& aError)
 {
   return nsNodeUtils::CloneNodeImpl(this, aDeep, aError);
 }
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -4181,20 +4181,16 @@ JS::Handle<JSObject*>
 GetPerInterfaceObjectHandle(JSContext* aCx,
                             size_t aSlotId,
                             CreateInterfaceObjectsMethod aCreator,
                             bool aDefineOnGlobal)
 {
   /* Make sure our global is sane.  Hopefully we can remove this sometime */
   JSObject* global = JS::CurrentGlobalOrNull(aCx);
   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
-    if (aSlotId == prototypes::id::HTMLDocument ||
-        aSlotId == prototypes::id::Document) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with a non-DOM global in GetPerInterfaceObjectHandle");
-    }
     return nullptr;
   }
 
   /* Check to see whether the interface objects are already installed */
   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
   if (!protoAndIfaceCache.HasEntryInSlot(aSlotId)) {
     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     aCreator(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
@@ -4209,40 +4205,16 @@ GetPerInterfaceObjectHandle(JSContext* a
    *
    * Calling address() avoids the read barrier that does gray unmarking, but
    * it's not possible for the object to be gray here.
    */
 
   const JS::Heap<JSObject*>& entrySlot =
     protoAndIfaceCache.EntrySlotMustExist(aSlotId);
   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
-
-  if (!entrySlot) {
-    switch (aSlotId) {
-      case prototypes::id::HTMLDocument: {
-         MOZ_CRASH("Looks like bug 1488480/1405521, with aCreator failing to create HTMLDocument.prototype");
-         break;
-      }
-      case prototypes::id::Document: {
-        MOZ_CRASH("Looks like bug 1488480/1405521, with aCreator failing to create Document.prototype");
-        break;
-      }
-      case prototypes::id::Node: {
-        MOZ_CRASH("Looks like bug 1488480/1405521, with aCreator failing to create Node.prototype");
-        break;
-      }
-      case prototypes::id::EventTarget: {
-        MOZ_CRASH("Looks like bug 1488480/1405521, with aCreator failing to create EventTarget.prototype");
-        break;
-      }
-      default:
-      break;
-    }
-  }
-
   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
 }
 
 namespace binding_detail {
 bool
 IsGetterEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj,
                 JSJitGetterOp aGetter,
                 const Prefable<const JSPropertySpec>* aAttributes)
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3491,17 +3491,17 @@ class CGConstructorEnabled(CGAbstractMet
                                           reindent=True)
         else:
             conditionsWrapper = CGGeneric("return true;\n")
 
         body.append(conditionsWrapper)
         return body.define()
 
 
-def CreateBindingJSObject(descriptor, properties, failureCode = ""):
+def CreateBindingJSObject(descriptor, properties):
     objDecl = "BindingJSObjectCreator<%s> creator(aCx);\n" % descriptor.nativeType
 
     # We don't always need to root obj, but there are a variety
     # of cases where we do, so for simplicity, just always root it.
     if descriptor.proxy:
         if descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
             create = dedent(
                 """
@@ -3516,24 +3516,22 @@ def CreateBindingJSObject(descriptor, pr
                 creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
                                           proto, aObject, JS::UndefinedHandleValue, aReflector);
                 """)
     else:
         create = dedent(
             """
             creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
             """)
-    return objDecl + create + fill(
+    return objDecl + create + dedent(
         """
         if (!aReflector) {
-          $*{failureCode}
           return false;
         }
-        """,
-        failureCode=failureCode)
+        """)
 
 
 def InitUnforgeablePropertiesOnHolder(descriptor, properties, failureCode,
                                       holderName="unforgeableHolder"):
     """
     Define the unforgeable properties on the unforgeable holder for
     the interface represented by descriptor.
 
@@ -3693,45 +3691,41 @@ def SetImmutablePrototype(descriptor, fa
         MOZ_ASSERT(succeeded,
                    "Making a fresh reflector instance have an immutable "
                    "prototype can internally fail, but it should never be "
                    "unsuccessful");
         """,
         failureCode=failureCode)
 
 
-def DeclareProto(noProto = "", wrapFail = ""):
+def DeclareProto():
     """
     Declare the canonicalProto and proto we have for our wrapping operation.
     """
-    return fill(
+    return dedent(
         """
         JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
         if (!canonicalProto) {
-          $*{noProto}
           return false;
         }
         JS::Rooted<JSObject*> proto(aCx);
         if (aGivenProto) {
           proto = aGivenProto;
           // Unfortunately, while aGivenProto was in the compartment of aCx
           // coming in, we changed compartments to that of "parent" so may need
           // to wrap the proto here.
           if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
             if (!JS_WrapObject(aCx, &proto)) {
-              $*{wrapFail}
               return false;
             }
           }
         } else {
           proto = canonicalProto;
         }
-        """,
-        noProto=noProto,
-        wrapFail=wrapFail)
+        """)
 
 
 class CGWrapWithCacheMethod(CGAbstractMethod):
     """
     Create a wrapper JSObject for a given native that implements nsWrapperCache.
 
     properties should be a PropertyArrays instance.
     """
@@ -3748,73 +3742,31 @@ class CGWrapWithCacheMethod(CGAbstractMe
     def definition_body(self):
         failureCode = dedent(
             """
             aCache->ReleaseWrapper(aObject);
             aCache->ClearWrapper();
             return false;
             """)
 
-        isDocument = False
-        iface = self.descriptor.interface
-        while iface:
-            if iface.identifier.name == "Document":
-                isDocument = True
-                break
-            iface = iface.parent
-
-        if isDocument:
-            noGlobal = fill(
-                """
-                MOZ_CRASH("Looks like bug 1488480/1405521, with ${name} not having a global");
-                """,
-                name = self.descriptor.name)
-            noProto = fill(
-                """
-                MOZ_CRASH("Looks like bug 1488480/1405521, with ${name} not having a proto");
-                """,
-                name = self.descriptor.name)
-            protoWrapFail = fill(
-                """
-                MOZ_CRASH("Looks like bug 1488480/1405521, with ${name} failing to wrap a custom proto");
-                """,
-                name = self.descriptor.name)
-            createObjectFailed = fill(
-                """
-                MOZ_CRASH("Looks like bug 1488480/1405521, with ${name} failing to CreateObject/CreateProxyObject");
-                """,
-                name = self.descriptor.name)
-            expandoAllocFail = fill(
-                """
-                MOZ_CRASH("Looks like bug 1488480/1405521, with ${name} failing to EnsureExpandoObject or JS_InitializePropertiesFromCompatibleNativeObject");
-                """,
-                name = self.descriptor.name)
-        else:
-            noGlobal = ""
-            noProto = ""
-            protoWrapFail = ""
-            createObjectFailed = ""
-            expandoAllocFail = ""
-
         return fill(
             """
             static_assert(!IsBaseOf<NonRefcountedDOMObject, ${nativeType}>::value,
                           "Shouldn't have wrappercached things that are not refcounted.");
             $*{assertInheritance}
             MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
             MOZ_ASSERT(!aCache->GetWrapper(),
                        "You should probably not be using Wrap() directly; use "
                        "GetOrCreateDOMReflector instead");
 
             MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
                        "nsISupports must be on our primary inheritance chain");
 
             JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
             if (!global) {
-              $*{noGlobal}
               return false;
             }
             MOZ_ASSERT(JS_IsGlobalObject(global));
             MOZ_ASSERT(JS::ObjectIsNotGray(global));
 
             // That might have ended up wrapping us already, due to the wonders
             // of XBL.  Check for that, and bail out as needed.
             aReflector.set(aCache->GetWrapper());
@@ -3845,24 +3797,21 @@ class CGWrapWithCacheMethod(CGAbstractMe
             // somewhat common) to have a non-null aGivenProto which is the
             // same as canonicalProto.
             if (proto != canonicalProto) {
               PreserveWrapper(aObject);
             }
 
             return true;
             """,
-            noGlobal=noGlobal,
             nativeType=self.descriptor.nativeType,
             assertInheritance=AssertInheritanceChain(self.descriptor),
-            declareProto=DeclareProto(noProto, protoWrapFail),
-            createObject=CreateBindingJSObject(self.descriptor, self.properties,
-                                               createObjectFailed),
+            declareProto=DeclareProto(),
+            createObject=CreateBindingJSObject(self.descriptor, self.properties),
             unforgeable=CopyUnforgeablePropertiesToInstance(self.descriptor,
-                                                            expandoAllocFail +
                                                             failureCode),
             slots=InitMemberSlots(self.descriptor, failureCode),
             setImmutablePrototype=SetImmutablePrototype(self.descriptor,
                                                         failureCode))
 
 
 class CGWrapMethod(CGAbstractMethod):
     def __init__(self, descriptor):
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -195,21 +195,17 @@ ImageDocument::Init()
   mFirstResize = true;
 
   return NS_OK;
 }
 
 JSObject*
 ImageDocument::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
-  JSObject* obj = ImageDocument_Binding::Wrap(aCx, this, aGivenProto);
-  if (!obj) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with ImageDocument::WrapNode failing");
-  }
-  return obj;
+  return ImageDocument_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 nsresult
 ImageDocument::StartDocumentLoad(const char*         aCommand,
                                  nsIChannel*         aChannel,
                                  nsILoadGroup*       aLoadGroup,
                                  nsISupports*        aContainer,
                                  nsIStreamListener** aDocListener,
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -197,21 +197,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHTM
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsHTMLDocument,
                                              nsDocument,
                                              nsIHTMLDocument)
 
 JSObject*
 nsHTMLDocument::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
-  JSObject* obj = HTMLDocument_Binding::Wrap(aCx, this, aGivenProto);
-  if (!obj) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with nsHTMLDocument::WrapNode failing");
-  }
-  return obj;
+  return HTMLDocument_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 nsresult
 nsHTMLDocument::Init()
 {
   nsresult rv = nsDocument::Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -623,22 +623,17 @@ XMLDocument::Clone(dom::NodeInfo* aNodeI
 
   clone.forget(aResult);
   return NS_OK;
 }
 
 JSObject*
 XMLDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
-  JSObject* obj;
   if (mIsPlainDocument) {
-    obj = Document_Binding::Wrap(aCx, this, aGivenProto);
-  } else {
-    obj = XMLDocument_Binding::Wrap(aCx, this, aGivenProto);
+    return Document_Binding::Wrap(aCx, this, aGivenProto);
   }
-  if (!obj) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with XMLDocument::WrapNode failing");
-  }
-  return obj;
+
+  return XMLDocument_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -1947,17 +1947,13 @@ XULDocument::DirectionChanged(const char
   if (aDoc) {
       aDoc->ResetDocumentDirection();
   }
 }
 
 JSObject*
 XULDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
-  JSObject* obj = XULDocument_Binding::Wrap(aCx, this, aGivenProto);
-  if (!obj) {
-      MOZ_CRASH("Looks like bug 1488480/1405521, with XULDocument_Binding::Wrap failing");
-  }
-  return obj;
+  return XULDocument_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
 } // namespace mozilla