mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1141234 - Part 1: Abstract PossiblyFail into the OOM testing machinery; r=sfink
This commit is contained in:
parent
74500c29ee
commit
180d3adfed
@ -95,9 +95,22 @@ static MOZ_NEVER_INLINE void js_failedAllocBreakpoint() { asm(""); }
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
namespace js {
|
||||
namespace oom {
|
||||
static inline bool ShouldFailWithOOM()
|
||||
{
|
||||
if (++OOM_counter > OOM_maxAllocations) {
|
||||
JS_OOM_CALL_BP_FUNC();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
# else
|
||||
# define JS_OOM_POSSIBLY_FAIL() do {} while(0)
|
||||
# define JS_OOM_POSSIBLY_FAIL_BOOL() do {} while(0)
|
||||
namespace js { namespace oom { static inline bool ShouldFailWithOOM() { return false; } } }
|
||||
# endif /* DEBUG || JS_OOM_BREAKPOINT */
|
||||
|
||||
static inline void* js_malloc(size_t bytes)
|
||||
|
@ -53,13 +53,6 @@ TryNewNurseryObject(JSContext *cx, size_t thingSize, size_t nDynamicSlots, const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
PossiblyFail()
|
||||
{
|
||||
JS_OOM_POSSIBLY_FAIL_BOOL();
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
GCIfNeeded(ExclusiveContext *cx)
|
||||
{
|
||||
@ -121,7 +114,7 @@ CheckAllocatorState(ExclusiveContext *cx, AllocKind kind)
|
||||
JS::AutoAssertOnGC::VerifyIsSafeToGC(rt);
|
||||
|
||||
// For testing out of memory conditions
|
||||
if (!PossiblyFail()) {
|
||||
if (js::oom::ShouldFailWithOOM()) {
|
||||
ReportOutOfMemory(ncx);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user