1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "js/TraceKind.h"
15 // Map from all trace kinds to the base GC type.
16 template <JS::TraceKind kind
>
17 struct MapTraceKindToType
{};
19 #define DEFINE_TRACE_KIND_MAP(name, type, _, _1) \
21 struct MapTraceKindToType<JS::TraceKind::name> { \
24 JS_FOR_EACH_TRACEKIND(DEFINE_TRACE_KIND_MAP
);
25 #undef DEFINE_TRACE_KIND_MAP
27 // Map from a possibly-derived type to the base GC type.
31 typename MapTraceKindToType
<JS::MapTypeToTraceKind
<T
>::kind
>::Type
;
32 static_assert(std::is_base_of_v
<type
, T
>, "Failed to find base type");
36 struct TraceKindCanBeGray
{};
37 #define EXPAND_TRACEKIND_DEF(_, type, canBeGray, _1) \
39 struct TraceKindCanBeGray<type> { \
40 static constexpr bool value = canBeGray; \
42 JS_FOR_EACH_TRACEKIND(EXPAND_TRACEKIND_DEF
)
43 #undef EXPAND_TRACEKIND_DEF
45 struct TraceKindCanBeGrayFunctor
{
48 return TraceKindCanBeGray
<T
>::value
;
52 static inline bool TraceKindCanBeMarkedGray(JS::TraceKind kind
) {
53 return DispatchTraceKindTyped(TraceKindCanBeGrayFunctor(), kind
);
59 #endif /* gc_TraceKind_h */