Bug 854614 - Root result and argument JS::Values. r=bz
☠☠ backed out by ed781d87fc46 ☠ ☠
authorTom Schuster <evilpies@gmail.com>
Thu, 11 Apr 2013 13:57:03 +0200
changeset 135209 2ceca4816688beb76f75aeb46fd0c8ebaa69df71
parent 135208 1174a55338e8cc5ca52a57f077133e44dcb22d37
child 135210 73adad5ded336441ca8ad6ade93fe740d127a705
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs854614
milestone23.0a1
Bug 854614 - Root result and argument JS::Values. r=bz
js/xpconnect/src/qsgen.py
--- a/js/xpconnect/src/qsgen.py
+++ b/js/xpconnect/src/qsgen.py
@@ -470,17 +470,17 @@ argumentUnboxingTemplates = {
         "        return JS_FALSE;\n",
 
     '[utf8string]':
         "    xpc_qsAUTF8String ${name}(cx, ${argVal}, ${argPtr});\n"
         "    if (!${name}.IsValid())\n"
         "        return JS_FALSE;\n",
 
     '[jsval]':
-        "    jsval ${name} = ${argVal};\n"
+        "    JS::RootedValue ${name}(cx, ${argVal});\n"
     }
 
 # From JSData2Native.
 #
 # Omitted optional arguments are treated as though the caller had passed JS
 # `null`; this behavior is from XPCWrappedNative::CallMethod. The 'jsval' type,
 # however, defaults to 'undefined'.
 #
@@ -505,17 +505,22 @@ def writeArgumentUnboxing(f, i, name, ty
         argPtr = "argv"
         argVal = "argv[0]"
     elif optional:
         if typeName == "[jsval]":
             val = "JSVAL_VOID"
         else:
             val = "JSVAL_NULL"
         argVal = "(%d < argc ? argv[%d] : %s)" % (i, i, val)
-        argPtr = "(%d < argc ? &argv[%d] : NULL)" % (i, i)
+        if typeName == "[jsval]":
+            # This should use the rooted argument,
+            # however we probably won't ever need to support that.
+            argPtr = None
+        else:
+            argPtr = "(%d < argc ? &argv[%d] : NULL)" % (i, i)
     else:
         argVal = "argv[%d]" % i
         argPtr = "&" + argVal
 
     params = {
         'name': name,
         'argVal': argVal,
         'argPtr': argPtr,
@@ -585,32 +590,32 @@ def writeResultDecl(f, type, varname):
             f.write("    %s %s;\n" % (typeName, varname))
             return
     elif t.kind == 'native':
         name = getBuiltinOrNativeTypeName(t)
         if name in ('[domstring]', '[astring]'):
             f.write("    nsString %s;\n" % varname)
             return
         elif name == '[jsval]':
-            f.write("    jsval %s;\n" % varname)
+            f.write("    JS::RootedValue %s(cx);\n" % varname)
             return
     elif t.kind in ('interface', 'forward'):
         f.write("    nsCOMPtr<%s> %s;\n" % (type.name, varname))
         return
 
     warn("Unable to declare result of type %s" % type.name)
     f.write("    !; // TODO - Declare out parameter `%s`.\n" % varname)
 
 def outParamForm(name, type):
     type = unaliasType(type)
     if type.kind == 'builtin':
         return '&' + name
     elif type.kind == 'native':
         if getBuiltinOrNativeTypeName(type) == '[jsval]':
-            return '&' + name
+            return name + '.address()'
         elif type.modifier == 'ref':
             return name
         else:
             return '&' + name
     else:
         return 'getter_AddRefs(%s)' % name
 
 # From NativeData2JS.
@@ -940,17 +945,17 @@ def writeQuickStub(f, customMethodCalls,
 
         # Call the method.
         if isMethod:
             comName = header.methodNativeName(member)
             argv = ['arg' + str(i) for i, p in enumerate(member.params)]
             if member.implicit_jscontext:
                 argv.append('cx')
             if member.optional_argc:
-                argv.append('std::min<uint32_t>(argc, %d) - %d' % 
+                argv.append('std::min<uint32_t>(argc, %d) - %d' %
                             (len(member.params), requiredArgs))
             if not isVoidType(member.realtype):
                 argv.append(outParamForm(resultname, member.realtype))
             args = ', '.join(argv)
         else:
             comName = header.attributeNativeName(member, isGetter)
             if isGetter:
                 args = outParamForm(resultname, member.realtype)