epstein@tellme.com's patch implementing JS_ClearNewbornRoots (106790, r=brendan, sr=jband).

This commit is contained in:
brendan%mozilla.org 2001-10-26 02:38:10 +00:00
parent 862a59da87
commit 63754279fd
2 changed files with 30 additions and 3 deletions

View File

@ -1497,6 +1497,15 @@ JS_AddNamedRoot(JSContext *cx, void *rp, const char *name)
return js_AddRoot(cx, rp, name);
}
JS_PUBLIC_API(void)
JS_ClearNewbornRoots(JSContext *cx)
{
uintN i;
for (i = 0; i < GCX_NTYPES; i++)
cx->newborn[i] = NULL;
}
#include "jshash.h" /* Added by JSIFY */
#ifdef DEBUG
@ -1617,7 +1626,7 @@ JS_GC(JSContext *cx)
{
if (cx->runtime->gcDisabled)
return;
if (cx->stackPool.current == &cx->stackPool.first)
JS_FinishArenaPool(&cx->stackPool);
JS_FinishArenaPool(&cx->codePool);
@ -2738,7 +2747,7 @@ JS_PUBLIC_API(JSPrincipalsTranscoder)
JS_SetPrincipalsTranscoder(JSRuntime *rt, JSPrincipalsTranscoder px)
{
JSPrincipalsTranscoder oldpx;
oldpx = rt->principalsTranscoder;
rt->principalsTranscoder = px;
return oldpx;
@ -3037,7 +3046,7 @@ JS_NewScriptObject(JSContext *cx, JSScript *script)
JSStackFrame dummy;
CHECK_REQUEST(cx);
memset(&dummy, 0, sizeof dummy);
dummy.down = cx->fp;
dummy.script = script;

View File

@ -529,6 +529,24 @@ JS_RemoveRoot(JSContext *cx, void *rp);
extern JS_PUBLIC_API(JSBool)
JS_RemoveRootRT(JSRuntime *rt, void *rp);
/*
* The last GC thing of each type (object, string, double, external string
* types) created on a given context is kept alive until another thing of the
* same type is created, using a newborn root in the context. These newborn
* roots help native code protect newly-created GC-things from GC invocations
* activated before those things can be rooted using local or global roots.
*
* However, the newborn roots can also entrain great gobs of garbage, so the
* JS_GC entry point clears them for the context on which GC is being forced.
* Embeddings may need to do likewise for all contexts.
*
* XXXbe See bug 40757 (http://bugzilla.mozilla.org/show_bug.cgi?id=40757),
* which proposes switching (with an #ifdef, alas, if we want to maintain API
* compatibility) to a JNI-like extensible local root frame stack model.
*/
extern JS_PUBLIC_API(void)
JS_ClearNewbornRoots(JSContext *cx);
#ifdef DEBUG
extern JS_PUBLIC_API(void)
JS_DumpNamedRoots(JSRuntime *rt,