зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1209911 - Add oomThreadTypes() test function to report the number of thread types we can simulate OOM on r=terrence
--HG-- extra : rebase_source : facfa7ff892375e7c5999cd9310948866542e2f9
This commit is contained in:
Родитель
810fbfb206
Коммит
298b347ff4
|
@ -984,6 +984,14 @@ DisableTrackAllocations(JSContext* cx, unsigned argc, Value* vp)
|
|||
}
|
||||
|
||||
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
|
||||
static bool
|
||||
OOMThreadTypes(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(js::oom::THREAD_TYPE_MAX);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
OOMAfterAllocations(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
|
@ -2928,6 +2936,11 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
|
|||
" Stop capturing the JS stack at every allocation."),
|
||||
|
||||
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
|
||||
JS_FN_HELP("oomThreadTypes", OOMThreadTypes, 0, 0,
|
||||
"oomThreadTypes()",
|
||||
" Get the number of thread types that can be used as an argument for\n"
|
||||
"oomAfterAllocations() and oomAtAllocation()."),
|
||||
|
||||
JS_FN_HELP("oomAfterAllocations", OOMAfterAllocations, 2, 0,
|
||||
"oomAfterAllocations(count [,threadType])",
|
||||
" After 'count' js_malloc memory allocations, fail every following allocation\n"
|
||||
|
|
|
@ -1,25 +1,29 @@
|
|||
// Function to test OOM handling by repeatedly calling a function and failing
|
||||
// successive allocations.
|
||||
|
||||
const verbose = false;
|
||||
|
||||
if (!("oomAtAllocation" in this && "resetOOMFailure" in this))
|
||||
if (!("oomAtAllocation" in this && "resetOOMFailure" in this && "oomThreadTypes" in this))
|
||||
quit();
|
||||
|
||||
if ("gczeal" in this)
|
||||
gczeal(0);
|
||||
|
||||
const verbose = ("os" in this) && os.getenv("OOM_VERBOSE");
|
||||
|
||||
// Test out of memory handing by calling a function f() while causing successive
|
||||
// memory allocations to fail. Repeat until f() finishes without reaching the
|
||||
// failing allocation.
|
||||
function oomTest(f) {
|
||||
for (let thread = 1; thread < oomThreadTypes(); thread++) {
|
||||
if (verbose)
|
||||
print("testing thread " + thread);
|
||||
|
||||
var i = 1;
|
||||
var more;
|
||||
do {
|
||||
if (verbose)
|
||||
print("fail at " + i);
|
||||
try {
|
||||
oomAtAllocation(i);
|
||||
oomAtAllocation(i, thread);
|
||||
f();
|
||||
more = resetOOMFailure();
|
||||
} catch (e) {
|
||||
|
@ -30,5 +34,6 @@ function oomTest(f) {
|
|||
} while(more);
|
||||
|
||||
if (verbose)
|
||||
print("finished after " + i);
|
||||
print("finished after " + (i - 2) + " failures");
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче