mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1125356 - Introduce JS_NewPlainObject. r=Waldo
This commit is contained in:
parent
18683688f4
commit
a29cc5e499
@ -511,7 +511,7 @@ js::ExecuteInGlobalAndReturnScope(JSContext *cx, HandleObject global, HandleScri
|
||||
Debugger::onNewScript(cx, script, global);
|
||||
}
|
||||
|
||||
RootedObject scope(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject scope(cx, JS_NewPlainObject(cx));
|
||||
if (!scope)
|
||||
return false;
|
||||
|
||||
|
@ -51,7 +51,7 @@ static bool
|
||||
GetBuildConfiguration(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RootedObject info(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject info(cx, JS_NewPlainObject(cx));
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
@ -1425,7 +1425,7 @@ static bool
|
||||
GetJitCompilerOptions(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
RootedObject info(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject info(cx, JS_NewPlainObject(cx));
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
|
@ -935,7 +935,7 @@ InitCTypeClass(JSContext* cx, HandleObject parent)
|
||||
static JSObject*
|
||||
InitABIClass(JSContext* cx, JSObject* parent)
|
||||
{
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr, NullPtr(), NullPtr()));
|
||||
RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
@ -4773,7 +4773,7 @@ AddFieldToArray(JSContext* cx,
|
||||
{
|
||||
RootedObject typeObj(cx, typeObj_);
|
||||
Rooted<JSFlatString*> name(cx, name_);
|
||||
RootedObject fieldObj(cx, JS_NewObject(cx, nullptr, NullPtr(), NullPtr()));
|
||||
RootedObject fieldObj(cx, JS_NewPlainObject(cx));
|
||||
if (!fieldObj)
|
||||
return false;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
FRAGMENT(JSObject, simple) {
|
||||
JS::Rooted<JSObject *> glob(cx, JS::CurrentGlobalOrNull(cx));
|
||||
JS::Rooted<JSObject *> plain(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::Rooted<JSObject *> plain(cx, JS_NewPlainObject(cx));
|
||||
JS::Rooted<JSObject *> global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
JS::Rooted<JSObject *> func(cx, (JSObject *) JS_NewFunction(cx, (JSNative) 1, 0, 0,
|
||||
global, "dys"));
|
||||
|
@ -38,7 +38,7 @@ FRAGMENT(Root, HeapSlot) {
|
||||
}
|
||||
|
||||
FRAGMENT(Root, barriers) {
|
||||
JSObject *obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
JSObject *obj = JS_NewPlainObject(cx);
|
||||
js::PreBarriered<JSObject *> prebarriered(obj);
|
||||
js::HeapPtr<JSObject *> heapptr(obj);
|
||||
js::RelocatablePtr<JSObject *> relocatable(obj);
|
||||
|
@ -30,7 +30,7 @@ BEGIN_TEST(testAddPropertyHook)
|
||||
*/
|
||||
static const int ExpectedCount = 100;
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
JS::RootedValue proto(cx, OBJECT_TO_JSVAL(obj));
|
||||
JS_InitClass(cx, global, obj, &AddPropertyClass, nullptr, 0, nullptr, nullptr, nullptr,
|
||||
|
@ -18,7 +18,7 @@ BEGIN_TEST(testDefineGetterSetterNonEnumerable)
|
||||
static const char PROPERTY_NAME[] = "foo";
|
||||
|
||||
JS::RootedValue vobj(cx);
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
vobj = OBJECT_TO_JSVAL(obj);
|
||||
|
||||
|
@ -41,7 +41,7 @@ CheckDescriptor(JS::Handle<JSPropertyDescriptor> desc, bool enumerable,
|
||||
|
||||
BEGIN_TEST(testDefinePropertyIgnoredAttributes)
|
||||
{
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
JS::Rooted<JSPropertyDescriptor> desc(cx);
|
||||
JS::RootedValue defineValue(cx);
|
||||
|
||||
|
@ -45,8 +45,7 @@ END_TEST(testForOfIterator_bug515273_part1)
|
||||
|
||||
BEGIN_TEST(testForOfIterator_bug515273_part2)
|
||||
{
|
||||
JS::RootedObject obj(cx,
|
||||
JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
JS::RootedValue v(cx, JS::ObjectValue(*obj));
|
||||
|
||||
|
@ -20,7 +20,7 @@ GivesAndTakesCells(JS::GCCellPtr cell)
|
||||
|
||||
BEGIN_TEST(testGCCellPtr)
|
||||
{
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
|
||||
JS::RootedString str(cx, JS_NewStringCopyZ(cx, "probably foobar"));
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
BEGIN_TEST(testGCExactRooting)
|
||||
{
|
||||
JS::RootedObject rootCx(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject rootRt(cx->runtime(), JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject rootCx(cx, JS_NewPlainObject(cx));
|
||||
JS::RootedObject rootRt(cx->runtime(), JS_NewPlainObject(cx));
|
||||
|
||||
JS_GC(cx->runtime());
|
||||
|
||||
|
@ -70,7 +70,7 @@ TestHeapPostBarriers(T initialObj)
|
||||
|
||||
JSObject *NurseryObject()
|
||||
{
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
JS_DefineProperty(cx, obj, "x", 42, 0);
|
||||
|
@ -53,7 +53,7 @@ BEGIN_TEST(testTracingIncomingCCWs)
|
||||
|
||||
// Define an object in one zone, that is wrapped by a CCW in another zone.
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj->zone() == global1->zone());
|
||||
|
||||
JSAutoCompartment ac(cx, global2);
|
||||
|
@ -70,9 +70,9 @@ BEGIN_TEST(testGCNurseryFinalizer)
|
||||
CHECK(ranFinalizer == 0);
|
||||
|
||||
// Null finalization list with non-empty nursery.
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewPlainObject(cx);
|
||||
CHECK(js::gc::IsInsideNursery(obj));
|
||||
obj = nullptr;
|
||||
rt->gc.minorGC(JS::gcreason::EVICT_NURSERY);
|
||||
@ -97,15 +97,15 @@ BEGIN_TEST(testGCNurseryFinalizer)
|
||||
ranFinalizer = 0;
|
||||
|
||||
// Interleaved finalizable things in nursery.
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewObject(cx, Jsvalify(&NurseryClass), JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewObject(cx, Jsvalify(&NurseryClass), JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewObject(cx, Jsvalify(&NurseryClass), JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
obj = JS_NewObject(cx, Jsvalify(&NurseryClass), JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
obj = JS_NewPlainObject(cx);
|
||||
CHECK(js::gc::IsInsideNursery(obj));
|
||||
obj = nullptr;
|
||||
rt->gc.minorGC(JS::gcreason::EVICT_NURSERY);
|
||||
|
@ -116,6 +116,6 @@ BEGIN_TEST(testGCStoreBufferRemoval)
|
||||
|
||||
JSObject *NurseryObject()
|
||||
{
|
||||
return JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
return JS_NewPlainObject(cx);
|
||||
}
|
||||
END_TEST(testGCStoreBufferRemoval)
|
||||
|
@ -15,7 +15,7 @@ BEGIN_TEST(testIsInsideNursery)
|
||||
|
||||
JS_GC(rt);
|
||||
|
||||
JS::RootedObject object(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject object(cx, JS_NewPlainObject(cx));
|
||||
|
||||
/* Objects are initially allocated in the nursery. */
|
||||
CHECK(js::gc::IsInsideNursery(object));
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
BEGIN_TEST(testJSEvaluateScript)
|
||||
{
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
|
||||
CHECK(JS::RuntimeOptionsRef(cx).varObjFix());
|
||||
|
@ -14,7 +14,7 @@ constructHook(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
// Check that arguments were passed properly from JS_New.
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, js::Jsvalify(&js::PlainObject::class_), JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
if (!obj) {
|
||||
JS_ReportError(cx, "test failed, could not construct object");
|
||||
return false;
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
BEGIN_TEST(testSetProperty_NativeGetterStubSetter)
|
||||
{
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
CHECK(obj);
|
||||
|
||||
CHECK(JS_DefineProperty(cx, global, "globalProp", obj, JSPROP_ENUMERATE,
|
||||
|
@ -19,7 +19,7 @@ BEGIN_TEST(testStructuredClone_object)
|
||||
JSAutoCompartment ac(cx, g1);
|
||||
JS::RootedValue prop(cx, JS::Int32Value(1337));
|
||||
|
||||
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
JS::RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
v1 = JS::ObjectOrNullValue(obj);
|
||||
CHECK(v1.isObject());
|
||||
CHECK(JS_SetProperty(cx, obj, "prop", prop));
|
||||
|
@ -49,7 +49,7 @@ BEGIN_TEST(testWeakMap_basicOperations)
|
||||
|
||||
JSObject *newKey()
|
||||
{
|
||||
return JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
return JS_NewPlainObject(cx);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -185,7 +185,7 @@ JSObject *newCCW(JS::HandleObject sourceZone, JS::HandleObject destZone)
|
||||
JS::RootedObject object(cx);
|
||||
{
|
||||
JSAutoCompartment ac(cx, destZone);
|
||||
object = JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
object = JS_NewPlainObject(cx);
|
||||
if (!object)
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2084,6 +2084,16 @@ JS_NewObjectWithGivenProto(JSContext *cx, const JSClass *jsclasp, HandleObject p
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_NewPlainObject(JSContext *cx)
|
||||
{
|
||||
MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
return NewBuiltinClassInstance<PlainObject>(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_NewObjectForConstructor(JSContext *cx, const JSClass *clasp, const CallArgs& args)
|
||||
{
|
||||
|
@ -2793,6 +2793,10 @@ extern JS_PUBLIC_API(JSObject *)
|
||||
JS_NewObjectWithGivenProto(JSContext *cx, const JSClass *clasp, JS::Handle<JSObject*> proto,
|
||||
JS::Handle<JSObject*> parent);
|
||||
|
||||
// Creates a new plain object, like `new Object()`, with Object.prototype as [[Prototype]].
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_NewPlainObject(JSContext *cx);
|
||||
|
||||
/*
|
||||
* Freeze obj, and all objects it refers to, recursively. This will not recurse
|
||||
* through non-extensible objects, on the assumption that those are already
|
||||
|
@ -1052,7 +1052,7 @@ JS::ObjectPtr::trace(JSTracer *trc, const char *name)
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js::GetTestingFunctions(JSContext *cx)
|
||||
{
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr, NullPtr(), NullPtr()));
|
||||
RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
|
@ -236,7 +236,7 @@ os_waitpid(JSContext* cx, unsigned argc, Value* vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject info(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject info(cx, JS_NewPlainObject(cx));
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
@ -293,7 +293,7 @@ static const JSFunctionSpecWithHelp os_functions[] = {
|
||||
bool
|
||||
js::DefineOS(JSContext *cx, HandleObject global)
|
||||
{
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
return obj &&
|
||||
JS_DefineFunctionsWithHelp(cx, obj, os_functions) &&
|
||||
JS_DefineProperty(cx, global, "os", obj, 0);
|
||||
|
@ -4708,7 +4708,7 @@ static const JSFunctionSpecWithHelp console_functions[] = {
|
||||
bool
|
||||
DefineConsole(JSContext *cx, HandleObject global)
|
||||
{
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
|
||||
RootedObject obj(cx, JS_NewPlainObject(cx));
|
||||
return obj &&
|
||||
JS_DefineFunctionsWithHelp(cx, obj, console_functions) &&
|
||||
JS_DefineProperty(cx, global, "console", obj, 0);
|
||||
|
@ -531,7 +531,7 @@ ReferenceFinder::addReferrer(jsval referrerArg, Path *path)
|
||||
JSObject *
|
||||
ReferenceFinder::findReferences(HandleObject target)
|
||||
{
|
||||
result = JS_NewObject(context, nullptr, JS::NullPtr(), JS::NullPtr());
|
||||
result = JS_NewPlainObject(context);
|
||||
if (!result)
|
||||
return nullptr;
|
||||
if (!visit(target, nullptr))
|
||||
|
Loading…
Reference in New Issue
Block a user