Bug 1881969 - Use the correct global for determining prototypes r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D202877
This commit is contained in:
Matthew Gaudet 2024-02-29 16:39:31 +00:00
parent 8d75a376ce
commit 4ebf3c88ba

View file

@ -102,23 +102,24 @@ static void InvalidateMegamorphicCache(JSContext* cx,
} }
void MaybePopReturnFuses(JSContext* cx, Handle<NativeObject*> nobj) { void MaybePopReturnFuses(JSContext* cx, Handle<NativeObject*> nobj) {
JSObject* objectProto = &cx->global()->getObjectPrototype(); GlobalObject* global = &nobj->global();
JSObject* objectProto = &global->getObjectPrototype();
if (nobj == objectProto) { if (nobj == objectProto) {
nobj->realm()->realmFuses.objectPrototypeHasNoReturnProperty.popFuse( nobj->realm()->realmFuses.objectPrototypeHasNoReturnProperty.popFuse(
cx, nobj->realm()->realmFuses); cx, nobj->realm()->realmFuses);
return; return;
} }
JSObject* iteratorProto = cx->global()->maybeGetIteratorPrototype(); JSObject* iteratorProto = global->maybeGetIteratorPrototype();
if (nobj == iteratorProto) { if (nobj == iteratorProto) {
nobj->realm()->realmFuses.iteratorPrototypeHasNoReturnProperty.popFuse( nobj->realm()->realmFuses.iteratorPrototypeHasNoReturnProperty.popFuse(
cx, nobj->realm()->realmFuses); cx, nobj->realm()->realmFuses);
return; return;
} }
JSObject* arrayIterProto = cx->global()->maybeGetArrayIteratorPrototype(); JSObject* arrayIterProto = global->maybeGetArrayIteratorPrototype();
if (nobj == arrayIterProto) { if (nobj == arrayIterProto) {
cx->realm()->realmFuses.arrayIteratorPrototypeHasNoReturnProperty.popFuse( nobj->realm()->realmFuses.arrayIteratorPrototypeHasNoReturnProperty.popFuse(
cx, nobj->realm()->realmFuses); cx, nobj->realm()->realmFuses);
return; return;
} }
@ -208,12 +209,12 @@ static bool WatchProtoChangeImpl(JSContext* cx, HandleObject obj) {
InvalidateMegamorphicCache(cx, obj.as<NativeObject>()); InvalidateMegamorphicCache(cx, obj.as<NativeObject>());
NativeObject* nobj = &obj->as<NativeObject>(); NativeObject* nobj = &obj->as<NativeObject>();
if (nobj == cx->global()->maybeGetArrayIteratorPrototype()) { if (nobj == nobj->global().maybeGetArrayIteratorPrototype()) {
nobj->realm()->realmFuses.arrayIteratorPrototypeHasIteratorProto.popFuse( nobj->realm()->realmFuses.arrayIteratorPrototypeHasIteratorProto.popFuse(
cx, nobj->realm()->realmFuses); cx, nobj->realm()->realmFuses);
} }
if (nobj == cx->global()->maybeGetIteratorPrototype()) { if (nobj == nobj->global().maybeGetIteratorPrototype()) {
nobj->realm()->realmFuses.iteratorPrototypeHasObjectProto.popFuse( nobj->realm()->realmFuses.iteratorPrototypeHasObjectProto.popFuse(
cx, nobj->realm()->realmFuses); cx, nobj->realm()->realmFuses);
} }