Bug 1928676 - Part 3: Use GCPtr instead of HeapPtr in GlobalObjectData r=sfink

Differential Revision: https://phabricator.services.mozilla.com/D227953
This commit is contained in:
Jon Coppeard 2024-11-07 10:43:20 +00:00
parent bac82d097e
commit dbb97f266d
6 changed files with 33 additions and 33 deletions

View File

@ -285,7 +285,7 @@ ArgumentsObject* GlobalObject::maybeArgumentsTemplateObject(bool mapped) const {
ArgumentsObject* GlobalObject::getOrCreateArgumentsTemplateObject(JSContext* cx,
bool mapped) {
GlobalObjectData& data = cx->global()->data();
HeapPtr<ArgumentsObject*>& obj =
GCPtr<ArgumentsObject*>& obj =
mapped ? data.mappedArgumentsTemplate : data.unmappedArgumentsTemplate;
ArgumentsObject* templateObj = obj;

View File

@ -128,8 +128,8 @@ class GlobalObjectData {
// referring to the original Array constructor. The actual (writable and even
// deletable) Object, Array, &c. properties are not stored here.
struct ConstructorWithProto {
HeapPtr<JSObject*> constructor;
HeapPtr<JSObject*> prototype;
GCPtr<JSObject*> constructor;
GCPtr<JSObject*> prototype;
};
using CtorArray = mozilla::EnumeratedArray<JSProtoKey, ConstructorWithProto,
size_t(JSProto_LIMIT)>;
@ -155,72 +155,72 @@ class GlobalObjectData {
Limit
};
using ProtoArray = mozilla::EnumeratedArray<ProtoKind, HeapPtr<JSObject*>,
using ProtoArray = mozilla::EnumeratedArray<ProtoKind, GCPtr<JSObject*>,
size_t(ProtoKind::Limit)>;
ProtoArray builtinProtos;
HeapPtr<GlobalScope*> emptyGlobalScope;
GCPtr<GlobalScope*> emptyGlobalScope;
// The lexical environment for global let/const/class bindings.
HeapPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
GCPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
// The WindowProxy associated with this global.
HeapPtr<JSObject*> windowProxy;
GCPtr<JSObject*> windowProxy;
// Functions and other top-level values for self-hosted code. The "computed"
// holder is used as the target of `SetIntrinsic` calls, but the same property
// may also be cached on the normal intrinsics holder for `GetIntrinsic`.
HeapPtr<NativeObject*> intrinsicsHolder;
HeapPtr<NativeObject*> computedIntrinsicsHolder;
GCPtr<NativeObject*> intrinsicsHolder;
GCPtr<NativeObject*> computedIntrinsicsHolder;
// Cache used to optimize certain for-of operations.
HeapPtr<NativeObject*> forOfPICChain;
GCPtr<NativeObject*> forOfPICChain;
// List of source URLs for this realm. This is used by the debugger.
HeapPtr<ArrayObject*> sourceURLsHolder;
GCPtr<ArrayObject*> sourceURLsHolder;
// Realm-specific object that can be used as key in WeakMaps.
HeapPtr<PlainObject*> realmKeyObject;
GCPtr<PlainObject*> realmKeyObject;
// The unique %ThrowTypeError% function for this global.
HeapPtr<JSFunction*> throwTypeError;
GCPtr<JSFunction*> throwTypeError;
// The unique %eval% function (for indirect eval) for this global.
HeapPtr<JSFunction*> eval;
GCPtr<JSFunction*> eval;
// Empty iterator object used for for-in with null/undefined.
HeapPtr<PropertyIteratorObject*> emptyIterator;
GCPtr<PropertyIteratorObject*> emptyIterator;
// Cached shape for new arrays with Array.prototype as prototype.
HeapPtr<SharedShape*> arrayShapeWithDefaultProto;
GCPtr<SharedShape*> arrayShapeWithDefaultProto;
// Shape for PlainObject with %Object.prototype% as proto, for each object
// AllocKind.
using PlainObjectShapeArray =
mozilla::EnumeratedArray<PlainObjectSlotsKind, HeapPtr<SharedShape*>,
mozilla::EnumeratedArray<PlainObjectSlotsKind, GCPtr<SharedShape*>,
size_t(PlainObjectSlotsKind::Limit)>;
PlainObjectShapeArray plainObjectShapesWithDefaultProto;
// Shape for JSFunction with %Function.prototype% as proto, for both
// non-extended and extended functions.
HeapPtr<SharedShape*> functionShapeWithDefaultProto;
HeapPtr<SharedShape*> extendedFunctionShapeWithDefaultProto;
GCPtr<SharedShape*> functionShapeWithDefaultProto;
GCPtr<SharedShape*> extendedFunctionShapeWithDefaultProto;
// Shape for BoundFunctionObject with %Function.prototype% as proto.
HeapPtr<SharedShape*> boundFunctionShapeWithDefaultProto;
GCPtr<SharedShape*> boundFunctionShapeWithDefaultProto;
// Global state for regular expressions.
RegExpRealm regExpRealm;
HeapPtr<ArgumentsObject*> mappedArgumentsTemplate;
HeapPtr<ArgumentsObject*> unmappedArgumentsTemplate;
GCPtr<ArgumentsObject*> mappedArgumentsTemplate;
GCPtr<ArgumentsObject*> unmappedArgumentsTemplate;
HeapPtr<PlainObject*> iterResultTemplate;
HeapPtr<PlainObject*> iterResultWithoutPrototypeTemplate;
GCPtr<PlainObject*> iterResultTemplate;
GCPtr<PlainObject*> iterResultWithoutPrototypeTemplate;
// Lazily initialized script source object to use for scripts cloned from the
// self-hosting stencil.
HeapPtr<ScriptSourceObject*> selfHostingScriptSource;
GCPtr<ScriptSourceObject*> selfHostingScriptSource;
UniquePtr<gc::FinalizationRegistryGlobalData> finalizationRegistryData;

View File

@ -1350,7 +1350,7 @@ PlainObject* js::CreateIterResultObject(JSContext* cx, HandleValue value,
}
PlainObject* GlobalObject::getOrCreateIterResultTemplateObject(JSContext* cx) {
HeapPtr<PlainObject*>& obj = cx->global()->data().iterResultTemplate;
GCPtr<PlainObject*>& obj = cx->global()->data().iterResultTemplate;
if (obj) {
return obj;
}
@ -1364,7 +1364,7 @@ PlainObject* GlobalObject::getOrCreateIterResultTemplateObject(JSContext* cx) {
/* static */
PlainObject* GlobalObject::getOrCreateIterResultWithoutPrototypeTemplateObject(
JSContext* cx) {
HeapPtr<PlainObject*>& obj =
GCPtr<PlainObject*>& obj =
cx->global()->data().iterResultWithoutPrototypeTemplate;
if (obj) {
return obj;

View File

@ -1652,7 +1652,7 @@ static SharedShape* GetFunctionShape(JSContext* cx, const JSClass* clasp,
SharedShape* GlobalObject::createFunctionShapeWithDefaultProto(JSContext* cx,
bool extended) {
GlobalObjectData& data = cx->global()->data();
HeapPtr<SharedShape*>& shapeRef =
GCPtr<SharedShape*>& shapeRef =
extended ? data.extendedFunctionShapeWithDefaultProto
: data.functionShapeWithDefaultProto;
MOZ_ASSERT(!shapeRef);

View File

@ -122,7 +122,7 @@ PlainObject* PlainObject::createWithTemplateFromDifferentRealm(
SharedShape* GlobalObject::createPlainObjectShapeWithDefaultProto(
JSContext* cx, gc::AllocKind kind) {
PlainObjectSlotsKind slotsKind = PlainObjectSlotsKindFromAllocKind(kind);
HeapPtr<SharedShape*>& shapeRef =
GCPtr<SharedShape*>& shapeRef =
cx->global()->data().plainObjectShapesWithDefaultProto[slotsKind];
MOZ_ASSERT(!shapeRef);

View File

@ -373,7 +373,7 @@ class RegExpRealm {
* Indices: Has a |groups| property. If |hasIndices| is set, used
* for the |.indices| property of the result object.
*/
HeapPtr<SharedShape*> matchResultShapes_[ResultShapeKind::NumKinds];
GCPtr<SharedShape*> matchResultShapes_[ResultShapeKind::NumKinds];
/*
* The shape of RegExp.prototype object that satisfies following:
@ -388,14 +388,14 @@ class RegExpRealm {
* * RegExp.prototype[@@match] is an own data property
* * RegExp.prototype[@@search] is an own data property
*/
HeapPtr<Shape*> optimizableRegExpPrototypeShape_;
GCPtr<Shape*> optimizableRegExpPrototypeShape_;
/*
* The shape of RegExp instance that satisfies following:
* * lastProperty is lastIndex
* * prototype is RegExp.prototype
*/
HeapPtr<Shape*> optimizableRegExpInstanceShape_;
GCPtr<Shape*> optimizableRegExpInstanceShape_;
SharedShape* createMatchResultShape(JSContext* cx, ResultShapeKind kind);
@ -461,7 +461,7 @@ class RegExpRealm {
return offsetof(RegExpRealm, regExpStatics);
}
static constexpr size_t offsetOfNormalMatchResultShape() {
static_assert(sizeof(HeapPtr<SharedShape*>) == sizeof(uintptr_t));
static_assert(sizeof(GCPtr<SharedShape*>) == sizeof(uintptr_t));
return offsetof(RegExpRealm, matchResultShapes_) +
ResultShapeKind::Normal * sizeof(uintptr_t);
}