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/. */
7 #ifndef nsCCUncollectableMarker_h_
8 #define nsCCUncollectableMarker_h_
10 #include "js/TracingAPI.h"
11 #include "mozilla/Attributes.h"
12 #include "nsIObserver.h"
14 class nsCCUncollectableMarker final
: public nsIObserver
{
19 * Inits a global nsCCUncollectableMarker. Should only be called once.
21 static nsresult
Init();
24 * Checks if we're collecting during a given generation
26 static bool InGeneration(uint32_t aGeneration
) {
27 return aGeneration
&& aGeneration
== sGeneration
;
30 template <class CCCallback
>
31 static bool InGeneration(CCCallback
& aCb
, uint32_t aGeneration
) {
32 return InGeneration(aGeneration
) && !aCb
.WantAllTraces();
35 static uint32_t sGeneration
;
38 nsCCUncollectableMarker() = default;
39 ~nsCCUncollectableMarker() = default;
44 void TraceBlackJS(JSTracer
* aTrc
);
46 } // namespace mozilla