If js_AddAsGCBytes is called from trace and wants to GC and we can bail off trace then do so instead of returning an error (476869, r=jorendorff).

This commit is contained in:
Andreas Gal 2009-02-06 10:11:45 -08:00
Родитель 026e52d0f6
Коммит d58e39985e
2 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -2290,8 +2290,15 @@ js_AddAsGCBytes(JSContext *cx, size_t sz)
#endif
) {
if (JS_ON_TRACE(cx)) {
JS_UNLOCK_GC(rt);
return JS_FALSE;
/*
* If we can't leave the trace, signal OOM condition, otherwise
* exit from trace and proceed with GC.
*/
if (!js_CanLeaveTrace(cx)) {
JS_UNLOCK_GC(rt);
return JS_FALSE;
}
js_LeaveTrace(cx);
}
js_GC(cx, GC_LAST_DITCH);
if (rt->gcBytes >= rt->gcMaxBytes ||

Просмотреть файл

@ -626,4 +626,15 @@ js_LeaveTrace(JSContext *cx)
js_GetTopStackFrame(cx);
}
static JS_INLINE bool
js_CanLeaveTrace(JSContext *cx)
{
JS_ASSERT(JS_ON_TRACE(cx));
#ifdef JS_TRACER
return cx->bailExit;
#else
return false;
#endif
}
#endif /* jstracer_h___ */