зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1377008 - Teach GCPolicy about Maybe;r=jonco
MozReview-Commit-ID: CdfNBojdx3K --HG-- extra : rebase_source : 1db545ca96345ed9b82c986b70cad794a6d764c2
This commit is contained in:
Родитель
22814d28f8
Коммит
c1cb83c9ea
|
@ -40,6 +40,7 @@
|
|||
#ifndef GCPolicyAPI_h
|
||||
#define GCPolicyAPI_h
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "js/TraceKind.h"
|
||||
|
@ -159,6 +160,23 @@ struct GCPolicy<mozilla::UniquePtr<T, D>>
|
|||
}
|
||||
};
|
||||
|
||||
// GCPolicy<Maybe<T>> forwards tracing/sweeping to GCPolicy<T*> if
|
||||
// when the Maybe<T> is full.
|
||||
template <typename T>
|
||||
struct GCPolicy<mozilla::Maybe<T>>
|
||||
{
|
||||
static mozilla::Maybe<T> initial() { return mozilla::Maybe<T>(); }
|
||||
static void trace(JSTracer* trc, mozilla::Maybe<T>* tp, const char* name) {
|
||||
if (tp->isSome())
|
||||
GCPolicy<T>::trace(trc, tp->ptr(), name);
|
||||
}
|
||||
static bool needsSweep(mozilla::Maybe<T>* tp) {
|
||||
if (tp->isSome())
|
||||
return GCPolicy<T>::needsSweep(tp->ptr());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
||||
#endif // GCPolicyAPI_h
|
||||
|
|
Загрузка…
Ссылка в новой задаче