Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / xpcom / base / nsCycleCollector.h
blob1c583e04cf7ab1baa795b8fea516a793bd0ff497
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 nsCycleCollector_h__
8 #define nsCycleCollector_h__
10 class nsICycleCollectorListener;
11 class nsICycleCollectorLogSink;
12 class nsISupports;
13 template <class T>
14 struct already_AddRefed;
16 #include <cstdint>
17 #include "mozilla/Attributes.h"
19 namespace js {
20 class SliceBudget;
23 namespace mozilla {
24 class CycleCollectedJSContext;
25 } // namespace mozilla
27 bool nsCycleCollector_init();
29 void nsCycleCollector_startup();
31 typedef void (*CC_BeforeUnlinkCallback)(void);
32 void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
34 typedef void (*CC_ForgetSkippableCallback)(void);
35 void nsCycleCollector_setForgetSkippableCallback(
36 CC_ForgetSkippableCallback aCB);
38 void nsCycleCollector_forgetSkippable(js::SliceBudget& aBudget,
39 bool aRemoveChildlessNodes = false,
40 bool aAsyncSnowWhiteFreeing = false);
42 void nsCycleCollector_prepareForGarbageCollection();
44 // If an incremental cycle collection is in progress, finish it.
45 void nsCycleCollector_finishAnyCurrentCollection();
47 void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
48 bool aPurge = false);
49 bool nsCycleCollector_doDeferredDeletion();
50 bool nsCycleCollector_doDeferredDeletionWithBudget(js::SliceBudget& aBudget);
52 already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
53 already_AddRefed<nsICycleCollectorListener> nsCycleCollector_createLogger();
55 // Run a cycle collection and return whether anything was collected.
56 bool nsCycleCollector_collect(mozilla::CCReason aReason,
57 nsICycleCollectorListener* aManualListener);
59 void nsCycleCollector_collectSlice(js::SliceBudget& budget,
60 mozilla::CCReason aReason,
61 bool aPreferShorterSlices = false);
63 uint32_t nsCycleCollector_suspectedCount();
65 // If aDoCollect is true, then run the GC and CC a few times before
66 // shutting down the CC completely.
67 MOZ_CAN_RUN_SCRIPT
68 void nsCycleCollector_shutdown(bool aDoCollect = true);
70 // Helpers for interacting with JS
71 void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
72 void nsCycleCollector_forgetJSContext();
74 #endif // nsCycleCollector_h__