From 2fd882441b64bf3c5cc367ba569f51d202defc5d Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 11 Mar 2015 22:33:59 -0400 Subject: [PATCH] Bug 1142282 part 1. Remove the parent argument of NewNativeObjectWithGivenProto. r=waldo --- js/src/jsobj.cpp | 3 +-- js/src/vm/Debugger.cpp | 16 +++++++--------- js/src/vm/DebuggerMemory.cpp | 3 +-- js/src/vm/GeneratorObject.cpp | 4 ++-- js/src/vm/GlobalObject.cpp | 5 ++--- js/src/vm/NativeObject-inl.h | 8 ++++---- js/src/vm/PIC.cpp | 2 +- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index bf4c7b9dde8b..4926f0012c6c 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1806,8 +1806,7 @@ js::DeepCloneObjectLiteral(JSContext *cx, HandleNativeObject obj, NewObjectKind RootedObject proto(cx, group->proto().toObject()); obj->assertParentIs(cx->global()); clone = NewNativeObjectWithGivenProto(cx, &PlainObject::class_, proto, - NullPtr(), kind, - newKind); + kind, newKind); } // Allocate the same number of slots. diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 76eea87911a5..ee915c498451 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -452,7 +452,7 @@ Debugger::getScriptFrameWithIter(JSContext *cx, AbstractFramePtr frame, /* Create and populate the Debugger.Frame object. */ RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_FRAME_PROTO).toObject()); RootedNativeObject frameobj(cx, NewNativeObjectWithGivenProto(cx, &DebuggerFrame_class, - proto, NullPtr())); + proto)); if (!frameobj) return false; @@ -771,7 +771,7 @@ Debugger::wrapEnvironment(JSContext *cx, Handle env, MutableHandleValue rv } else { /* Create a new Debugger.Environment for env. */ RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_ENV_PROTO).toObject()); - envobj = NewNativeObjectWithGivenProto(cx, &DebuggerEnv_class, proto, NullPtr(), + envobj = NewNativeObjectWithGivenProto(cx, &DebuggerEnv_class, proto, TenuredObject); if (!envobj) return false; @@ -814,7 +814,7 @@ Debugger::wrapDebuggeeValue(JSContext *cx, MutableHandleValue vp) /* Create a new Debugger.Object for obj. */ RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_OBJECT_PROTO).toObject()); NativeObject *dobj = - NewNativeObjectWithGivenProto(cx, &DebuggerObject_class, proto, NullPtr(), + NewNativeObjectWithGivenProto(cx, &DebuggerObject_class, proto, TenuredObject); if (!dobj) return false; @@ -2917,8 +2917,7 @@ Debugger::construct(JSContext *cx, unsigned argc, Value *vp) * Debugger.{Frame,Object,Script,Memory}.prototype in reserved slots. The * rest of the reserved slots are for hooks; they default to undefined. */ - RootedNativeObject obj(cx, NewNativeObjectWithGivenProto(cx, &Debugger::jsclass, proto, - NullPtr())); + RootedNativeObject obj(cx, NewNativeObjectWithGivenProto(cx, &Debugger::jsclass, proto)); if (!obj) return false; for (unsigned slot = JSSLOT_DEBUG_PROTO_START; slot < JSSLOT_DEBUG_PROTO_STOP; slot++) @@ -4160,7 +4159,7 @@ Debugger::newDebuggerScript(JSContext *cx, HandleScript script) RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_SCRIPT_PROTO).toObject()); MOZ_ASSERT(proto); NativeObject *scriptobj = NewNativeObjectWithGivenProto(cx, &DebuggerScript_class, - proto, NullPtr(), TenuredObject); + proto, TenuredObject); if (!scriptobj) return nullptr; scriptobj->setReservedSlot(JSSLOT_DEBUGSCRIPT_OWNER, ObjectValue(*object)); @@ -5182,7 +5181,7 @@ Debugger::newDebuggerSource(JSContext *cx, HandleScriptSource source) RootedObject proto(cx, &object->getReservedSlot(JSSLOT_DEBUG_SOURCE_PROTO).toObject()); MOZ_ASSERT(proto); NativeObject *sourceobj = NewNativeObjectWithGivenProto(cx, &DebuggerSource_class, - proto, NullPtr(), TenuredObject); + proto, TenuredObject); if (!sourceobj) return nullptr; sourceobj->setReservedSlot(JSSLOT_DEBUGSOURCE_OWNER, ObjectValue(*object)); @@ -5822,8 +5821,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp) RootedObject proto(cx, GlobalObject::getOrCreateArrayPrototype(cx, global)); if (!proto) return false; - argsobj = NewNativeObjectWithGivenProto(cx, &DebuggerArguments_class, proto, - GlobalObject::upcast(global)); + argsobj = NewNativeObjectWithGivenProto(cx, &DebuggerArguments_class, proto); if (!argsobj) return false; SetReservedSlot(argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj)); diff --git a/js/src/vm/DebuggerMemory.cpp b/js/src/vm/DebuggerMemory.cpp index 23a3b2678def..0dfbba2e1116 100644 --- a/js/src/vm/DebuggerMemory.cpp +++ b/js/src/vm/DebuggerMemory.cpp @@ -41,8 +41,7 @@ DebuggerMemory::create(JSContext *cx, Debugger *dbg) { Value memoryProtoValue = dbg->object->getReservedSlot(Debugger::JSSLOT_DEBUG_MEMORY_PROTO); RootedObject memoryProto(cx, &memoryProtoValue.toObject()); - RootedNativeObject memory(cx, NewNativeObjectWithGivenProto(cx, &class_, memoryProto, - NullPtr())); + RootedNativeObject memory(cx, NewNativeObjectWithGivenProto(cx, &class_, memoryProto)); if (!memory) return nullptr; diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp index 072ccd0d1c23..914c8ebbf646 100644 --- a/js/src/vm/GeneratorObject.cpp +++ b/js/src/vm/GeneratorObject.cpp @@ -35,13 +35,13 @@ GeneratorObject::create(JSContext *cx, AbstractFramePtr frame) if (!proto) return nullptr; } - obj = NewNativeObjectWithGivenProto(cx, &StarGeneratorObject::class_, proto, global); + obj = NewNativeObjectWithGivenProto(cx, &StarGeneratorObject::class_, proto); } else { MOZ_ASSERT(frame.script()->isLegacyGenerator()); RootedObject proto(cx, GlobalObject::getOrCreateLegacyGeneratorObjectPrototype(cx, global)); if (!proto) return nullptr; - obj = NewNativeObjectWithGivenProto(cx, &LegacyGeneratorObject::class_, proto, global); + obj = NewNativeObjectWithGivenProto(cx, &LegacyGeneratorObject::class_, proto); } if (!obj) return nullptr; diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 2e9dca3a1f81..62f3382c00cd 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -442,7 +442,7 @@ CreateBlankProto(JSContext *cx, const Class *clasp, HandleObject proto, HandleOb { MOZ_ASSERT(clasp != &JSFunction::class_); - RootedNativeObject blankProto(cx, NewNativeObjectWithGivenProto(cx, clasp, proto, global, + RootedNativeObject blankProto(cx, NewNativeObjectWithGivenProto(cx, clasp, proto, SingletonObject)); if (!blankProto || !blankProto->setDelegate(cx)) return nullptr; @@ -524,8 +524,7 @@ GlobalObject::getOrCreateDebuggers(JSContext *cx, Handle global) if (debuggers) return debuggers; - NativeObject *obj = NewNativeObjectWithGivenProto(cx, &GlobalDebuggees_class, NullPtr(), - global); + NativeObject *obj = NewNativeObjectWithGivenProto(cx, &GlobalDebuggees_class, NullPtr()); if (!obj) return nullptr; debuggers = cx->new_(); diff --git a/js/src/vm/NativeObject-inl.h b/js/src/vm/NativeObject-inl.h index 31ce00e794ea..6b9bb4fdbd19 100644 --- a/js/src/vm/NativeObject-inl.h +++ b/js/src/vm/NativeObject-inl.h @@ -360,18 +360,18 @@ NewNativeObjectWithGivenTaggedProto(ExclusiveContext *cx, const Class *clasp, inline NativeObject * NewNativeObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, - HandleObject proto, HandleObject parent, + HandleObject proto, gc::AllocKind allocKind, NewObjectKind newKind) { - return MaybeNativeObject(NewObjectWithGivenProto(cx, clasp, proto, parent, allocKind, newKind)); + return MaybeNativeObject(NewObjectWithGivenProto(cx, clasp, proto, NullPtr(), allocKind, newKind)); } inline NativeObject * NewNativeObjectWithGivenProto(ExclusiveContext *cx, const Class *clasp, - HandleObject proto, HandleObject parent, + HandleObject proto, NewObjectKind newKind = GenericObject) { - return MaybeNativeObject(NewObjectWithGivenProto(cx, clasp, proto, parent, newKind)); + return MaybeNativeObject(NewObjectWithGivenProto(cx, clasp, proto, NullPtr(), newKind)); } inline NativeObject * diff --git a/js/src/vm/PIC.cpp b/js/src/vm/PIC.cpp index 165e705a9b42..e7c9a2cec64d 100644 --- a/js/src/vm/PIC.cpp +++ b/js/src/vm/PIC.cpp @@ -308,7 +308,7 @@ const Class ForOfPIC::jsclass = { js::ForOfPIC::createForOfPICObject(JSContext *cx, Handle global) { assertSameCompartment(cx, global); - NativeObject *obj = NewNativeObjectWithGivenProto(cx, &ForOfPIC::jsclass, NullPtr(), global); + NativeObject *obj = NewNativeObjectWithGivenProto(cx, &ForOfPIC::jsclass, NullPtr()); if (!obj) return nullptr; ForOfPIC::Chain *chain = cx->new_();