Backed out changeset 3b19f13cf22a (bug 1406746) for rooting hazards

This commit is contained in:
Jon Coppeard 2017-10-10 13:03:36 +01:00
Родитель d059041927
Коммит 4ee603a0a2
1 изменённых файлов: 11 добавлений и 6 удалений

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

@ -6850,12 +6850,15 @@ CreateFunctionInfo(JSContext* cx,
HandleObject returnType,
const HandleValueArray& args)
{
auto fninfo = cx->make_unique<FunctionInfo>();
FunctionInfo* fninfo(cx->new_<FunctionInfo>());
if (!fninfo) {
JS_ReportOutOfMemory(cx);
return false;
}
// Stash the FunctionInfo in a reserved slot.
JS_SetReservedSlot(typeObj, SLOT_FNINFO, PrivateValue(fninfo));
ffi_abi abi;
if (!GetABI(cx, abiType, &abi)) {
JS_ReportErrorASCII(cx, "Invalid ABI specification");
@ -6865,7 +6868,7 @@ CreateFunctionInfo(JSContext* cx,
fninfo->mReturnType = returnType;
// Prepare the argument types.
// prepare the argument types
if (!fninfo->mArgTypes.reserve(args.length()) ||
!fninfo->mFFITypes.reserve(args.length())) {
JS_ReportOutOfMemory(cx);
@ -6910,12 +6913,14 @@ CreateFunctionInfo(JSContext* cx,
fninfo->mFFITypes.infallibleAppend(ffiType);
}
// For variadic functions, wait to PrepareCIF until the function is called.
if (!fninfo->mIsVariadic && !PrepareCIF(cx, fninfo.get()))
if (fninfo->mIsVariadic) {
// wait to PrepareCIF until function is called
return true;
}
if (!PrepareCIF(cx, fninfo))
return false;
// Now the FunctionInfo has been initialized, store it in a reserved slot.
JS_SetReservedSlot(typeObj, SLOT_FNINFO, PrivateValue(fninfo.release()));
return true;
}