Bug 1430703 - Fix some too-loose static assertions r=cduan
authorPaul Bone <pbone@mozilla.com>
Wed, 13 Dec 2017 11:31:39 +1100
changeset 721526 abf83566cc101a7abc5c180b9e491b753023ca38
parent 721525 4efc37f978d2817177068b0df224fcdc3abebeee
child 721527 7eaf34a4efa6768d94a9b7c4ceeabbde1e6910eb
push id95856
push userjwatt@jwatt.org
push dateWed, 17 Jan 2018 10:55:16 +0000
reviewerscduan
bugs1430703
milestone59.0a1
Bug 1430703 - Fix some too-loose static assertions r=cduan
js/public/TraceKind.h
--- a/js/public/TraceKind.h
+++ b/js/public/TraceKind.h
@@ -59,21 +59,26 @@ enum class TraceKind
     // The following kinds do not have an exposed C++ idiom.
     BaseShape = 0x0F,
     JitCode = 0x1F,
     LazyScript = 0x2F,
     Scope = 0x3F,
     RegExpShared = 0x4F
 };
 const static uintptr_t OutOfLineTraceKindMask = 0x07;
-static_assert(uintptr_t(JS::TraceKind::BaseShape) & OutOfLineTraceKindMask, "mask bits are set");
-static_assert(uintptr_t(JS::TraceKind::JitCode) & OutOfLineTraceKindMask, "mask bits are set");
-static_assert(uintptr_t(JS::TraceKind::LazyScript) & OutOfLineTraceKindMask, "mask bits are set");
-static_assert(uintptr_t(JS::TraceKind::Scope) & OutOfLineTraceKindMask, "mask bits are set");
-static_assert(uintptr_t(JS::TraceKind::RegExpShared) & OutOfLineTraceKindMask, "mask bits are set");
+
+#define ASSERT_TRACE_KIND(tk) \
+    static_assert((uintptr_t(tk) & OutOfLineTraceKindMask) == OutOfLineTraceKindMask, \
+        "mask bits are set")
+ASSERT_TRACE_KIND(JS::TraceKind::BaseShape);
+ASSERT_TRACE_KIND(JS::TraceKind::JitCode);
+ASSERT_TRACE_KIND(JS::TraceKind::LazyScript);
+ASSERT_TRACE_KIND(JS::TraceKind::Scope);
+ASSERT_TRACE_KIND(JS::TraceKind::RegExpShared);
+#undef ASSERT_TRACE_KIND
 
 // When this header is imported inside SpiderMonkey, the class definitions are
 // available and we can query those definitions to find the correct kind
 // directly from the class hierarchy.
 template <typename T>
 struct MapTypeToTraceKind {
     static const JS::TraceKind kind = T::TraceKind;
 };