mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
Bug 1302448 part 3 - Rename WorkerJSRuntime to WorkerJSContext. r=baku
--HG-- extra : rebase_source : a1df9ae95f0c80f67ce21bc494bb92a20cbc5784
This commit is contained in:
parent
7f794780e0
commit
919372cf5c
@ -892,11 +892,11 @@ FinishAsyncTaskCallback(JS::AsyncTask* aTask)
|
||||
return true;
|
||||
}
|
||||
|
||||
class WorkerJSRuntime;
|
||||
class WorkerJSContext;
|
||||
|
||||
class WorkerThreadContextPrivate : private PerThreadAtomCache
|
||||
{
|
||||
friend class WorkerJSRuntime;
|
||||
friend class WorkerJSContext;
|
||||
|
||||
WorkerPrivate* mWorkerPrivate;
|
||||
|
||||
@ -1043,18 +1043,18 @@ static const JSWrapObjectCallbacks WrapObjectCallbacks = {
|
||||
nullptr,
|
||||
};
|
||||
|
||||
class WorkerJSRuntime : public mozilla::CycleCollectedJSContext
|
||||
class MOZ_STACK_CLASS WorkerJSContext final : public mozilla::CycleCollectedJSContext
|
||||
{
|
||||
public:
|
||||
// The heap size passed here doesn't matter, we will change it later in the
|
||||
// call to JS_SetGCParameter inside InitJSContextForWorker.
|
||||
explicit WorkerJSRuntime(WorkerPrivate* aWorkerPrivate)
|
||||
explicit WorkerJSContext(WorkerPrivate* aWorkerPrivate)
|
||||
: mWorkerPrivate(aWorkerPrivate)
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
}
|
||||
|
||||
~WorkerJSRuntime()
|
||||
~WorkerJSContext()
|
||||
{
|
||||
JSContext* cx = MaybeContext();
|
||||
if (!cx) {
|
||||
@ -1460,7 +1460,7 @@ GetCurrentThreadWorkerPrivate()
|
||||
|
||||
void* cxPrivate = JS_GetContextPrivate(cx);
|
||||
if (!cxPrivate) {
|
||||
// This can happen if the nsCycleCollector_shutdown() in ~WorkerJSRuntime()
|
||||
// This can happen if the nsCycleCollector_shutdown() in ~WorkerJSContext()
|
||||
// triggers any calls to GetCurrentThreadWorkerPrivate(). At this stage
|
||||
// CycleCollectedJSContext::Get() will still return a context, but
|
||||
// the context private has already been cleared.
|
||||
@ -2832,17 +2832,17 @@ WorkerThreadPrimaryRunnable::Run()
|
||||
{
|
||||
nsCycleCollector_startup();
|
||||
|
||||
WorkerJSRuntime runtime(mWorkerPrivate);
|
||||
nsresult rv = runtime.Initialize(mParentContext);
|
||||
WorkerJSContext context(mWorkerPrivate);
|
||||
nsresult rv = context.Initialize(mParentContext);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
JSContext* cx = runtime.Context();
|
||||
JSContext* cx = context.Context();
|
||||
|
||||
if (!InitJSContextForWorker(mWorkerPrivate, cx)) {
|
||||
// XXX need to fire an error at parent.
|
||||
NS_ERROR("Failed to create runtime and context!");
|
||||
NS_ERROR("Failed to create context!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -2889,7 +2889,7 @@ WorkerThreadPrimaryRunnable::Run()
|
||||
// cleanup.
|
||||
mWorkerPrivate->ClearMainEventQueue(WorkerPrivate::WorkerRan);
|
||||
|
||||
// Now WorkerJSRuntime goes out of scope and its destructor will shut
|
||||
// Now WorkerJSContext goes out of scope and its destructor will shut
|
||||
// down the cycle collector. This breaks any remaining cycles and collects
|
||||
// any remaining C++ objects.
|
||||
}
|
||||
|
@ -1508,16 +1508,16 @@ StartsWithExplicit(nsACString& s)
|
||||
}
|
||||
#endif
|
||||
|
||||
class WorkerJSRuntimeStats : public JS::RuntimeStats
|
||||
class MOZ_STACK_CLASS WorkerJSContextStats final : public JS::RuntimeStats
|
||||
{
|
||||
const nsACString& mRtPath;
|
||||
|
||||
public:
|
||||
explicit WorkerJSRuntimeStats(const nsACString& aRtPath)
|
||||
explicit WorkerJSContextStats(const nsACString& aRtPath)
|
||||
: JS::RuntimeStats(JsWorkerMallocSizeOf), mRtPath(aRtPath)
|
||||
{ }
|
||||
|
||||
~WorkerJSRuntimeStats()
|
||||
~WorkerJSContextStats()
|
||||
{
|
||||
for (size_t i = 0; i != zoneStatsVector.length(); i++) {
|
||||
delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
|
||||
@ -2027,10 +2027,10 @@ public:
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
// Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and
|
||||
// Assumes that WorkerJSContextStats will hold a reference to |path|, and
|
||||
// not a copy, as TryToMapAddon() may later modify it.
|
||||
nsCString path;
|
||||
WorkerJSRuntimeStats rtStats(path);
|
||||
WorkerJSContextStats cxStats(path);
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
@ -2060,13 +2060,13 @@ public:
|
||||
|
||||
TryToMapAddon(path);
|
||||
|
||||
if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
|
||||
if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&cxStats, aAnonymize)) {
|
||||
// Returning NS_OK here will effectively report 0 memory.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path, aHandleReport, aData,
|
||||
xpc::ReportJSRuntimeExplicitTreeStats(cxStats, path, aHandleReport, aData,
|
||||
aAnonymize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user