Bug 1137536, part 3 - Move the top level DeferredFinalize functions into their own file. r=smaug

This commit is contained in:
Andrew McCreight 2015-03-18 11:36:03 -07:00
parent fa747a90b0
commit c34850707a
10 changed files with 68 additions and 49 deletions

View File

@ -14,6 +14,8 @@
#include "mozilla/Alignment.h"
#include "mozilla/Array.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/DeferredFinalize.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackObject.h"
#include "mozilla/dom/DOMJSClass.h"
@ -26,8 +28,6 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/Likely.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "nsCycleCollector.h"
#include "nsIGlobalObject.h"
#include "nsIXPConnect.h"
#include "nsJSUtils.h"

View File

@ -50,12 +50,12 @@
#include "prprf.h"
#include "nsNodeUtils.h"
#include "nsJSUtils.h"
#include "nsCycleCollector.h"
// Nasty hack. Maybe we could move some of the classinfo utility methods
// (e.g. WrapNative) over to nsContentUtils?
#include "nsDOMClassInfo.h"
#include "mozilla/DeferredFinalize.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/ShadowRoot.h"

View File

@ -8,6 +8,7 @@
#include "xpcprivate.h"
#include "jsprf.h"
#include "mozilla/DeferredFinalize.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "nsCCUncollectableMarker.h"
#include "nsContentUtils.h"

View File

@ -19,6 +19,7 @@
#include "nsContentUtils.h"
#include <stdint.h>
#include "mozilla/DeferredFinalize.h"
#include "mozilla/Likely.h"
#include "mozilla/dom/BindingUtils.h"
#include <algorithm>

View File

@ -7,10 +7,10 @@
#ifndef mozilla_CycleCollectedJSRuntime_h__
#define mozilla_CycleCollectedJSRuntime_h__
#include "mozilla/DeferredFinalize.h"
#include "mozilla/MemoryReporting.h"
#include "jsapi.h"
#include "nsCycleCollector.h"
#include "nsCycleCollectionParticipant.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"

View File

@ -0,0 +1,28 @@
/* -*- 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/. */
#include "mozilla/DeferredFinalize.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSRuntime.h"
void
mozilla::DeferredFinalize(nsISupports* aSupports)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->DeferredFinalize(aSupports);
}
void
mozilla::DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
DeferredFinalizeFunction aFunc,
void* aThing)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->DeferredFinalize(aAppendFunc, aFunc, aThing);
}

View File

@ -0,0 +1,32 @@
/* -*- 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 mozilla_DeferredFinalize_h
#define mozilla_DeferredFinalize_h
class nsISupports;
namespace mozilla {
// 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.
typedef void* (*DeferredFinalizeAppendFunction)(void* aPointers, void* aThing);
// 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.
typedef bool (*DeferredFinalizeFunction)(uint32_t aSlice, void* aData);
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
DeferredFinalizeFunction aFunc,
void* aThing);
void DeferredFinalize(nsISupports* aSupports);
} // namespace mozilla
#endif // mozilla_DeferredFinalize_h

View File

@ -76,6 +76,7 @@ EXPORTS.mozilla += [
'CountingAllocatorBase.h',
'CycleCollectedJSRuntime.h',
'Debug.h',
'DeferredFinalize.h',
'ErrorNames.h',
'HoldDropJSObjects.h',
'LinuxUtils.h',
@ -99,6 +100,7 @@ UNIFIED_SOURCES += [
'ClearOnShutdown.cpp',
'CycleCollectedJSRuntime.cpp',
'Debug.cpp',
'DeferredFinalize.cpp',
'ErrorNames.cpp',
'HoldDropJSObjects.cpp',
'nsConsoleMessage.cpp',

View File

@ -3908,30 +3908,6 @@ CycleCollectedJSRuntime::Get()
return nullptr;
}
namespace mozilla {
void
DeferredFinalize(nsISupports* aSupports)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->DeferredFinalize(aSupports);
}
void
DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
DeferredFinalizeFunction aFunc,
void* aThing)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->DeferredFinalize(aAppendFunc, aFunc, aThing);
}
} // namespace mozilla
MOZ_NEVER_INLINE static void
SuspectAfterShutdown(void* aPtr, nsCycleCollectionParticipant* aCp,
nsCycleCollectingAutoRefCnt* aRefCnt,

View File

@ -18,19 +18,7 @@ template<class T> struct already_AddRefed;
#include "js/SliceBudget.h"
namespace mozilla {
class CycleCollectedJSRuntime;
// 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.
typedef void* (*DeferredFinalizeAppendFunction)(void* aPointers, void* aThing);
// 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.
typedef bool (*DeferredFinalizeFunction)(uint32_t aSlice, void* aData);
}
bool nsCycleCollector_init();
@ -77,13 +65,4 @@ nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
const nsIID& aIID,
void** aInstancePtr);
namespace mozilla {
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
DeferredFinalizeFunction aFunc,
void* aThing);
void DeferredFinalize(nsISupports* aSupports);
} // namespace mozilla
#endif // nsCycleCollector_h__