Bug 766583 part 7. Stop declaring variadic arguments as const on the stack in bindings code. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 25 Apr 2013 19:03:07 -0400
changeset 129998 c6da9de6c80756fa8e7939a6baf0b5202d8e50ca
parent 129997 6268bbee606ec6e30189c65e611db61b1b9a47f8
child 129999 0a7e98a3c3ebbdd7f11770f24a3a71bae9199918
push id1552
push userttaubert@mozilla.com
push dateSat, 27 Apr 2013 15:33:29 +0000
treeherderfx-team@40dafc376794 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs766583
milestone23.0a1
Bug 766583 part 7. Stop declaring variadic arguments as const on the stack in bindings code. r=smaug
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -3463,25 +3463,24 @@ class CGArgumentConverter(CGThing):
         if elementHolderType is not None:
             raise TypeError("Shouldn't need holders for variadics")
 
         replacer = dict(self.argcAndIndex, **self.replacementVariables)
         replacer["seqType"] = CGTemplatedType("AutoSequence", elementDeclType).define()
         replacer["elemType"] = elementDeclType.define()
 
         # NOTE: Keep this in sync with sequence conversions as needed
-        variadicConversion = string.Template("""const ${seqType} ${declName};
+        variadicConversion = string.Template("""${seqType} ${declName};
 if (${argc} > ${index}) {
-  ${seqType}& arr = const_cast< ${seqType}& >(${declName});
-  if (!arr.SetCapacity(${argc} - ${index})) {
+  if (!${declName}.SetCapacity(${argc} - ${index})) {
     JS_ReportOutOfMemory(cx);
     return false;
   }
   for (uint32_t variadicArg = ${index}; variadicArg < ${argc}; ++variadicArg) {
-    ${elemType}& slot = *arr.AppendElement();
+    ${elemType}& slot = *${declName}.AppendElement();
 """).substitute(replacer)
 
         val = string.Template("${argv}[variadicArg]").substitute(replacer)
         variadicConversion += CGIndenter(CGGeneric(
                 string.Template(elementTemplate).substitute(
                     {
                         "val" : val,
                         "valPtr": "&" + val,
@@ -3969,16 +3968,17 @@ class CGCallGenerator(CGThing):
                     return True
                 if a.type.nullable():
                     return True
                 if a.type.isString():
                     return True
                 if a.optional and not a.defaultValue:
                     # If a.defaultValue, then it's not going to use an Optional,
                     # so doesn't need to be const just due to being optional.
+                    # This also covers variadic arguments.
                     return True
                 if a.type.isUnion():
                     return True
                 return False
             if needsConst(a):
                 arg = CGWrapper(arg, pre="Constify(", post=")")
             args.append(arg)