From 11b739d096b1caaa7dae00aa3b1c405773f8eaa7 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Thu, 9 Apr 2020 09:49:24 +0000 Subject: [PATCH] Bug 1628389 - Replace standard library traits classes with _v and _t versions in the GC r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D70224 --HG-- extra : moz-landing-system : lando --- js/public/RootingAPI.h | 12 ++++++------ js/src/gc/Cell.h | 8 ++++---- js/src/gc/Marking-inl.h | 18 ++++++++---------- js/src/gc/Marking.cpp | 15 +++++++-------- js/src/gc/Policy.h | 3 +-- js/src/gc/Tracer.h | 2 +- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 4748556152c1..b7eea22735bd 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -230,15 +230,15 @@ inline T SafelyInitialized() { // That presumption holds for pointers, where value initialization produces // a null pointer. - constexpr bool IsPointer = std::is_pointer::value; + constexpr bool IsPointer = std::is_pointer_v; // For classes and unions we *assume* that if |T|'s default constructor is // non-trivial it'll initialize correctly. (This is unideal, but C++ // doesn't offer a type trait indicating whether a class's constructor is // user-defined, which better approximates our desired semantics.) constexpr bool IsNonTriviallyDefaultConstructibleClassOrUnion = - (std::is_class::value || std::is_union::value) && - !std::is_trivially_default_constructible::value; + (std::is_class_v || + std::is_union_v)&&!std::is_trivially_default_constructible_v; static_assert(IsPointer || IsNonTriviallyDefaultConstructibleClassOrUnion, "T() must evaluate to a safely-initialized T"); @@ -1087,9 +1087,9 @@ class MOZ_RAII Rooted : public js::RootedBase> { // If T can be constructed with a cx, then define another constructor for it // that will be preferred. - template ::value>::type> + template < + typename RootingContext, + typename = std::enable_if_t>> Rooted(const RootingContext& cx, CtorDispatcher, detail::PreferredOverload) : Rooted(cx, T(cx)) {} diff --git a/js/src/gc/Cell.h b/js/src/gc/Cell.h index bd60dc701aa4..1e81166bcf73 100644 --- a/js/src/gc/Cell.h +++ b/js/src/gc/Cell.h @@ -654,10 +654,10 @@ class CellHeaderWithLengthAndFlags { // The low bits of the word (see CellFlagBitsReservedForGC) are reserved for GC. template class CellHeaderWithNonGCPointer : public CellHeader { - static_assert(!std::is_pointer::value, + static_assert(!std::is_pointer_v, "PtrT should be the type of the referent, not of the pointer"); static_assert( - !std::is_base_of::value, + !std::is_base_of_v, "Don't use CellHeaderWithNonGCPointer for pointers to GC things"); public: @@ -704,10 +704,10 @@ class CellHeaderWithTenuredGCPointer : public CellHeader { // These static asserts are not in class scope because the PtrT may not be // defined when this class template is instantiated. static_assert( - !std::is_pointer::value, + !std::is_pointer_v, "PtrT should be the type of the referent, not of the pointer"); static_assert( - std::is_base_of::value, + std::is_base_of_v, "Only use CellHeaderWithTenuredGCPointer for pointers to GC things"); } diff --git a/js/src/gc/Marking-inl.h b/js/src/gc/Marking-inl.h index 2a9fa92d576a..e0de8a840ffd 100644 --- a/js/src/gc/Marking-inl.h +++ b/js/src/gc/Marking-inl.h @@ -35,7 +35,7 @@ struct TaggedPtr { static JS::Value wrap(JS::BigInt* bi) { return JS::BigIntValue(bi); } template static JS::Value wrap(T* priv) { - static_assert(std::is_base_of::value, + static_assert(std::is_base_of_v, "Type must be a GC thing derived from js::gc::Cell"); return JS::PrivateGCThingValue(priv); } @@ -59,18 +59,16 @@ struct TaggedPtr { template struct MightBeForwarded { - static_assert(std::is_base_of::value, "T must derive from Cell"); + static_assert(std::is_base_of_v, "T must derive from Cell"); static_assert(!std::is_same_v && !std::is_same_v, "T must not be Cell or TenuredCell"); - static const bool value = std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value; + static const bool value = + std::is_base_of_v || std::is_base_of_v || + std::is_base_of_v || std::is_base_of_v || + std::is_base_of_v || + std::is_base_of_v || std::is_base_of_v || + std::is_base_of_v; }; template diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index b565eb7de589..0d03f63aeed6 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -199,9 +199,8 @@ void js::CheckTracedThing(JSTracer* trc, T* thing) { // Check that CellHeader is the first field in the cell. static_assert( - std::is_base_ofcellHeader())>::type>::type>::value, + std::is_base_of_vcellHeader())>>>, "GC things must provide a cellHeader() method that returns a reference " "to the cell header"); MOZ_ASSERT(static_cast(&thing->cellHeader()) == @@ -3082,8 +3081,8 @@ void js::gc::StoreBuffer::WholeCellBuffer::trace(TenuringTracer& mover) { template void js::gc::StoreBuffer::CellPtrEdge::trace(TenuringTracer& mover) const { - static_assert(std::is_base_of::value, "T must be a Cell type"); - static_assert(!std::is_base_of::value, + static_assert(std::is_base_of_v, "T must be a Cell type"); + static_assert(!std::is_base_of_v, "T must not be a tenured Cell type"); if (!*edge) { @@ -3574,9 +3573,9 @@ static inline bool ShouldCheckMarkState(JSRuntime* rt, T** thingp) { template struct MightBeNurseryAllocated { - static const bool value = std::is_base_of::value || - std::is_base_of::value || - std::is_base_of::value; + static const bool value = std::is_base_of_v || + std::is_base_of_v || + std::is_base_of_v; }; template diff --git a/js/src/gc/Policy.h b/js/src/gc/Policy.h index 4d8294c5949c..1c8425b85ed4 100644 --- a/js/src/gc/Policy.h +++ b/js/src/gc/Policy.h @@ -22,8 +22,7 @@ template struct InternalGCPointerPolicy : public JS::GCPointerPolicy { using Type = std::remove_pointer_t; -#define IS_BASE_OF_OR(_1, BaseType, _2, _3) \ - std::is_base_of::value || +#define IS_BASE_OF_OR(_1, BaseType, _2, _3) std::is_base_of_v || static_assert( JS_FOR_EACH_TRACEKIND(IS_BASE_OF_OR) false, "InternalGCPointerPolicy must only be used for GC thing pointers"); diff --git a/js/src/gc/Tracer.h b/js/src/gc/Tracer.h index 18da2d7b6ba4..95f92df4145f 100644 --- a/js/src/gc/Tracer.h +++ b/js/src/gc/Tracer.h @@ -68,7 +68,7 @@ template struct BaseGCType { using type = typename MapTraceKindToType::kind>::Type; - static_assert(std::is_base_of::value, "Failed to find base type"); + static_assert(std::is_base_of_v, "Failed to find base type"); }; // Our barrier templates are parameterized on the pointer types so that we can