2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsCycleCollector_h__
|
|
|
|
#define nsCycleCollector_h__
|
|
|
|
|
2010-08-11 17:03:23 -07:00
|
|
|
class nsICycleCollectorListener;
|
2013-04-30 10:41:22 -07:00
|
|
|
class nsISupports;
|
2013-06-18 12:01:26 -07:00
|
|
|
class nsScriptObjectTracer;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 07:28:15 -07:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
|
2013-06-18 12:02:16 -07:00
|
|
|
namespace mozilla {
|
2013-07-09 07:28:15 -07:00
|
|
|
|
2013-06-18 12:02:16 -07:00
|
|
|
class CycleCollectedJSRuntime;
|
2013-07-09 07:28:15 -07:00
|
|
|
|
|
|
|
// See the comments in nsContentUtils.h for explanations of these functions.
|
|
|
|
typedef void* (*DeferredFinalizeAppendFunction)(void* pointers, void* thing);
|
|
|
|
typedef bool (*DeferredFinalizeFunction)(uint32_t slice, void* data);
|
|
|
|
|
2013-06-18 12:02:16 -07:00
|
|
|
}
|
|
|
|
|
2012-02-23 20:16:37 -08:00
|
|
|
// Contains various stats about the cycle collection.
|
|
|
|
class nsCycleCollectorResults
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsCycleCollectorResults() :
|
2013-04-29 16:41:41 -07:00
|
|
|
mForcedGC(false), mMergedZones(false),
|
|
|
|
mVisitedRefCounted(0), mVisitedGCed(0),
|
2012-02-23 20:16:37 -08:00
|
|
|
mFreedRefCounted(0), mFreedGCed(0) {}
|
|
|
|
bool mForcedGC;
|
2013-04-29 16:41:41 -07:00
|
|
|
bool mMergedZones;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mVisitedRefCounted;
|
|
|
|
uint32_t mVisitedGCed;
|
|
|
|
uint32_t mFreedRefCounted;
|
|
|
|
uint32_t mFreedGCed;
|
2012-02-23 20:16:37 -08:00
|
|
|
};
|
|
|
|
|
2013-03-25 14:26:00 -07:00
|
|
|
bool nsCycleCollector_init();
|
|
|
|
|
2013-08-13 10:45:32 -07:00
|
|
|
void nsCycleCollector_startup();
|
2012-01-14 08:58:05 -08:00
|
|
|
|
|
|
|
typedef void (*CC_BeforeUnlinkCallback)(void);
|
|
|
|
void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
|
|
|
|
|
|
|
|
typedef void (*CC_ForgetSkippableCallback)(void);
|
|
|
|
void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB);
|
|
|
|
|
2013-07-27 03:48:45 -07:00
|
|
|
void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false,
|
|
|
|
bool aAsyncSnowWhiteFreeing = false);
|
2012-01-14 08:58:05 -08:00
|
|
|
|
2013-08-03 16:55:39 -07:00
|
|
|
void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false);
|
|
|
|
bool nsCycleCollector_doDeferredDeletion();
|
2013-07-09 10:30:58 -07:00
|
|
|
|
2013-04-29 16:41:41 -07:00
|
|
|
void nsCycleCollector_collect(bool aManuallyTriggered,
|
2012-06-27 08:09:56 -07:00
|
|
|
nsCycleCollectorResults *aResults,
|
2013-09-10 16:33:41 -07:00
|
|
|
nsICycleCollectorListener *aManualListener);
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t nsCycleCollector_suspectedCount();
|
2007-03-27 02:49:06 -07:00
|
|
|
void nsCycleCollector_shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-03 12:28:11 -07:00
|
|
|
// Helpers for interacting with JS
|
2013-06-18 12:02:16 -07:00
|
|
|
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime *aRt);
|
2012-05-03 12:28:11 -07:00
|
|
|
void nsCycleCollector_forgetJSRuntime();
|
|
|
|
|
2010-08-11 17:03:23 -07:00
|
|
|
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
|
|
|
|
{ 0x58be81b4, 0x39d2, 0x437c, \
|
|
|
|
{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
|
|
|
|
|
|
|
|
extern nsresult
|
|
|
|
nsCycleCollectorLoggerConstructor(nsISupports* outer,
|
|
|
|
const nsIID& aIID,
|
|
|
|
void* *aInstancePtr);
|
|
|
|
|
2013-06-18 12:01:26 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace cyclecollector {
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-08-15 10:29:02 -07:00
|
|
|
bool IsJSHolder(void* aHolder);
|
2013-06-18 12:01:26 -07:00
|
|
|
#endif
|
|
|
|
|
2013-07-09 07:28:15 -07:00
|
|
|
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
|
|
|
DeferredFinalizeFunction aFunc,
|
|
|
|
void* aThing);
|
|
|
|
void DeferredFinalize(nsISupports* aSupports);
|
|
|
|
|
|
|
|
|
2013-06-18 12:01:26 -07:00
|
|
|
} // namespace cyclecollector
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsCycleCollector_h__
|