Bug 866151 - Clean up usage of nsCycleCollector.h and nsCycleCollectorUtils.h. r=smaug,bsmedberg

--HG--
rename : xpcom/base/nsCycleCollector.h => xpcom/glue/nsCycleCollectionJSRuntime.h
This commit is contained in:
Andrew McCreight 2013-04-30 10:41:22 -07:00
parent d6895e4f9d
commit fd769e05e8
15 changed files with 73 additions and 57 deletions

View File

@ -116,7 +116,6 @@
#include "nsDOMMutationObserver.h"
#include "nsSVGFeatures.h"
#include "nsWrapperCacheInlines.h"
#include "nsCycleCollector.h"
#include "xpcpublic.h"
#include "nsIScriptError.h"
#include "nsLayoutStatics.h"

View File

@ -125,7 +125,6 @@
#include "jsapi.h"
#include "nsIXPConnect.h"
#include "nsCycleCollector.h"
#include "nsCCUncollectableMarker.h"
#include "nsIContentPolicy.h"
#include "nsContentPolicyUtils.h"

View File

@ -26,7 +26,6 @@
#include "nsContentList.h"
#include "nsContentUtils.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCycleCollector.h"
#include "nsDocument.h"
#include "mozilla/dom/Attr.h"
#include "nsDOMAttributeMap.h"

View File

@ -64,7 +64,6 @@
#include "mozilla/dom/DesktopNotification.h"
#include "nsContentCID.h"
#include "nsLayoutStatics.h"
#include "nsCycleCollector.h"
#include "nsCCUncollectableMarker.h"
#include "nsAutoJSValHolder.h"
#include "nsDOMMediaQueryList.h"

View File

@ -19,9 +19,11 @@
#include "nsIArray.h"
#include "mozilla/Attributes.h"
class nsICycleCollectorListener;
class nsIXPConnectJSObjectHolder;
class nsRootedJSValueArray;
class nsScriptNameSpaceManager;
namespace mozilla {
template <class> class Maybe;
}

View File

