Bug 1133900 - Only collect JS telemetry for web content (not add-on or chrome JS). r=jandem
authorChris Peterson <cpeterson@mozilla.com>
Tue, 17 Feb 2015 11:00:02 -0800
changeset 256947 d563f8e2d157bf939a02671a59e97b94a2618248
parent 256946 b213954a5d30d946088cc8267d7c064753cec0a4
child 256948 a58a44e992d2918fe9af10dae182cb65a2b24046
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1133900
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1133900 - Only collect JS telemetry for web content (not add-on or chrome JS). r=jandem
js/src/frontend/Parser.cpp
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/vm/Interpreter.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -8381,16 +8381,16 @@ Parser<ParseHandler>::exprInParens()
 
 template <typename ParseHandler>
 void
 Parser<ParseHandler>::addTelemetry(JSCompartment::DeprecatedLanguageExtension e)
 {
     JSContext* cx = context->maybeJSContext();
     if (!cx)
         return;
-    cx->compartment()->addTelemetry(e);
+    cx->compartment()->addTelemetry(getFilename(), e);
 }
 
 template class Parser<FullParseHandler>;
 template class Parser<SyntaxParseHandler>;
 
 } /* namespace frontend */
 } /* namespace js */
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -851,8 +851,18 @@ JSCompartment::reportTelemetry()
     JS::AutoSuppressGCAnalysis nogc;
 
     // Call back into Firefox's Telemetry reporter.
     for (size_t i = 0; i < DeprecatedLanguageExtensionCount; i++) {
         if (sawDeprecatedLanguageExtension[i])
             runtime_->addTelemetry(JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, i);
     }
 }
+
+void
+JSCompartment::addTelemetry(const char *filename, DeprecatedLanguageExtension e)
+{
+    // Only report telemetry for web content, not add-ons or chrome JS.
+    if (addonId || isSystem || !filename || strncmp(filename, "http", 4) != 0)
+        return;
+
+    sawDeprecatedLanguageExtension[e] = true;
+}
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -553,19 +553,17 @@ struct JSCompartment
 
   private:
     // Used for collecting telemetry on SpiderMonkey's deprecated language extensions.
     bool sawDeprecatedLanguageExtension[DeprecatedLanguageExtensionCount];
 
     void reportTelemetry();
 
   public:
-    void addTelemetry(DeprecatedLanguageExtension e) {
-        sawDeprecatedLanguageExtension[e] = true;
-    }
+    void addTelemetry(const char *filename, DeprecatedLanguageExtension e);
 };
 
 inline bool
 JSRuntime::isAtomsZone(JS::Zone *zone)
 {
     return zone == atomsCompartment_->zone();
 }
 
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -195,17 +195,21 @@ NoSuchMethod(JSContext *cx, unsigned arg
     args[0].set(obj->getReservedSlot(JSSLOT_SAVED_ID));
     JSObject *argsobj = NewDenseCopiedArray(cx, argc, vp + 2);
     if (!argsobj)
         return false;
     args[1].setObject(*argsobj);
     bool ok = Invoke(cx, args);
     vp[0] = args.rval();
 
-    cx->compartment()->addTelemetry(JSCompartment::DeprecatedNoSuchMethod);
+    if (JSScript *script = cx->currentScript()) {
+        const char *filename = script->filename();
+        cx->compartment()->addTelemetry(filename, JSCompartment::DeprecatedNoSuchMethod);
+    }
+
     return ok;
 }
 
 #endif /* JS_HAS_NO_SUCH_METHOD */
 
 static inline bool
 GetPropertyOperation(JSContext *cx, InterpreterFrame *fp, HandleScript script, jsbytecode *pc,
                      MutableHandleValue lval, MutableHandleValue vp)