зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1723715 part 16 - Move WindowProxy to GlobalObjectData. r=jonco
This is done last because it requires reordering the initialization code, and we can finally do this now. Differential Revision: https://phabricator.services.mozilla.com/D121996
This commit is contained in:
Родитель
6bd69b8edd
Коммит
29d4bbfc82
|
@ -572,7 +572,7 @@ static const uint32_t JSCLASS_FOREGROUND_FINALIZE =
|
||||||
// application.
|
// application.
|
||||||
static const uint32_t JSCLASS_GLOBAL_APPLICATION_SLOTS = 5;
|
static const uint32_t JSCLASS_GLOBAL_APPLICATION_SLOTS = 5;
|
||||||
static const uint32_t JSCLASS_GLOBAL_SLOT_COUNT =
|
static const uint32_t JSCLASS_GLOBAL_SLOT_COUNT =
|
||||||
JSCLASS_GLOBAL_APPLICATION_SLOTS + 2;
|
JSCLASS_GLOBAL_APPLICATION_SLOTS + 1;
|
||||||
|
|
||||||
static constexpr uint32_t JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(uint32_t n) {
|
static constexpr uint32_t JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(uint32_t n) {
|
||||||
return JSCLASS_IS_GLOBAL |
|
return JSCLASS_IS_GLOBAL |
|
||||||
|
|
|
@ -661,26 +661,11 @@ GlobalObject* GlobalObject::createInternal(JSContext* cx,
|
||||||
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
|
||||||
MOZ_ASSERT(global->isUnqualifiedVarObj());
|
MOZ_ASSERT(global->isUnqualifiedVarObj());
|
||||||
|
|
||||||
Rooted<GlobalLexicalEnvironmentObject*> lexical(
|
|
||||||
cx, GlobalLexicalEnvironmentObject::create(cx, global));
|
|
||||||
if (!lexical) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rooted<GlobalScope*> emptyGlobalScope(
|
|
||||||
cx, GlobalScope::createEmpty(cx, ScopeKind::Global));
|
|
||||||
if (!emptyGlobalScope) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto data = cx->make_unique<GlobalObjectData>();
|
auto data = cx->make_unique<GlobalObjectData>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
data->emptyGlobalScope.init(emptyGlobalScope);
|
|
||||||
data->lexicalEnvironment.init(lexical);
|
|
||||||
|
|
||||||
// Note: it's important for the realm's global to be initialized at the
|
// Note: it's important for the realm's global to be initialized at the
|
||||||
// same time as the global's GlobalObjectData, because we free the global's
|
// same time as the global's GlobalObjectData, because we free the global's
|
||||||
// data when Realm::global_ is cleared.
|
// data when Realm::global_ is cleared.
|
||||||
|
@ -689,6 +674,20 @@ GlobalObject* GlobalObject::createInternal(JSContext* cx,
|
||||||
MemoryUse::GlobalObjectData);
|
MemoryUse::GlobalObjectData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rooted<GlobalLexicalEnvironmentObject*> lexical(
|
||||||
|
cx, GlobalLexicalEnvironmentObject::create(cx, global));
|
||||||
|
if (!lexical) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
global->data().lexicalEnvironment.init(lexical);
|
||||||
|
|
||||||
|
Rooted<GlobalScope*> emptyGlobalScope(
|
||||||
|
cx, GlobalScope::createEmpty(cx, ScopeKind::Global));
|
||||||
|
if (!emptyGlobalScope) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
global->data().emptyGlobalScope.init(emptyGlobalScope);
|
||||||
|
|
||||||
if (!JSObject::setQualifiedVarObj(cx, global)) {
|
if (!JSObject::setQualifiedVarObj(cx, global)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1162,9 +1161,10 @@ void GlobalObjectData::trace(JSTracer* trc) {
|
||||||
TraceNullableEdge(trc, &proto, "global-builtin-proto");
|
TraceNullableEdge(trc, &proto, "global-builtin-proto");
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceEdge(trc, &emptyGlobalScope, "global-empty-scope");
|
TraceNullableEdge(trc, &emptyGlobalScope, "global-empty-scope");
|
||||||
|
|
||||||
TraceNullableEdge(trc, &lexicalEnvironment, "global-lexical-env");
|
TraceNullableEdge(trc, &lexicalEnvironment, "global-lexical-env");
|
||||||
|
TraceNullableEdge(trc, &windowProxy, "global-window-proxy");
|
||||||
TraceNullableEdge(trc, ®ExpStatics, "global-regexp-statics");
|
TraceNullableEdge(trc, ®ExpStatics, "global-regexp-statics");
|
||||||
TraceNullableEdge(trc, &intrinsicsHolder, "global-intrinsics-holder");
|
TraceNullableEdge(trc, &intrinsicsHolder, "global-intrinsics-holder");
|
||||||
TraceNullableEdge(trc, &forOfPICChain, "global-for-of-pic");
|
TraceNullableEdge(trc, &forOfPICChain, "global-for-of-pic");
|
||||||
|
|
|
@ -116,6 +116,9 @@ class GlobalObjectData {
|
||||||
// The lexical environment for global let/const/class bindings.
|
// The lexical environment for global let/const/class bindings.
|
||||||
HeapPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
|
HeapPtr<GlobalLexicalEnvironmentObject*> lexicalEnvironment;
|
||||||
|
|
||||||
|
// The WindowProxy associated with this global.
|
||||||
|
HeapPtr<JSObject*> windowProxy;
|
||||||
|
|
||||||
// Global state for regular expressions.
|
// Global state for regular expressions.
|
||||||
HeapPtr<RegExpStaticsObject*> regExpStatics;
|
HeapPtr<RegExpStaticsObject*> regExpStatics;
|
||||||
|
|
||||||
|
@ -155,7 +158,6 @@ class GlobalObjectData {
|
||||||
class GlobalObject : public NativeObject {
|
class GlobalObject : public NativeObject {
|
||||||
enum : unsigned {
|
enum : unsigned {
|
||||||
GLOBAL_DATA_SLOT = JSCLASS_GLOBAL_APPLICATION_SLOTS,
|
GLOBAL_DATA_SLOT = JSCLASS_GLOBAL_APPLICATION_SLOTS,
|
||||||
WINDOW_PROXY,
|
|
||||||
|
|
||||||
// Total reserved-slot count for global objects.
|
// Total reserved-slot count for global objects.
|
||||||
RESERVED_SLOTS
|
RESERVED_SLOTS
|
||||||
|
@ -922,16 +924,10 @@ class GlobalObject : public NativeObject {
|
||||||
static NativeObject* getOrCreateForOfPICObject(JSContext* cx,
|
static NativeObject* getOrCreateForOfPICObject(JSContext* cx,
|
||||||
Handle<GlobalObject*> global);
|
Handle<GlobalObject*> global);
|
||||||
|
|
||||||
JSObject* windowProxy() const {
|
JSObject* maybeWindowProxy() const { return data().windowProxy; }
|
||||||
return &getReservedSlot(WINDOW_PROXY).toObject();
|
|
||||||
}
|
|
||||||
JSObject* maybeWindowProxy() const {
|
|
||||||
Value v = getReservedSlot(WINDOW_PROXY);
|
|
||||||
MOZ_ASSERT(v.isObject() || v.isUndefined());
|
|
||||||
return v.isObject() ? &v.toObject() : nullptr;
|
|
||||||
}
|
|
||||||
void setWindowProxy(JSObject* windowProxy) {
|
void setWindowProxy(JSObject* windowProxy) {
|
||||||
setReservedSlot(WINDOW_PROXY, ObjectValue(*windowProxy));
|
data().windowProxy = windowProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayObject* getSourceURLsHolder() const { return data().sourceURLsHolder; }
|
ArrayObject* getSourceURLsHolder() const { return data().sourceURLsHolder; }
|
||||||
|
|
Загрузка…
Ссылка в новой задаче