bug 557140 - avoid abort() on OOM with ill-lopping traced code. r=jorendorff

This commit is contained in:
Igor Bukanov 2010-04-16 14:31:17 +02:00
Родитель ee58225166
Коммит c2478655ef
1 изменённых файлов: 18 добавлений и 2 удалений

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

@ -1844,11 +1844,27 @@ js_InvokeOperationCallback(JSContext *cx)
* not yield. Operation callbacks are supposed to happen rarely (seconds,
* not milliseconds) so it is acceptable to yield at every callback.
*/
if (cx->runtime->gcIsNeeded)
JSRuntime *rt = cx->runtime;
if (rt->gcIsNeeded) {
js_GC(cx, GC_NORMAL);
/*
* On trace we can exceed the GC quota, see comments in NewGCArena. So
* we check the quota and report OOM here when we are off trace.
*/
bool delayedOutOfMemory;
JS_LOCK_GC(rt);
delayedOutOfMemory = (rt->gcBytes > rt->gcMaxBytes);
JS_UNLOCK_GC(rt);
if (delayedOutOfMemory) {
js_ReportOutOfMemory(cx);
return false;
}
}
#ifdef JS_THREADSAFE
else
else {
JS_YieldRequest(cx);
}
#endif
JSOperationCallback cb = cx->operationCallback;