Bug 1302448 part 1 - Rename CycleCollectedJSRuntime to CycleCollectedJSContext. r=mccr8

This commit is contained in:
Jan de Mooij
2016-09-14 15:47:32 +02:00
parent 72dceb1a3b
commit b402a91ead
34 changed files with 298 additions and 298 deletions

View File

@@ -16,7 +16,7 @@
#include "js/UbiNodeDominatorTree.h"
#include "js/UbiNodeShortestPaths.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/devtools/AutoMemMap.h"
#include "mozilla/devtools/CoreDump.pb.h"
#include "mozilla/devtools/DeserializedNode.h"
@@ -62,9 +62,9 @@ using JS::ubi::ShortestPaths;
MallocSizeOf
GetCurrentThreadDebuggerMallocSizeOf()
{
auto ccrt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(ccrt);
auto cx = ccrt->Context();
auto ccjscx = CycleCollectedJSContext::Get();
MOZ_ASSERT(ccjscx);
auto cx = ccjscx->Context();
MOZ_ASSERT(cx);
auto mallocSizeOf = JS::dbg::GetDebuggerMallocSizeOf(cx);
MOZ_ASSERT(mallocSizeOf);
@@ -555,9 +555,9 @@ HeapSnapshot::ComputeDominatorTree(ErrorResult& rv)
{
Maybe<JS::ubi::DominatorTree> maybeTree;
{
auto ccrt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(ccrt);
auto cx = ccrt->Context();
auto ccjscx = CycleCollectedJSContext::Get();
MOZ_ASSERT(ccjscx);
auto cx = ccjscx->Context();
MOZ_ASSERT(cx);
JS::AutoCheckCannotGC nogc(cx);
maybeTree = JS::ubi::DominatorTree::Create(cx, nogc, getRoot());

View File

@@ -15,7 +15,7 @@
#include "gmock/gmock.h"
#include "mozilla/devtools/HeapSnapshot.h"
#include "mozilla/dom/ChromeUtils.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Move.h"
#include "js/Principals.h"
#include "js/UbiNode.h"
@@ -60,7 +60,7 @@ struct DevTools : public ::testing::Test {
}
JSContext* getContext() {
return CycleCollectedJSRuntime::Get()->Context();
return CycleCollectedJSContext::Get()->Context();
}
static void reportError(JSContext* cx, const char* message, JSErrorReport* report) {

View File

@@ -1335,14 +1335,14 @@ Animation::GetRenderedDocument() const
void
Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag)
{
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
if (aSyncNotifyFlag == SyncNotifyFlag::Sync) {
DoFinishNotificationImmediately();
} else if (!mFinishNotificationTask.IsPending()) {
RefPtr<nsRunnableMethod<Animation>> runnable =
NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately);
runtime->DispatchToMicroTask(do_AddRef(runnable));
context->DispatchToMicroTask(do_AddRef(runnable));
mFinishNotificationTask = runnable.forget();
}
}

View File

@@ -12,7 +12,7 @@
#include "jsfriendapi.h"
#include "mozilla/Assertions.h"
#include "mozilla/CondVar.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/asmjscache/PAsmJSCacheEntryChild.h"
#include "mozilla/dom/asmjscache/PAsmJSCacheEntryParent.h"
#include "mozilla/dom/ContentChild.h"

View File

@@ -7,7 +7,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "jsapi.h"
#include "xpcpublic.h"
@@ -289,14 +289,14 @@ namespace danger {
JSContext*
GetJSContext()
{
return CycleCollectedJSRuntime::Get()->Context();
return CycleCollectedJSContext::Get()->Context();
}
} // namespace danger
JS::RootingContext*
RootingCx()
{
return CycleCollectedJSRuntime::Get()->RootingCx();
return CycleCollectedJSContext::Get()->RootingCx();
}
AutoJSAPI::AutoJSAPI()

View File

@@ -5197,16 +5197,16 @@ nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) {
void
nsContentUtils::RunInStableState(already_AddRefed<nsIRunnable> aRunnable)
{
MOZ_ASSERT(CycleCollectedJSRuntime::Get(), "Must be on a script thread!");
CycleCollectedJSRuntime::Get()->RunInStableState(Move(aRunnable));
MOZ_ASSERT(CycleCollectedJSContext::Get(), "Must be on a script thread!");
CycleCollectedJSContext::Get()->RunInStableState(Move(aRunnable));
}
/* static */
void
nsContentUtils::RunInMetastableState(already_AddRefed<nsIRunnable> aRunnable)
{
MOZ_ASSERT(CycleCollectedJSRuntime::Get(), "Must be on a script thread!");
CycleCollectedJSRuntime::Get()->RunInMetastableState(Move(aRunnable));
MOZ_ASSERT(CycleCollectedJSContext::Get(), "Must be on a script thread!");
CycleCollectedJSContext::Get()->RunInMetastableState(Move(aRunnable));
}
void

View File

@@ -29,7 +29,7 @@
#include "nsIScriptSecurityManager.h"
#include "nsIDOMClassInfo.h"
#include "xpcpublic.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/IntentionalCrash.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"

View File

@@ -56,7 +56,7 @@
#include "mozilla/dom/DOMExceptionBinding.h"
#include "mozilla/dom/ErrorEvent.h"
#include "nsAXPCNativeCallContext.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "nsJSPrincipals.h"
@@ -75,7 +75,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/asmjscache/AsmJSCache.h"
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/ContentEvents.h"
#include "nsCycleCollectionNoteRootCallback.h"
@@ -1208,7 +1208,7 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
sNeedsFullGC = false;
JS::PrepareForFullGC(sContext);
} else {
CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC();
CycleCollectedJSContext::Get()->PrepareWaitingZonesForGC();
}
if (aIncremental == IncrementalGC) {

View File

@@ -9,7 +9,7 @@
#include "js/Class.h"
#include "js/Proxy.h"
#include "mozilla/dom/DOMJSProxyHandler.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/HoldDropJSObjects.h"
#include "nsCycleCollectionTraversalCallback.h"
#include "nsCycleCollector.h"
@@ -31,7 +31,7 @@ nsWrapperCache::HoldJSObjects(void* aScriptObjectHolder,
{
cyclecollector::HoldJSObjectsImpl(aScriptObjectHolder, aTracer);
if (mWrapper && !JS::ObjectIsTenured(mWrapper)) {
CycleCollectedJSRuntime::Get()->NurseryWrapperPreserved(mWrapper);
CycleCollectedJSContext::Get()->NurseryWrapperPreserved(mWrapper);
}
}
@@ -42,7 +42,7 @@ nsWrapperCache::SetWrapperJSObject(JSObject* aWrapper)
UnsetWrapperFlags(kWrapperFlagsMask & ~WRAPPER_IS_NOT_DOM_BINDING);
if (aWrapper && !JS::ObjectIsTenured(aWrapper)) {
CycleCollectedJSRuntime::Get()->NurseryWrapperAdded(this);
CycleCollectedJSContext::Get()->NurseryWrapperAdded(this);
}
}

View File

@@ -14,7 +14,7 @@
#include "mozilla/Alignment.h"
#include "mozilla/Array.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/DeferredFinalize.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackObject.h"

View File

@@ -10,7 +10,7 @@
#include "js/TypeDecls.h"
#include "jsapi.h"
#include "jsprf.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/ScriptSettings.h"
@@ -145,12 +145,12 @@ Throw(JSContext* aCx, nsresult aRv, const nsACString& aMessage)
return false;
}
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
nsCOMPtr<nsIException> existingException = runtime->GetPendingException();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
nsCOMPtr<nsIException> existingException = context->GetPendingException();
// Make sure to clear the pending exception now. Either we're going to reuse
// it (and we already grabbed it), or we plan to throw something else and this
// pending exception is no longer relevant.
runtime->SetPendingException(nullptr);
context->SetPendingException(nullptr);
// Ignore the pending exception if we have a non-default message passed in.
if (aMessage.IsEmpty() && existingException) {

View File

@@ -9,7 +9,7 @@
#include "mozilla/AddonPathService.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"

View File

@@ -19,7 +19,7 @@
#include "nsDOMJSUtils.h"
#include "WorkerPrivate.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/JSEventHandler.h"
#include "mozilla/Likely.h"

View File

@@ -9,7 +9,7 @@
#include "js/Debug.h"
#include "mozilla/Atomics.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/Preferences.h"
@@ -62,7 +62,7 @@ public:
const JS::Value& aValue)
: mPromise(aPromise)
, mCallback(aCallback)
, mValue(CycleCollectedJSRuntime::Get()->Runtime(), aValue)
, mValue(CycleCollectedJSContext::Get()->Context(), aValue)
{
MOZ_ASSERT(aPromise);
MOZ_ASSERT(aCallback);
@@ -187,7 +187,7 @@ public:
JS::Handle<JSObject*> aThenable,
PromiseInit* aThen)
: mPromise(aPromise)
, mThenable(CycleCollectedJSRuntime::Get()->Runtime(), aThenable)
, mThenable(CycleCollectedJSContext::Get()->Context(), aThenable)
, mThen(aThen)
{
MOZ_ASSERT(aPromise);
@@ -1041,11 +1041,11 @@ Promise::PerformMicroTaskCheckpoint()
{
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
// On the main thread, we always use the main promise micro task queue.
std::queue<nsCOMPtr<nsIRunnable>>& microtaskQueue =
runtime->GetPromiseMicroTaskQueue();
context->GetPromiseMicroTaskQueue();
if (microtaskQueue.empty()) {
return false;
@@ -1064,7 +1064,7 @@ Promise::PerformMicroTaskCheckpoint()
return false;
}
aso.CheckForInterrupt();
runtime->AfterProcessMicrotask();
context->AfterProcessMicrotask();
} while (!microtaskQueue.empty());
return true;
@@ -1075,17 +1075,17 @@ Promise::PerformWorkerMicroTaskCheckpoint()
{
MOZ_ASSERT(!NS_IsMainThread(), "Wrong thread!");
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
for (;;) {
// For a normal microtask checkpoint, we try to use the debugger microtask
// queue first. If the debugger queue is empty, we use the normal microtask
// queue instead.
std::queue<nsCOMPtr<nsIRunnable>>* microtaskQueue =
&runtime->GetDebuggerPromiseMicroTaskQueue();
&context->GetDebuggerPromiseMicroTaskQueue();
if (microtaskQueue->empty()) {
microtaskQueue = &runtime->GetPromiseMicroTaskQueue();
microtaskQueue = &context->GetPromiseMicroTaskQueue();
if (microtaskQueue->empty()) {
break;
}
@@ -1100,7 +1100,7 @@ Promise::PerformWorkerMicroTaskCheckpoint()
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
runtime->AfterProcessMicrotask();
context->AfterProcessMicrotask();
}
}
@@ -1109,13 +1109,13 @@ Promise::PerformWorkerDebuggerMicroTaskCheckpoint()
{
MOZ_ASSERT(!NS_IsMainThread(), "Wrong thread!");
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
for (;;) {
// For a debugger microtask checkpoint, we always use the debugger microtask
// queue.
std::queue<nsCOMPtr<nsIRunnable>>* microtaskQueue =
&runtime->GetDebuggerPromiseMicroTaskQueue();
&context->GetDebuggerPromiseMicroTaskQueue();
if (microtaskQueue->empty()) {
break;
@@ -1130,7 +1130,7 @@ Promise::PerformWorkerDebuggerMicroTaskCheckpoint()
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
runtime->AfterProcessMicrotask();
context->AfterProcessMicrotask();
}
}
@@ -2715,7 +2715,7 @@ Promise::ResolveInternal(JSContext* aCx,
{
NS_ASSERT_OWNINGTHREAD(Promise);
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
mResolvePending = true;
@@ -2757,7 +2757,7 @@ Promise::ResolveInternal(JSContext* aCx,
new PromiseInit(nullptr, thenObj, mozilla::dom::GetIncumbentGlobal());
RefPtr<PromiseResolveThenableJob> task =
new PromiseResolveThenableJob(this, valueObj, thenCallback);
runtime->DispatchToMicroTask(task.forget());
context->DispatchToMicroTask(task.forget());
return;
}
}
@@ -2861,7 +2861,7 @@ Promise::TriggerPromiseReactions()
{
NS_ASSERT_OWNINGTHREAD(Promise);
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* runtime = CycleCollectedJSContext::Get();
nsTArray<RefPtr<PromiseCallback>> callbacks;
callbacks.SwapElements(mState == Resolved ? mResolveCallbacks

View File

@@ -7,7 +7,7 @@
#include "js/Value.h"
#include "nsThreadUtils.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/TimeStamp.h"
@@ -318,7 +318,7 @@ PromiseDebugging::GetTimeToSettle(GlobalObject&, JS::Handle<JSObject*> aPromise,
PromiseDebugging::AddUncaughtRejectionObserver(GlobalObject&,
UncaughtRejectionObserver& aObserver)
{
CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* storage = CycleCollectedJSContext::Get();
nsTArray<nsCOMPtr<nsISupports>>& observers = storage->mUncaughtRejectionObservers;
observers.AppendElement(&aObserver);
}
@@ -327,7 +327,7 @@ PromiseDebugging::AddUncaughtRejectionObserver(GlobalObject&,
PromiseDebugging::RemoveUncaughtRejectionObserver(GlobalObject&,
UncaughtRejectionObserver& aObserver)
{
CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* storage = CycleCollectedJSContext::Get();
nsTArray<nsCOMPtr<nsISupports>>& observers = storage->mUncaughtRejectionObservers;
for (size_t i = 0; i < observers.Length(); ++i) {
UncaughtRejectionObserver* observer = static_cast<UncaughtRejectionObserver*>(observers[i].get());
@@ -345,7 +345,7 @@ PromiseDebugging::RemoveUncaughtRejectionObserver(GlobalObject&,
PromiseDebugging::AddUncaughtRejection(JS::HandleObject aPromise)
{
// This might OOM, but won't set a pending exception, so we'll just ignore it.
if (CycleCollectedJSRuntime::Get()->mUncaughtRejections.append(aPromise)) {
if (CycleCollectedJSContext::Get()->mUncaughtRejections.append(aPromise)) {
FlushRejections::DispatchNeeded();
}
}
@@ -356,7 +356,7 @@ PromiseDebugging::AddConsumedRejection(JS::HandleObject aPromise)
// If the promise is in our list of uncaught rejections, we haven't yet
// reported it as unhandled. In that case, just remove it from the list
// and don't add it to the list of consumed rejections.
auto& uncaughtRejections = CycleCollectedJSRuntime::Get()->mUncaughtRejections;
auto& uncaughtRejections = CycleCollectedJSContext::Get()->mUncaughtRejections;
for (size_t i = 0; i < uncaughtRejections.length(); i++) {
if (uncaughtRejections[i] == aPromise) {
// To avoid large amounts of memmoves, we don't shrink the vector here.
@@ -366,7 +366,7 @@ PromiseDebugging::AddConsumedRejection(JS::HandleObject aPromise)
}
}
// This might OOM, but won't set a pending exception, so we'll just ignore it.
if (CycleCollectedJSRuntime::Get()->mConsumedRejections.append(aPromise)) {
if (CycleCollectedJSContext::Get()->mConsumedRejections.append(aPromise)) {
FlushRejections::DispatchNeeded();
}
}
@@ -374,7 +374,7 @@ PromiseDebugging::AddConsumedRejection(JS::HandleObject aPromise)
/* static */ void
PromiseDebugging::FlushUncaughtRejectionsInternal()
{
CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* storage = CycleCollectedJSContext::Get();
auto& uncaught = storage->mUncaughtRejections;
auto& consumed = storage->mConsumedRejections;
@@ -427,14 +427,14 @@ PromiseDebugging::FlushUncaughtRejectionsInternal()
/* static */ void
PromiseDebugging::AddUncaughtRejection(Promise& aPromise)
{
CycleCollectedJSRuntime::Get()->mUncaughtRejections.AppendElement(&aPromise);
CycleCollectedJSContext::Get()->mUncaughtRejections.AppendElement(&aPromise);
FlushRejections::DispatchNeeded();
}
/* void */ void
PromiseDebugging::AddConsumedRejection(Promise& aPromise)
{
CycleCollectedJSRuntime::Get()->mConsumedRejections.AppendElement(&aPromise);
CycleCollectedJSContext::Get()->mConsumedRejections.AppendElement(&aPromise);
FlushRejections::DispatchNeeded();
}
@@ -456,7 +456,7 @@ PromiseDebugging::GetPromiseID(GlobalObject&,
/* static */ void
PromiseDebugging::FlushUncaughtRejectionsInternal()
{
CycleCollectedJSRuntime* storage = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* storage = CycleCollectedJSContext::Get();
// The Promise that have been left uncaught (rejected and last in
// their chain) since the last call to this function.

View File

@@ -28,7 +28,7 @@
#include "jsfriendapi.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/asmjscache/AsmJSCache.h"
@@ -1043,7 +1043,7 @@ static const JSWrapObjectCallbacks WrapObjectCallbacks = {
nullptr,
};
class WorkerJSRuntime : public mozilla::CycleCollectedJSRuntime
class WorkerJSRuntime : public mozilla::CycleCollectedJSContext
{
public:
// The heap size passed here doesn't matter, we will change it later in the
@@ -1078,7 +1078,7 @@ public:
nsresult Initialize(JSContext* aParentContext)
{
nsresult rv =
CycleCollectedJSRuntime::Initialize(aParentContext,
CycleCollectedJSContext::Initialize(aParentContext,
WORKER_DEFAULT_RUNTIME_HEAPSIZE,
WORKER_DEFAULT_NURSERY_SIZE);
if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -1142,10 +1142,10 @@ public:
// Only perform the Promise microtask checkpoint on the outermost event
// loop. Don't run it, for example, during sync XHR or importScripts.
if (aRecursionDepth == 2) {
CycleCollectedJSRuntime::AfterProcessTask(aRecursionDepth);
CycleCollectedJSContext::AfterProcessTask(aRecursionDepth);
} else if (aRecursionDepth > 2) {
AutoDisableMicroTaskCheckpoint disableMicroTaskCheckpoint;
CycleCollectedJSRuntime::AfterProcessTask(aRecursionDepth);
CycleCollectedJSContext::AfterProcessTask(aRecursionDepth);
}
}
@@ -1450,19 +1450,19 @@ GetCurrentThreadWorkerPrivate()
{
MOZ_ASSERT(!NS_IsMainThread());
CycleCollectedJSRuntime* ccrt = CycleCollectedJSRuntime::Get();
if (!ccrt) {
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
if (!ccjscx) {
return nullptr;
}
JSContext* cx = ccrt->Context();
JSContext* cx = ccjscx->Context();
MOZ_ASSERT(cx);
void* cxPrivate = JS_GetContextPrivate(cx);
if (!cxPrivate) {
// This can happen if the nsCycleCollector_shutdown() in ~WorkerJSRuntime()
// triggers any calls to GetCurrentThreadWorkerPrivate(). At this stage
// CycleCollectedJSRuntime::Get() will still return a runtime, but
// CycleCollectedJSContext::Get() will still return a context, but
// the context private has already been cleared.
return nullptr;
}
@@ -1883,7 +1883,7 @@ RuntimeService::ScheduleWorker(WorkerPrivate* aWorkerPrivate)
NS_WARNING("Could not set the thread's priority!");
}
JSContext* cx = CycleCollectedJSRuntime::Get()->Context();
JSContext* cx = CycleCollectedJSContext::Get()->Context();
nsCOMPtr<nsIRunnable> runnable =
new WorkerThreadPrimaryRunnable(aWorkerPrivate, thread,
JS_GetParentContext(cx));

View File

@@ -4598,7 +4598,7 @@ WorkerPrivate::OnProcessNextEvent()
{
AssertIsOnWorkerThread();
uint32_t recursionDepth = CycleCollectedJSRuntime::Get()->RecursionDepth();
uint32_t recursionDepth = CycleCollectedJSContext::Get()->RecursionDepth();
MOZ_ASSERT(recursionDepth);
// Normally we process control runnables in DoRunLoop or RunCurrentSyncLoop.
@@ -4617,7 +4617,7 @@ void
WorkerPrivate::AfterProcessNextEvent()
{
AssertIsOnWorkerThread();
MOZ_ASSERT(CycleCollectedJSRuntime::Get()->RecursionDepth());
MOZ_ASSERT(CycleCollectedJSContext::Get()->RecursionDepth());
}
void

View File

@@ -331,7 +331,7 @@ WorkerThread::Observer::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
// PrimaryWorkerRunnable::Run() and don't want to process the event in
// mWorkerPrivate yet.
if (aMayWait) {
MOZ_ASSERT(CycleCollectedJSRuntime::Get()->RecursionDepth() == 2);
MOZ_ASSERT(CycleCollectedJSContext::Get()->RecursionDepth() == 2);
MOZ_ASSERT(!BackgroundChild::GetForCurrentThread());
return NS_OK;
}

View File

@@ -76,8 +76,8 @@ var ignoreCallees = {
"js::ClassOps.finalize" : true,
"JSRuntime.destroyPrincipals" : true,
"icu_50::UObject.__deleting_dtor" : true, // destructors in ICU code can't cause GC
"mozilla::CycleCollectedJSRuntime.DescribeCustomObjects" : true, // During tracing, cannot GC.
"mozilla::CycleCollectedJSRuntime.NoteCustomGCThingXPCOMChildren" : true, // During tracing, cannot GC.
"mozilla::CycleCollectedJSContext.DescribeCustomObjects" : true, // During tracing, cannot GC.
"mozilla::CycleCollectedJSContext.NoteCustomGCThingXPCOMChildren" : true, // During tracing, cannot GC.
"PLDHashTableOps.hashKey" : true,
"z_stream_s.zfree" : true,
"z_stream_s.zalloc" : true,

View File

@@ -655,7 +655,7 @@ XPCJSRuntime::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& c
void
XPCJSRuntime::UnmarkSkippableJSHolders()
{
CycleCollectedJSRuntime::UnmarkSkippableJSHolders();
CycleCollectedJSContext::UnmarkSkippableJSHolders();
}
void
@@ -1475,7 +1475,7 @@ XPCJSRuntime::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
n += mClassInfo2NativeSetMap->ShallowSizeOfIncludingThis(mallocSizeOf);
n += mNativeSetMap->SizeOfIncludingThis(mallocSizeOf);
n += CycleCollectedJSRuntime::SizeOfExcludingThis(mallocSizeOf);
n += CycleCollectedJSContext::SizeOfExcludingThis(mallocSizeOf);
// There are other XPCJSRuntime members that could be measured; the above
// ones have been seen by DMD to be worth measuring. More stuff may be
@@ -1591,10 +1591,10 @@ XPCJSRuntime::~XPCJSRuntime()
// Therefore the context must be non-null.
MOZ_ASSERT(MaybeContext());
// This destructor runs before ~CycleCollectedJSRuntime, which does the
// actual JS_DestroyRuntime() call. But destroying the runtime triggers
// one final GC, which can call back into the runtime with various
// callback if we aren't careful. Null out the relevant callbacks.
// This destructor runs before ~CycleCollectedJSContext, which does the
// actual JS_DestroyContext() call. But destroying the context triggers
// one final GC, which can call back into the context with various
// callbacks if we aren't careful. Null out the relevant callbacks.
js::SetActivityCallback(Context(), nullptr, nullptr);
JS_RemoveFinalizeCallback(Context(), FinalizeCallback);
JS_RemoveWeakPointerZoneGroupCallback(Context(), WeakPointerZoneGroupCallback);
@@ -3371,7 +3371,7 @@ GetWindowsStackSize()
nsresult
XPCJSRuntime::Initialize()
{
nsresult rv = CycleCollectedJSRuntime::Initialize(nullptr,
nsresult rv = CycleCollectedJSContext::Initialize(nullptr,
JS::DefaultHeapMaxBytes,
JS::DefaultNurseryBytes);
if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -3665,7 +3665,7 @@ XPCJSRuntime::BeforeProcessTask(bool aMightBlock)
// cancel any ongoing performance measurement.
js::ResetPerformanceMonitoring(Get()->Context());
CycleCollectedJSRuntime::BeforeProcessTask(aMightBlock);
CycleCollectedJSContext::BeforeProcessTask(aMightBlock);
}
void
@@ -3679,7 +3679,7 @@ XPCJSRuntime::AfterProcessTask(uint32_t aNewRecursionDepth)
MOZ_ASSERT(NS_IsMainThread());
nsJSContext::MaybePokeCC();
CycleCollectedJSRuntime::AfterProcessTask(aNewRecursionDepth);
CycleCollectedJSContext::AfterProcessTask(aNewRecursionDepth);
// Now that we are certain that the event is complete,
// we can flush any ongoing performance measurement.

View File

@@ -293,7 +293,7 @@ xpc::ErrorReport::ErrorReportToMessageString(JSErrorReport* aReport,
aString.Truncate();
const char16_t* m = aReport->ucmessage;
if (m) {
JSFlatString* name = js::GetErrorTypeName(CycleCollectedJSRuntime::Get()->Context(), aReport->exnType);
JSFlatString* name = js::GetErrorTypeName(CycleCollectedJSContext::Get()->Context(), aReport->exnType);
if (name) {
AssignJSFlatString(aString, name);
aString.AppendLiteral(": ");

View File

@@ -79,7 +79,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/Maybe.h"
#include "mozilla/MemoryReporting.h"
@@ -409,7 +409,7 @@ private:
mozilla::Maybe<StringType> mStrings[2];
};
class XPCJSRuntime final : public mozilla::CycleCollectedJSRuntime
class XPCJSRuntime final : public mozilla::CycleCollectedJSContext
{
public:
static XPCJSRuntime* newXPCJSRuntime();

View File

@@ -11,7 +11,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "nsCSSParser.h"
#include "nsCSSRules.h"
#include "nsIDocument.h"

View File

@@ -54,7 +54,7 @@
// To improve debugging, if WantAllTraces() is true all JS objects are
// traversed.
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include <algorithm>
#include "mozilla/ArrayUtils.h"
#include "mozilla/AutoRestore.h"
@@ -106,9 +106,9 @@ struct DeferredFinalizeFunctionHolder
class IncrementalFinalizeRunnable : public Runnable
{
typedef AutoTArray<DeferredFinalizeFunctionHolder, 16> DeferredFinalizeArray;
typedef CycleCollectedJSRuntime::DeferredFinalizerTable DeferredFinalizerTable;
typedef CycleCollectedJSContext::DeferredFinalizerTable DeferredFinalizerTable;
CycleCollectedJSRuntime* mRuntime;
CycleCollectedJSContext* mContext;
DeferredFinalizeArray mDeferredFinalizeFunctions;
uint32_t mFinalizeFunctionToRun;
bool mReleasing;
@@ -116,7 +116,7 @@ class IncrementalFinalizeRunnable : public Runnable
static const PRTime SliceMillis = 5; /* ms */
public:
IncrementalFinalizeRunnable(CycleCollectedJSRuntime* aRt,
IncrementalFinalizeRunnable(CycleCollectedJSContext* aCx,
DeferredFinalizerTable& aFinalizerTable);
virtual ~IncrementalFinalizeRunnable();
@@ -297,24 +297,24 @@ NS_IMETHODIMP
JSGCThingParticipant::Traverse(void* aPtr,
nsCycleCollectionTraversalCallback& aCb)
{
auto runtime = reinterpret_cast<CycleCollectedJSRuntime*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime,
auto runtime = reinterpret_cast<CycleCollectedJSContext*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSContext,
mGCThingCycleCollectorGlobal));
JS::GCCellPtr cellPtr(aPtr, JS::GCThingTraceKind(aPtr));
runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL, cellPtr, aCb);
runtime->TraverseGCThing(CycleCollectedJSContext::TRAVERSE_FULL, cellPtr, aCb);
return NS_OK;
}
// NB: This is only used to initialize the participant in
// CycleCollectedJSRuntime. It should never be used directly.
// CycleCollectedJSContext. It should never be used directly.
static JSGCThingParticipant sGCThingCycleCollectorGlobal;
NS_IMETHODIMP
JSZoneParticipant::Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb)
{
auto runtime = reinterpret_cast<CycleCollectedJSRuntime*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime,
auto runtime = reinterpret_cast<CycleCollectedJSContext*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSContext,
mJSZoneCycleCollectorGlobal));
MOZ_ASSERT(!aCb.WantAllTraces());
@@ -403,13 +403,13 @@ NoteJSChildGrayWrapperShim(void* aData, JS::GCCellPtr aThing)
*/
// NB: This is only used to initialize the participant in
// CycleCollectedJSRuntime. It should never be used directly.
// CycleCollectedJSContext. It should never be used directly.
static const JSZoneParticipant sJSZoneCycleCollectorGlobal;
static
void JSObjectsTenuredCb(JSContext* aContext, void* aData)
{
static_cast<CycleCollectedJSRuntime*>(aData)->JSObjectsTenured();
static_cast<CycleCollectedJSContext*>(aData)->JSObjectsTenured();
}
bool
@@ -435,7 +435,7 @@ mozilla::GetBuildId(JS::BuildIdCharVector* aBuildID)
return true;
}
CycleCollectedJSRuntime::CycleCollectedJSRuntime()
CycleCollectedJSContext::CycleCollectedJSContext()
: mGCThingCycleCollectorGlobal(sGCThingCycleCollectorGlobal)
, mJSZoneCycleCollectorGlobal(sJSZoneCycleCollectorGlobal)
, mJSContext(nullptr)
@@ -452,7 +452,7 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime()
MOZ_RELEASE_ASSERT(mOwningThread);
}
CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
CycleCollectedJSContext::~CycleCollectedJSContext()
{
// If the allocation failed, here we are.
if (!mJSContext) {
@@ -481,7 +481,7 @@ CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
JS_DestroyContext(mJSContext);
mJSContext = nullptr;
nsCycleCollector_forgetJSRuntime();
nsCycleCollector_forgetJSContext();
mozilla::dom::DestroyScriptSettings();
@@ -496,7 +496,7 @@ MozCrashWarningReporter(JSContext*, const char*, JSErrorReport*)
}
nsresult
CycleCollectedJSRuntime::Initialize(JSContext* aParentContext,
CycleCollectedJSContext::Initialize(JSContext* aParentContext,
uint32_t aMaxBytes,
uint32_t aMaxNurseryBytes)
{
@@ -561,13 +561,13 @@ CycleCollectedJSRuntime::Initialize(JSContext* aParentContext,
JS::dbg::SetDebuggerMallocSizeOf(mJSContext, moz_malloc_size_of);
nsCycleCollector_registerJSRuntime(this);
nsCycleCollector_registerJSContext(this);
return NS_OK;
}
size_t
CycleCollectedJSRuntime::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
CycleCollectedJSContext::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = 0;
@@ -579,7 +579,7 @@ CycleCollectedJSRuntime::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
}
void
CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
CycleCollectedJSContext::UnmarkSkippableJSHolders()
{
for (auto iter = mJSHolders.Iter(); !iter.Done(); iter.Next()) {
void* holder = iter.Key();
@@ -589,7 +589,7 @@ CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
}
void
CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
CycleCollectedJSContext::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const
{
if (!aCb.WantDebugInfo()) {
@@ -631,7 +631,7 @@ CycleCollectedJSRuntime::DescribeGCThing(bool aIsMarked, JS::GCCellPtr aThing,
}
void
CycleCollectedJSRuntime::NoteGCThingJSChildren(JS::GCCellPtr aThing,
CycleCollectedJSContext::NoteGCThingJSChildren(JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb) const
{
MOZ_ASSERT(mJSContext);
@@ -640,7 +640,7 @@ CycleCollectedJSRuntime::NoteGCThingJSChildren(JS::GCCellPtr aThing,
}
void
CycleCollectedJSRuntime::NoteGCThingXPCOMChildren(const js::Class* aClasp,
CycleCollectedJSContext::NoteGCThingXPCOMChildren(const js::Class* aClasp,
JSObject* aObj,
nsCycleCollectionTraversalCallback& aCb) const
{
@@ -676,7 +676,7 @@ CycleCollectedJSRuntime::NoteGCThingXPCOMChildren(const js::Class* aClasp,
}
void
CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThing,
CycleCollectedJSContext::TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThing,
nsCycleCollectionTraversalCallback& aCb)
{
bool isMarkedGray = JS::GCThingIsMarkedGray(aThing);
@@ -706,11 +706,11 @@ CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, JS::GCCellPtr aThin
struct TraverseObjectShimClosure
{
nsCycleCollectionTraversalCallback& cb;
CycleCollectedJSRuntime* self;
CycleCollectedJSContext* self;
};
void
CycleCollectedJSRuntime::TraverseZone(JS::Zone* aZone,
CycleCollectedJSContext::TraverseZone(JS::Zone* aZone,
nsCycleCollectionTraversalCallback& aCb)
{
MOZ_ASSERT(mJSContext);
@@ -747,18 +747,18 @@ CycleCollectedJSRuntime::TraverseZone(JS::Zone* aZone,
}
/* static */ void
CycleCollectedJSRuntime::TraverseObjectShim(void* aData, JS::GCCellPtr aThing)
CycleCollectedJSContext::TraverseObjectShim(void* aData, JS::GCCellPtr aThing)
{
TraverseObjectShimClosure* closure =
static_cast<TraverseObjectShimClosure*>(aData);
MOZ_ASSERT(aThing.is<JSObject>());
closure->self->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_CPP,
closure->self->TraverseGCThing(CycleCollectedJSContext::TRAVERSE_CPP,
aThing, closure->cb);
}
void
CycleCollectedJSRuntime::TraverseNativeRoots(nsCycleCollectionNoteRootCallback& aCb)
CycleCollectedJSContext::TraverseNativeRoots(nsCycleCollectionNoteRootCallback& aCb)
{
// NB: This is here just to preserve the existing XPConnect order. I doubt it
// would hurt to do this after the JS holders.
@@ -784,28 +784,28 @@ CycleCollectedJSRuntime::TraverseNativeRoots(nsCycleCollectionNoteRootCallback&
}
/* static */ void
CycleCollectedJSRuntime::TraceBlackJS(JSTracer* aTracer, void* aData)
CycleCollectedJSContext::TraceBlackJS(JSTracer* aTracer, void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
self->TraceNativeBlackRoots(aTracer);
}
/* static */ void
CycleCollectedJSRuntime::TraceGrayJS(JSTracer* aTracer, void* aData)
CycleCollectedJSContext::TraceGrayJS(JSTracer* aTracer, void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
// Mark these roots as gray so the CC can walk them later.
self->TraceNativeGrayRoots(aTracer);
}
/* static */ void
CycleCollectedJSRuntime::GCCallback(JSContext* aContext,
CycleCollectedJSContext::GCCallback(JSContext* aContext,
JSGCStatus aStatus,
void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
MOZ_ASSERT(aContext == self->Context());
@@ -813,11 +813,11 @@ CycleCollectedJSRuntime::GCCallback(JSContext* aContext,
}
/* static */ void
CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext,
CycleCollectedJSContext::GCSliceCallback(JSContext* aContext,
JS::GCProgress aProgress,
const JS::GCDescription& aDesc)
{
CycleCollectedJSRuntime* self = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* self = CycleCollectedJSContext::Get();
MOZ_ASSERT(self->Context() == aContext);
if (aProgress == JS::GC_CYCLE_END) {
@@ -883,11 +883,11 @@ public:
};
/* static */ void
CycleCollectedJSRuntime::GCNurseryCollectionCallback(JSContext* aContext,
CycleCollectedJSContext::GCNurseryCollectionCallback(JSContext* aContext,
JS::GCNurseryProgress aProgress,
JS::gcreason::Reason aReason)
{
CycleCollectedJSRuntime* self = CycleCollectedJSRuntime::Get();
CycleCollectedJSContext* self = CycleCollectedJSContext::Get();
MOZ_ASSERT(self->Context() == aContext);
MOZ_ASSERT(NS_IsMainThread());
@@ -905,10 +905,10 @@ CycleCollectedJSRuntime::GCNurseryCollectionCallback(JSContext* aContext,
/* static */ void
CycleCollectedJSRuntime::OutOfMemoryCallback(JSContext* aContext,
CycleCollectedJSContext::OutOfMemoryCallback(JSContext* aContext,
void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
MOZ_ASSERT(aContext == self->Context());
@@ -916,9 +916,9 @@ CycleCollectedJSRuntime::OutOfMemoryCallback(JSContext* aContext,
}
/* static */ void
CycleCollectedJSRuntime::LargeAllocationFailureCallback(void* aData)
CycleCollectedJSContext::LargeAllocationFailureCallback(void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
self->OnLargeAllocationFailure();
}
@@ -953,7 +953,7 @@ private:
/* static */
JSObject*
CycleCollectedJSRuntime::GetIncumbentGlobalCallback(JSContext* aCx)
CycleCollectedJSContext::GetIncumbentGlobalCallback(JSContext* aCx)
{
nsIGlobalObject* global = mozilla::dom::GetIncumbentGlobal();
if (global) {
@@ -964,13 +964,13 @@ CycleCollectedJSRuntime::GetIncumbentGlobalCallback(JSContext* aCx)
/* static */
bool
CycleCollectedJSRuntime::EnqueuePromiseJobCallback(JSContext* aCx,
CycleCollectedJSContext::EnqueuePromiseJobCallback(JSContext* aCx,
JS::HandleObject aJob,
JS::HandleObject aAllocationSite,
JS::HandleObject aIncumbentGlobal,
void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
MOZ_ASSERT(aCx == self->Context());
MOZ_ASSERT(Get() == self);
@@ -986,13 +986,13 @@ CycleCollectedJSRuntime::EnqueuePromiseJobCallback(JSContext* aCx,
#ifdef SPIDERMONKEY_PROMISE
/* static */
void
CycleCollectedJSRuntime::PromiseRejectionTrackerCallback(JSContext* aCx,
CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext* aCx,
JS::HandleObject aPromise,
PromiseRejectionHandlingState state,
void* aData)
{
#ifdef DEBUG
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
CycleCollectedJSContext* self = static_cast<CycleCollectedJSContext*>(aData);
#endif // DEBUG
MOZ_ASSERT(aCx == self->Context());
MOZ_ASSERT(Get() == self);
@@ -1058,7 +1058,7 @@ mozilla::TraceScriptHolder(nsISupports* aHolder, JSTracer* aTracer)
}
void
CycleCollectedJSRuntime::TraceNativeGrayRoots(JSTracer* aTracer)
CycleCollectedJSContext::TraceNativeGrayRoots(JSTracer* aTracer)
{
MOZ_ASSERT(mJSContext);
@@ -1074,7 +1074,7 @@ CycleCollectedJSRuntime::TraceNativeGrayRoots(JSTracer* aTracer)
}
void
CycleCollectedJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
CycleCollectedJSContext::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
{
MOZ_ASSERT(mJSContext);
mJSHolders.Put(aHolder, aTracer);
@@ -1125,7 +1125,7 @@ struct ClearJSHolder : public TraceCallbacks
};
void
CycleCollectedJSRuntime::RemoveJSHolder(void* aHolder)
CycleCollectedJSContext::RemoveJSHolder(void* aHolder)
{
MOZ_ASSERT(mJSContext);
@@ -1139,7 +1139,7 @@ CycleCollectedJSRuntime::RemoveJSHolder(void* aHolder)
#ifdef DEBUG
bool
CycleCollectedJSRuntime::IsJSHolder(void* aHolder)
CycleCollectedJSContext::IsJSHolder(void* aHolder)
{
MOZ_ASSERT(mJSContext);
return mJSHolders.Get(aHolder, nullptr);
@@ -1152,7 +1152,7 @@ AssertNoGcThing(JS::GCCellPtr aGCThing, const char* aName, void* aClosure)
}
void
CycleCollectedJSRuntime::AssertNoObjectsToTrace(void* aPossibleJSHolder)
CycleCollectedJSContext::AssertNoObjectsToTrace(void* aPossibleJSHolder)
{
MOZ_ASSERT(mJSContext);
@@ -1164,7 +1164,7 @@ CycleCollectedJSRuntime::AssertNoObjectsToTrace(void* aPossibleJSHolder)
#endif
already_AddRefed<nsIException>
CycleCollectedJSRuntime::GetPendingException() const
CycleCollectedJSContext::GetPendingException() const
{
MOZ_ASSERT(mJSContext);
@@ -1173,42 +1173,42 @@ CycleCollectedJSRuntime::GetPendingException() const
}
void
CycleCollectedJSRuntime::SetPendingException(nsIException* aException)
CycleCollectedJSContext::SetPendingException(nsIException* aException)
{
MOZ_ASSERT(mJSContext);
mPendingException = aException;
}
std::queue<nsCOMPtr<nsIRunnable>>&
CycleCollectedJSRuntime::GetPromiseMicroTaskQueue()
CycleCollectedJSContext::GetPromiseMicroTaskQueue()
{
MOZ_ASSERT(mJSContext);
return mPromiseMicroTaskQueue;
}
std::queue<nsCOMPtr<nsIRunnable>>&
CycleCollectedJSRuntime::GetDebuggerPromiseMicroTaskQueue()
CycleCollectedJSContext::GetDebuggerPromiseMicroTaskQueue()
{
MOZ_ASSERT(mJSContext);
return mDebuggerPromiseMicroTaskQueue;
}
nsCycleCollectionParticipant*
CycleCollectedJSRuntime::GCThingParticipant()
CycleCollectedJSContext::GCThingParticipant()
{
MOZ_ASSERT(mJSContext);
return &mGCThingCycleCollectorGlobal;
}
nsCycleCollectionParticipant*
CycleCollectedJSRuntime::ZoneParticipant()
CycleCollectedJSContext::ZoneParticipant()
{
MOZ_ASSERT(mJSContext);
return &mJSZoneCycleCollectorGlobal;
}
nsresult
CycleCollectedJSRuntime::TraverseRoots(nsCycleCollectionNoteRootCallback& aCb)
CycleCollectedJSContext::TraverseRoots(nsCycleCollectionNoteRootCallback& aCb)
{
MOZ_ASSERT(mJSContext);
@@ -1221,13 +1221,13 @@ CycleCollectedJSRuntime::TraverseRoots(nsCycleCollectionNoteRootCallback& aCb)
}
bool
CycleCollectedJSRuntime::UsefulToMergeZones() const
CycleCollectedJSContext::UsefulToMergeZones() const
{
return false;
}
void
CycleCollectedJSRuntime::FixWeakMappingGrayBits() const
CycleCollectedJSContext::FixWeakMappingGrayBits() const
{
MOZ_ASSERT(mJSContext);
MOZ_ASSERT(!JS::IsIncrementalGCInProgress(mJSContext),
@@ -1237,14 +1237,14 @@ CycleCollectedJSRuntime::FixWeakMappingGrayBits() const
}
bool
CycleCollectedJSRuntime::AreGCGrayBitsValid() const
CycleCollectedJSContext::AreGCGrayBitsValid() const
{
MOZ_ASSERT(mJSContext);
return js::AreGCGrayBitsValid(mJSContext);
}
void
CycleCollectedJSRuntime::GarbageCollect(uint32_t aReason) const
CycleCollectedJSContext::GarbageCollect(uint32_t aReason) const
{
MOZ_ASSERT(mJSContext);
@@ -1256,7 +1256,7 @@ CycleCollectedJSRuntime::GarbageCollect(uint32_t aReason) const
}
void
CycleCollectedJSRuntime::JSObjectsTenured()
CycleCollectedJSContext::JSObjectsTenured()
{
MOZ_ASSERT(mJSContext);
@@ -1282,7 +1282,7 @@ for (auto iter = mPreservedNurseryObjects.Iter(); !iter.Done(); iter.Next()) {
}
void
CycleCollectedJSRuntime::NurseryWrapperAdded(nsWrapperCache* aCache)
CycleCollectedJSContext::NurseryWrapperAdded(nsWrapperCache* aCache)
{
MOZ_ASSERT(mJSContext);
MOZ_ASSERT(aCache);
@@ -1292,7 +1292,7 @@ CycleCollectedJSRuntime::NurseryWrapperAdded(nsWrapperCache* aCache)
}
void
CycleCollectedJSRuntime::NurseryWrapperPreserved(JSObject* aWrapper)
CycleCollectedJSContext::NurseryWrapperPreserved(JSObject* aWrapper)
{
MOZ_ASSERT(mJSContext);
@@ -1301,7 +1301,7 @@ CycleCollectedJSRuntime::NurseryWrapperPreserved(JSObject* aWrapper)
}
void
CycleCollectedJSRuntime::DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
CycleCollectedJSContext::DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
DeferredFinalizeFunction aFunc,
void* aThing)
{
@@ -1317,7 +1317,7 @@ CycleCollectedJSRuntime::DeferredFinalize(DeferredFinalizeAppendFunction aAppend
}
void
CycleCollectedJSRuntime::DeferredFinalize(nsISupports* aSupports)
CycleCollectedJSContext::DeferredFinalize(nsISupports* aSupports)
{
MOZ_ASSERT(mJSContext);
@@ -1327,13 +1327,13 @@ CycleCollectedJSRuntime::DeferredFinalize(nsISupports* aSupports)
}
void
CycleCollectedJSRuntime::DumpJSHeap(FILE* aFile)
CycleCollectedJSContext::DumpJSHeap(FILE* aFile)
{
js::DumpHeap(Context(), aFile, js::CollectNurseryBeforeDump);
}
void
CycleCollectedJSRuntime::ProcessStableStateQueue()
CycleCollectedJSContext::ProcessStableStateQueue()
{
MOZ_ASSERT(mJSContext);
MOZ_RELEASE_ASSERT(!mDoingStableStates);
@@ -1349,7 +1349,7 @@ CycleCollectedJSRuntime::ProcessStableStateQueue()
}
void
CycleCollectedJSRuntime::ProcessMetastableStateQueue(uint32_t aRecursionDepth)
CycleCollectedJSContext::ProcessMetastableStateQueue(uint32_t aRecursionDepth)
{
MOZ_ASSERT(mJSContext);
MOZ_RELEASE_ASSERT(!mDoingStableStates);
@@ -1380,7 +1380,7 @@ CycleCollectedJSRuntime::ProcessMetastableStateQueue(uint32_t aRecursionDepth)
}
void
CycleCollectedJSRuntime::AfterProcessTask(uint32_t aRecursionDepth)
CycleCollectedJSContext::AfterProcessTask(uint32_t aRecursionDepth)
{
MOZ_ASSERT(mJSContext);
@@ -1405,14 +1405,14 @@ CycleCollectedJSRuntime::AfterProcessTask(uint32_t aRecursionDepth)
}
void
CycleCollectedJSRuntime::AfterProcessMicrotask()
CycleCollectedJSContext::AfterProcessMicrotask()
{
MOZ_ASSERT(mJSContext);
AfterProcessMicrotask(RecursionDepth());
}
void
CycleCollectedJSRuntime::AfterProcessMicrotask(uint32_t aRecursionDepth)
CycleCollectedJSContext::AfterProcessMicrotask(uint32_t aRecursionDepth)
{
MOZ_ASSERT(mJSContext);
@@ -1422,20 +1422,20 @@ CycleCollectedJSRuntime::AfterProcessMicrotask(uint32_t aRecursionDepth)
}
uint32_t
CycleCollectedJSRuntime::RecursionDepth()
CycleCollectedJSContext::RecursionDepth()
{
return mOwningThread->RecursionDepth();
}
void
CycleCollectedJSRuntime::RunInStableState(already_AddRefed<nsIRunnable>&& aRunnable)
CycleCollectedJSContext::RunInStableState(already_AddRefed<nsIRunnable>&& aRunnable)
{
MOZ_ASSERT(mJSContext);
mStableStateEvents.AppendElement(Move(aRunnable));
}
void
CycleCollectedJSRuntime::RunInMetastableState(already_AddRefed<nsIRunnable>&& aRunnable)
CycleCollectedJSContext::RunInMetastableState(already_AddRefed<nsIRunnable>&& aRunnable)
{
MOZ_ASSERT(mJSContext);
@@ -1460,9 +1460,9 @@ CycleCollectedJSRuntime::RunInMetastableState(already_AddRefed<nsIRunnable>&& aR
mMetastableStateEvents.AppendElement(Move(data));
}
IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSRuntime* aRt,
IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSContext* aCx,
DeferredFinalizerTable& aFinalizers)
: mRuntime(aRt)
: mContext(aCx)
, mFinalizeFunctionToRun(0)
, mReleasing(false)
{
@@ -1481,7 +1481,7 @@ IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSRuntime
IncrementalFinalizeRunnable::~IncrementalFinalizeRunnable()
{
MOZ_ASSERT(this != mRuntime->mFinalizeRunnable);
MOZ_ASSERT(this != mContext->mFinalizeRunnable);
}
void
@@ -1529,17 +1529,17 @@ IncrementalFinalizeRunnable::ReleaseNow(bool aLimited)
}
if (mFinalizeFunctionToRun == mDeferredFinalizeFunctions.Length()) {
MOZ_ASSERT(mRuntime->mFinalizeRunnable == this);
MOZ_ASSERT(mContext->mFinalizeRunnable == this);
mDeferredFinalizeFunctions.Clear();
// NB: This may delete this!
mRuntime->mFinalizeRunnable = nullptr;
mContext->mFinalizeRunnable = nullptr;
}
}
NS_IMETHODIMP
IncrementalFinalizeRunnable::Run()
{
if (mRuntime->mFinalizeRunnable != this) {
if (mContext->mFinalizeRunnable != this) {
/* These items were already processed synchronously in JSGC_END. */
MOZ_ASSERT(!mDeferredFinalizeFunctions.Length());
return NS_OK;
@@ -1562,7 +1562,7 @@ IncrementalFinalizeRunnable::Run()
}
void
CycleCollectedJSRuntime::FinalizeDeferredThings(DeferredFinalizeType aType)
CycleCollectedJSContext::FinalizeDeferredThings(DeferredFinalizeType aType)
{
MOZ_ASSERT(mJSContext);
@@ -1601,7 +1601,7 @@ CycleCollectedJSRuntime::FinalizeDeferredThings(DeferredFinalizeType aType)
}
void
CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
CycleCollectedJSContext::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
OOMState aNewState)
{
MOZ_ASSERT(mJSContext);
@@ -1620,7 +1620,7 @@ CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
}
void
CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
CycleCollectedJSContext::OnGC(JSGCStatus aStatus)
{
MOZ_ASSERT(mJSContext);
@@ -1652,7 +1652,7 @@ CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
}
void
CycleCollectedJSRuntime::OnOutOfMemory()
CycleCollectedJSContext::OnOutOfMemory()
{
MOZ_ASSERT(mJSContext);
@@ -1662,7 +1662,7 @@ CycleCollectedJSRuntime::OnOutOfMemory()
}
void
CycleCollectedJSRuntime::OnLargeAllocationFailure()
CycleCollectedJSContext::OnLargeAllocationFailure()
{
MOZ_ASSERT(mJSContext);
@@ -1672,7 +1672,7 @@ CycleCollectedJSRuntime::OnLargeAllocationFailure()
}
void
CycleCollectedJSRuntime::PrepareWaitingZonesForGC()
CycleCollectedJSContext::PrepareWaitingZonesForGC()
{
if (mZonesWaitingForGC.Count() == 0) {
JS::PrepareForFullGC(Context());
@@ -1685,7 +1685,7 @@ CycleCollectedJSRuntime::PrepareWaitingZonesForGC()
}
void
CycleCollectedJSRuntime::DispatchToMicroTask(already_AddRefed<nsIRunnable> aRunnable)
CycleCollectedJSContext::DispatchToMicroTask(already_AddRefed<nsIRunnable> aRunnable)
{
RefPtr<nsIRunnable> runnable(aRunnable);
@@ -1696,7 +1696,7 @@ CycleCollectedJSRuntime::DispatchToMicroTask(already_AddRefed<nsIRunnable> aRunn
}
void
CycleCollectedJSRuntime::EnvironmentPreparer::invoke(JS::HandleObject scope,
CycleCollectedJSContext::EnvironmentPreparer::invoke(JS::HandleObject scope,
js::ScriptEnvironmentPreparer::Closure& closure)
{
nsIGlobalObject* global = xpc::NativeGlobal(scope);

View File

@@ -4,8 +4,8 @@
* 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_CycleCollectedJSRuntime_h__
#define mozilla_CycleCollectedJSRuntime_h__
#ifndef mozilla_CycleCollectedJSContext_h__
#define mozilla_CycleCollectedJSContext_h__
#include <queue>
@@ -134,14 +134,14 @@ struct CycleCollectorResults
uint32_t mNumSlices;
};
class CycleCollectedJSRuntime
class CycleCollectedJSContext
{
friend class JSGCThingParticipant;
friend class JSZoneParticipant;
friend class IncrementalFinalizeRunnable;
protected:
CycleCollectedJSRuntime();
virtual ~CycleCollectedJSRuntime();
CycleCollectedJSContext();
virtual ~CycleCollectedJSContext();
nsresult Initialize(JSContext* aParentContext,
uint32_t aMaxBytes,
@@ -350,18 +350,18 @@ public:
{
public:
AutoDisableMicroTaskCheckpoint()
: mCCRT(CycleCollectedJSRuntime::Get())
: mCCJSCX(CycleCollectedJSContext::Get())
{
mOldValue = mCCRT->MicroTaskCheckpointDisabled();
mCCRT->DisableMicroTaskCheckpoint(true);
mOldValue = mCCJSCX->MicroTaskCheckpointDisabled();
mCCJSCX->DisableMicroTaskCheckpoint(true);
}
~AutoDisableMicroTaskCheckpoint()
{
mCCRT->DisableMicroTaskCheckpoint(mOldValue);
mCCJSCX->DisableMicroTaskCheckpoint(mOldValue);
}
CycleCollectedJSRuntime* mCCRT;
CycleCollectedJSContext* mCCJSCX;
bool mOldValue;
};
@@ -384,9 +384,9 @@ public:
// Runs after the current microtask completes.
void RunInMetastableState(already_AddRefed<nsIRunnable>&& aRunnable);
// Get the current thread's CycleCollectedJSRuntime. Returns null if there
// Get the current thread's CycleCollectedJSContext. Returns null if there
// isn't one.
static CycleCollectedJSRuntime* Get();
static CycleCollectedJSContext* Get();
// Add aZone to the set of zones waiting for a GC.
void AddZoneWaitingForGC(JS::Zone* aZone)
@@ -490,4 +490,4 @@ GetBuildId(JS::BuildIdCharVector* aBuildID);
} // namespace mozilla
#endif // mozilla_CycleCollectedJSRuntime_h__
#endif // mozilla_CycleCollectedJSContext_h__

View File

@@ -7,7 +7,7 @@
#include "mozilla/DebuggerOnGCRunnable.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Move.h"
#include "js/Debug.h"

View File

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

View File

@@ -7,7 +7,7 @@
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/Assertions.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
namespace mozilla {
namespace cyclecollector {
@@ -15,9 +15,9 @@ namespace cyclecollector {
void
HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->AddJSHolder(aHolder, aTracer);
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
cx->AddJSHolder(aHolder, aTracer);
}
void
@@ -35,9 +35,9 @@ HoldJSObjectsImpl(nsISupports* aHolder)
void
DropJSObjectsImpl(void* aHolder)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
rt->RemoveJSHolder(aHolder);
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
cx->RemoveJSHolder(aHolder);
}
void
@@ -59,9 +59,9 @@ DropJSObjectsImpl(nsISupports* aHolder)
bool
IsJSHolder(void* aHolder)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
return rt->IsJSHolder(aHolder);
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
return cx->IsJSHolder(aHolder);
}
#endif

View File

@@ -75,7 +75,7 @@ EXPORTS.mozilla += [
'AvailableMemoryTracker.h',
'ClearOnShutdown.h',
'CountingAllocatorBase.h',
'CycleCollectedJSRuntime.h',
'CycleCollectedJSContext.h',
'Debug.h',
'DebuggerOnGCRunnable.h',
'DeferredFinalize.h',
@@ -101,7 +101,7 @@ SOURCES['nsDebugImpl.cpp'].no_pgo = True
UNIFIED_SOURCES += [
'AvailableMemoryTracker.cpp',
'ClearOnShutdown.cpp',
'CycleCollectedJSRuntime.cpp',
'CycleCollectedJSContext.cpp',
'Debug.cpp',
'DebuggerOnGCRunnable.cpp',
'DeferredFinalize.cpp',

View File

@@ -154,7 +154,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/HoldDropJSObjects.h"
/* This must occur *after* base/process_util.h to avoid typedefs conflicts. */
@@ -1268,7 +1268,7 @@ private:
CycleCollectorResults mResults;
TimeStamp mCollectionStart;
CycleCollectedJSRuntime* mJSRuntime;
CycleCollectedJSContext* mJSContext;
ccPhase mIncrementalPhase;
CCGraph mGraph;
@@ -1299,8 +1299,8 @@ private:
public:
nsCycleCollector();
void RegisterJSRuntime(CycleCollectedJSRuntime* aJSRuntime);
void ForgetJSRuntime();
void RegisterJSContext(CycleCollectedJSContext* aJSContext);
void ForgetJSContext();
void SetBeforeUnlinkCallback(CC_BeforeUnlinkCallback aBeforeUnlinkCB)
{
@@ -1408,7 +1408,7 @@ public:
struct CollectorData
{
RefPtr<nsCycleCollector> mCollector;
CycleCollectedJSRuntime* mRuntime;
CycleCollectedJSContext* mContext;
};
static MOZ_THREAD_LOCAL(CollectorData*) sCollectorData;
@@ -1830,8 +1830,8 @@ public:
NS_ENSURE_SUCCESS(rv, rv);
// Dump the JS heap.
CollectorData* data = sCollectorData.get();
if (data && data->mRuntime) {
data->mRuntime->DumpJSHeap(gcLog);
if (data && data->mContext) {
data->mContext->DumpJSHeap(gcLog);
}
rv = mLogSink->CloseGCLog();
NS_ENSURE_SUCCESS(rv, rv);
@@ -2073,7 +2073,7 @@ private:
public:
CCGraphBuilder(CCGraph& aGraph,
CycleCollectorResults& aResults,
CycleCollectedJSRuntime* aJSRuntime,
CycleCollectedJSContext* aJSContext,
nsCycleCollectorLogger* aLogger,
bool aMergeZones);
virtual ~CCGraphBuilder();
@@ -2171,7 +2171,7 @@ private:
CCGraphBuilder::CCGraphBuilder(CCGraph& aGraph,
CycleCollectorResults& aResults,
CycleCollectedJSRuntime* aJSRuntime,
CycleCollectedJSContext* aJSContext,
nsCycleCollectorLogger* aLogger,
bool aMergeZones)
: mGraph(aGraph)
@@ -2183,9 +2183,9 @@ CCGraphBuilder::CCGraphBuilder(CCGraph& aGraph,
, mLogger(aLogger)
, mMergeZones(aMergeZones)
{
if (aJSRuntime) {
mJSParticipant = aJSRuntime->GCThingParticipant();
mJSZoneParticipant = aJSRuntime->ZoneParticipant();
if (aJSContext) {
mJSParticipant = aJSContext->GCThingParticipant();
mJSZoneParticipant = aJSContext->ZoneParticipant();
}
if (mLogger) {
@@ -2871,8 +2871,8 @@ nsCycleCollector::ForgetSkippable(bool aRemoveChildlessNodes,
// lose track of an object that was mutated during graph building.
MOZ_ASSERT(IsIdle());
if (mJSRuntime) {
mJSRuntime->PrepareForForgetSkippable();
if (mJSContext) {
mJSContext->PrepareForForgetSkippable();
}
MOZ_ASSERT(!mScanInProgress,
"Don't forget skippable or free snow-white while scan is in progress.");
@@ -3055,11 +3055,11 @@ nsCycleCollector::ScanIncrementalRoots()
mPurpleBuf.VisitEntries(purpleScanBlackVisitor);
timeLog.Checkpoint("ScanIncrementalRoots::fix purple");
bool hasJSRuntime = !!mJSRuntime;
bool hasJSContext = !!mJSContext;
nsCycleCollectionParticipant* jsParticipant =
hasJSRuntime ? mJSRuntime->GCThingParticipant() : nullptr;
hasJSContext ? mJSContext->GCThingParticipant() : nullptr;
nsCycleCollectionParticipant* zoneParticipant =
hasJSRuntime ? mJSRuntime->ZoneParticipant() : nullptr;
hasJSContext ? mJSContext->ZoneParticipant() : nullptr;
bool hasLogger = !!mLogger;
NodePool::Enumerator etor(mGraph.mNodes);
@@ -3078,7 +3078,7 @@ nsCycleCollector::ScanIncrementalRoots()
// now marked black by the GC, it was probably gray before and was exposed
// to active JS, so it may have been stored somewhere, so it needs to be
// treated as live.
if (pi->IsGrayJS() && MOZ_LIKELY(hasJSRuntime)) {
if (pi->IsGrayJS() && MOZ_LIKELY(hasJSContext)) {
// If the object is still marked gray by the GC, nothing could have gotten
// hold of it, so it isn't an incremental root.
if (pi->mParticipant == jsParticipant) {
@@ -3290,16 +3290,16 @@ nsCycleCollector::CollectWhite()
uint32_t numWhiteGCed = 0;
uint32_t numWhiteJSZones = 0;
bool hasJSRuntime = !!mJSRuntime;
bool hasJSContext = !!mJSContext;
nsCycleCollectionParticipant* zoneParticipant =
hasJSRuntime ? mJSRuntime->ZoneParticipant() : nullptr;
hasJSContext ? mJSContext->ZoneParticipant() : nullptr;
NodePool::Enumerator etor(mGraph.mNodes);
while (!etor.IsDone()) {
PtrInfo* pinfo = etor.GetNext();
if (pinfo->mColor == white && pinfo->mParticipant) {
if (pinfo->IsGrayJS()) {
MOZ_ASSERT(mJSRuntime);
MOZ_ASSERT(mJSContext);
++numWhiteGCed;
JS::Zone* zone;
if (MOZ_UNLIKELY(pinfo->mParticipant == zoneParticipant)) {
@@ -3309,7 +3309,7 @@ nsCycleCollector::CollectWhite()
JS::GCCellPtr ptr(pinfo->mPointer, JS::GCThingTraceKind(pinfo->mPointer));
zone = JS::GetTenuredGCThingZone(ptr);
}
mJSRuntime->AddZoneWaitingForGC(zone);
mJSContext->AddZoneWaitingForGC(zone);
} else {
whiteNodes.InfallibleAppend(pinfo);
pinfo->mParticipant->Root(pinfo->mPointer);
@@ -3338,8 +3338,8 @@ nsCycleCollector::CollectWhite()
"Unlink shouldn't see objects removed from graph.");
pinfo->mParticipant->Unlink(pinfo->mPointer);
#ifdef DEBUG
if (mJSRuntime) {
mJSRuntime->AssertNoObjectsToTrace(pinfo->mPointer);
if (mJSContext) {
mJSContext->AssertNoObjectsToTrace(pinfo->mPointer);
}
#endif
}
@@ -3411,7 +3411,7 @@ nsCycleCollector::nsCycleCollector() :
mActivelyCollecting(false),
mFreeingSnowWhite(false),
mScanInProgress(false),
mJSRuntime(nullptr),
mJSContext(nullptr),
mIncrementalPhase(IdlePhase),
#ifdef DEBUG
mThread(NS_GetCurrentThread()),
@@ -3430,10 +3430,10 @@ nsCycleCollector::~nsCycleCollector()
}
void
nsCycleCollector::RegisterJSRuntime(CycleCollectedJSRuntime* aJSRuntime)
nsCycleCollector::RegisterJSContext(CycleCollectedJSContext* aJSContext)
{
MOZ_RELEASE_ASSERT(!mJSRuntime, "Multiple registrations of JS runtime in cycle collector");
mJSRuntime = aJSRuntime;
MOZ_RELEASE_ASSERT(!mJSContext, "Multiple registrations of JS context in cycle collector");
mJSContext = aJSContext;
if (!NS_IsMainThread()) {
return;
@@ -3446,10 +3446,10 @@ nsCycleCollector::RegisterJSRuntime(CycleCollectedJSRuntime* aJSRuntime)
}
void
nsCycleCollector::ForgetJSRuntime()
nsCycleCollector::ForgetJSContext()
{
MOZ_RELEASE_ASSERT(mJSRuntime, "Forgetting JS runtime in cycle collector before a JS runtime was registered");
mJSRuntime = nullptr;
MOZ_RELEASE_ASSERT(mJSContext, "Forgetting JS context in cycle collector before a JS context was registered");
mJSContext = nullptr;
}
#ifdef DEBUG
@@ -3500,7 +3500,7 @@ nsCycleCollector::CheckThreadSafety()
// The cycle collector uses the mark bitmap to discover what JS objects
// were reachable only from XPConnect roots that might participate in
// cycles. We ask the JS runtime whether we need to force a GC before
// cycles. We ask the JS context whether we need to force a GC before
// this CC. It returns true on startup (before the mark bits have been set),
// and also when UnmarkGray has run out of stack. We also force GCs on shut
// down to collect cycles involving both DOM and JS.
@@ -3509,15 +3509,15 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
{
CheckThreadSafety();
if (!mJSRuntime) {
if (!mJSContext) {
return;
}
if (!aForceGC) {
mJSRuntime->FixWeakMappingGrayBits();
mJSContext->FixWeakMappingGrayBits();
aTimeLog.Checkpoint("FixWeakMappingGrayBits");
bool needGC = !mJSRuntime->AreGCGrayBitsValid();
bool needGC = !mJSContext->AreGCGrayBitsValid();
// Only do a telemetry ping for non-shutdown CCs.
CC_TELEMETRY(_NEED_GC, needGC);
if (!needGC) {
@@ -3526,7 +3526,7 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
mResults.mForcedGC = true;
}
mJSRuntime->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
mJSContext->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
JS::gcreason::CC_FORCED);
aTimeLog.Checkpoint("FixGrayBits GC");
}
@@ -3534,7 +3534,7 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
bool
nsCycleCollector::IsIncrementalGCInProgress()
{
return mJSRuntime && JS::IsIncrementalGCInProgress(mJSRuntime->Context());
return mJSContext && JS::IsIncrementalGCInProgress(mJSContext->Context());
}
void
@@ -3542,8 +3542,8 @@ nsCycleCollector::FinishAnyIncrementalGCInProgress()
{
if (IsIncrementalGCInProgress()) {
NS_WARNING("Finishing incremental GC in progress during CC");
JS::PrepareForIncrementalGC(mJSRuntime->Context());
JS::FinishIncrementalGC(mJSRuntime->Context(), JS::gcreason::CC_FORCED);
JS::PrepareForIncrementalGC(mJSContext->Context());
JS::FinishIncrementalGC(mJSContext->Context(), JS::gcreason::CC_FORCED);
}
}
@@ -3577,11 +3577,11 @@ nsCycleCollector::CleanupAfterCollection()
CC_TELEMETRY(_COLLECTED, mWhiteNodeCount);
timeLog.Checkpoint("CleanupAfterCollection::telemetry");
if (mJSRuntime) {
mJSRuntime->FinalizeDeferredThings(mResults.mAnyManual
? CycleCollectedJSRuntime::FinalizeNow
: CycleCollectedJSRuntime::FinalizeIncrementally);
mJSRuntime->EndCycleCollectionCallback(mResults);
if (mJSContext) {
mJSContext->FinalizeDeferredThings(mResults.mAnyManual
? CycleCollectedJSContext::FinalizeNow
: CycleCollectedJSContext::FinalizeIncrementally);
mJSContext->EndCycleCollectionCallback(mResults);
timeLog.Checkpoint("CleanupAfterCollection::EndCycleCollectionCallback()");
}
mIncrementalPhase = IdlePhase;
@@ -3759,7 +3759,7 @@ static const uint32_t kMaxConsecutiveMerged = 3;
bool
nsCycleCollector::ShouldMergeZones(ccType aCCType)
{
if (!mJSRuntime) {
if (!mJSContext) {
return false;
}
@@ -3777,7 +3777,7 @@ nsCycleCollector::ShouldMergeZones(ccType aCCType)
return false;
}
if (aCCType == SliceCC && mJSRuntime->UsefulToMergeZones()) {
if (aCCType == SliceCC && mJSContext->UsefulToMergeZones()) {
mMergedInARow++;
return true;
} else {
@@ -3795,8 +3795,8 @@ nsCycleCollector::BeginCollection(ccType aCCType,
mCollectionStart = TimeStamp::Now();
if (mJSRuntime) {
mJSRuntime->BeginCycleCollectionCallback();
if (mJSContext) {
mJSContext->BeginCycleCollectionCallback();
timeLog.Checkpoint("BeginCycleCollectionCallback()");
}
@@ -3849,13 +3849,13 @@ nsCycleCollector::BeginCollection(ccType aCCType,
mResults.mMergedZones = mergeZones;
MOZ_ASSERT(!mBuilder, "Forgot to clear mBuilder");
mBuilder = new CCGraphBuilder(mGraph, mResults, mJSRuntime, mLogger,
mBuilder = new CCGraphBuilder(mGraph, mResults, mJSContext, mLogger,
mergeZones);
timeLog.Checkpoint("BeginCollection prepare graph builder");
if (mJSRuntime) {
mJSRuntime->TraverseRoots(*mBuilder);
timeLog.Checkpoint("mJSRuntime->TraverseRoots()");
if (mJSContext) {
mJSContext->TraverseRoots(*mBuilder);
timeLog.Checkpoint("mJSContext->TraverseRoots()");
}
AutoRestore<bool> ar(mScanInProgress);
@@ -3911,7 +3911,7 @@ nsCycleCollector::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
*aPurpleBufferSize = mPurpleBuf.SizeOfExcludingThis(aMallocSizeOf);
// These fields are deliberately not measured:
// - mJSRuntime: because it's non-owning and measured by JS reporters.
// - mJSContext: because it's non-owning and measured by JS reporters.
// - mParams: because it only contains scalars.
}
@@ -3935,47 +3935,47 @@ nsCycleCollector::GetJSPurpleBuffer()
////////////////////////////////////////////////////////////////////////
void
nsCycleCollector_registerJSRuntime(CycleCollectedJSRuntime* aRt)
nsCycleCollector_registerJSContext(CycleCollectedJSContext* aCx)
{
CollectorData* data = sCollectorData.get();
// We should have started the cycle collector by now.
MOZ_ASSERT(data);
MOZ_ASSERT(data->mCollector);
// But we shouldn't already have a runtime.
MOZ_ASSERT(!data->mRuntime);
// But we shouldn't already have a context.
MOZ_ASSERT(!data->mContext);
data->mRuntime = aRt;
data->mCollector->RegisterJSRuntime(aRt);
data->mContext = aCx;
data->mCollector->RegisterJSContext(aCx);
}
void
nsCycleCollector_forgetJSRuntime()
nsCycleCollector_forgetJSContext()
{
CollectorData* data = sCollectorData.get();
// We should have started the cycle collector by now.
MOZ_ASSERT(data);
// And we shouldn't have already forgotten our runtime.
MOZ_ASSERT(data->mRuntime);
// And we shouldn't have already forgotten our context.
MOZ_ASSERT(data->mContext);
// But it may have shutdown already.
if (data->mCollector) {
data->mCollector->ForgetJSRuntime();
data->mRuntime = nullptr;
data->mCollector->ForgetJSContext();
data->mContext = nullptr;
} else {
data->mRuntime = nullptr;
data->mContext = nullptr;
delete data;
sCollectorData.set(nullptr);
}
}
/* static */ CycleCollectedJSRuntime*
CycleCollectedJSRuntime::Get()
/* static */ CycleCollectedJSContext*
CycleCollectedJSContext::Get()
{
CollectorData* data = sCollectorData.get();
if (data) {
return data->mRuntime;
return data->mContext;
}
return nullptr;
}
@@ -4055,7 +4055,7 @@ nsCycleCollector_startup()
CollectorData* data = new CollectorData;
data->mCollector = new nsCycleCollector();
data->mRuntime = nullptr;
data->mContext = nullptr;
sCollectorData.set(data);
}
@@ -4106,9 +4106,9 @@ nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes,
void
nsCycleCollector_dispatchDeferredDeletion(bool aContinuation, bool aPurge)
{
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
if (rt) {
rt->DispatchDeferredDeletion(aContinuation, aPurge);
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
if (cx) {
cx->DispatchDeferredDeletion(aContinuation, aPurge);
}
}
@@ -4120,7 +4120,7 @@ nsCycleCollector_doDeferredDeletion()
// We should have started the cycle collector by now.
MOZ_ASSERT(data);
MOZ_ASSERT(data->mCollector);
MOZ_ASSERT(data->mRuntime);
MOZ_ASSERT(data->mContext);
return data->mCollector->FreeSnowWhite(false);
}
@@ -4204,12 +4204,12 @@ nsCycleCollector_shutdown(bool aDoCollect)
data->mCollector->Shutdown(aDoCollect);
data->mCollector = nullptr;
if (data->mRuntime) {
if (data->mContext) {
// Run any remaining tasks that may have been enqueued via
// RunInStableState during the final cycle collection.
data->mRuntime->ProcessStableStateQueue();
data->mContext->ProcessStableStateQueue();
}
if (!data->mRuntime) {
if (!data->mContext) {
delete data;
sCollectorData.set(nullptr);
}

View File

@@ -18,7 +18,7 @@ template<class T> struct already_AddRefed;
#include "js/SliceBudget.h"
namespace mozilla {
class CycleCollectedJSRuntime;
class CycleCollectedJSContext;
} // namespace mozilla
bool nsCycleCollector_init();
@@ -57,8 +57,8 @@ uint32_t nsCycleCollector_suspectedCount();
void nsCycleCollector_shutdown(bool aDoCollect = true);
// Helpers for interacting with JS
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime* aRt);
void nsCycleCollector_forgetJSRuntime();
void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
void nsCycleCollector_forgetJSContext();
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
{ 0x58be81b4, 0x39d2, 0x437c, \

View File

@@ -17,7 +17,7 @@
#include "js/TracingAPI.h"
#include "js/HeapAPI.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
using namespace JS;
using namespace mozilla;
@@ -127,9 +127,9 @@ CreateGlobalAndRunTest(JSContext* cx)
}
TEST(GCPostBarriers, nsTArray) {
CycleCollectedJSRuntime* ccrt = CycleCollectedJSRuntime::Get();
ASSERT_TRUE(ccrt != nullptr);
JSContext* cx = ccrt->Context();
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
ASSERT_TRUE(ccjscx != nullptr);
JSContext* cx = ccjscx->Context();
ASSERT_TRUE(cx != nullptr);
JS_BeginRequest(cx);

View File

@@ -21,7 +21,7 @@
#include "nsCOMPtr.h"
#include "nsQueryObject.h"
#include "pratom.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/Logging.h"
#include "nsIObserverService.h"
#include "mozilla/HangMonitor.h"
@@ -1260,7 +1260,7 @@ nsThread::PopEventQueue(nsIEventTarget* aInnermostTarget)
}
void
nsThread::SetScriptObserver(mozilla::CycleCollectedJSRuntime* aScriptObserver)
nsThread::SetScriptObserver(mozilla::CycleCollectedJSContext* aScriptObserver)
{
if (!aScriptObserver) {
mScriptObserver = nullptr;

View File

@@ -20,7 +20,7 @@
#include "mozilla/AlreadyAddRefed.h"
namespace mozilla {
class CycleCollectedJSRuntime;
class CycleCollectedJSContext;
}
using mozilla::NotNull;
@@ -72,7 +72,7 @@ public:
}
void
SetScriptObserver(mozilla::CycleCollectedJSRuntime* aScriptObserver);
SetScriptObserver(mozilla::CycleCollectedJSContext* aScriptObserver);
uint32_t
RecursionDepth() const;
@@ -200,7 +200,7 @@ protected:
mozilla::Mutex mLock;
nsCOMPtr<nsIThreadObserver> mObserver;
mozilla::CycleCollectedJSRuntime* mScriptObserver;
mozilla::CycleCollectedJSContext* mScriptObserver;
// Only accessed on the target thread.
nsAutoTObserverArray<NotNull<nsCOMPtr<nsIThreadObserver>>, 2> mEventObservers;