summaryrefslogtreecommitdiffstats
path: root/js/src/vm
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm')
-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
7 files changed, 29 insertions, 26 deletions
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();
}