Bug 1270746 part 4 - Inline Proxy::hasInstance call instead of using a class hook. r=iain

This can be changed more later on, but for now this ensures no change in behavior.

Differential Revision: https://phabricator.services.mozilla.com/D141345
This commit is contained in:
Jan de Mooij 2022-03-20 11:28:03 +00:00
parent 07e7d34e88
commit b1c10b996e
2 changed files with 8 additions and 5 deletions

View File

@ -921,7 +921,7 @@ const JSClassOps js::ProxyClassOps = {
nullptr, // mayResolve
proxy_Finalize, // finalize
nullptr, // call
Proxy::hasInstance, // hasInstance
nullptr, // hasInstance
nullptr, // construct
ProxyObject::trace, // trace
};

View File

@ -839,12 +839,15 @@ extern bool JS::InstanceofOperator(JSContext* cx, HandleObject obj,
}
bool js::HasInstance(JSContext* cx, HandleObject obj, HandleValue v, bool* bp) {
const JSClass* clasp = obj->getClass();
RootedValue local(cx, v);
if (JSHasInstanceOp hasInstance = clasp->getHasInstance()) {
if (MOZ_UNLIKELY(obj->is<ProxyObject>())) {
RootedValue local(cx, v);
return Proxy::hasInstance(cx, obj, &local, bp);
}
if (JSHasInstanceOp hasInstance = obj->getClass()->getHasInstance()) {
RootedValue local(cx, v);
return hasInstance(cx, obj, &local, bp);
}
return JS::InstanceofOperator(cx, obj, local, bp);
return JS::InstanceofOperator(cx, obj, v, bp);
}
JSType js::TypeOfObject(JSObject* obj) {