Three different fixes to help us start up with WAY_TOO_MUCH_GC defined (307317, r+sr from bz/mrbkap/shaver).

This commit is contained in:
brendan%mozilla.org 2005-09-14 22:35:43 +00:00
parent 2b00d0d082
commit 2cdb0aa1d9
3 changed files with 27 additions and 12 deletions

View File

@ -2029,13 +2029,15 @@ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
if (!atom)
return NULL;
/* Create a prototype object for this class. */
proto = js_NewObject(cx, clasp, parent_proto, obj);
if (!proto)
if (!js_EnterLocalRootScope(cx))
return NULL;
if (!js_EnterLocalRootScope(cx))
goto bad2;
/* Create a prototype object for this class. */
proto = js_NewObject(cx, clasp, parent_proto, obj);
if (!proto) {
named = JS_FALSE;
goto bad;
}
if (!constructor) {
/* Lacking a constructor, name the prototype (e.g., Math). */
@ -2104,9 +2106,6 @@ bad:
js_LeaveLocalRootScope(cx);
if (named)
(void) OBJ_DELETE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), &rval);
bad2:
cx->newborn[GCX_OBJECT] = NULL;
return NULL;
}

View File

@ -1962,6 +1962,7 @@ JSBool
js_FindConstructor(JSContext *cx, JSObject *start, const char *name, jsval *vp)
{
JSAtom *atom;
JSBool ok;
JSObject *obj, *pobj;
JSProperty *prop;
JSScopeProperty *sprop;
@ -1984,11 +1985,22 @@ js_FindConstructor(JSContext *cx, JSObject *start, const char *name, jsval *vp)
}
}
/* XXX require global objects to be native to avoid recursive death */
JS_ASSERT(OBJ_IS_NATIVE(obj));
if (!js_LookupPropertyWithFlags(cx, obj, ATOM_TO_JSID(atom),
JSRESOLVE_CLASSNAME, &pobj, &prop)) {
/*
* Switch from cx->newborn to cx->localRootStack to preserve the invariant
* that callers of js_NewGCThing (who calls us via GetClassPrototype) need
* not protect newborns of types other than the one being allocated.
*/
if (!js_EnterLocalRootScope(cx))
return JS_FALSE;
}
ok = js_LookupPropertyWithFlags(cx, obj, ATOM_TO_JSID(atom),
JSRESOLVE_CLASSNAME, &pobj, &prop);
js_LeaveLocalRootScope(cx);
if (!ok)
return JS_FALSE;
if (!prop) {
*vp = JSVAL_VOID;
return JS_TRUE;

View File

@ -345,7 +345,11 @@ XPCCallContext::~XPCCallContext()
}
else
{
JS_ClearNewbornRoots(mJSContext);
// Don't clear newborns if JS frames (compilation or execution)
// are active! Doing so violates ancient invariants in the JS
// engine, and it's not necessary to fix JS component leaks.
if (!mJSContext->fp)
JS_ClearNewbornRoots(mJSContext);
}
}