@ -24,6 +24,7 @@
#include "nsLayoutStatics.h"
#include "nsContentUtils.h"
#include "nsCCUncollectableMarker.h"
#include "nsCycleCollectorUtils.h"
#include "nsScriptLoader.h"
#include "jsfriendapi.h"
#include "js/MemoryMetrics.h"
@ -488,8 +489,8 @@ XPCJSRuntime::SuspectWrappedNative(XPCWrappedNative *wrapper,
if (!wrapper->IsValid() || wrapper->IsWrapperExpired())
return;
NS_ASSERTION(NS_IsMainThread() || NS_IsCycleCollectorThread(),
"Suspecting wrapped natives from non-CC thread");
MOZ_ASSERT(NS_IsMainThread() || NS_IsCycleCollectorThread(),
"Suspecting wrapped natives from non-CC thread");
// Only record objects that might be part of a cycle as roots, unless
// the callback wants all traces (a debug feature).

View File

@ -38,6 +38,8 @@
#include "mozilla/dom/TextEncoderBinding.h"
#include "nsWrapperCacheInlines.h"
#include "nsCycleCollector.h"
#include "nsCycleCollectorUtils.h"
#include "nsDOMMutationObserver.h"
#include "nsICycleCollectorListener.h"
#include "nsThread.h"

View File

@ -108,7 +108,7 @@
#include "nsXPCOM.h"
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCycleCollector.h"
#include "nsCycleCollectionJSRuntime.h"
#include "nsDebug.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"

View File

@ -100,7 +100,6 @@ using namespace mozilla::system;
#include "nsError.h"
#include "nsCycleCollector.h"
#include "nsJSEnvironment.h"
#include "nsContentSink.h"
#include "nsFrameMessageManager.h"

View File

@ -97,6 +97,7 @@
/* This must occur *after* base/process_util.h to avoid typedefs conflicts. */
#include "mozilla/Util.h"
#include "nsCycleCollectionJSRuntime.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCycleCollectorUtils.h"
#include "nsIProgrammingLanguage.h"

View File

@ -6,10 +6,9 @@
#ifndef nsCycleCollector_h__
#define nsCycleCollector_h__
class nsISupports;
class nsCycleCollectionJSRuntime;
class nsICycleCollectorListener;
class nsCycleCollectionParticipant;
class nsCycleCollectionTraversalCallback;
class nsISupports;
// Contains various stats about the cycle collection.
class nsCycleCollectorResults
@ -49,50 +48,8 @@ uint32_t nsCycleCollector_suspectedCount();
void nsCycleCollector_shutdownThreads();
void nsCycleCollector_shutdown();
// Various methods the cycle collector needs to deal with Javascript.
struct nsCycleCollectionJSRuntime
{
virtual nsresult BeginCycleCollection(nsCycleCollectionTraversalCallback &cb) = 0;
/**
* Called before/after transitioning to/from the main thread.
*
* NotifyLeaveMainThread may return 'false' to prevent the cycle collector
* from leaving the main thread.
*/
virtual bool NotifyLeaveMainThread() = 0;
virtual void NotifyEnterCycleCollectionThread() = 0;
virtual void NotifyLeaveCycleCollectionThread() = 0;
virtual void NotifyEnterMainThread() = 0;
/**
* Unmark gray any weak map values, as needed.
*/
virtual void FixWeakMappingGrayBits() = 0;
/**
* Should we force a JavaScript GC before a CC?
*/
virtual bool NeedCollect() = 0;
/**
* Runs the JavaScript GC. |reason| is a gcreason::Reason from jsfriendapi.h.
*/
virtual void Collect(uint32_t reason) = 0;
/**
* Get the JS cycle collection participant.
*/
virtual nsCycleCollectionParticipant *GetParticipant() = 0;
#ifdef DEBUG
virtual void SetObjectToUnlink(void* aObject) = 0;
virtual void AssertNoObjectsToTrace(void* aPossibleJSHolder) = 0;
#endif
};
// Helpers for interacting with JS
void nsCycleCollector_registerJSRuntime(nsCycleCollectionJSRuntime *rt);
void nsCycleCollector_registerJSRuntime(nsCycleCollectionJSRuntime *aRt);
void nsCycleCollector_forgetJSRuntime();
#define NS_CYCLE_COLLECTOR_LOGGER_CID \

View File

@ -15,6 +15,7 @@
#include "nsStaticComponents.h"
#include "prlink.h"
#include "nsCycleCollector.h"
#include "nsObserverList.h"
#include "nsObserverService.h"
#include "nsProperties.h"

View File

@ -37,6 +37,7 @@ SDK_HEADERS = \
nsCategoryCache.h \
nsClassHashtable.h \
nsComponentManagerUtils.h \
nsCycleCollectionJSRuntime.h \
nsCycleCollectionParticipant.h \
nsCycleCollectorUtils.h \
nsDataHashtable.h \

View File

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsCycleCollectionJSRuntime_h__
#define nsCycleCollectionJSRuntime_h__
class nsCycleCollectionParticipant;
class nsCycleCollectionTraversalCallback;
// Various methods the cycle collector needs to deal with Javascript.
struct nsCycleCollectionJSRuntime
{
virtual nsresult BeginCycleCollection(nsCycleCollectionTraversalCallback &aCb) = 0;
/**
* Called before/after transitioning to/from the main thread.
*
* NotifyLeaveMainThread may return 'false' to prevent the cycle collector
* from leaving the main thread.
*/
virtual bool NotifyLeaveMainThread() = 0;
virtual void NotifyEnterCycleCollectionThread() = 0;
virtual void NotifyLeaveCycleCollectionThread() = 0;
virtual void NotifyEnterMainThread() = 0;
/**
* Unmark gray any weak map values, as needed.
*/
virtual void FixWeakMappingGrayBits() = 0;
/**
* Should we force a JavaScript GC before a CC?
*/
virtual bool NeedCollect() = 0;
/**
* Runs the JavaScript GC. |reason| is a gcreason::Reason from jsfriendapi.h.
*/
virtual void Collect(uint32_t aReason) = 0;
/**
* Get the JS cycle collection participant.
*/
virtual nsCycleCollectionParticipant *GetParticipant() = 0;
#ifdef DEBUG
virtual void SetObjectToUnlink(void* aObject) = 0;
virtual void AssertNoObjectsToTrace(void* aPossibleJSHolder) = 0;
#endif
};
#endif // nsCycleCollectionJSRuntime_h__

View File

@ -23,12 +23,13 @@
#if !defined(XPCOM_GLUE_AVOID_NSPR)
#include "prthread.h" /* needed for thread-safety checks */
#include "nsAtomicRefcnt.h" /* for NS_Atomic{Increment,Decrement}Refcnt */
#endif
#ifdef DEBUG
#include "nsCycleCollectorUtils.h" /* for NS_IsCycleCollectorThread */
#endif // DEBUG
#endif // !XPCOM_GLUE_AVOID_NSPR
#include "nsDebug.h"
#include "nsTraceRefcnt.h"
#include "nsCycleCollector.h"
#include "nsCycleCollectorUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/Assertions.h"
#include "mozilla/Likely.h"