mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 905926 - Move rambo GC to runtime destruction. r=jonco
This commit is contained in:
parent
a2da8aae46
commit
7a4e1969f2
@ -17,7 +17,7 @@ namespace JS {
|
||||
/* Reasons internal to the JS engine */ \
|
||||
D(API) \
|
||||
D(MAYBEGC) \
|
||||
D(LAST_CONTEXT) \
|
||||
D(DESTROY_RUNTIME) \
|
||||
D(DESTROY_CONTEXT) \
|
||||
D(LAST_DITCH) \
|
||||
D(TOO_MUCH_MALLOC) \
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "jsstr.h"
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h"
|
||||
#include "jswatchpoint.h"
|
||||
#include "jsweakmap.h"
|
||||
#ifdef JS_THREADSAFE
|
||||
#include "jsworkers.h"
|
||||
@ -716,7 +717,6 @@ JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads)
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DestroyRuntime(JSRuntime *rt)
|
||||
{
|
||||
js_free(rt->defaultLocale);
|
||||
js_delete(rt);
|
||||
}
|
||||
|
||||
|
@ -251,44 +251,13 @@ js::DestroyContext(JSContext *cx, DestroyContextMode mode)
|
||||
JS_ASSERT(!rt->isHeapBusy());
|
||||
|
||||
/*
|
||||
* Dump remaining type inference results first. This printing
|
||||
* depends on atoms still existing.
|
||||
* Dump remaining type inference results while we still have a context.
|
||||
* This printing depends on atoms still existing.
|
||||
*/
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
c->types.print(cx, false);
|
||||
|
||||
/* Off thread compilation and parsing depend on atoms still existing. */
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
CancelOffThreadIonCompile(c, NULL);
|
||||
WaitForOffThreadParsingToFinish(rt);
|
||||
|
||||
#ifdef JS_WORKER_THREADS
|
||||
if (rt->workerThreadState)
|
||||
rt->workerThreadState->cleanup(rt);
|
||||
#endif
|
||||
|
||||
/* Unpin all common names before final GC. */
|
||||
FinishCommonNames(rt);
|
||||
|
||||
/* Clear debugging state to remove GC roots. */
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
c->clearTraps(rt->defaultFreeOp());
|
||||
if (WatchpointMap *wpmap = c->watchpointMap)
|
||||
wpmap->clear();
|
||||
}
|
||||
|
||||
/* Clear the statics table to remove GC roots. */
|
||||
rt->staticStrings.finish();
|
||||
|
||||
JS::PrepareForFullGC(rt);
|
||||
GC(rt, GC_NORMAL, JS::gcreason::LAST_CONTEXT);
|
||||
|
||||
/*
|
||||
* Clear the self-hosted global and delete self-hosted classes *after*
|
||||
* GC, as finalizers for objects check for clasp->finalize during GC.
|
||||
*/
|
||||
rt->finishSelfHosting();
|
||||
} else if (mode == DCM_FORCE_GC) {
|
||||
}
|
||||
if (mode == DCM_FORCE_GC) {
|
||||
JS_ASSERT(!rt->isHeapBusy());
|
||||
JS::PrepareForFullGC(rt);
|
||||
GC(rt, GC_NORMAL, JS::gcreason::DESTROY_CONTEXT);
|
||||
|
@ -4380,7 +4380,7 @@ IncrementalCollectSlice(JSRuntime *rt,
|
||||
if (!finished)
|
||||
break;
|
||||
|
||||
EndSweepPhase(rt, gckind, reason == JS::gcreason::LAST_CONTEXT);
|
||||
EndSweepPhase(rt, gckind, reason == JS::gcreason::DESTROY_RUNTIME);
|
||||
|
||||
if (rt->gcSweepOnBackgroundThread)
|
||||
rt->gcHelperThread.startBackgroundSweep(gckind == GC_SHRINK);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "jsnativestack.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsscript.h"
|
||||
#include "jswatchpoint.h"
|
||||
#include "jswrapper.h"
|
||||
|
||||
#include "jit/AsmJSSignalHandlers.h"
|
||||
@ -393,6 +394,40 @@ JSRuntime::init(uint32_t maxbytes)
|
||||
|
||||
JSRuntime::~JSRuntime()
|
||||
{
|
||||
JS_ASSERT(!isHeapBusy());
|
||||
|
||||
/* Off thread compilation and parsing depend on atoms still existing. */
|
||||
for (CompartmentsIter comp(this); !comp.done(); comp.next())
|
||||
CancelOffThreadIonCompile(comp, NULL);
|
||||
WaitForOffThreadParsingToFinish(this);
|
||||
|
||||
#ifdef JS_WORKER_THREADS
|
||||
if (workerThreadState)
|
||||
workerThreadState->cleanup(this);
|
||||
#endif
|
||||
|
||||
/* Poison common names before final GC. */
|
||||
FinishCommonNames(this);
|
||||
|
||||
/* Clear debugging state to remove GC roots. */
|
||||
for (CompartmentsIter comp(this); !comp.done(); comp.next()) {
|
||||
comp->clearTraps(defaultFreeOp());
|
||||
if (WatchpointMap *wpmap = comp->watchpointMap)
|
||||
wpmap->clear();
|
||||
}
|
||||
|
||||
/* Clear the statics table to remove GC roots. */
|
||||
staticStrings.finish();
|
||||
|
||||
JS::PrepareForFullGC(this);
|
||||
GC(this, GC_NORMAL, JS::gcreason::DESTROY_RUNTIME);
|
||||
|
||||
/*
|
||||
* Clear the self-hosted global and delete self-hosted classes *after*
|
||||
* GC, as finalizers for objects check for clasp->finalize during GC.
|
||||
*/
|
||||
finishSelfHosting();
|
||||
|
||||
mainThread.removeFromThreadList();
|
||||
|
||||
#ifdef JS_WORKER_THREADS
|
||||
@ -449,6 +484,7 @@ JSRuntime::~JSRuntime()
|
||||
PR_DestroyLock(gcLock);
|
||||
#endif
|
||||
|
||||
js_free(defaultLocale);
|
||||
js_delete(bumpAlloc_);
|
||||
js_delete(mathCache_);
|
||||
#ifdef JS_ION
|
||||
|
@ -471,10 +471,10 @@ CycleCollectedJSRuntime::DestroyRuntime()
|
||||
|
||||
// Clear mPendingException first, since it might be cycle collected.
|
||||
mPendingException = nullptr;
|
||||
nsCycleCollector_forgetJSRuntime();
|
||||
|
||||
JS_DestroyRuntime(mJSRuntime);
|
||||
mJSRuntime = nullptr;
|
||||
nsCycleCollector_forgetJSRuntime();
|
||||
}
|
||||
|
||||
CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
|
||||
|
Loading…
Reference in New Issue
Block a user