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:
@@ -285,7 +285,7 @@ ArgumentsObject* GlobalObject::maybeArgumentsTemplateObject(bool mapped) const {
|
|||||||
ArgumentsObject* GlobalObject::getOrCreateArgumentsTemplateObject(JSContext* cx,
|
ArgumentsObject* GlobalObject::getOrCreateArgumentsTemplateObject(JSContext* cx,
|
||||||
bool mapped) {
|
bool mapped) {
|
||||||
GlobalObjectData& data = cx->global()->data();
|
GlobalObjectData& data = cx->global()->data();
|
||||||
HeapPtr<ArgumentsObject*>& obj =
|
GCPtr<ArgumentsObject*>& obj =
|
||||||
mapped ? data.mappedArgumentsTemplate : data.unmappedArgumentsTemplate;
|
mapped ? data.mappedArgumentsTemplate : data.unmappedArgumentsTemplate;
|
||||||
|
|
||||||
ArgumentsObject* templateObj = obj;
|
ArgumentsObject* templateObj = obj;
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ class GlobalObjectData {
|
|||||||
// referring to the original Array constructor. The actual (writable and even
|
// referring to the original Array constructor. The actual (writable and even
|
||||||
// deletable) Object, Array, &c. properties are not stored here.
|
// deletable) Object, Array, &c. properties are not stored here.
|
||||||
struct ConstructorWithProto {
|
struct ConstructorWithProto {
|
||||||
HeapPtr<JSObject*> constructor;
|
GCPtr<JSObject*> constructor;
|
||||||
HeapPtr<JSObject*> prototype;
|
GCPtr<JSObject*> prototype;
|
||||||
};
|
};
|
||||||
using CtorArray = mozilla::EnumeratedArray<JSProtoKey, ConstructorWithProto,
|
using CtorArray = mozilla::EnumeratedArray<JSProtoKey, ConstructorWithProto,
|
||||||
size_t(JSProto_LIMIT)>;
|
size_t(JSProto_LIMIT)>;
|
||||||
@@ -155,72 +155,72 @@ class GlobalObjectData {
|
|||||||
|
|
||||||
Limit
|
Limit
|
||||||
};
|
};
|
||||||
using ProtoArray = mozilla::EnumeratedArray<ProtoKind, HeapPtr<JSObject*>,
|
using ProtoArray = mozilla::EnumeratedArray<ProtoKind, GCPtr<JSObject*>,
|
||||||
size_t(ProtoKind::Limit)>;
|
size_t(ProtoKind::Limit)>;
|
||||||
ProtoArray builtinProtos;
|
ProtoArray builtinProtos;
|
||||||
|
|
||||||
HeapPtr<GlobalScope*> emptyGlobalScope;
|
GCPtr<GlobalScope*> emptyGlobalScope;
|
||||||
|
|
||||||
// The lexical environment for global let/const/class bindings.
|
// The lexical environment for global let/const/class bindings.
|
||||||
HeapPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
|
GCPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
|
||||||
|
|
||||||
// The WindowProxy associated with this global.
|
// The WindowProxy associated with this global.
|
||||||
HeapPtr<JSObject*> windowProxy;
|
GCPtr<JSObject*> windowProxy;
|
||||||
|
|
||||||
// Functions and other top-level values for self-hosted code. The "computed"
|
// 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
|
// holder is used as the target of `SetIntrinsic` calls, but the same property
|
||||||
// may also be cached on the normal intrinsics holder for `GetIntrinsic`.
|
// may also be cached on the normal intrinsics holder for `GetIntrinsic`.
|
||||||
HeapPtr<NativeObject*> intrinsicsHolder;
|
GCPtr<NativeObject*> intrinsicsHolder;
|
||||||
HeapPtr<NativeObject*> computedIntrinsicsHolder;
|
GCPtr<NativeObject*> computedIntrinsicsHolder;
|
||||||
|
|
||||||
// Cache used to optimize certain for-of operations.
|
// 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.
|
// 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.
|
// Realm-specific object that can be used as key in WeakMaps.
|
||||||
HeapPtr<PlainObject*> realmKeyObject;
|
GCPtr<PlainObject*> realmKeyObject;
|
||||||
|
|
||||||
// The unique %ThrowTypeError% function for this global.
|
// The unique %ThrowTypeError% function for this global.
|
||||||
HeapPtr<JSFunction*> throwTypeError;
|
GCPtr<JSFunction*> throwTypeError;
|
||||||
|
|
||||||
// The unique %eval% function (for indirect eval) for this global.
|
// 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.
|
// 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.
|
// 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
|
// Shape for PlainObject with %Object.prototype% as proto, for each object
|
||||||
// AllocKind.
|
// AllocKind.
|
||||||
using PlainObjectShapeArray =
|
using PlainObjectShapeArray =
|
||||||
mozilla::EnumeratedArray<PlainObjectSlotsKind, HeapPtr<SharedShape*>,
|
mozilla::EnumeratedArray<PlainObjectSlotsKind, GCPtr<SharedShape*>,
|
||||||
size_t(PlainObjectSlotsKind::Limit)>;
|
size_t(PlainObjectSlotsKind::Limit)>;
|
||||||
PlainObjectShapeArray plainObjectShapesWithDefaultProto;
|
PlainObjectShapeArray plainObjectShapesWithDefaultProto;
|
||||||
|
|
||||||
// Shape for JSFunction with %Function.prototype% as proto, for both
|
// Shape for JSFunction with %Function.prototype% as proto, for both
|
||||||
// non-extended and extended functions.
|
// non-extended and extended functions.
|
||||||
HeapPtr<SharedShape*> functionShapeWithDefaultProto;
|
GCPtr<SharedShape*> functionShapeWithDefaultProto;
|
||||||
HeapPtr<SharedShape*> extendedFunctionShapeWithDefaultProto;
|
GCPtr<SharedShape*> extendedFunctionShapeWithDefaultProto;
|
||||||
|
|
||||||
// Shape for BoundFunctionObject with %Function.prototype% as proto.
|
// Shape for BoundFunctionObject with %Function.prototype% as proto.
|
||||||
HeapPtr<SharedShape*> boundFunctionShapeWithDefaultProto;
|
GCPtr<SharedShape*> boundFunctionShapeWithDefaultProto;
|
||||||
|
|
||||||
// Global state for regular expressions.
|
// Global state for regular expressions.
|
||||||
RegExpRealm regExpRealm;
|
RegExpRealm regExpRealm;
|
||||||
|
|
||||||
HeapPtr<ArgumentsObject*> mappedArgumentsTemplate;
|
GCPtr<ArgumentsObject*> mappedArgumentsTemplate;
|
||||||
HeapPtr<ArgumentsObject*> unmappedArgumentsTemplate;
|
GCPtr<ArgumentsObject*> unmappedArgumentsTemplate;
|
||||||
|
|
||||||
HeapPtr<PlainObject*> iterResultTemplate;
|
GCPtr<PlainObject*> iterResultTemplate;
|
||||||
HeapPtr<PlainObject*> iterResultWithoutPrototypeTemplate;
|
GCPtr<PlainObject*> iterResultWithoutPrototypeTemplate;
|
||||||
|
|
||||||
// Lazily initialized script source object to use for scripts cloned from the
|
// Lazily initialized script source object to use for scripts cloned from the
|
||||||
// self-hosting stencil.
|
// self-hosting stencil.
|
||||||
HeapPtr<ScriptSourceObject*> selfHostingScriptSource;
|
GCPtr<ScriptSourceObject*> selfHostingScriptSource;
|
||||||
|
|
||||||
UniquePtr<gc::FinalizationRegistryGlobalData> finalizationRegistryData;
|
UniquePtr<gc::FinalizationRegistryGlobalData> finalizationRegistryData;
|
||||||
|
|
||||||
|
|||||||
@@ -1350,7 +1350,7 @@ PlainObject* js::CreateIterResultObject(JSContext* cx, HandleValue value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlainObject* GlobalObject::getOrCreateIterResultTemplateObject(JSContext* cx) {
|
PlainObject* GlobalObject::getOrCreateIterResultTemplateObject(JSContext* cx) {
|
||||||
HeapPtr<PlainObject*>& obj = cx->global()->data().iterResultTemplate;
|
GCPtr<PlainObject*>& obj = cx->global()->data().iterResultTemplate;
|
||||||
if (obj) {
|
if (obj) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -1364,7 +1364,7 @@ PlainObject* GlobalObject::getOrCreateIterResultTemplateObject(JSContext* cx) {
|
|||||||
/* static */
|
/* static */
|
||||||
PlainObject* GlobalObject::getOrCreateIterResultWithoutPrototypeTemplateObject(
|
PlainObject* GlobalObject::getOrCreateIterResultWithoutPrototypeTemplateObject(
|
||||||
JSContext* cx) {
|
JSContext* cx) {
|
||||||
HeapPtr<PlainObject*>& obj =
|
GCPtr<PlainObject*>& obj =
|
||||||
cx->global()->data().iterResultWithoutPrototypeTemplate;
|
cx->global()->data().iterResultWithoutPrototypeTemplate;
|
||||||
if (obj) {
|
if (obj) {
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
@@ -1652,7 +1652,7 @@ static SharedShape* GetFunctionShape(JSContext* cx, const JSClass* clasp,
|
|||||||
SharedShape* GlobalObject::createFunctionShapeWithDefaultProto(JSContext* cx,
|
SharedShape* GlobalObject::createFunctionShapeWithDefaultProto(JSContext* cx,
|
||||||
bool extended) {
|
bool extended) {
|
||||||
GlobalObjectData& data = cx->global()->data();
|
GlobalObjectData& data = cx->global()->data();
|
||||||
HeapPtr<SharedShape*>& shapeRef =
|
GCPtr<SharedShape*>& shapeRef =
|
||||||
extended ? data.extendedFunctionShapeWithDefaultProto
|
extended ? data.extendedFunctionShapeWithDefaultProto
|
||||||
: data.functionShapeWithDefaultProto;
|
: data.functionShapeWithDefaultProto;
|
||||||
MOZ_ASSERT(!shapeRef);
|
MOZ_ASSERT(!shapeRef);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ PlainObject* PlainObject::createWithTemplateFromDifferentRealm(
|
|||||||
SharedShape* GlobalObject::createPlainObjectShapeWithDefaultProto(
|
SharedShape* GlobalObject::createPlainObjectShapeWithDefaultProto(
|
||||||
JSContext* cx, gc::AllocKind kind) {
|
JSContext* cx, gc::AllocKind kind) {
|
||||||
PlainObjectSlotsKind slotsKind = PlainObjectSlotsKindFromAllocKind(kind);
|
PlainObjectSlotsKind slotsKind = PlainObjectSlotsKindFromAllocKind(kind);
|
||||||
HeapPtr<SharedShape*>& shapeRef =
|
GCPtr<SharedShape*>& shapeRef =
|
||||||
cx->global()->data().plainObjectShapesWithDefaultProto[slotsKind];
|
cx->global()->data().plainObjectShapesWithDefaultProto[slotsKind];
|
||||||
MOZ_ASSERT(!shapeRef);
|
MOZ_ASSERT(!shapeRef);
|
||||||
|
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ class RegExpRealm {
|
|||||||
* Indices: Has a |groups| property. If |hasIndices| is set, used
|
* Indices: Has a |groups| property. If |hasIndices| is set, used
|
||||||
* for the |.indices| property of the result object.
|
* 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:
|
* 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[@@match] is an own data property
|
||||||
* * RegExp.prototype[@@search] 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:
|
* The shape of RegExp instance that satisfies following:
|
||||||
* * lastProperty is lastIndex
|
* * lastProperty is lastIndex
|
||||||
* * prototype is RegExp.prototype
|
* * prototype is RegExp.prototype
|
||||||
*/
|
*/
|
||||||
HeapPtr<Shape*> optimizableRegExpInstanceShape_;
|
GCPtr<Shape*> optimizableRegExpInstanceShape_;
|
||||||
|
|
||||||
SharedShape* createMatchResultShape(JSContext* cx, ResultShapeKind kind);
|
SharedShape* createMatchResultShape(JSContext* cx, ResultShapeKind kind);
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ class RegExpRealm {
|
|||||||
return offsetof(RegExpRealm, regExpStatics);
|
return offsetof(RegExpRealm, regExpStatics);
|
||||||
}
|
}
|
||||||
static constexpr size_t offsetOfNormalMatchResultShape() {
|
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_) +
|
return offsetof(RegExpRealm, matchResultShapes_) +
|
||||||
ResultShapeKind::Normal * sizeof(uintptr_t);
|
ResultShapeKind::Normal * sizeof(uintptr_t);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user