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

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

@ -7527,7 +7527,7 @@ ParseFunction(ModuleCompiler &m, ParseNode **fnOut)
return false; return false;
// This flows into FunctionBox, so must be tenured. // 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, m.cx()->global(), name, JSFunction::FinalizeKind,
TenuredObject)); TenuredObject));
if (!fun) if (!fun)

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

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

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

@ -1236,7 +1236,7 @@ Parser<ParseHandler>::newFunction(HandleAtom atom, FunctionSyntaxKind kind, Hand
gc::AllocKind allocKind = JSFunction::FinalizeKind; gc::AllocKind allocKind = JSFunction::FinalizeKind;
if (kind == Arrow) if (kind == Arrow)
allocKind = JSFunction::ExtendedFinalizeKind; allocKind = JSFunction::ExtendedFinalizeKind;
fun = NewFunctionWithProto(context, NullPtr(), nullptr, 0, flags, NullPtr(), atom, proto, fun = NewFunctionWithProto(context, nullptr, 0, flags, NullPtr(), atom, proto,
allocKind, MaybeSingletonObject); allocKind, MaybeSingletonObject);
if (!fun) if (!fun)
return nullptr; 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); RootedAtom atom(cx, JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : nullptr);
if (getter && !(attrs & JSPROP_GETTER)) { if (getter && !(attrs & JSPROP_GETTER)) {
RootedObject global(cx, (JSObject*) &obj->global()); RootedObject global(cx, (JSObject*) &obj->global());
JSFunction *getobj = NewFunction(cx, NullPtr(), (Native) getter, 0, JSFunction *getobj = NewFunction(cx, (Native) getter, 0,
zeroFlags, global, atom); zeroFlags, global, atom);
if (!getobj) if (!getobj)
return false; 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. // Root just the getter, since the setter is not yet a JSObject.
AutoRooterGetterSetter getRoot(cx, JSPROP_GETTER, &getter, nullptr); AutoRooterGetterSetter getRoot(cx, JSPROP_GETTER, &getter, nullptr);
RootedObject global(cx, (JSObject*) &obj->global()); RootedObject global(cx, (JSObject*) &obj->global());
JSFunction *setobj = NewFunction(cx, NullPtr(), (Native) setter, 1, JSFunction *setobj = NewFunction(cx, (Native) setter, 1,
zeroFlags, global, atom); zeroFlags, global, atom);
if (!setobj) if (!setobj)
return false; return false;
@ -3158,7 +3158,7 @@ JS_NewFunction(JSContext *cx, JSNative native, unsigned nargs, unsigned flags,
} }
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(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 *) 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)); RootedAtom name(cx, JSID_TO_ATOM(id));
JSFunction::Flags funFlags = JSAPIToJSFunctionFlags(flags); 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 *) JS_PUBLIC_API(JSFunction *)
@ -4016,7 +4016,7 @@ CompileFunction(JSContext *cx, const ReadOnlyCompileOptions &options,
return false; 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)); funAtom, JSFunction::FinalizeKind, TenuredObject));
if (!fun) if (!fun)
return false; return false;

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

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

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

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

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

@ -511,14 +511,14 @@ extern bool
Generator(JSContext *cx, unsigned argc, Value *vp); Generator(JSContext *cx, unsigned argc, Value *vp);
extern JSFunction * 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, JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
gc::AllocKind allocKind = JSFunction::FinalizeKind, gc::AllocKind allocKind = JSFunction::FinalizeKind,
NewObjectKind newKind = GenericObject); NewObjectKind newKind = GenericObject);
// If proto is nullptr, Function.prototype is used instead. // If proto is nullptr, Function.prototype is used instead.
extern JSFunction * 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, JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
HandleObject proto, gc::AllocKind allocKind = JSFunction::FinalizeKind, HandleObject proto, gc::AllocKind allocKind = JSFunction::FinalizeKind,
NewObjectKind newKind = GenericObject); 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, * (FIXME: remove this dependency on the exact identity of the parent,
* perhaps as part of bug 638316.) * 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)); JSFunction::NATIVE_CTOR, obj, atom, ctorKind));
if (!fun) if (!fun)
goto bad; goto bad;

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

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

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

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

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

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

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

@ -435,7 +435,7 @@ GlobalObject::createConstructor(JSContext *cx, Native ctor, JSAtom *nameArg, uns
{ {
RootedAtom name(cx, nameArg); RootedAtom name(cx, nameArg);
RootedObject self(cx, this); 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 * static NativeObject *
@ -597,7 +597,7 @@ GlobalObject::getSelfHostedFunction(JSContext *cx, HandleAtom selfHostedName, Ha
if (cx->global()->maybeGetIntrinsicValue(shId, funVal.address())) if (cx->global()->maybeGetIntrinsicValue(shId, funVal.address()))
return true; 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); holder, name, JSFunction::ExtendedFinalizeKind, SingletonObject);
if (!fun) if (!fun)
return false; return false;

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

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

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

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

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

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