mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1155618 - Don't retry memory allocation if we're simulating OOM r=terrence
This commit is contained in:
parent
47cc82c456
commit
57d849ede0
@ -82,17 +82,25 @@ static MOZ_NEVER_INLINE void js_failedAllocBreakpoint() { asm(""); }
|
||||
|
||||
namespace js {
|
||||
namespace oom {
|
||||
static inline bool ShouldFailWithOOM()
|
||||
|
||||
static inline bool
|
||||
IsSimulatedOOMAllocation()
|
||||
{
|
||||
return OOM_counter == OOM_maxAllocations ||
|
||||
(OOM_counter > OOM_maxAllocations && OOM_failAlways);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ShouldFailWithOOM()
|
||||
{
|
||||
OOM_counter++;
|
||||
if (OOM_counter == OOM_maxAllocations ||
|
||||
(OOM_counter > OOM_maxAllocations && OOM_failAlways))
|
||||
{
|
||||
if (IsSimulatedOOMAllocation()) {
|
||||
JS_OOM_CALL_BP_FUNC();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace oom */
|
||||
} /* namespace js */
|
||||
|
||||
@ -114,6 +122,7 @@ static inline bool ShouldFailWithOOM()
|
||||
# define JS_OOM_POSSIBLY_FAIL_BOOL() do {} while(0)
|
||||
namespace js {
|
||||
namespace oom {
|
||||
static inline bool IsSimulatedOOMAllocation() { return false; }
|
||||
static inline bool ShouldFailWithOOM() { return false; }
|
||||
} /* namespace oom */
|
||||
} /* namespace js */
|
||||
|
@ -744,27 +744,29 @@ JSRuntime::onOutOfMemory(AllocFunction allocFunc, size_t nbytes, void* reallocPt
|
||||
if (isHeapBusy())
|
||||
return nullptr;
|
||||
|
||||
/*
|
||||
* Retry when we are done with the background sweeping and have stopped
|
||||
* all the allocations and released the empty GC chunks.
|
||||
*/
|
||||
gc.onOutOfMallocMemory();
|
||||
void* p;
|
||||
switch (allocFunc) {
|
||||
case AllocFunction::Malloc:
|
||||
p = js_malloc(nbytes);
|
||||
break;
|
||||
case AllocFunction::Calloc:
|
||||
p = js_calloc(nbytes);
|
||||
break;
|
||||
case AllocFunction::Realloc:
|
||||
p = js_realloc(reallocPtr, nbytes);
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
if (!oom::IsSimulatedOOMAllocation()) {
|
||||
/*
|
||||
* Retry when we are done with the background sweeping and have stopped
|
||||
* all the allocations and released the empty GC chunks.
|
||||
*/
|
||||
gc.onOutOfMallocMemory();
|
||||
void* p;
|
||||
switch (allocFunc) {
|
||||
case AllocFunction::Malloc:
|
||||
p = js_malloc(nbytes);
|
||||
break;
|
||||
case AllocFunction::Calloc:
|
||||
p = js_calloc(nbytes);
|
||||
break;
|
||||
case AllocFunction::Realloc:
|
||||
p = js_realloc(reallocPtr, nbytes);
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
if (p)
|
||||
return p;
|
||||
}
|
||||
if (p)
|
||||
return p;
|
||||
|
||||
if (maybecx)
|
||||
ReportOutOfMemory(maybecx);
|
||||
|
Loading…
Reference in New Issue
Block a user