diff --git a/js/public/GCPolicyAPI.h b/js/public/GCPolicyAPI.h index cffaee7140..0649c23265 100644 --- a/js/public/GCPolicyAPI.h +++ b/js/public/GCPolicyAPI.h @@ -39,6 +39,7 @@ #ifndef GCPolicyAPI_h #define GCPolicyAPI_h +#include "mozilla/Maybe.h" #include "mozilla/UniquePtr.h" #include "js/TraceKind.h" @@ -160,6 +161,23 @@ struct GCPolicy> } }; +// GCPolicy> forwards tracing/sweeping to GCPolicy if +// when the Maybe is full. +template +struct GCPolicy> +{ + static mozilla::Maybe initial() { return mozilla::Maybe(); } + static void trace(JSTracer* trc, mozilla::Maybe* tp, const char* name) { + if (tp->isSome()) + GCPolicy::trace(trc, tp->ptr(), name); + } + static bool needsSweep(mozilla::Maybe* tp) { + if (tp->isSome()) + return GCPolicy::needsSweep(tp->ptr()); + return false; + } +}; + } // namespace JS #endif // GCPolicyAPI_h