2014-06-30 15:39:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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-01-04 22:31:26 +00:00
|
|
|
|
|
|
|
#ifndef nsCycleCollector_h__
|
|
|
|
#define nsCycleCollector_h__
|
|
|
|
|
2010-08-12 00:03:23 +00:00
|
|
|
class nsICycleCollectorListener;
|
2014-05-13 17:13:00 +00:00
|
|
|
class nsICycleCollectorLogSink;
|
2013-04-30 17:41:22 +00:00
|
|
|
class nsISupports;
|
2014-05-13 17:13:00 +00:00
|
|
|
template<class T> struct already_AddRefed;
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2013-07-09 14:28:15 +00:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
|
2014-11-06 09:14:00 +00:00
|
|
|
#include "js/SliceBudget.h"
|
|
|
|
|
2013-06-18 19:02:16 +00:00
|
|
|
namespace mozilla {
|
2013-07-09 14:28:15 +00:00
|
|
|
|
2013-06-18 19:02:16 +00:00
|
|
|
class CycleCollectedJSRuntime;
|
2013-07-09 14:28:15 +00:00
|
|
|
|
2014-06-26 16:29:05 +00:00
|
|
|
// Called back from DeferredFinalize. Should add 'thing' to the array of smart
|
|
|
|
// pointers in 'pointers', creating the array if 'pointers' is null, and return
|
|
|
|
// the array.
|
2014-05-14 20:14:58 +00:00
|
|
|
typedef void* (*DeferredFinalizeAppendFunction)(void* aPointers, void* aThing);
|
2014-06-26 16:29:05 +00:00
|
|
|
|
|
|
|
// Called to finalize a number of objects. Slice is the number of objects
|
|
|
|
// to finalize, or if it's UINT32_MAX, all objects should be finalized.
|
|
|
|
// Return value indicates whether it finalized all objects in the buffer.
|
2014-05-14 20:14:58 +00:00
|
|
|
typedef bool (*DeferredFinalizeFunction)(uint32_t aSlice, void* aData);
|
2013-07-09 14:28:15 +00:00
|
|
|
|
2013-06-18 19:02:16 +00:00
|
|
|
}
|
|
|
|
|
2013-03-25 21:26:00 +00:00
|
|
|
bool nsCycleCollector_init();
|
|
|
|
|
2013-08-13 17:45:32 +00:00
|
|
|
void nsCycleCollector_startup();
|
2012-01-14 16:58:05 +00: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 10:48:45 +00:00
|
|
|
void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false,
|
|
|
|
bool aAsyncSnowWhiteFreeing = false);
|
2012-01-14 16:58:05 +00:00
|
|
|
|
2013-12-06 18:17:20 +00:00
|
|
|
void nsCycleCollector_prepareForGarbageCollection();
|
|
|
|
|
2014-05-07 00:25:26 +00:00
|
|
|
// If an incremental cycle collection is in progress, finish it.
|
|
|
|
void nsCycleCollector_finishAnyCurrentCollection();
|
|
|
|
|
2013-08-03 23:55:39 +00:00
|
|
|
void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false);
|
|
|
|
bool nsCycleCollector_doDeferredDeletion();
|
2013-07-09 17:30:58 +00:00
|
|
|
|
2014-05-13 17:13:00 +00:00
|
|
|
already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
|
|
|
|
|
2014-05-13 17:41:38 +00:00
|
|
|
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
|
2013-12-22 14:58:19 +00:00
|
|
|
|
2014-11-27 11:47:51 +00:00
|
|
|
void nsCycleCollector_collectSlice(js::SliceBudget& budget,
|
|
|
|
bool aPreferShorterSlices = false);
|
2014-05-07 00:25:26 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t nsCycleCollector_suspectedCount();
|
2007-03-27 09:49:06 +00:00
|
|
|
void nsCycleCollector_shutdown();
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2012-05-03 19:28:11 +00:00
|
|
|
// Helpers for interacting with JS
|
2014-05-13 17:41:38 +00:00
|
|
|
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime* aRt);
|
2012-05-03 19:28:11 +00:00
|
|
|
void nsCycleCollector_forgetJSRuntime();
|
|
|
|
|
2010-08-12 00:03:23 +00:00
|
|
|
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
|
|
|
|
{ 0x58be81b4, 0x39d2, 0x437c, \
|
|
|
|
{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
|
|
|
|
|
|
|
|
extern nsresult
|
2014-05-13 17:41:38 +00:00
|
|
|
nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
2010-08-12 00:03:23 +00:00
|
|
|
const nsIID& aIID,
|
2014-05-13 17:41:38 +00:00
|
|
|
void** aInstancePtr);
|
2010-08-12 00:03:23 +00:00
|
|
|
|
2013-06-18 19:01:26 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace cyclecollector {
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-08-15 17:29:02 +00:00
|
|
|
bool IsJSHolder(void* aHolder);
|
2013-06-18 19:01:26 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-09 14:28:15 +00:00
|
|
|
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
|
|
|
DeferredFinalizeFunction aFunc,
|
|
|
|
void* aThing);
|
|
|
|
void DeferredFinalize(nsISupports* aSupports);
|
|
|
|
|
|
|
|
|
2013-06-18 19:01:26 +00:00
|
|
|
} // namespace cyclecollector
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-01-04 22:31:26 +00:00
|
|
|
#endif // nsCycleCollector_h__
|