Bug 865785 part 1. Go back to passing a JSContext* to the constructors for JS-implemented interfaces. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 04 May 2013 21:43:58 -0400
changeset 130869 1531a6ec12c179ea3b8614f10f4f231081081517
parent 130868 adaaf66417853e0e0c68a8688e316eadabb98c01
child 130870 1a60a6e9d9b8bd5f6efb50f35410974236a58e7b
push id24637
push userphilringnalda@gmail.com
push dateMon, 06 May 2013 00:15:12 +0000
treeherdermozilla-central@b109e2dbf03b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs865785
milestone23.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 865785 part 1. Go back to passing a JSContext* to the constructors for JS-implemented interfaces. r=mccr8
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -4046,19 +4046,21 @@ def getRetvalDeclarationForType(returnTy
         return result, False
     raise TypeError("Don't know how to declare return value for %s" %
                     returnType)
 
 def isResultAlreadyAddRefed(descriptor, extendedAttributes):
     # Default to already_AddRefed on the main thread, raw pointer in workers
     return not descriptor.workers and not 'resultNotAddRefed' in extendedAttributes
 
-def needCx(returnType, arguments, extendedAttributes, descriptorProvider):
-    return (typeNeedsCx(returnType, descriptorProvider, True) or
-            any(typeNeedsCx(a.type, descriptorProvider) for a in arguments) or
+def needCx(returnType, arguments, extendedAttributes, descriptorProvider,
+           considerTypes):
+    return (considerTypes and
+            (typeNeedsCx(returnType, descriptorProvider, True) or
+             any(typeNeedsCx(a.type, descriptorProvider) for a in arguments)) or
             'implicitJSContext' in extendedAttributes)
 
 class CGCallGenerator(CGThing):
     """
     A class to generate an actual call to a C++ object.  Assumes that the C++
     object is stored in a variable whose name is given by the |object| argument.
 
     errorReport should be a CGThing for an error report or None if no
@@ -4289,19 +4291,21 @@ class CGPerSignatureCall(CGThing):
                 globalObjectType = "Worker" + globalObjectType
             cgThings.append(CGGeneric("""%s global(cx, obj);
 if (global.Failed()) {
   return false;
 }
 """ % globalObjectType))
             argsPre.append("global")
 
-        needsCx = (not descriptor.interface.isJSImplemented() and
-                   needCx(returnType, arguments, self.extendedAttributes,
-                          descriptor))
+        # For JS-implemented interfaces we do not want to base the
+        # needsCx decision on the types involved, just on our extended
+        # attributes.
+        needsCx = needCx(returnType, arguments, self.extendedAttributes,
+                         descriptor, not descriptor.interface.isJSImplemented())
         if needsCx and not (static and descriptor.workers):
             argsPre.append("cx")
 
         if idlNode.isMethod() and idlNode.isLegacycaller():
             # If we can have legacycaller with identifier, we can't
             # just use the idlNode to determine whether we're
             # generating code for the legacycaller or not.
             assert idlNode.isIdentifierLess()
@@ -7962,17 +7966,21 @@ class CGBindingRoot(CGThing):
         return self.root.deps()
 
 class CGNativeMember(ClassMethod):
     def __init__(self, descriptor, member, name, signature, extendedAttrs,
                  breakAfter=True, passCxAsNeeded=True, visibility="public",
                  jsObjectsArePtr=False, variadicIsSequence=False):
         """
         If jsObjectsArePtr is true, typed arrays and "object" will be
-        passed as JSObject*
+        passed as JSObject*.
+
+        If passCxAsNeeded is false, we don't automatically pass in a
+        JSContext* based on the return and argument types.  We can
+        still pass it based on 'implicitJSContext' annotations.
         """
         self.descriptor = descriptor
         self.member = member
         self.extendedAttrs = extendedAttrs
         self.resultAlreadyAddRefed = isResultAlreadyAddRefed(self.descriptor,
                                                              self.extendedAttrs)
         self.passCxAsNeeded = passCxAsNeeded
         self.jsObjectsArePtr = jsObjectsArePtr
@@ -8139,19 +8147,18 @@ class CGNativeMember(ClassMethod):
             # Use aRv so it won't conflict with local vars named "rv"
             args.append(Argument("ErrorResult&", "aRv"))
         # The legacycaller thisval
         if self.member.isMethod() and self.member.isLegacycaller():
             # If it has an identifier, we can't deal with it yet
             assert self.member.isIdentifierLess()
             args.insert(0, Argument("JS::Value", "aThisVal"))
         # And jscontext bits.
-        if (self.passCxAsNeeded and
-            needCx(returnType, argList, self.extendedAttrs,
-                   self.descriptor)):
+        if needCx(returnType, argList, self.extendedAttrs,
+                  self.descriptor, self.passCxAsNeeded):
             args.insert(0, Argument("JSContext*", "cx"))
         # And if we're static, a global
         if self.member.isStatic():
             globalObjectType = "GlobalObject"
             if self.descriptor.workers:
                 globalObjectType = "Worker" + globalObjectType
             args.insert(0, Argument("const %s&" % globalObjectType, "global"))
         return args