mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 09:18:42 +09:00
1320408 - Part 9: Change JSObject::setFlags and depending methods to static method.
This commit is contained in:
parent
7e0b20a7bf
commit
7f856ff769
14 changed files with 61 additions and 55 deletions
|
|
@ -3489,7 +3489,7 @@ CreateNonSyntacticEnvironmentChain(JSContext* cx, AutoObjectVector& envChain,
|
|||
// declaration was qualified by "var". There is only sadness.
|
||||
//
|
||||
// See JSObject::isQualifiedVarObj.
|
||||
if (!env->setQualifiedVarObj(cx))
|
||||
if (!JSObject::setQualifiedVarObj(cx, env))
|
||||
return false;
|
||||
|
||||
// Also get a non-syntactic lexical environment to capture 'let' and
|
||||
|
|
|
|||
|
|
@ -3266,7 +3266,7 @@ CreateArrayPrototype(JSContext* cx, JSProtoKey key)
|
|||
metadata));
|
||||
if (!arrayProto ||
|
||||
!JSObject::setSingleton(cx, arrayProto) ||
|
||||
!arrayProto->setDelegate(cx) ||
|
||||
!JSObject::setDelegate(cx, arrayProto) ||
|
||||
!AddLengthProperty(cx, arrayProto))
|
||||
{
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ VectorToKeyIterator(JSContext* cx, HandleObject obj, unsigned flags, AutoIdVecto
|
|||
{
|
||||
MOZ_ASSERT(!(flags & JSITER_FOREACH));
|
||||
|
||||
if (obj->isSingleton() && !obj->setIteratedSingleton(cx))
|
||||
if (obj->isSingleton() && !JSObject::setIteratedSingleton(cx, obj))
|
||||
return false;
|
||||
MarkObjectGroupFlags(cx, obj, OBJECT_FLAG_ITERATED);
|
||||
|
||||
|
|
@ -698,7 +698,7 @@ VectorToValueIterator(JSContext* cx, HandleObject obj, unsigned flags, AutoIdVec
|
|||
{
|
||||
MOZ_ASSERT(flags & JSITER_FOREACH);
|
||||
|
||||
if (obj->isSingleton() && !obj->setIteratedSingleton(cx))
|
||||
if (obj->isSingleton() && !JSObject::setIteratedSingleton(cx, obj))
|
||||
return false;
|
||||
MarkObjectGroupFlags(cx, obj, OBJECT_FLAG_ITERATED);
|
||||
|
||||
|
|
|
|||
|
|
@ -1842,7 +1842,7 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
|
|||
if (!oldproto->as<NativeObject>().generateOwnShape(cx))
|
||||
return false;
|
||||
} else {
|
||||
if (!oldproto->setUncacheableProto(cx))
|
||||
if (!JSObject::setUncacheableProto(cx, oldproto))
|
||||
return false;
|
||||
}
|
||||
if (!obj->isDelegate()) {
|
||||
|
|
@ -1854,8 +1854,11 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
|
|||
oldproto = oldproto->staticPrototype();
|
||||
}
|
||||
|
||||
if (proto.isObject() && !proto.toObject()->setDelegate(cx))
|
||||
return false;
|
||||
if (proto.isObject()) {
|
||||
RootedObject protoObj(cx, proto.toObject());
|
||||
if (!JSObject::setDelegate(cx, protoObj))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj->isSingleton()) {
|
||||
/*
|
||||
|
|
@ -2611,7 +2614,7 @@ js::PreventExtensions(JSContext* cx, HandleObject obj, ObjectOpResult& result, I
|
|||
}
|
||||
}
|
||||
|
||||
if (!obj->setFlags(cx, BaseShape::NOT_EXTENSIBLE, JSObject::GENERATE_SHAPE)) {
|
||||
if (!JSObject::setFlags(cx, obj, BaseShape::NOT_EXTENSIBLE, JSObject::GENERATE_SHAPE)) {
|
||||
// We failed to mark the object non-extensible, so reset the frozen
|
||||
// flag on the elements.
|
||||
MOZ_ASSERT(obj->nonProxyIsExtensible());
|
||||
|
|
@ -2751,7 +2754,7 @@ js::SetImmutablePrototype(ExclusiveContext* cx, HandleObject obj, bool* succeede
|
|||
return Proxy::setImmutablePrototype(cx->asJSContext(), obj, succeeded);
|
||||
}
|
||||
|
||||
if (!obj->setFlags(cx, BaseShape::IMMUTABLE_PROTOTYPE))
|
||||
if (!JSObject::setFlags(cx, obj, BaseShape::IMMUTABLE_PROTOTYPE))
|
||||
return false;
|
||||
*succeeded = true;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ class JSObject : public js::gc::Cell
|
|||
GENERATE_SHAPE
|
||||
};
|
||||
|
||||
bool setFlags(js::ExclusiveContext* cx, js::BaseShape::Flag flags,
|
||||
GenerateShape generateShape = GENERATE_NONE);
|
||||
static bool setFlags(js::ExclusiveContext* cx, JS::HandleObject obj, js::BaseShape::Flag flags,
|
||||
GenerateShape generateShape = GENERATE_NONE);
|
||||
inline bool hasAllFlags(js::BaseShape::Flag flags) const;
|
||||
|
||||
/*
|
||||
|
|
@ -214,16 +214,16 @@ class JSObject : public js::gc::Cell
|
|||
* (see Purge{Scope,Proto}Chain in jsobj.cpp).
|
||||
*/
|
||||
inline bool isDelegate() const;
|
||||
bool setDelegate(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::DELEGATE, GENERATE_SHAPE);
|
||||
static bool setDelegate(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::DELEGATE, GENERATE_SHAPE);
|
||||
}
|
||||
|
||||
inline bool isBoundFunction() const;
|
||||
inline bool hasSpecialEquality() const;
|
||||
|
||||
inline bool watched() const;
|
||||
bool setWatched(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::WATCHED, GENERATE_SHAPE);
|
||||
static bool setWatched(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::WATCHED, GENERATE_SHAPE);
|
||||
}
|
||||
|
||||
// A "qualified" varobj is the object on which "qualified" variable
|
||||
|
|
@ -247,8 +247,8 @@ class JSObject : public js::gc::Cell
|
|||
// (e.g., Gecko and XPConnect), as they often wish to run scripts under a
|
||||
// scope that captures var bindings.
|
||||
inline bool isQualifiedVarObj() const;
|
||||
bool setQualifiedVarObj(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::QUALIFIED_VAROBJ);
|
||||
static bool setQualifiedVarObj(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::QUALIFIED_VAROBJ);
|
||||
}
|
||||
|
||||
// An "unqualified" varobj is the object on which "unqualified"
|
||||
|
|
@ -262,11 +262,11 @@ class JSObject : public js::gc::Cell
|
|||
// generate a new shape when their prototype changes, regardless of this
|
||||
// hasUncacheableProto flag.
|
||||
inline bool hasUncacheableProto() const;
|
||||
bool setUncacheableProto(js::ExclusiveContext* cx) {
|
||||
MOZ_ASSERT(hasStaticPrototype(),
|
||||
static bool setUncacheableProto(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
MOZ_ASSERT(obj->hasStaticPrototype(),
|
||||
"uncacheability as a concept is only applicable to static "
|
||||
"(not dynamically-computed) prototypes");
|
||||
return setFlags(cx, js::BaseShape::UNCACHEABLE_PROTO, GENERATE_SHAPE);
|
||||
return setFlags(cx, obj, js::BaseShape::UNCACHEABLE_PROTO, GENERATE_SHAPE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -274,8 +274,8 @@ class JSObject : public js::gc::Cell
|
|||
* PropertyTree::MAX_HEIGHT.
|
||||
*/
|
||||
inline bool hadElementsAccess() const;
|
||||
bool setHadElementsAccess(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::HAD_ELEMENTS_ACCESS);
|
||||
static bool setHadElementsAccess(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::HAD_ELEMENTS_ACCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -421,8 +421,8 @@ class JSObject : public js::gc::Cell
|
|||
* is purged on GC.
|
||||
*/
|
||||
inline bool isIteratedSingleton() const;
|
||||
bool setIteratedSingleton(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::ITERATED_SINGLETON);
|
||||
static bool setIteratedSingleton(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::ITERATED_SINGLETON);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -434,8 +434,8 @@ class JSObject : public js::gc::Cell
|
|||
|
||||
// Mark an object as having its 'new' script information cleared.
|
||||
inline bool wasNewScriptCleared() const;
|
||||
bool setNewScriptCleared(js::ExclusiveContext* cx) {
|
||||
return setFlags(cx, js::BaseShape::NEW_SCRIPT_CLEARED);
|
||||
static bool setNewScriptCleared(js::ExclusiveContext* cx, JS::HandleObject obj) {
|
||||
return setFlags(cx, obj, js::BaseShape::NEW_SCRIPT_CLEARED);
|
||||
}
|
||||
|
||||
/* Set a new prototype for an object with a singleton type. */
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ WatchpointMap::watch(JSContext* cx, HandleObject obj, HandleId id,
|
|||
{
|
||||
MOZ_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id) || JSID_IS_SYMBOL(id));
|
||||
|
||||
if (!obj->setWatched(cx))
|
||||
if (!JSObject::setWatched(cx, obj))
|
||||
return false;
|
||||
|
||||
Watchpoint w(handler, closure, false);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ CrossCompartmentWrapper::getPrototype(JSContext* cx, HandleObject wrapper,
|
|||
if (!GetPrototype(cx, wrapped, protop))
|
||||
return false;
|
||||
if (protop) {
|
||||
if (!protop->setDelegate(cx))
|
||||
if (!JSObject::setDelegate(cx, protop))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ CrossCompartmentWrapper::getPrototypeIfOrdinary(JSContext* cx, HandleObject wrap
|
|||
return true;
|
||||
|
||||
if (protop) {
|
||||
if (!protop->setDelegate(cx))
|
||||
if (!JSObject::setDelegate(cx, protop))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -816,7 +816,7 @@ NonSyntacticVariablesObject::create(JSContext* cx)
|
|||
return nullptr;
|
||||
|
||||
MOZ_ASSERT(obj->isUnqualifiedVarObj());
|
||||
if (!obj->setQualifiedVarObj(cx))
|
||||
if (!JSObject::setQualifiedVarObj(cx, obj))
|
||||
return nullptr;
|
||||
|
||||
obj->initEnclosingEnvironment(&cx->global()->lexicalEnvironment());
|
||||
|
|
@ -957,7 +957,7 @@ LexicalEnvironmentObject::createHollowForDebug(JSContext* cx, Handle<LexicalScop
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (!env->setFlags(cx, BaseShape::NOT_EXTENSIBLE, JSObject::GENERATE_SHAPE))
|
||||
if (!JSObject::setFlags(cx, env, BaseShape::NOT_EXTENSIBLE, JSObject::GENERATE_SHAPE))
|
||||
return nullptr;
|
||||
|
||||
env->initScopeUnchecked(scope);
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ GlobalObject::initLegacyGeneratorProto(JSContext* cx, Handle<GlobalObject*> glob
|
|||
return true;
|
||||
|
||||
RootedObject proto(cx, NewSingletonObjectWithObjectPrototype(cx, global));
|
||||
if (!proto || !proto->setDelegate(cx))
|
||||
if (!proto || !JSObject::setDelegate(cx, proto))
|
||||
return false;
|
||||
if (!DefinePropertiesAndFunctions(cx, proto, nullptr, legacy_generator_methods))
|
||||
return false;
|
||||
|
|
@ -309,7 +309,7 @@ GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
|||
}
|
||||
|
||||
RootedObject genFunctionProto(cx, NewSingletonObjectWithFunctionPrototype(cx, global));
|
||||
if (!genFunctionProto || !genFunctionProto->setDelegate(cx))
|
||||
if (!genFunctionProto || !JSObject::setDelegate(cx, genFunctionProto))
|
||||
return false;
|
||||
if (!LinkConstructorAndPrototype(cx, genFunctionProto, genObjectProto) ||
|
||||
!DefineToStringTag(cx, genFunctionProto, cx->names().GeneratorFunction))
|
||||
|
|
|
|||
|
|
@ -329,9 +329,9 @@ GlobalObject::createInternal(JSContext* cx, const Class* clasp)
|
|||
|
||||
cx->compartment()->initGlobal(*global);
|
||||
|
||||
if (!global->setQualifiedVarObj(cx))
|
||||
if (!JSObject::setQualifiedVarObj(cx, global))
|
||||
return nullptr;
|
||||
if (!global->setDelegate(cx))
|
||||
if (!JSObject::setDelegate(cx, global))
|
||||
return nullptr;
|
||||
|
||||
return global;
|
||||
|
|
@ -595,7 +595,7 @@ CreateBlankProto(JSContext* cx, const Class* clasp, HandleObject proto, HandleOb
|
|||
|
||||
RootedNativeObject blankProto(cx, NewNativeObjectWithGivenProto(cx, clasp, proto,
|
||||
SingletonObject));
|
||||
if (!blankProto || !blankProto->setDelegate(cx))
|
||||
if (!blankProto || !JSObject::setDelegate(cx, blankProto))
|
||||
return nullptr;
|
||||
|
||||
return blankProto;
|
||||
|
|
|
|||
|
|
@ -1543,7 +1543,7 @@ SetObjectElementOperation(JSContext* cx, HandleObject obj, HandleId id, HandleVa
|
|||
}
|
||||
}
|
||||
|
||||
if (obj->isNative() && !JSID_IS_INT(id) && !obj->setHadElementsAccess(cx))
|
||||
if (obj->isNative() && !JSID_IS_INT(id) && !JSObject::setHadElementsAccess(cx, obj))
|
||||
return false;
|
||||
|
||||
ObjectOpResult result;
|
||||
|
|
|
|||
|
|
@ -278,8 +278,11 @@ JSObject::splicePrototype(JSContext* cx, HandleObject obj, const Class* clasp,
|
|||
// Windows may not appear on prototype chains.
|
||||
MOZ_ASSERT_IF(proto.isObject(), !IsWindow(proto.toObject()));
|
||||
|
||||
if (proto.isObject() && !proto.toObject()->setDelegate(cx))
|
||||
return false;
|
||||
if (proto.isObject()) {
|
||||
RootedObject protoObj(cx, proto.toObject());
|
||||
if (!JSObject::setDelegate(cx, protoObj))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force type instantiation when splicing lazy group.
|
||||
RootedObjectGroup group(cx, JSObject::getGroup(cx, obj));
|
||||
|
|
@ -346,7 +349,7 @@ JSObject::makeLazyGroup(JSContext* cx, HandleObject obj)
|
|||
JSObject::setNewGroupUnknown(JSContext* cx, const js::Class* clasp, JS::HandleObject obj)
|
||||
{
|
||||
ObjectGroup::setDefaultNewGroupUnknown(cx, clasp, obj);
|
||||
return obj->setFlags(cx, BaseShape::NEW_GROUP_UNKNOWN);
|
||||
return JSObject::setFlags(cx, obj, BaseShape::NEW_GROUP_UNKNOWN);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -508,7 +511,7 @@ ObjectGroup::defaultNewGroup(ExclusiveContext* cx, const Class* clasp,
|
|||
|
||||
if (proto.isObject() && !proto.toObject()->isDelegate()) {
|
||||
RootedObject protoObj(cx, proto.toObject());
|
||||
if (!protoObj->setDelegate(cx))
|
||||
if (!JSObject::setDelegate(cx, protoObj))
|
||||
return nullptr;
|
||||
|
||||
// Objects which are prototypes of one another should be singletons, so
|
||||
|
|
|
|||
|
|
@ -1206,38 +1206,37 @@ NativeObject::shadowingShapeChange(ExclusiveContext* cx, const Shape& shape)
|
|||
return generateOwnShape(cx);
|
||||
}
|
||||
|
||||
bool
|
||||
JSObject::setFlags(ExclusiveContext* cx, BaseShape::Flag flags, GenerateShape generateShape)
|
||||
/* static */ bool
|
||||
JSObject::setFlags(ExclusiveContext* cx, HandleObject obj, BaseShape::Flag flags,
|
||||
GenerateShape generateShape)
|
||||
{
|
||||
if (hasAllFlags(flags))
|
||||
if (obj->hasAllFlags(flags))
|
||||
return true;
|
||||
|
||||
RootedObject self(cx, this);
|
||||
|
||||
Shape* existingShape = self->ensureShape(cx);
|
||||
Shape* existingShape = obj->ensureShape(cx);
|
||||
if (!existingShape)
|
||||
return false;
|
||||
|
||||
if (isNative() && as<NativeObject>().inDictionaryMode()) {
|
||||
if (generateShape == GENERATE_SHAPE && !as<NativeObject>().generateOwnShape(cx))
|
||||
if (obj->isNative() && obj->as<NativeObject>().inDictionaryMode()) {
|
||||
if (generateShape == GENERATE_SHAPE && !obj->as<NativeObject>().generateOwnShape(cx))
|
||||
return false;
|
||||
StackBaseShape base(self->as<NativeObject>().lastProperty());
|
||||
StackBaseShape base(obj->as<NativeObject>().lastProperty());
|
||||
base.flags |= flags;
|
||||
UnownedBaseShape* nbase = BaseShape::getUnowned(cx, base);
|
||||
if (!nbase)
|
||||
return false;
|
||||
|
||||
self->as<NativeObject>().lastProperty()->base()->adoptUnowned(nbase);
|
||||
obj->as<NativeObject>().lastProperty()->base()->adoptUnowned(nbase);
|
||||
return true;
|
||||
}
|
||||
|
||||
Shape* newShape = Shape::setObjectFlags(cx, flags, self->taggedProto(), existingShape);
|
||||
Shape* newShape = Shape::setObjectFlags(cx, flags, obj->taggedProto(), existingShape);
|
||||
if (!newShape)
|
||||
return false;
|
||||
|
||||
// The success of the |JSObject::ensureShape| call above means that |self|
|
||||
// The success of the |JSObject::ensureShape| call above means that |obj|
|
||||
// can be assumed to have a shape.
|
||||
self->as<ShapedObject>().setShape(newShape);
|
||||
obj->as<ShapedObject>().setShape(newShape);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2945,7 +2945,8 @@ ObjectGroup::clearNewScript(ExclusiveContext* cx, ObjectGroup* replacement /* =
|
|||
|
||||
// Mark the constructing function as having its 'new' script cleared, so we
|
||||
// will not try to construct another one later.
|
||||
if (!newScript->function()->setNewScriptCleared(cx))
|
||||
RootedFunction fun(cx, newScript->function());
|
||||
if (!JSObject::setNewScriptCleared(cx, fun))
|
||||
cx->recoverFromOutOfMemory();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue