зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1278265 - Give each JS shell thread its own SPS pseudo stack to avoid races. r=sfink
This commit is contained in:
Родитель
cae841f134
Коммит
a877b2bc01
|
@ -1561,67 +1561,6 @@ Terminate(JSContext* cx, unsigned arg, Value* vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
#define SPS_PROFILING_STACK_MAX_SIZE 1000
|
||||
static ProfileEntry SPS_PROFILING_STACK[SPS_PROFILING_STACK_MAX_SIZE];
|
||||
static uint32_t SPS_PROFILING_STACK_SIZE = 0;
|
||||
|
||||
static bool
|
||||
EnableSPSProfiling(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
// Disable before re-enabling; see the assertion in |SPSProfiler::setProfilingStack|.
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
|
||||
SetRuntimeProfilingStack(cx->runtime(), SPS_PROFILING_STACK, &SPS_PROFILING_STACK_SIZE,
|
||||
SPS_PROFILING_STACK_MAX_SIZE);
|
||||
cx->runtime()->spsProfiler.enableSlowAssertions(false);
|
||||
cx->runtime()->spsProfiler.enable(true);
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
EnableSPSProfilingWithSlowAssertions(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setUndefined();
|
||||
|
||||
if (cx->runtime()->spsProfiler.enabled()) {
|
||||
// If profiling already enabled with slow assertions disabled,
|
||||
// this is a no-op.
|
||||
if (cx->runtime()->spsProfiler.slowAssertionsEnabled())
|
||||
return true;
|
||||
|
||||
// Slow assertions are off. Disable profiling before re-enabling
|
||||
// with slow assertions on.
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
}
|
||||
|
||||
// Disable before re-enabling; see the assertion in |SPSProfiler::setProfilingStack|.
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
|
||||
SetRuntimeProfilingStack(cx->runtime(), SPS_PROFILING_STACK, &SPS_PROFILING_STACK_SIZE,
|
||||
SPS_PROFILING_STACK_MAX_SIZE);
|
||||
cx->runtime()->spsProfiler.enableSlowAssertions(true);
|
||||
cx->runtime()->spsProfiler.enable(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DisableSPSProfiling(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ReadSPSProfilingStack(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
|
@ -3787,20 +3726,6 @@ gc::ZealModeHelpText),
|
|||
" Terminate JavaScript execution, as if we had run out of\n"
|
||||
" memory or been terminated by the slow script dialog."),
|
||||
|
||||
JS_FN_HELP("enableSPSProfiling", EnableSPSProfiling, 0, 0,
|
||||
"enableSPSProfiling()",
|
||||
" Enables SPS instrumentation and corresponding assertions, with slow\n"
|
||||
" assertions disabled.\n"),
|
||||
|
||||
JS_FN_HELP("enableSPSProfilingWithSlowAssertions", EnableSPSProfilingWithSlowAssertions, 0, 0,
|
||||
"enableSPSProfilingWithSlowAssertions()",
|
||||
" Enables SPS instrumentation and corresponding assertions, with slow\n"
|
||||
" assertions enabled.\n"),
|
||||
|
||||
JS_FN_HELP("disableSPSProfiling", DisableSPSProfiling, 0, 0,
|
||||
"disableSPSProfiling()",
|
||||
" Disables SPS instrumentation"),
|
||||
|
||||
JS_FN_HELP("readSPSProfilingStack", ReadSPSProfilingStack, 0, 0,
|
||||
"readSPSProfilingStack()",
|
||||
" Reads the jit stack using ProfilingFrameIterator."),
|
||||
|
|
|
@ -184,6 +184,10 @@ struct ShellRuntime
|
|||
|
||||
UniqueChars readLineBuf;
|
||||
size_t readLineBufPos;
|
||||
|
||||
static const uint32_t SpsProfilingMaxStackSize = 1000;
|
||||
ProfileEntry spsProfilingStack[SpsProfilingMaxStackSize];
|
||||
uint32_t spsProfilingStackSize;
|
||||
};
|
||||
|
||||
struct MOZ_STACK_CLASS EnvironmentPreparer : public js::ScriptEnvironmentPreparer {
|
||||
|
@ -327,7 +331,8 @@ ShellRuntime::ShellRuntime(JSRuntime* rt)
|
|||
#endif // SPIDERMONKEY_PROMISE
|
||||
exitCode(0),
|
||||
quitting(false),
|
||||
readLineBufPos(0)
|
||||
readLineBufPos(0),
|
||||
spsProfilingStackSize(0)
|
||||
{}
|
||||
|
||||
static ShellRuntime*
|
||||
|
@ -4620,6 +4625,67 @@ IsLatin1(JSContext* cx, unsigned argc, Value* vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
EnableSPSProfiling(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
ShellRuntime* sr = GetShellRuntime(cx);
|
||||
|
||||
// Disable before re-enabling; see the assertion in |SPSProfiler::setProfilingStack|.
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
|
||||
SetRuntimeProfilingStack(cx->runtime(), sr->spsProfilingStack, &sr->spsProfilingStackSize,
|
||||
ShellRuntime::SpsProfilingMaxStackSize);
|
||||
cx->runtime()->spsProfiler.enableSlowAssertions(false);
|
||||
cx->runtime()->spsProfiler.enable(true);
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
EnableSPSProfilingWithSlowAssertions(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setUndefined();
|
||||
|
||||
ShellRuntime* sr = GetShellRuntime(cx);
|
||||
|
||||
if (cx->runtime()->spsProfiler.enabled()) {
|
||||
// If profiling already enabled with slow assertions disabled,
|
||||
// this is a no-op.
|
||||
if (cx->runtime()->spsProfiler.slowAssertionsEnabled())
|
||||
return true;
|
||||
|
||||
// Slow assertions are off. Disable profiling before re-enabling
|
||||
// with slow assertions on.
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
}
|
||||
|
||||
// Disable before re-enabling; see the assertion in |SPSProfiler::setProfilingStack|.
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
|
||||
SetRuntimeProfilingStack(cx->runtime(), sr->spsProfilingStack, &sr->spsProfilingStackSize,
|
||||
ShellRuntime::SpsProfilingMaxStackSize);
|
||||
cx->runtime()->spsProfiler.enableSlowAssertions(true);
|
||||
cx->runtime()->spsProfiler.enable(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DisableSPSProfiling(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (cx->runtime()->spsProfiler.installed())
|
||||
cx->runtime()->spsProfiler.enable(false);
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Global mailbox that is used to communicate a SharedArrayBuffer
|
||||
// value from one worker to another.
|
||||
//
|
||||
|
@ -5573,6 +5639,20 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
|
|||
"disableSingleStepProfiling()",
|
||||
" Return the array of backtraces recorded by enableSingleStepProfiling."),
|
||||
|
||||
JS_FN_HELP("enableSPSProfiling", EnableSPSProfiling, 0, 0,
|
||||
"enableSPSProfiling()",
|
||||
" Enables SPS instrumentation and corresponding assertions, with slow\n"
|
||||
" assertions disabled.\n"),
|
||||
|
||||
JS_FN_HELP("enableSPSProfilingWithSlowAssertions", EnableSPSProfilingWithSlowAssertions, 0, 0,
|
||||
"enableSPSProfilingWithSlowAssertions()",
|
||||
" Enables SPS instrumentation and corresponding assertions, with slow\n"
|
||||
" assertions enabled.\n"),
|
||||
|
||||
JS_FN_HELP("disableSPSProfiling", DisableSPSProfiling, 0, 0,
|
||||
"disableSPSProfiling()",
|
||||
" Disables SPS instrumentation"),
|
||||
|
||||
JS_FN_HELP("isLatin1", IsLatin1, 1, 0,
|
||||
"isLatin1(s)",
|
||||
" Return true iff the string's characters are stored as Latin1."),
|
||||
|
|
Загрузка…
Ссылка в новой задаче