зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1514007 - Annotate <script> evaluation profiler labels with async/defer. r=smaug
This also moves the label from ScriptLoader::ProcessScriptElement to ScriptLoader::EvaluateScript so that it also kicks in for scripts that are run from NotifyOffThreadScriptLoadCompletedRunnable::Run. Differential Revision: https://phabricator.services.mozilla.com/D14924 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
19405e9ba6
Коммит
9570f02a8c
|
@ -1431,14 +1431,6 @@ bool ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement) {
|
|||
|
||||
NS_ASSERTION(!aElement->IsMalformed(), "Executing malformed script");
|
||||
|
||||
nsAutoCString url;
|
||||
nsCOMPtr<nsIURI> scriptURI = aElement->GetScriptURI();
|
||||
if (scriptURI) {
|
||||
scriptURI->GetAsciiSpec(url);
|
||||
}
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("ScriptLoader::ProcessScriptElement",
|
||||
JS, url);
|
||||
|
||||
nsCOMPtr<nsIContent> scriptContent = do_QueryInterface(aElement);
|
||||
|
||||
nsAutoString type;
|
||||
|
@ -2462,6 +2454,49 @@ static nsresult ExecuteCompiledScript(JSContext* aCx,
|
|||
return aExec.ExecScript();
|
||||
}
|
||||
|
||||
static void GetProfilerLabelForRequest(ScriptLoadRequest* aRequest,
|
||||
nsACString& aOutString) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!profiler_is_active()) {
|
||||
aOutString.Append("<script> element");
|
||||
return;
|
||||
}
|
||||
aOutString.Append("<script");
|
||||
if (aRequest->IsAsyncScript()) {
|
||||
aOutString.Append(" async");
|
||||
} else if (aRequest->IsDeferredScript()) {
|
||||
aOutString.Append(" defer");
|
||||
}
|
||||
if (aRequest->IsModuleRequest()) {
|
||||
aOutString.Append(" type=\"module\"");
|
||||
}
|
||||
|
||||
nsAutoCString url;
|
||||
if (aRequest->mURI) {
|
||||
aRequest->mURI->GetAsciiSpec(url);
|
||||
} else {
|
||||
url = "<unknown>";
|
||||
}
|
||||
|
||||
if (aRequest->mIsInline) {
|
||||
if (aRequest->GetParserCreated() != NOT_FROM_PARSER) {
|
||||
aOutString.Append("> inline at line ");
|
||||
aOutString.AppendInt(aRequest->mLineNo);
|
||||
aOutString.Append(" of ");
|
||||
} else {
|
||||
aOutString.Append("> inline (dynamically created) in ");
|
||||
}
|
||||
aOutString.Append(url);
|
||||
} else {
|
||||
aOutString.Append(" src=\"");
|
||||
aOutString.Append(url);
|
||||
aOutString.Append("\">");
|
||||
}
|
||||
#else
|
||||
aOutString.Append("<script> element");
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
|
||||
using namespace mozilla::Telemetry;
|
||||
MOZ_ASSERT(aRequest->IsReadyToRun());
|
||||
|
@ -2499,7 +2534,9 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
|
|||
// New script entry point required, due to the "Create a script" sub-step of
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-block
|
||||
nsAutoMicroTask mt;
|
||||
AutoEntryScript aes(globalObject, "<script> element", true);
|
||||
nsAutoCString profilerLabelString;
|
||||
GetProfilerLabelForRequest(aRequest, profilerLabelString);
|
||||
AutoEntryScript aes(globalObject, profilerLabelString.get(), true);
|
||||
JSContext* cx = aes.cx();
|
||||
JS::Rooted<JSObject*> global(cx, globalObject->GetGlobalJSObject());
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче