Bug 1600019 - Part 4: Prefer js::Call over JS::Call for engine-internal calls. r=jonco

`js::Call` avoids copying the arguments into a separate `InvokeArgs` struct,
therefore it's generally preferred for calls within SpiderMonkey.

Depends on D55088

Differential Revision: https://phabricator.services.mozilla.com/D55089

--HG--
extra : moz-landing-system : lando
This commit is contained in:
André Bargull 2019-11-28 16:56:37 +00:00
Родитель 4a83568d4d
Коммит e890f95e14
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -587,19 +587,22 @@ bool FinalizationGroupObject::cleanupQueuedHoldings(
// 4. If callback is undefined, set callback to
// finalizationGroup.[[CleanupCallback]].
RootedObject callback(cx, callbackArg);
if (!callbackArg) {
callback = group->cleanupCallback();
RootedValue callback(cx);
if (callbackArg) {
callback.setObject(*callbackArg);
} else {
JSObject* cleanupCallback = group->cleanupCallback();
MOZ_ASSERT(cleanupCallback);
callback.setObject(*cleanupCallback);
}
// 5. Set finalizationGroup.[[IsFinalizationGroupCleanupJobActive]] to true.
group->setCleanupJobActive(true);
// 6. Let result be Call(callback, undefined, iterator).
RootedValue iteratorVal(cx, ObjectValue(*iterator));
RootedValue rval(cx);
JS::AutoValueArray<1> args(cx);
args[0].setObject(*iterator);
bool ok = JS::Call(cx, UndefinedHandleValue, callback, args, &rval);
bool ok = Call(cx, callback, UndefinedHandleValue, iteratorVal, &rval);
// Remove holdings that were iterated over.
size_t index = iterator->index();