Commit 104c0bd8 authored by Steve Fink's avatar Steve Fink
Browse files

Bug 1534430 - Pointer types should default to RootKind::Traceable unless a...

Bug 1534430 - Pointer types should default to RootKind::Traceable unless a more specific RootKind has been set via MapTypeToTraceKind r=jwalden

Differential Revision: https://phabricator.services.mozilla.com/D23040

--HG--
extra : moz-landing-system : lando
parent b0f3ca80
......@@ -156,20 +156,22 @@ JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF)
// Specify the RootKind for all types. Value and jsid map to special cases;
// Cell pointer types we can derive directly from the TraceKind; everything else
// should go in the Traceable list and use GCPolicy<T>::trace for tracing.
template <typename T>
//
// The second, defaulted template parameter here is purely so a specialization
// can get a soft (SFINAE) failure to fall back on this default of Traceable.
template <typename T, typename = void>
struct MapTypeToRootKind {
static const JS::RootKind kind = JS::RootKind::Traceable;
};
// For any type for which MapTypeToTraceKind<T> exists, map that trace kind to
// the appropriate root kind and use it for pointers to that type. For anything
// else, the second template parameter will cause a failure and thus fall back
// to the generic RootKind::Traceable version above.
template <typename T>
struct MapTypeToRootKind<T*> {
struct MapTypeToRootKind<T*, JS::MapTypeToTraceKind<T>> {
static const JS::RootKind kind =
JS::MapTraceKindToRootKind<JS::MapTypeToTraceKind<T>::kind>::kind;
};
template <>
struct MapTypeToRootKind<JS::Realm*> {
// Not a pointer to a GC cell. Use GCPolicy.
static const JS::RootKind kind = JS::RootKind::Traceable;
};
template <typename T>
struct MapTypeToRootKind<mozilla::UniquePtr<T>> {
static const JS::RootKind kind = JS::MapTypeToRootKind<T>::kind;
......
......@@ -203,11 +203,6 @@ class RematerializedFrame {
namespace JS {
template <>
struct MapTypeToRootKind<js::jit::RematerializedFrame*> {
static const RootKind kind = RootKind::Traceable;
};
template <>
struct GCPolicy<js::jit::RematerializedFrame*>
: public NonGCPointerPolicy<js::jit::RematerializedFrame*> {};
......
......@@ -28,11 +28,6 @@ template <>
struct DeletePolicy<js::GCManagedObjectWeakMap>
: public js::GCManagedDeletePolicy<js::GCManagedObjectWeakMap> {};
template <>
struct MapTypeToRootKind<js::GCManagedObjectWeakMap*> {
static const JS::RootKind kind = JS::RootKind::Traceable;
};
template <>
struct GCPolicy<js::GCManagedObjectWeakMap*>
: public NonGCPointerPolicy<js::GCManagedObjectWeakMap*> {};
......
......@@ -22,7 +22,7 @@ struct TestStruct {
W wrapper;
};
// A specialized version for GCPtr that adds a zone() method.
// A specialized version for GCPtr that adds a trace() method.
template <typename T>
struct TestStruct<js::GCPtr<T>> {
js::GCPtr<T> wrapper;
......
......@@ -1465,10 +1465,6 @@ template <typename T>
struct ScopeDataGCPolicy : public NonGCPointerPolicy<T> {};
#define DEFINE_SCOPE_DATA_GCPOLICY(Data) \
template <> \
struct MapTypeToRootKind<Data*> { \
static const RootKind kind = RootKind::Traceable; \
}; \
template <> \
struct GCPolicy<Data*> : public ScopeDataGCPolicy<Data*> {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment