Bug 1140586 part 3. Drop the funobjArg of js::NewFunction and js::NewFunctionWithProto. r=waldo

This commit is contained in:
Boris Zbarsky 2015-03-11 22:33:59 -04:00
Родитель 3e6ae938f8
Коммит 3b6d207238
16 изменённых файлов: 50 добавлений и 55 удалений

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

@ -799,7 +799,7 @@ NewExportedFunction(JSContext *cx, const AsmJSModule::ExportedFunction &func,
{
RootedPropertyName name(cx, func.name());
unsigned numArgs = func.isChangeHeap() ? 1 : func.numArgs();
JSFunction *fun = NewFunction(cx, NullPtr(), CallAsmJS, numArgs, JSFunction::ASMJS_CTOR,
JSFunction *fun = NewFunction(cx, CallAsmJS, numArgs, JSFunction::ASMJS_CTOR,
cx->global(), name, JSFunction::ExtendedFinalizeKind);
if (!fun)
return nullptr;
@ -821,7 +821,7 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
if (!src)
return false;
RootedFunction fun(cx, NewFunction(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
RootedFunction fun(cx, NewFunction(cx, nullptr, 0, JSFunction::INTERPRETED,
cx->global(), name, JSFunction::FinalizeKind,
TenuredObject));
if (!fun)
@ -1092,7 +1092,7 @@ js::NewAsmJSModuleFunction(ExclusiveContext *cx, JSFunction *origFun, HandleObje
JSFunction::Flags flags = origFun->isLambda() ? JSFunction::ASMJS_LAMBDA_CTOR
: JSFunction::ASMJS_CTOR;
JSFunction *moduleFun = NewFunction(cx, NullPtr(), LinkAsmJS, origFun->nargs(),
JSFunction *moduleFun = NewFunction(cx, LinkAsmJS, origFun->nargs(),
flags, NullPtr(), name,
JSFunction::ExtendedFinalizeKind, TenuredObject);
if (!moduleFun)

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

@ -7527,7 +7527,7 @@ ParseFunction(ModuleCompiler &m, ParseNode **fnOut)
return false;
// This flows into FunctionBox, so must be tenured.
RootedFunction fun(m.cx(), NewFunction(m.cx(), NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
RootedFunction fun(m.cx(), NewFunction(m.cx(), nullptr, 0, JSFunction::INTERPRETED,
m.cx()->global(), name, JSFunction::FinalizeKind,
TenuredObject));
if (!fun)

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

@ -1084,7 +1084,7 @@ CreateObjectConstructor(JSContext *cx, JSProtoKey key)
return nullptr;
/* Create the Object function now that we have a [[Prototype]] for it. */
return NewFunction(cx, NullPtr(), obj_construct, 1, JSFunction::NATIVE_CTOR,
return NewFunction(cx, obj_construct, 1, JSFunction::NATIVE_CTOR,
self, HandlePropertyName(cx->names().Object),
JSFunction::FinalizeKind, SingletonObject);
}

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

@ -1236,7 +1236,7 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind, Hand
gc::AllocKind allocKind = JSFunction::FinalizeKind;
if (kind == Arrow)
allocKind = JSFunction::ExtendedFinalizeKind;
fun = NewFunctionWithProto(context, NullPtr(), nullptr, 0, flags, NullPtr(), atom, proto,
fun = NewFunctionWithProto(context, nullptr, 0, flags, NullPtr(), atom, proto,
allocKind, MaybeSingletonObject);
if (!fun)
return nullptr;

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

@ -2176,7 +2176,7 @@ DefinePropertyById(JSContext *cx, HandleObject obj, HandleId id, HandleValue val
RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : nullptr);
if (getter && !(attrs & JSPROP_GETTER)) {
RootedObject global(cx, (JSObject*) &obj->global());
JSFunction *getobj = NewFunction(cx, NullPtr(), (Native) getter, 0,
JSFunction *getobj = NewFunction(cx, (Native) getter, 0,
zeroFlags, global, atom);
if (!getobj)
return false;
@ -2191,7 +2191,7 @@ DefinePropertyById(JSContext *cx, HandleObject obj, HandleId id, HandleValue val
// Root just the getter, since the setter is not yet a JSObject.
AutoRooterGetterSetter getRoot(cx, JSPROP_GETTER, &getter, nullptr);
RootedObject global(cx, (JSObject*) &obj->global());
JSFunction *setobj = NewFunction(cx, NullPtr(), (Native) setter, 1,
JSFunction *setobj = NewFunction(cx, (Native) setter, 1,
zeroFlags, global, atom);
if (!setobj)
return false;
@ -3158,7 +3158,7 @@ JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
}
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), atom);
return NewFunction(cx, native, nargs, funFlags, NullPtr(), atom);
}
JS_PUBLIC_API(JSFunction *)
@ -3173,7 +3173,7 @@ JS_NewFunctionById(JSContext *cx, JSNative native, unsigned nargs, unsigned flag
RootedAtom name(cx, JSID_TO_ATOM(id));
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), name);
return NewFunction(cx, native, nargs, funFlags, NullPtr(), name);
}
JS_PUBLIC_API(JSFunction *)
@ -4016,7 +4016,7 @@ CompileFunction(JSContext *cx, const ReadOnlyCompileOptions &options,
return false;
}
fun.set(NewFunction(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED, enclosingDynamicScope,
fun.set(NewFunction(cx, nullptr, 0, JSFunction::INTERPRETED, enclosingDynamicScope,
funAtom, JSFunction::FinalizeKind, TenuredObject));
if (!fun)
return false;

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

@ -435,7 +435,7 @@ js::NewFunctionWithReserved(JSContext *cx, JSNative native, unsigned nargs, unsi
}
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), atom,
return NewFunction(cx, native, nargs, funFlags, NullPtr(), atom,
JSFunction::ExtendedFinalizeKind);
}
@ -449,7 +449,7 @@ js::NewFunctionByIdWithReserved(JSContext *cx, JSNative native, unsigned nargs,
RootedAtom atom(cx, JSID_TO_ATOM(id));
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags);
return NewFunction(cx, NullPtr(), native, nargs, funFlags, NullPtr(), atom,
return NewFunction(cx, native, nargs, funFlags, NullPtr(), atom,
JSFunction::ExtendedFinalizeKind);
}

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

@ -599,7 +599,7 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
gc::AllocKind allocKind = JSFunction::FinalizeKind;
if (uint16_t(flagsword) & JSFunction::EXTENDED)
allocKind = JSFunction::ExtendedFinalizeKind;
fun = NewFunctionWithProto(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
fun = NewFunctionWithProto(cx, nullptr, 0, JSFunction::INTERPRETED,
/* parent = */ NullPtr(), NullPtr(), proto,
allocKind, TenuredObject);
if (!fun)
@ -656,7 +656,7 @@ js::CloneFunctionAndScript(JSContext *cx, HandleObject enclosingScope, HandleFun
gc::AllocKind allocKind = JSFunction::FinalizeKind;
if (srcFun->isExtended())
allocKind = JSFunction::ExtendedFinalizeKind;
RootedFunction clone(cx, NewFunctionWithProto(cx, NullPtr(), nullptr, 0,
RootedFunction clone(cx, NewFunctionWithProto(cx, nullptr, 0,
JSFunction::INTERPRETED, NullPtr(), NullPtr(),
cloneProto, allocKind, TenuredObject));
if (!clone)
@ -781,7 +781,7 @@ CreateFunctionConstructor(JSContext *cx, JSProtoKey key)
RootedObject functionProto(cx, &global->getPrototype(JSProto_Function).toObject());
RootedObject functionCtor(cx,
NewFunctionWithProto(cx, NullPtr(), Function, 1, JSFunction::NATIVE_CTOR,
NewFunctionWithProto(cx, Function, 1, JSFunction::NATIVE_CTOR,
global, HandlePropertyName(cx->names().Function),
functionProto, JSFunction::FinalizeKind, SingletonObject));
if (!functionCtor)
@ -802,7 +802,7 @@ CreateFunctionPrototype(JSContext *cx, JSProtoKey key)
* give it the guts to be one.
*/
JSObject *functionProto_ =
NewFunctionWithProto(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
NewFunctionWithProto(cx, nullptr, 0, JSFunction::INTERPRETED,
self, NullPtr(), objectProto, JSFunction::FinalizeKind,
SingletonObject);
if (!functionProto_)
@ -870,7 +870,7 @@ CreateFunctionPrototype(JSContext *cx, JSProtoKey key)
// creating that as far as the world is concerned, so things will get all
// confused.
RootedFunction throwTypeError(cx,
NewFunctionWithProto(cx, NullPtr(), ThrowTypeError, 0, JSFunction::NATIVE_FUN,
NewFunctionWithProto(cx, ThrowTypeError, 0, JSFunction::NATIVE_FUN,
self, NullPtr(), functionProto, JSFunction::FinalizeKind,
SingletonObject));
if (!throwTypeError || !PreventExtensions(cx, throwTypeError))
@ -1700,7 +1700,7 @@ js::fun_bind(JSContext *cx, HandleObject target, HandleValue thisArg,
// Step 4.
JSFunction::Flags flags = target->isConstructor() ? JSFunction::NATIVE_CTOR
: JSFunction::NATIVE_FUN;
RootedFunction fun(cx, NewFunction(cx, js::NullPtr(), CallOrConstructBoundFunction, length,
RootedFunction fun(cx, NewFunction(cx, CallOrConstructBoundFunction, length,
flags, cx->global(), nameAtom));
if (!fun)
return nullptr;
@ -1946,7 +1946,7 @@ FunctionConstructor(JSContext *cx, unsigned argc, Value *vp, GeneratorKind gener
if (!proto)
return false;
}
RootedFunction fun(cx, NewFunctionWithProto(cx, js::NullPtr(), nullptr, 0,
RootedFunction fun(cx, NewFunctionWithProto(cx, nullptr, 0,
JSFunction::INTERPRETED_LAMBDA, global,
anonymousAtom, proto,
JSFunction::FinalizeKind, TenuredObject));
@ -1997,17 +1997,17 @@ JSFunction::isBuiltinFunctionConstructor()
}
JSFunction *
js::NewFunction(ExclusiveContext *cx, HandleObject funobjArg, Native native, unsigned nargs,
js::NewFunction(ExclusiveContext *cx, Native native, unsigned nargs,
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
gc::AllocKind allocKind /* = JSFunction::FinalizeKind */,
NewObjectKind newKind /* = GenericObject */)
{
return NewFunctionWithProto(cx, funobjArg, native, nargs, flags, parent, atom, NullPtr(),
return NewFunctionWithProto(cx, native, nargs, flags, parent, atom, NullPtr(),
allocKind, newKind);
}
JSFunction *
js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native native,
js::NewFunctionWithProto(ExclusiveContext *cx, Native native,
unsigned nargs, JSFunction::Flags flags, HandleObject parent,
HandleAtom atom, HandleObject proto,
gc::AllocKind allocKind /* = JSFunction::FinalizeKind */,
@ -2017,23 +2017,18 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
MOZ_ASSERT(sizeof(JSFunction) <= gc::Arena::thingSize(JSFunction::FinalizeKind));
MOZ_ASSERT(sizeof(FunctionExtended) <= gc::Arena::thingSize(JSFunction::ExtendedFinalizeKind));
RootedObject funobj(cx, funobjArg);
if (funobj) {
MOZ_ASSERT(funobj->is<JSFunction>());
funobj->assertParentIs(parent);
MOZ_ASSERT_IF(native, funobj->isSingleton());
} else {
// Don't mark asm.js module functions as singleton since they are
// cloned (via CloneFunctionObjectIfNotSingleton) which assumes that
// isSingleton implies isInterpreted.
if (native && !IsAsmJSModuleNative(native))
newKind = SingletonObject;
RootedObject realParent(cx, SkipScopeParent(parent));
funobj = NewObjectWithClassProto(cx, &JSFunction::class_, proto, realParent, allocKind,
newKind);
if (!funobj)
return nullptr;
}
RootedObject funobj(cx);
// Don't mark asm.js module functions as singleton since they are
// cloned (via CloneFunctionObjectIfNotSingleton) which assumes that
// isSingleton implies isInterpreted.
if (native && !IsAsmJSModuleNative(native))
newKind = SingletonObject;
RootedObject realParent(cx, SkipScopeParent(parent));
funobj = NewObjectWithClassProto(cx, &JSFunction::class_, proto, realParent, allocKind,
newKind);
if (!funobj)
return nullptr;
RootedFunction fun(cx, &funobj->as<JSFunction>());
if (allocKind == JSFunction::ExtendedFinalizeKind)
@ -2206,7 +2201,7 @@ js::DefineFunction(JSContext *cx, HandleObject obj, HandleId id, Native native,
if (!atom)
return nullptr;
RootedFunction fun(cx, NewFunction(cx, NullPtr(), native, nargs, funFlags, obj, atom,
RootedFunction fun(cx, NewFunction(cx, native, nargs, funFlags, obj, atom,
allocKind, newKind));
if (!fun)
return nullptr;

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

@ -511,14 +511,14 @@ extern bool
Generator(JSContext *cx, unsigned argc, Value *vp);
extern JSFunction *
NewFunction(ExclusiveContext *cx, HandleObject funobj, JSNative native, unsigned nargs,
NewFunction(ExclusiveContext *cx, JSNative native, unsigned nargs,
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
gc::AllocKind allocKind = JSFunction::FinalizeKind,
NewObjectKind newKind = GenericObject);
// If proto is nullptr, Function.prototype is used instead.
extern JSFunction *
NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobj, JSNative native, unsigned nargs,
NewFunctionWithProto(ExclusiveContext *cx, JSNative native, unsigned nargs,
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
HandleObject proto, gc::AllocKind allocKind = JSFunction::FinalizeKind,
NewObjectKind newKind = GenericObject);

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

@ -2510,7 +2510,7 @@ DefineConstructorAndPrototype(JSContext *cx, HandleObject obj, JSProtoKey key, H
* (FIXME: remove this dependency on the exact identity of the parent,
* perhaps as part of bug 638316.)
*/
RootedFunction fun(cx, NewFunction(cx, js::NullPtr(), constructor, nargs,
RootedFunction fun(cx, NewFunction(cx, constructor, nargs,
JSFunction::NATIVE_CTOR, obj, atom, ctorKind));
if (!fun)
goto bad;

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

@ -1548,7 +1548,7 @@ js::InitArrayBufferClass(JSContext *cx, HandleObject obj)
RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER;
JSObject *getter = NewFunction(cx, js::NullPtr(), ArrayBufferObject::byteLengthGetter, 0,
JSObject *getter = NewFunction(cx, ArrayBufferObject::byteLengthGetter, 0,
JSFunction::NATIVE_FUN, global, js::NullPtr());
if (!getter)
return nullptr;

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

@ -5840,7 +5840,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
Rooted<jsid> id(cx);
for (unsigned i = 0; i < fargc; i++) {
RootedFunction getobj(cx);
getobj = NewFunction(cx, js::NullPtr(), DebuggerArguments_getArg, 0,
getobj = NewFunction(cx, DebuggerArguments_getArg, 0,
JSFunction::NATIVE_FUN, global, js::NullPtr(),
JSFunction::ExtendedFinalizeKind);
if (!getobj)

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

@ -311,7 +311,7 @@ GlobalObject::initGeneratorClasses(JSContext *cx, Handle<GlobalObject *> global)
return false;
RootedObject proto(cx, &function.toObject());
RootedAtom name(cx, cx->names().GeneratorFunction);
RootedObject genFunction(cx, NewFunctionWithProto(cx, NullPtr(), Generator, 1,
RootedObject genFunction(cx, NewFunctionWithProto(cx, Generator, 1,
JSFunction::NATIVE_CTOR, global, name,
proto));
if (!genFunction)

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

@ -435,7 +435,7 @@ GlobalObject::createConstructor(JSContext *cx, Native ctor, JSAtom *nameArg, uns
{
RootedAtom name(cx, nameArg);
RootedObject self(cx, this);
return NewFunction(cx, NullPtr(), ctor, length, JSFunction::NATIVE_CTOR, self, name, kind);
return NewFunction(cx, ctor, length, JSFunction::NATIVE_CTOR, self, name, kind);
}
static NativeObject *
@ -597,7 +597,7 @@ GlobalObject::getSelfHostedFunction(JSContext *cx, HandleAtom selfHostedName, Ha
if (cx->global()->maybeGetIntrinsicValue(shId, funVal.address()))
return true;
JSFunction *fun = NewFunction(cx, NullPtr(), nullptr, nargs, JSFunction::INTERPRETED_LAZY,
JSFunction *fun = NewFunction(cx, nullptr, nargs, JSFunction::INTERPRETED_LAZY,
holder, name, JSFunction::ExtendedFinalizeKind, SingletonObject);
if (!fun)
return false;

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

@ -345,7 +345,7 @@ js::InitSharedArrayBufferClass(JSContext *cx, HandleObject obj)
RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
JSObject *getter = NewFunction(cx, NullPtr(), SharedArrayBufferObject::byteLengthGetter, 0,
JSObject *getter = NewFunction(cx, SharedArrayBufferObject::byteLengthGetter, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
return nullptr;

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

@ -350,7 +350,7 @@ class SharedTypedArrayObjectTemplate : public SharedTypedArrayObject
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER;
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), native, 0,
JSObject *getter = NewFunction(cx, native, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
return false;

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

@ -232,7 +232,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
if (!ctorProto)
return nullptr;
return NewFunctionWithProto(cx, NullPtr(), class_constructor, 3,
return NewFunctionWithProto(cx, class_constructor, 3,
JSFunction::NATIVE_CTOR, global,
ClassName(key, cx),
ctorProto, JSFunction::FinalizeKind,
@ -252,7 +252,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
}
RootedFunction fun(cx);
fun = NewFunction(cx, NullPtr(), ArrayBufferObject::createTypedArrayFromBuffer<NativeType>,
fun = NewFunction(cx, ArrayBufferObject::createTypedArrayFromBuffer<NativeType>,
0, JSFunction::NATIVE_FUN, cx->global(), NullPtr());
if (!fun)
return false;
@ -1946,7 +1946,7 @@ DataViewObject::defineGetter(JSContext *cx, PropertyName *name, HandleNativeObje
unsigned attrs = JSPROP_SHARED | JSPROP_GETTER;
Rooted<GlobalObject*> global(cx, cx->compartment()->maybeGlobal());
JSObject *getter = NewFunction(cx, NullPtr(), DataViewObject::getter<ValueGetter>, 0,
JSObject *getter = NewFunction(cx, DataViewObject::getter<ValueGetter>, 0,
JSFunction::NATIVE_FUN, global, NullPtr());
if (!getter)
return false;
@ -1991,7 +1991,7 @@ DataViewObject::initClass(JSContext *cx)
* |new DataView(new otherWindow.ArrayBuffer())|, and install it in the
* global for use by the DataViewObject constructor.
*/
RootedFunction fun(cx, NewFunction(cx, NullPtr(), ArrayBufferObject::createDataViewForThis,
RootedFunction fun(cx, NewFunction(cx, ArrayBufferObject::createDataViewForThis,
0, JSFunction::NATIVE_FUN, global, NullPtr()));
if (!fun)
return false;