gecko-dev/tools/profiler
Nicholas Nethercote 8876b32323 Bug 1345262 (part 5) - Fix how JS sampling is started/stopped by the profiler. r=mstange,djvj.
Currently, JS sampling has major problems.

- JS sampling is enabled for all JS threads from the thread that runs
  locked_profiler_start() -- currently only the main thread -- but the JS
  engine can't handle enabling from off-thread, and asserts. This makes
  profiling workers impossible in a debug build.

- No JS thread will be JS sampled unless enableJSSampling() is called, but that
  only happens in locked_profiler_start(). That means any worker threads
  created while the profiler is active won't be JS sampled.

- Only the thread that runs locked_profiler_stop() -- currently only the main
  thread -- ever calls disableJSSampling(). This means that worker threads that
  start being JS sampled never stop being JS sampled.

This patch fixes these three problems in the following ways.

- locked_profiler_start() now sets a flag in PseudoStack that indicates
  JS sampling is desired, but doesn't directly enable it. Instead, the JS
  thread polls that flag and enables JS sampling itself when it sees the flag
  is set. The polling is done by the interrupt callback. There was already a
  flag of this sort (mJSSampling) but the new one is better.

  This required adding a call to profiler_js_operation_callback() to the
  InterruptCallback() in XPCJSContext.cpp. (In comparison, the
  InterruptCallback() in dom/workers/RuntimeService.cpp already had such a
  call.)

- RegisterCurrentThread() now requests JS sampling of a JS thread when the
  profiler is active, the thread is being profiled, and JS sampling is enabled.

- locked_profiler_stop() now calls stopJSSampling() on all live threads.

The patch makes the following smaller changes as well.

- Renames profiler_js_operation_callback() as profiler_js_interrupt_callback(),
  because "interrupt callback" is the standard name (viz.
  JS_AddInterruptCallback()).

- Calls js::RegisterContextProfilingEventMarker() with nullptr when stopping
  JS sampling, so that ProfilerJSEventMarker won't fire unnecessarily.

- Some minor formatting changes.

--HG--
extra : rebase_source : 372f94c963a9e5b2493389892499b1ca205ebc2f
2017-03-10 09:04:23 +11:00
..
core Bug 1345262 (part 5) - Fix how JS sampling is started/stopped by the profiler. r=mstange,djvj. 2017-03-10 09:04:23 +11:00
gecko Bug 1346356 (part 4) - Clean up notification in the profiler. r=mstange. 2017-03-14 10:03:33 +11:00
lul Bug 1343557 - Make PfxInstr::operator== const; r=jseward 2017-03-01 15:26:29 -05:00
public Bug 1345262 (part 5) - Fix how JS sampling is started/stopped by the profiler. r=mstange,djvj. 2017-03-10 09:04:23 +11:00
tasktracer Bug 1346151 - Avoid compile time warning for format strings. r=cervantes 2017-03-10 02:03:00 -05:00
tests Bug 1340161 - Fix PseudoStack handling when profiler threads are marked with SetPendingDelete(). r=jseward. 2017-03-08 11:37:00 +11:00
merge-profiles.py
moz.build Bug 1328378 (part 6) - Eliminate SyncProfile. r=mstange. 2017-02-27 12:56:42 +11:00
nm-symbolicate.py