summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 19:26:40 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:23 -0400
commit6bbc8d66646f49a1aa8a02765c1111bb3a92ee80 (patch)
treeb77ebf0048d8bddf12b51f8942bb38606f06ca2a
parent2d1d2cefbbaff4b0380bfbcdab4631a1dcf142af (diff)
downloadUXP-6bbc8d66646f49a1aa8a02765c1111bb3a92ee80.tar
UXP-6bbc8d66646f49a1aa8a02765c1111bb3a92ee80.tar.gz
UXP-6bbc8d66646f49a1aa8a02765c1111bb3a92ee80.tar.lz
UXP-6bbc8d66646f49a1aa8a02765c1111bb3a92ee80.tar.xz
UXP-6bbc8d66646f49a1aa8a02765c1111bb3a92ee80.zip
1320408 - Part 6: Change JSObject::splicePrototype to static method.
-rw-r--r--js/src/builtin/Object.cpp2
-rw-r--r--js/src/jsfriendapi.cpp2
-rw-r--r--js/src/jsobj.cpp6
-rw-r--r--js/src/jsobj.h3
-rw-r--r--js/src/vm/ObjectGroup.cpp13
5 files changed, 13 insertions, 13 deletions
diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp
index e4bee5457..a6dcab099 100644
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -1409,7 +1409,7 @@ FinishObjectClassInit(JSContext* cx, JS::HandleObject ctor, JS::HandleObject pro
*/
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
if (global->shouldSplicePrototype(cx)) {
- if (!global->splicePrototype(cx, global->getClass(), tagged))
+ if (!JSObject::splicePrototype(cx, global, global->getClass(), tagged))
return false;
}
return true;
diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp
index 5baba0beb..f7622cb44 100644
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -113,7 +113,7 @@ JS_SplicePrototype(JSContext* cx, HandleObject obj, HandleObject proto)
}
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
- return obj->splicePrototype(cx, obj->getClass(), tagged);
+ return JSObject::splicePrototype(cx, obj, obj->getClass(), tagged);
}
JS_FRIEND_API(JSObject*)
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index ce2f9a614..f4a524d44 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -884,7 +884,7 @@ CreateThisForFunctionWithGroup(JSContext* cx, HandleObjectGroup group,
if (newKind == SingletonObject) {
Rooted<TaggedProto> proto(cx, TaggedProto(templateObject->staticPrototype()));
- if (!res->splicePrototype(cx, &PlainObject::class_, proto))
+ if (!JSObject::splicePrototype(cx, res, &PlainObject::class_, proto))
return nullptr;
} else {
res->setGroup(group);
@@ -1722,7 +1722,7 @@ DefineConstructorAndPrototype(JSContext* cx, HandleObject obj, JSProtoKey key, H
/* Bootstrap Function.prototype (see also JS_InitStandardClasses). */
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
- if (ctor->getClass() == clasp && !ctor->splicePrototype(cx, clasp, tagged))
+ if (ctor->getClass() == clasp && !JSObject::splicePrototype(cx, ctor, clasp, tagged))
goto bad;
}
@@ -1862,7 +1862,7 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
* Just splice the prototype, but mark the properties as unknown for
* consistent behavior.
*/
- if (!obj->splicePrototype(cx, clasp, proto))
+ if (!JSObject::splicePrototype(cx, obj, clasp, proto))
return false;
MarkObjectGroupUnknownProperties(cx, obj->group());
return true;
diff --git a/js/src/jsobj.h b/js/src/jsobj.h
index 49b7c5e8e..bdfe75b92 100644
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -439,7 +439,8 @@ class JSObject : public js::gc::Cell
}
/* Set a new prototype for an object with a singleton type. */
- bool splicePrototype(JSContext* cx, const js::Class* clasp, js::Handle<js::TaggedProto> proto);
+ static bool splicePrototype(JSContext* cx, js::HandleObject obj, const js::Class* clasp,
+ js::Handle<js::TaggedProto> proto);
/*
* For bootstrapping, whether to splice a prototype for Function.prototype
diff --git a/js/src/vm/ObjectGroup.cpp b/js/src/vm/ObjectGroup.cpp
index 6e9000894..fbad85e57 100644
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -262,19 +262,18 @@ JSObject::shouldSplicePrototype(JSContext* cx)
return isSingleton();
}
-bool
-JSObject::splicePrototype(JSContext* cx, const Class* clasp, Handle<TaggedProto> proto)
+/* static */ bool
+JSObject::splicePrototype(JSContext* cx, HandleObject obj, const Class* clasp,
+ Handle<TaggedProto> proto)
{
- MOZ_ASSERT(cx->compartment() == compartment());
-
- RootedObject self(cx, this);
+ MOZ_ASSERT(cx->compartment() == obj->compartment());
/*
* For singleton groups representing only a single JSObject, the proto
* can be rearranged as needed without destroying type information for
* the old or new types.
*/
- MOZ_ASSERT(self->isSingleton());
+ MOZ_ASSERT(obj->isSingleton());
// Windows may not appear on prototype chains.
MOZ_ASSERT_IF(proto.isObject(), !IsWindow(proto.toObject()));
@@ -283,7 +282,7 @@ JSObject::splicePrototype(JSContext* cx, const Class* clasp, Handle<TaggedProto>
return false;
// Force type instantiation when splicing lazy group.
- RootedObjectGroup group(cx, JSObject::getGroup(cx, self));
+ RootedObjectGroup group(cx, JSObject::getGroup(cx, obj));
if (!group)
return false;
RootedObjectGroup protoGroup(cx, nullptr);