mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Bug 1445973: Part 2: Add 'clearSavedFrames' testing function to JS shell. r=jorendorff
OOM tests often depend on invoking a function repeatedly, failing a different allocation each time. Flushing the caches helps ensure consistent behavior from one invocation to the next. --HG-- extra : rebase_source : 0bf4a46c7c3e0bceb0fe77bbf96e422558a988c4 extra : source : 1a11067ab1e6b62602b79081e3208dcad31807bd
This commit is contained in:
parent
663b9d62d5
commit
8490101998
@ -1241,6 +1241,23 @@ GetSavedFrameCount(JSContext* cx, unsigned argc, Value* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ClearSavedFrames(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
js::SavedStacks& savedStacks = cx->compartment()->savedStacks();
|
||||
if (savedStacks.initialized())
|
||||
savedStacks.clear();
|
||||
|
||||
for (ActivationIterator iter(cx); !iter.done(); ++iter) {
|
||||
iter->clearLiveSavedFrameCache();
|
||||
}
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
SaveStack(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
@ -5170,6 +5187,12 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
|
||||
" Return the number of SavedFrame instances stored in this compartment's\n"
|
||||
" SavedStacks cache."),
|
||||
|
||||
JS_FN_HELP("clearSavedFrames", ClearSavedFrames, 0, 0,
|
||||
"clearSavedFrames()",
|
||||
" Empty the current compartment's cache of SavedFrame objects, so that\n"
|
||||
" subsequent stack captures allocate fresh objects to represent frames.\n"
|
||||
" Clear the current stack's LiveSavedFrameCaches."),
|
||||
|
||||
JS_FN_HELP("saveStack", SaveStack, 0, 0,
|
||||
"saveStack([maxDepth [, compartment]])",
|
||||
" Capture a stack. If 'maxDepth' is given, capture at most 'maxDepth' number\n"
|
||||
|
Loading…
Reference in New Issue
Block a user