mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
8876b32323
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 |
||
---|---|---|
.. | ||
core | ||
gecko | ||
lul | ||
public | ||
tasktracer | ||
tests | ||
merge-profiles.py | ||
moz.build | ||
nm-symbolicate.py |