mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
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:
parent
2b00d0d082
commit
2cdb0aa1d9
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user