Bug 1088249 - Report OOMs from the js_alloc*CanGC functions, r=luke

--HG--
extra : rebase_source : 47f348d2d448ee51fb6e1f6929fd6b35e14b1e60
This commit is contained in:
Steve Fink 2014-11-03 13:59:31 -08:00
parent 5cf875b9ba
commit dfb2f27cf1
2 changed files with 6 additions and 8 deletions

View File

@ -5366,11 +5366,10 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {
/*
* If a large allocation fails, the JS engine may call the large-allocation-
* failure callback, if set, to allow the embedding to flush caches, possibly
* perform shrinking GCs, etc. to make some room so that the allocation will
* succeed if retried. After the callback returns, the JS engine will try to
* allocate again and may be succesful.
* If a large allocation fails when calling pod_{calloc,realloc}CanGC, the JS
* engine may call the large-allocation- failure callback, if set, to allow the
* embedding to flush caches, possibly perform shrinking GCs, etc. to make some
* room. The allocation will then be retried (and may still fail.)
*/
typedef void

View File

@ -699,9 +699,8 @@ JSRuntime::onOutOfMemory(void *p, size_t nbytes, JSContext *cx)
void *
JSRuntime::onOutOfMemoryCanGC(void *p, size_t bytes)
{
if (!largeAllocationFailureCallback || bytes < LARGE_ALLOCATION)
return nullptr;
largeAllocationFailureCallback(largeAllocationFailureCallbackData);
if (largeAllocationFailureCallback && bytes >= LARGE_ALLOCATION)
largeAllocationFailureCallback(largeAllocationFailureCallbackData);
return onOutOfMemory(p, bytes);
}