Bug 1259877 - Update Reflect.parse callback code to work with InvokeArgs and js::Call. r=arai
authorJeff Walden <jwalden@mit.edu>
Mon, 21 Mar 2016 16:13:36 -0700
changeset 293148 ceeb25518b0c0e7e02867e91de33eb99cc6a7b5e
parent 293147 8cf68d45fea85347a87615a49ab2b0e987e24e63
child 293149 69079481ba3a240784613c05e58cd9ed9841afc3
push id30175
push usercbook@mozilla.com
push dateThu, 14 Apr 2016 09:38:40 +0000
treeherdermozilla-central@91115264629d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1259877
milestone48.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 1259877 - Update Reflect.parse callback code to work with InvokeArgs and js::Call. r=arai
js/src/builtin/ReflectParse.cpp
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -300,53 +300,53 @@ class NodeBuilder
         return true;
     }
 
     void setTokenStream(TokenStream* ts) {
         tokenStream = ts;
     }
 
   private:
-    template <size_t N>
-    bool callbackHelper(HandleValue fun, AutoValueArray<N>& args, size_t i,
+    bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i,
                         TokenPos* pos, MutableHandleValue dst)
     {
         // The end of the implementation of callback(). All arguments except
-        // loc have already been stored in range [0, i) or args.
-        MOZ_ASSERT(i == N - 1);
+        // loc have already been stored in range [0, i).
         if (saveLoc) {
-            RootedValue loc(cx);
-            if (!newNodeLoc(pos, &loc))
+            if (!newNodeLoc(pos, args[i]))
                 return false;
-            args[i++].set(loc);
         }
-        return Invoke(cx, userv, fun, N, args.begin(), dst);
+
+        return js::Call(cx, fun, userv, args, dst);
     }
 
     // Helper function for callback(). Note that all Arguments must be types
-    // that convert to HandleValue, so this is not really as template-y as it
-    // seems, just variadic.
-    template <size_t N, typename... Arguments>
-    bool callbackHelper(HandleValue fun, AutoValueArray<N>& args, size_t i,
+    // that convert to HandleValue, so this isn't as template-y as it seems,
+    // just variadic.
+    template <typename... Arguments>
+    bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i,
                         HandleValue head, Arguments&&... tail)
     {
-        // Recursive loop to store the arguments in the array. This eventually
+        // Recursive loop to store the arguments into args. This eventually
         // bottoms out in a call to the non-template callbackHelper() above.
         args[i].set(head);
         return callbackHelper(fun, args, i + 1, Forward<Arguments>(tail)...);
     }
 
     // Invoke a user-defined callback. The actual signature is:
     //
     //     bool callback(HandleValue fun, HandleValue... args, TokenPos* pos,
     //                   MutableHandleValue dst);
     template <typename... Arguments>
     bool callback(HandleValue fun, Arguments&&... args) {
-        AutoValueArray<sizeof...(args) - 1> argv(cx);
-        return callbackHelper(fun, argv, 0, Forward<Arguments>(args)...);
+        InvokeArgs iargs(cx);
+        if (!iargs.init(sizeof...(args) - 2 + size_t(saveLoc)))
+            return false;
+
+        return callbackHelper(fun, iargs, 0, Forward<Arguments>(args)...);
     }
 
     // WARNING: Returning a Handle is non-standard, but it works in this case
     // because both |v| and |UndefinedHandleValue| are definitely rooted on a
     // previous stack frame (i.e. we're just choosing between two
     // already-rooted values).
     HandleValue opt(HandleValue v) {
         MOZ_ASSERT_IF(v.isMagic(), v.whyMagic() == JS_SERIALIZE_NO_NODE);