Bug 1259877 - Update various miscellaneous function-calling code to js::Call. r=jandem
authorJeff Walden <jwalden@mit.edu>
Mon, 21 Mar 2016 16:05:36 -0700
changeset 293145 a6fa04f4dee918095135374f540172ae161189ec
parent 293144 7a299a5909505d317c9ee86a236c64caef988fcf
child 293146 9cf2b9587eb898379f51692c5adc91ce1fbda11c
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)
reviewersjandem
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 various miscellaneous function-calling code to js::Call. r=jandem
js/src/jit/VMFunctions.cpp
js/src/vm/ForOfIterator.cpp
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -96,17 +96,24 @@ InvokeFunction(JSContext* cx, HandleObje
 
         // Otherwise the default |this| has already been created.  We could
         // almost perform a *call* at this point, but we'd break |new.target|
         // in the function.  So in this one weird case we call a one-off
         // construction path that *won't* set |this| to JS_IS_CONSTRUCTING.
         return InternalConstructWithProvidedThis(cx, fval, thisv, cargs, newTarget, rval);
     }
 
-    return Invoke(cx, thisv, fval, argc, argvWithoutThis, rval);
+    InvokeArgs args(cx);
+    if (!args.init(argc))
+        return false;
+
+    for (size_t i = 0; i < argc; i++)
+        args[i].set(argvWithoutThis[i]);
+
+    return Call(cx, fval, thisv, args, rval);
 }
 
 bool
 InvokeFunctionShuffleNewTarget(JSContext* cx, HandleObject obj, uint32_t numActualArgs,
                                uint32_t numFormalArgs, Value* argv, MutableHandleValue rval)
 {
     MOZ_ASSERT(numFormalArgs > numActualArgs);
     argv[1 + numActualArgs] = argv[1 + numFormalArgs];
@@ -785,32 +792,23 @@ InterpretResume(JSContext* cx, HandleObj
     if (!GlobalObject::getIntrinsicValue(cx, cx->global(), cx->names().InterpretGeneratorResume,
                                          &selfHostedFun))
     {
         return false;
     }
 
     MOZ_ASSERT(selfHostedFun.toObject().is<JSFunction>());
 
-    InvokeArgs args(cx);
-    if (!args.init(3))
-        return false;
-
-    args.setCallee(selfHostedFun);
-    args.setThis(UndefinedValue());
+    FixedInvokeArgs<3> args(cx);
 
     args[0].setObject(*obj);
     args[1].set(val);
     args[2].setString(kind);
 
-    if (!Invoke(cx, args))
-        return false;
-
-    rval.set(args.rval());
-    return true;
+    return Call(cx, selfHostedFun, UndefinedHandleValue, args, rval);
 }
 
 bool
 DebugAfterYield(JSContext* cx, BaselineFrame* frame)
 {
     // The BaselineFrame has just been constructed by JSOP_RESUME in the
     // caller. We need to set its debuggee flag as necessary.
     if (frame->script()->isDebuggee())
--- a/js/src/vm/ForOfIterator.cpp
+++ b/js/src/vm/ForOfIterator.cpp
@@ -42,22 +42,16 @@ ForOfIterator::init(HandleValue iterable
             index = 0;
             iterator = iterableObj;
             return true;
         }
     }
 
     MOZ_ASSERT(index == NOT_ARRAY);
 
-    // The iterator is the result of calling obj[@@iterator]().
-    InvokeArgs args(cx);
-    if (!args.init(0))
-        return false;
-    args.setThis(iterable);
-
     RootedValue callee(cx);
     RootedId iteratorId(cx, SYMBOL_TO_JSID(cx->wellKnownSymbols().iterator));
     if (!GetProperty(cx, iterableObj, iterableObj, iteratorId, &callee))
         return false;
 
     // If obj[@@iterator] is undefined and we were asked to allow non-iterables,
     // bail out now without setting iterator.  This will make valueIsIterable(),
     // which our caller should check, return false.
@@ -71,21 +65,21 @@ ForOfIterator::init(HandleValue iterable
     if (!callee.isObject() || !callee.toObject().isCallable()) {
         UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, iterable, nullptr);
         if (!bytes)
             return false;
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes.get());
         return false;
     }
 
-    args.setCallee(callee);
-    if (!Invoke(cx, args))
+    RootedValue res(cx);
+    if (!js::Call(cx, callee, iterable, &res))
         return false;
 
-    iterator = ToObject(cx, args.rval());
+    iterator = ToObject(cx, res);
     if (!iterator)
         return false;
 
     return true;
 }
 
 inline bool
 ForOfIterator::nextFromOptimizedArray(MutableHandleValue vp, bool* done)
@@ -129,58 +123,50 @@ ForOfIterator::next(MutableHandleValue v
             return nextFromOptimizedArray(vp, done);
 
         // ArrayIterator.prototype.next changed, materialize a proper
         // ArrayIterator instance and fall through to slowpath case.
         if (!materializeArrayIterator())
             return false;
     }
 
-    RootedValue method(cx_);
-    if (!GetProperty(cx_, iterator, iterator, cx_->names().next, &method))
+    RootedValue v(cx_);
+    if (!GetProperty(cx_, iterator, iterator, cx_->names().next, &v))
+        return false;
+
+    if (!js::Call(cx_, v, iterator, &v))
         return false;
 
-    InvokeArgs args(cx_);
-    if (!args.init(0))
-        return false;
-    args.setCallee(method);
-    args.setThis(ObjectValue(*iterator));
-    if (!Invoke(cx_, args))
+    RootedObject resultObj(cx_, ToObject(cx_, v));
+    if (!resultObj)
         return false;
 
-    RootedObject resultObj(cx_, ToObject(cx_, args.rval()));
-    if (!resultObj)
+    if (!GetProperty(cx_, resultObj, resultObj, cx_->names().done, &v))
         return false;
-    RootedValue doneVal(cx_);
-    if (!GetProperty(cx_, resultObj, resultObj, cx_->names().done, &doneVal))
-        return false;
-    *done = ToBoolean(doneVal);
+
+    *done = ToBoolean(v);
     if (*done) {
         vp.setUndefined();
         return true;
     }
+
     return GetProperty(cx_, resultObj, resultObj, cx_->names().value, vp);
 }
 
 bool
 ForOfIterator::materializeArrayIterator()
 {
     MOZ_ASSERT(index != NOT_ARRAY);
 
     HandlePropertyName name = cx_->names().ArrayValuesAt;
     RootedValue val(cx_);
     if (!GlobalObject::getSelfHostedFunction(cx_, cx_->global(), name, name, 1, &val))
         return false;
 
-    InvokeArgs args(cx_);
-    if (!args.init(1))
-        return false;
-    args.setCallee(val);
-    args.setThis(ObjectValue(*iterator));
-    args[0].set(Int32Value(index));
-    if (!Invoke(cx_, args))
+    RootedValue indexOrRval(cx_, Int32Value(index));
+    if (!js::Call(cx_, val, iterator, indexOrRval, &indexOrRval))
         return false;
 
     index = NOT_ARRAY;
     // Result of call to ArrayValuesAt must be an object.
-    iterator = &args.rval().toObject();
+    iterator = &indexOrRval.toObject();
     return true;
 }