зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1618038 - Add some |if constexpr| to eliminate |to{,Mutable}Handle| functions on |FakeRooted|. r=sfink
Depends on D64236 Differential Revision: https://phabricator.services.mozilla.com/D64239 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b8b7080914
Коммит
6ad06a9362
|
@ -100,10 +100,6 @@ struct DefineComparisonOps<FakeMutableHandle<T>> : std::true_type {
|
|||
* Types for a variable that either should or shouldn't be rooted, depending on
|
||||
* the template parameter allowGC. Used for implementing functions that can
|
||||
* operate on either rooted or unrooted data.
|
||||
*
|
||||
* The toHandle() and toMutableHandle() functions are for calling functions
|
||||
* which require handle types and are only called in the CanGC case. These
|
||||
* allow the calling code to type check.
|
||||
*/
|
||||
|
||||
template <typename T, AllowGC allowGC>
|
||||
|
@ -116,10 +112,6 @@ class MaybeRooted<T, CanGC> {
|
|||
using RootType = JS::Rooted<T>;
|
||||
using MutableHandleType = JS::MutableHandle<T>;
|
||||
|
||||
static JS::Handle<T> toHandle(HandleType v) { return v; }
|
||||
|
||||
static JS::MutableHandle<T> toMutableHandle(MutableHandleType v) { return v; }
|
||||
|
||||
template <typename T2>
|
||||
static JS::Handle<T2*> downcastHandle(HandleType v) {
|
||||
return v.template as<T2>();
|
||||
|
@ -133,12 +125,6 @@ class MaybeRooted<T, NoGC> {
|
|||
using RootType = FakeRooted<T>;
|
||||
using MutableHandleType = FakeMutableHandle<T>;
|
||||
|
||||
static JS::Handle<T> toHandle(HandleType v) { MOZ_CRASH("Bad conversion"); }
|
||||
|
||||
static JS::MutableHandle<T> toMutableHandle(MutableHandleType v) {
|
||||
MOZ_CRASH("Bad conversion");
|
||||
}
|
||||
|
||||
template <typename T2>
|
||||
static T2* downcastHandle(HandleType v) {
|
||||
return &v->template as<T2>();
|
||||
|
|
|
@ -805,28 +805,24 @@ static MOZ_ALWAYS_INLINE bool LookupOwnPropertyInline(
|
|||
// id was not found in obj. Try obj's resolve hook, if any.
|
||||
if (obj->getClass()->getResolve()) {
|
||||
MOZ_ASSERT(!cx->isHelperThreadContext());
|
||||
if (!allowGC) {
|
||||
if constexpr (!allowGC) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
bool recursed;
|
||||
if (!CallResolveOp(cx, obj, id, propp, &recursed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool recursed;
|
||||
if (!CallResolveOp(
|
||||
cx, MaybeRooted<NativeObject*, allowGC>::toHandle(obj),
|
||||
MaybeRooted<jsid, allowGC>::toHandle(id),
|
||||
MaybeRooted<PropertyResult, allowGC>::toMutableHandle(propp),
|
||||
&recursed)) {
|
||||
return false;
|
||||
}
|
||||
if (recursed) {
|
||||
propp.setNotFound();
|
||||
*donep = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (recursed) {
|
||||
propp.setNotFound();
|
||||
*donep = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (propp) {
|
||||
*donep = true;
|
||||
return true;
|
||||
if (propp) {
|
||||
*donep = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,14 +899,11 @@ static MOZ_ALWAYS_INLINE bool LookupPropertyInline(
|
|||
}
|
||||
if (!proto->isNative()) {
|
||||
MOZ_ASSERT(!cx->isHelperThreadContext());
|
||||
if (!allowGC) {
|
||||
if constexpr (!allowGC) {
|
||||
return false;
|
||||
} else {
|
||||
return LookupProperty(cx, proto, id, objp, propp);
|
||||
}
|
||||
return LookupProperty(
|
||||
cx, MaybeRooted<JSObject*, allowGC>::toHandle(proto),
|
||||
MaybeRooted<jsid, allowGC>::toHandle(id),
|
||||
MaybeRooted<JSObject*, allowGC>::toMutableHandle(objp),
|
||||
MaybeRooted<PropertyResult, allowGC>::toMutableHandle(propp));
|
||||
}
|
||||
|
||||
current = &proto->template as<NativeObject>();
|
||||
|
|
|
@ -2327,14 +2327,11 @@ static MOZ_ALWAYS_INLINE bool GetExistingProperty(
|
|||
}
|
||||
}
|
||||
|
||||
if (!allowGC) {
|
||||
if constexpr (!allowGC) {
|
||||
return false;
|
||||
} else {
|
||||
return CallGetter(cx, obj, receiver, shape, vp);
|
||||
}
|
||||
|
||||
return CallGetter(cx, MaybeRooted<JSObject*, allowGC>::toHandle(obj),
|
||||
MaybeRooted<Value, allowGC>::toHandle(receiver),
|
||||
MaybeRooted<Shape*, allowGC>::toHandle(shape),
|
||||
MaybeRooted<Value, allowGC>::toMutableHandle(vp));
|
||||
}
|
||||
|
||||
bool js::NativeGetExistingProperty(JSContext* cx, HandleObject receiver,
|
||||
|
|
Загрузка…
Ссылка в новой задаче