summaryrefslogtreecommitdiffstats
path: root/js/src
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 19:49:29 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:24 -0400
commit1d0ab1c752c583c153b850af339edb86d23f6cc8 (patch)
treea59897de81ee25b02faad4dd67c08e3acf1272a5 /js/src
parentfe20cd26491f8db4e7304d509a2639cfccf26c7e (diff)
downloadUXP-1d0ab1c752c583c153b850af339edb86d23f6cc8.tar
UXP-1d0ab1c752c583c153b850af339edb86d23f6cc8.tar.gz
UXP-1d0ab1c752c583c153b850af339edb86d23f6cc8.tar.lz
UXP-1d0ab1c752c583c153b850af339edb86d23f6cc8.tar.xz
UXP-1d0ab1c752c583c153b850af339edb86d23f6cc8.zip
1320408 - Part 9: Change JSObject::setFlags and depending methods to static method.
Diffstat (limited to 'js/src')
-rw-r--r--js/src/jsapi.cpp2
-rw-r--r--js/src/jsarray.cpp2
-rw-r--r--js/src/jsiter.cpp4
-rw-r--r--js/src/jsobj.cpp13
-rw-r--r--js/src/jsobj.h34
-rw-r--r--js/src/jswatchpoint.cpp2
-rw-r--r--js/src/proxy/CrossCompartmentWrapper.cpp4
-rw-r--r--js/src/vm/EnvironmentObject.cpp4
-rw-r--r--js/src/vm/GeneratorObject.cpp4
-rw-r--r--js/src/vm/GlobalObject.cpp6
-rw-r--r--js/src/vm/Interpreter.cpp2
-rw-r--r--js/src/vm/ObjectGroup.cpp11
-rw-r--r--js/src/vm/Shape.cpp25
-rw-r--r--js/src/vm/TypeInference.cpp3
14 files changed, 61 insertions, 55 deletions
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index 949e4796b..e2d572598 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -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
diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp
index c1a6dcfab..aef98cc60 100644
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -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;
diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp
index 004c7fc0d..84d9a45c3 100644
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -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);
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index b08e8a619..78efca8de 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -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;
diff --git a/js/src/jsobj.h b/js/src/jsobj.h
index 3eabf448a..db2c22b76 100644
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -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. */
diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp
index e37323555..34479a990 100644
--- a/js/src/jswatchpoint.cpp
+++ b/js/src/jswatchpoint.cpp
@@ -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);
diff --git a/js/src/proxy/CrossCompartmentWrapper.cpp b/js/src/proxy/CrossCompartmentWrapper.cpp
index 2a6cb5400..246639956 100644
--- a/js/src/proxy/CrossCompartmentWrapper.cpp
+++ b/js/src/proxy/CrossCompartmentWrapper.cpp
@@ -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;
}
}
diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp
index 3125aa41c..611f0e194 100644
--- a/js/src/vm/EnvironmentObject.cpp
+++ b/js/src/vm/EnvironmentObject.cpp
@@ -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);
diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp
index 690c0bf48..82b774a35 100644
--- a/js/src/vm/GeneratorObject.cpp
+++ b/js/src/vm/GeneratorObject.cpp
@@ -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))
diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp
index c90b6b85f..c431b5f1d 100644
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -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;
diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
index 77637aab8..097b7b0f3 100644
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -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;
diff --git a/js/src/vm/ObjectGroup.cpp b/js/src/vm/ObjectGroup.cpp
index bbbac743d..ec0a7aec1 100644
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -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
diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp
index 15fb71343..065a96337 100644
--- a/js/src/vm/Shape.cpp
+++ b/js/src/vm/Shape.cpp
@@ -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;
}
diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp
index 60d9e183a..7c2c0194e 100644
--- a/js/src/vm/TypeInference.cpp
+++ b/js/src/vm/TypeInference.cpp
@@ -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();
}