Bug 1912715: Simplify with-env handling in FetchName r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D219198
This commit is contained in:
Iain Ireland 2024-08-20 17:55:37 +00:00
Родитель 198d5fc1be
Коммит fab7e5c28e
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -128,7 +128,8 @@ inline bool FetchName(JSContext* cx, HandleObject receiver, HandleObject holder,
}
/* Take the slow path if shape was not found in a native object. */
if (!receiver->is<NativeObject>() || !holder->is<NativeObject>()) {
if (!receiver->is<NativeObject>() || !holder->is<NativeObject>() ||
receiver->is<WithEnvironmentObject>()) {
Rooted<jsid> id(cx, NameToId(name));
if (!GetProperty(cx, receiver, receiver, id, vp)) {
return false;
@ -139,11 +140,8 @@ inline bool FetchName(JSContext* cx, HandleObject receiver, HandleObject holder,
/* Fast path for Object instance properties. */
vp.set(holder->as<NativeObject>().getSlot(propInfo.slot()));
} else {
// Unwrap 'with' environments for reasons given in
// GetNameBoundInEnvironment.
RootedObject normalized(cx, MaybeUnwrapWithEnvironment(receiver));
RootedId id(cx, NameToId(name));
if (!NativeGetExistingProperty(cx, normalized, holder.as<NativeObject>(),
if (!NativeGetExistingProperty(cx, receiver, holder.as<NativeObject>(),
id, propInfo, vp)) {
return false;
}