Bug 1054630 - Part 1: Add plumbing for SpiderMonkey parser telemetry. r=till

This commit is contained in:
Chris Peterson 2014-08-23 13:35:17 -07:00
parent 9ba80f83cb
commit 3b4765acc2
5 changed files with 40 additions and 1 deletions

View File

@ -449,6 +449,8 @@ Parser<ParseHandler>::Parser(ExclusiveContext *cx, LifoAlloc *alloc,
template <typename ParseHandler>
Parser<ParseHandler>::~Parser()
{
accumulateTelemetry();
alloc.release(tempPoolMark);
/*
@ -7567,6 +7569,29 @@ Parser<ParseHandler>::exprInParens()
return pn;
}
template <typename ParseHandler>
void
Parser<ParseHandler>::accumulateTelemetry()
{
JSContext* cx = context->maybeJSContext();
if (!cx)
return;
JSAccumulateTelemetryDataCallback cb = cx->runtime()->telemetryCallback;
if (!cb)
return;
const char* filename = getFilename();
if (!filename)
return;
bool isHTTP = strncmp(filename, "http://", 7) == 0 || strncmp(filename, "https://", 8) == 0;
// Only report telemetry for web content, not add-ons or chrome JS.
if (!isHTTP)
return;
// TODO: Call back into Firefox's Telemetry reporter.
}
template class Parser<FullParseHandler>;
template class Parser<SyntaxParseHandler>;

View File

@ -658,6 +658,8 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
bool asmJS(Node list);
void accumulateTelemetry();
friend class LegacyCompExprTransplanter;
friend struct BindData<ParseHandler>;
};

View File

@ -119,7 +119,8 @@ enum {
JS_TELEMETRY_GC_INCREMENTAL_DISABLED,
JS_TELEMETRY_GC_NON_INCREMENTAL,
JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS,
JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS
JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS,
JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT
};
typedef void

View File

@ -2929,6 +2929,11 @@ AccumulateTelemetryCallback(int id, uint32_t sample)
case JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS:
Telemetry::Accumulate(Telemetry::GC_SCC_SWEEP_MAX_PAUSE_MS, sample);
break;
case JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT:
Telemetry::Accumulate(Telemetry::JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, sample);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected JS_TELEMETRY id");
}
}

View File

@ -318,6 +318,12 @@
"kind": "flag",
"description": "Has seen location error"
},
"JS_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT": {
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 10,
"description": "Use of SpiderMonkey's deprecated language extensions in web content"
},
"TELEMETRY_PING": {
"expires_in_version": "never",
"kind": "exponential",