зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1694044 - Remove implementation of js::LookupPropertyPure. r=jandem
Combine implementation of: - NativeLookupPropertyInline - LookupPropertyPure Instead of checking for `is<NativeObject>`, check for a lookupProperty hook which is more indicative of what we are worried about. Differential Revision: https://phabricator.services.mozilla.com/D106240
This commit is contained in:
Родитель
dd39a2a8f0
Коммит
c4c2d069d8
|
@ -2132,27 +2132,11 @@ bool js::HasOwnProperty(JSContext* cx, HandleObject obj, HandleId id,
|
|||
|
||||
bool js::LookupPropertyPure(JSContext* cx, JSObject* obj, jsid id,
|
||||
JSObject** objp, PropertyResult* propp) {
|
||||
do {
|
||||
if (!LookupOwnPropertyPure(cx, obj, id, propp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propp->isFound()) {
|
||||
*objp = obj;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (propp->shouldIgnoreProtoChain()) {
|
||||
*objp = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
obj = obj->staticPrototype();
|
||||
} while (obj);
|
||||
|
||||
*objp = nullptr;
|
||||
propp->setNotFound();
|
||||
return true;
|
||||
if (obj->getOpsLookupProperty()) {
|
||||
return false;
|
||||
}
|
||||
return NativeLookupPropertyInline<NoGC, LookupResolveMode::CheckMayResolve>(
|
||||
cx, &obj->as<NativeObject>(), id, objp, propp);
|
||||
}
|
||||
|
||||
bool js::LookupOwnPropertyPure(JSContext* cx, JSObject* obj, jsid id,
|
||||
|
|
|
@ -780,35 +780,38 @@ static MOZ_ALWAYS_INLINE bool NativeLookupPropertyInline(
|
|||
propp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propp.isFound()) {
|
||||
objp.set(current);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (propp.shouldIgnoreProtoChain()) {
|
||||
objp.set(nullptr);
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
typename MaybeRooted<JSObject*, allowGC>::RootType proto(
|
||||
cx, current->staticPrototype());
|
||||
|
||||
JSObject* proto = current->staticPrototype();
|
||||
if (!proto) {
|
||||
break;
|
||||
}
|
||||
if (!proto->template is<NativeObject>()) {
|
||||
MOZ_ASSERT(!cx->isHelperThreadContext());
|
||||
if constexpr (!allowGC) {
|
||||
return false;
|
||||
|
||||
// If a `lookupProperty` hook exists, recurse into LookupProperty, otherwise
|
||||
// we can simply loop within this call frame.
|
||||
if (proto->getOpsLookupProperty()) {
|
||||
if constexpr (allowGC) {
|
||||
MOZ_ASSERT(!cx->isHelperThreadContext());
|
||||
RootedObject protoRoot(cx, proto);
|
||||
return LookupProperty(cx, protoRoot, id, objp, propp);
|
||||
} else {
|
||||
return LookupProperty(cx, proto, id, objp, propp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
current = &proto->template as<NativeObject>();
|
||||
current = &proto->as<NativeObject>();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(propp.isNotFound());
|
||||
objp.set(nullptr);
|
||||
propp.setNotFound();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче