Bug 1553286. Mark legacycall hooks (and a few other binding hooks) as MOZ_CAN_RUN_SCRIPT. r=mccr8 a=jcristau
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 22 May 2019 02:50:55 +0000
changeset 536438 77f31bca1162ba864c92da3050a6cfa079aaa0d7
parent 536437 33e1639074404212817de4e245aa1fac0d64d2eb
child 536439 e408eb60134bd6b5a148fa7d2e46076596e9dd94
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, jcristau
bugs1553286
milestone68.0
Bug 1553286. Mark legacycall hooks (and a few other binding hooks) as MOZ_CAN_RUN_SCRIPT. r=mccr8 a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D32053
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -7973,17 +7973,23 @@ class CGPerSignatureCall(CGThing):
         else:
             cgThings.append(CGCallGenerator(
                 self.isFallible(),
                 needsCallerType(idlNode),
                 isChromeOnly(idlNode),
                 self.getArguments(), argsPre, returnType,
                 self.extendedAttributes, descriptor,
                 nativeMethodName,
-                static, argsPost=argsPost, resultVar=resultVar))
+                static,
+                # We know our "self" must be being kept alive; otherwise we have
+                # a serious problem.  In common cases it's just an argument and
+                # we're MOZ_CAN_RUN_SCRIPT, but in some cases it's on the stack
+                # and being kept alive via references from JS.
+                object="MOZ_KnownLive(self)",
+                argsPost=argsPost, resultVar=resultVar))
 
         if useCounterName:
             # Generate a telemetry call for when [UseCounter] is used.
             code = "SetDocumentAndPageUseCounter(obj, eUseCounter_%s);\n" % useCounterName
             cgThings.append(CGGeneric(code))
 
         self.cgRoot = CGList(cgThings)
 
@@ -8747,17 +8753,18 @@ class CGAbstractBindingMethod(CGAbstract
     'obj'.
 
     callArgs should be code for getting a JS::CallArgs into a variable
     called 'args'.  This can be "" if there is already such a variable
     around.
     """
     def __init__(self, descriptor, name, args, getThisObj,
                  callArgs="JS::CallArgs args = JS::CallArgsFromVp(argc, vp);\n"):
-        CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args)
+        CGAbstractStaticMethod.__init__(self, descriptor, name, "bool", args,
+                                        canRunScript=True)
 
         self.unwrapFailureCode = 'return ThrowErrorMessage(cx, MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, "Value", "%s");\n' % descriptor.interface.identifier.name
 
         if getThisObj == "":
             self.getThisObj = None
         else:
             self.getThisObj = CGGeneric("JS::Rooted<JSObject*> obj(cx, %s);\n" %
                                         getThisObj)