2014-06-30 08:39:45 -07: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 12:12:37 +01: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 12:03:23 +12:00
|
|
|
class nsICycleCollectorListener;
|
2014-05-13 13:13:00 -04:00
|
|
|
class nsICycleCollectorLogSink;
|
2013-04-30 10:41:22 -07:00
|
|
|
class nsISupports;
|
2014-05-13 13:13:00 -04:00
|
|
|
template<class T> struct already_AddRefed;
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2013-07-09 07:28:15 -07:00
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
|
2014-11-06 10:14:00 +01:00
|
|
|
#include "js/SliceBudget.h"
|
|
|
|
|
2013-06-18 12:02:16 -07:00
|
|
|
namespace mozilla {
|
2016-09-14 15:47:32 +02:00
|
|
|
class CycleCollectedJSContext;
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace mozilla
|
2013-06-18 12:02:16 -07: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 18:58:05 +02:00
|
|
|
|
|
|
|
typedef void (*CC_BeforeUnlinkCallback)(void);
|
|
|
|
void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
|
|
|
|
|
|
|
|
typedef void (*CC_ForgetSkippableCallback)(void);
|
|
|
|
void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB);
|
|
|
|
|
2017-06-30 13:44:59 +03:00
|
|
|
void nsCycleCollector_forgetSkippable(js::SliceBudget& aBudget,
|
|
|
|
bool aRemoveChildlessNodes = false,
|
2013-07-27 13:48:45 +03:00
|
|
|
bool aAsyncSnowWhiteFreeing = false);
|
2012-01-14 18:58:05 +02:00
|
|
|
|
2013-12-06 10:17:20 -08:00
|
|
|
void nsCycleCollector_prepareForGarbageCollection();
|
|
|
|
|
2014-05-06 17:25:26 -07:00
|
|
|
// If an incremental cycle collection is in progress, finish it.
|
|
|
|
void nsCycleCollector_finishAnyCurrentCollection();
|
|
|
|
|
Bug 1203840 - Trigger dirty pages purge after CC. r=njn,r=smaug,r=mccr8
Jemalloc 4 purges dirty pages regularly during free() when the ratio of dirty
pages compared to active pages is higher than 1 << lg_dirty_mult. We set
lg_dirty_mult in jemalloc_config to limit RSS usage, but it also has an impact
on performance.
So instead of enforcing a high ratio to force more pages being purged, we keep
jemalloc's default ratio of 8, and force a regular purge of all dirty pages,
after cycle collection.
Keeping jemalloc's default ratio avoids cycle-collection-triggered purge to
have to go through really all dirty pages when there are a lot, in which case
the normal jemalloc purge during free() will already have kicked in. It also
takes care of everything that doesn't run the cycle collector still having
a level of purge, like plugins in the plugin-container.
At the same time, since jemalloc_purge_freed_pages does nothing with jemalloc 4,
repurpose the MEMORY_FREE_PURGED_PAGES_MS telemetry probe to track the time
spent in this cycle-collector-triggered purge.
2015-09-11 14:12:21 +09:00
|
|
|
void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
|
|
|
|
bool aPurge = false);
|
2013-08-03 16:55:39 -07:00
|
|
|
bool nsCycleCollector_doDeferredDeletion();
|
2013-07-09 13:30:58 -04:00
|
|
|
|
2014-05-13 13:13:00 -04:00
|
|
|
already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
|
|
|
|
|
2014-05-13 20:41:38 +03:00
|
|
|
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
|
2013-12-22 09:58:19 -05:00
|
|
|
|
2014-11-27 13:47:51 +02:00
|
|
|
void nsCycleCollector_collectSlice(js::SliceBudget& budget,
|
|
|
|
bool aPreferShorterSlices = false);
|
2014-05-06 17:25:26 -07:00
|
|
|
|
2012-08-22 11:56:38 -04:00
|
|
|
uint32_t nsCycleCollector_suspectedCount();
|
2016-09-08 13:04:30 -07:00
|
|
|
|
|
|
|
// If aDoCollect is true, then run the GC and CC a few times before
|
|
|
|
// shutting down the CC completely.
|
|
|
|
void nsCycleCollector_shutdown(bool aDoCollect = true);
|
2007-01-04 22:31:26 +00:00
|
|
|
|
2012-05-03 12:28:11 -07:00
|
|
|
// Helpers for interacting with JS
|
2016-09-14 15:47:32 +02:00
|
|
|
void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
|
|
|
|
void nsCycleCollector_forgetJSContext();
|
2012-05-03 12:28:11 -07:00
|
|
|
|
2017-04-24 13:54:27 -07:00
|
|
|
// Helpers for cooperative threads.
|
|
|
|
void nsCycleCollector_registerNonPrimaryContext(mozilla::CycleCollectedJSContext* aCx);
|
|
|
|
void nsCycleCollector_forgetNonPrimaryContext();
|
|
|
|
|
2010-08-12 12:03:23 +12:00
|
|
|
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
|
|
|
|
{ 0x58be81b4, 0x39d2, 0x437c, \
|
|
|
|
{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
|
|
|
|
|
|
|
|
extern nsresult
|
2014-05-13 20:41:38 +03:00
|
|
|
nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
2010-08-12 12:03:23 +12:00
|
|
|
const nsIID& aIID,
|
2014-05-13 20:41:38 +03:00
|
|
|
void** aInstancePtr);
|
2010-08-12 12:03:23 +12:00
|
|
|
|
2007-01-04 22:31:26 +00:00
|
|
|
#endif // nsCycleCollector_h__
|