gecko-dev/js
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
..
ductwork/debugger Bug 503613 - Remove old 'tail =' lines from xpcshell.ini files; r=gps 2017-01-18 10:30:39 +00:00
examples
ipc Bug 1339036 - Rename JSTYPE_VOID to JSTYPE_UNDEFINED. r=arai 2017-02-13 17:26:16 +01:00
public Bug 1346389. Make --enable-shared-js link again, at least for an opt mac build with intl api disabled. r=sfink, a=waldo on the gcc-specific bits. 2017-03-10 23:52:55 -05:00
src Merge inbound to central, a=merge 2017-03-14 17:18:59 -07:00
xpconnect 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
ffi.configure Bug 1335666 - Remove @depends_when. r=chmanchester 2017-02-01 16:25:29 +09:00
moz.configure Backed out changeset 54d759872a2c (bug 1332466) for build failures a=backout 2017-02-02 16:05:55 -08:00