Bug 1501479. Add instrumentation to figure out why Document.prototype creation is failing. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 24 Oct 2018 02:00:49 +0200
changeset 490979 f7910a01b5330b1ddedf7cd01af6bd7add1c58c7
parent 490978 48344052a1d6042ad48e4b88c2ec9d1def456e6f
child 490980 6d09c69fd7e699339628f3c398445318ffe59efc
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersmccr8
bugs1501479
milestone65.0a1
Bug 1501479. Add instrumentation to figure out why Document.prototype creation is failing. r=mccr8
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2968,49 +2968,63 @@ class CGCreateInterfaceObjectsMethod(CGA
         getConstructorProto += "(aCx)"
 
         needInterfaceObject = self.descriptor.interface.hasInterfaceObject()
         needInterfacePrototypeObject = self.descriptor.interface.hasInterfacePrototypeObject()
 
         # if we don't need to create anything, why are we generating this?
         assert needInterfaceObject or needInterfacePrototypeObject
 
+        def maybecrash(reason):
+            if self.descriptor.name == "Document":
+                return 'MOZ_CRASH("Bug 1405521/1488480: %s");\n' % reason
+            return ""
+
         getParentProto = fill(
             """
             JS::${type}<JSObject*> parentProto(${getParentProto});
             if (!parentProto) {
+              $*{maybeCrash}
               return;
             }
             """,
+            maybeCrash=maybecrash("Can't get Node.prototype"),
             type=parentProtoType,
             getParentProto=getParentProto)
 
         getConstructorProto = fill(
             """
             JS::${type}<JSObject*> constructorProto(${getConstructorProto});
             if (!constructorProto) {
+              $*{maybeCrash}
               return;
             }
             """,
+            maybeCrash=maybecrash("Can't get Node"),
             type=constructorProtoType,
             getConstructorProto=getConstructorProto)
 
         idsToInit = []
         # There is no need to init any IDs in bindings that don't want Xrays.
         if self.descriptor.wantsXrays:
             if self.properties.hasNonChromeOnly():
                 idsToInit.append("sNativeProperties")
             if self.properties.hasChromeOnly():
                 idsToInit.append("sChromeOnlyNativeProperties")
         if len(idsToInit) > 0:
             initIdCalls = ["!InitIds(aCx, %s.Upcast())" % (properties)
                            for properties in idsToInit]
             idsInitedFlag = CGGeneric("static bool sIdsInited = false;\n")
             setFlag = CGGeneric("sIdsInited = true;\n")
-            initIdConditionals = [CGIfWrapper(CGGeneric("return;\n"), call)
+            initIdConditionals = [CGIfWrapper(CGGeneric(fill(
+                """
+                $*{maybeCrash}
+                return;
+                """,
+                maybeCrash=maybecrash("Can't init IDs"))), call)
                                   for call in initIdCalls]
             initIds = CGList([idsInitedFlag,
                               CGIfWrapper(CGList(initIdConditionals + [setFlag]),
                                           "!sIdsInited && NS_IsMainThread()")])
         else:
             initIds = None
 
         prefCacheData = []
@@ -3203,20 +3217,22 @@ class CGCreateInterfaceObjectsMethod(CGA
                 holderProto = "*protoCache"
             createUnforgeableHolder = CGGeneric(fill(
                 """
                 JS::Rooted<JSObject*> unforgeableHolder(aCx);
                 {
                   JS::Rooted<JSObject*> holderProto(aCx, ${holderProto});
                   unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, ${holderClass}, holderProto);
                   if (!unforgeableHolder) {
+                    $*{maybeCrash}
                     $*{failureCode}
                   }
                 }
                 """,
+                maybeCrash=maybecrash("Can't create unforgeable holder"),
                 holderProto=holderProto,
                 holderClass=holderClass,
                 failureCode=failureCode))
             defineUnforgeables = InitUnforgeablePropertiesOnHolder(self.descriptor,
                                                                    self.properties,
                                                                    failureCode)
             createUnforgeableHolder = CGList(
                 [createUnforgeableHolder, defineUnforgeables])
@@ -3542,22 +3558,32 @@ def InitUnforgeablePropertiesOnHolder(de
     """
     assert (properties.unforgeableAttrs.hasNonChromeOnly() or
             properties.unforgeableAttrs.hasChromeOnly() or
             properties.unforgeableMethods.hasNonChromeOnly() or
             properties.unforgeableMethods.hasChromeOnly())
 
     unforgeables = []
 
+    if descriptor.name == "Document":
+        maybeCrash = dedent(
+            """
+            MOZ_CRASH("Bug 1405521/1488480: Can't define unforgeable attributes");
+            """);
+    else:
+        maybeCrash = "";
+
     defineUnforgeableAttrs = fill(
         """
         if (!DefineUnforgeableAttributes(aCx, ${holderName}, %s)) {
+          $*{maybeCrash}
           $*{failureCode}
         }
         """,
+        maybeCrash=maybeCrash,
         failureCode=failureCode,
         holderName=holderName)
     defineUnforgeableMethods = fill(
         """
         if (!DefineUnforgeableMethods(aCx, ${holderName}, %s)) {
           $*{failureCode}
         }
         """,