Bug 1611053 - Add profiler marker for XPCJSContext::InterruptScript; r=gerald

Differential Revision: https://phabricator.services.mozilla.com/D60792

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jim Porter 2020-03-14 11:33:46 +00:00
Родитель 029804e3f7
Коммит 11bcce27a9
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -61,6 +61,9 @@
#include "nsIXULRuntime.h"
#include "nsJSPrincipals.h"
#include "ExpandedPrincipal.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
#endif
#if defined(XP_LINUX) && !defined(ANDROID)
// For getrlimit and min/max.
@ -582,6 +585,21 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
// Now is a good time to turn on profiling if it's pending.
PROFILER_JS_INTERRUPT_CALLBACK();
#ifdef MOZ_GECKO_PROFILER
nsDependentCString filename("unknown file");
JS::AutoFilename scriptFilename;
// Computing the line number can be very expensive (see bug 1330231 for
// example), so don't request it here.
if (JS::DescribeScriptedCaller(cx, &scriptFilename)) {
if (const char* file = scriptFilename.get()) {
filename.Assign(file, strlen(file));
}
PROFILER_ADD_MARKER_WITH_PAYLOAD("JS::InterruptCallback", JS,
TextMarkerPayload,
(filename, TimeStamp::Now()));
}
#endif
// Normally we record mSlowScriptCheckpoint when we start to process an
// event. However, we can run JS outside of event handlers. This code takes
// care of that case.