Bug 963312 - Get JS engine telemetry values from Components.utils, not nsIXPConnect. r=bholley,taras
authorAndrew McCreight <continuation@gmail.com>
Sun, 26 Jan 2014 07:57:00 -0800
changeset 181279 b182f29bb7b1ebb63554dbfb5155548190fe3648
parent 181278 99c61f40109b72615ac80d44f98a7933870cd46a
child 181280 d25dbecf3769d8df80fdb247c041ada00af1c02e
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, taras
bugs963312
milestone29.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 963312 - Get JS engine telemetry values from Components.utils, not nsIXPConnect. r=bholley,taras
js/xpconnect/idl/moz.build
js/xpconnect/idl/nsIJSEngineTelemetryStats.idl
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
toolkit/components/telemetry/TelemetryPing.jsm
--- a/js/xpconnect/idl/moz.build
+++ b/js/xpconnect/idl/moz.build
@@ -1,17 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'mozIJSSubScriptLoader.idl',
-    'nsIJSEngineTelemetryStats.idl',
     'nsIJSRuntimeService.idl',
     'nsIScriptError.idl',
     'nsIXPConnect.idl',
     'nsIXPCScriptable.idl',
     'nsIXPCSecurityManager.idl',
     'xpccomponents.idl',
     'xpcexception.idl',
     'xpcIJSGetFactory.idl',
deleted file mode 100644
--- a/js/xpconnect/idl/nsIJSEngineTelemetryStats.idl
+++ /dev/null
@@ -1,21 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-/**
- * Telemetry uses this interface on the @mozilla.org/js/xpc/XPConnect;1 service
- * to extract JS engine stats.
- */
-[scriptable, uuid(5a6ea52b-4e23-402f-93e3-59f29b2f1a88)]
-interface nsIJSEngineTelemetryStats : nsISupports
-{
-  /**
-   * The value returned by this attribute is included as the 'js' property of
-   * the telemetry ping JSON blob.
-   */
-  [implicit_jscontext]
-  readonly attribute jsval telemetryValue;
-};
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -115,17 +115,17 @@ interface nsIXPCComponents_utils_Sandbox
 interface ScheduledGCCallback : nsISupports
 {
     void callback();
 };
 
 /**
 * interface of Components.utils
 */
-[scriptable, uuid(872b0aa4-c234-4c46-b72c-1bc861d6c5eb)]
+[scriptable, uuid(c9ab0d20-8499-11e3-baa7-0800200c9a66)]
 interface nsIXPCComponents_Utils : nsISupports
 {
 
     /* reportError is designed to be called from JavaScript only.
      *
      * It will report a JS Error object to the JS console, and return. It
      * is meant for use in exception handler blocks which want to "eat"
      * an exception, but still want to report it to the console.
@@ -253,30 +253,30 @@ interface nsIXPCComponents_Utils : nsISu
     void forceGC();
 
     /*
      * To be called from JS only.
      *
      * Force an immediate cycle collection cycle.
      */
     void forceCC();
-    
+
     /*
      * To be called from JS only.
      *
      * Force an immediate shrinking garbage collection cycle.
      */
     void forceShrinkingGC();
 
     /*
      * Schedule a garbage collection cycle for a point in the future when no JS
      * is running. Call the provided function once this has occurred.
      */
     void schedulePreciseGC(in ScheduledGCCallback callback);
-    
+
     /*
      * Schedule a shrinking garbage collection cycle for a point in the future
      * when no JS is running. Call the provided function once this has occured.
      */
     void schedulePreciseShrinkingGC(in ScheduledGCCallback callback);
 
     /**
      * Return the keys in a weak map.  This operation is
@@ -543,16 +543,19 @@ interface nsIXPCComponents_Utils : nsISu
       *
       * Valid categories:
       *   "RuntimeStateChange"      - Runtime switching between active and inactive states
       *   "WatchdogWakeup"          - Watchdog waking up from sleeping
       *   "WatchdogHibernateStart"  - Watchdog begins hibernating
       *   "WatchdogHibernateStop"   - Watchdog stops hibernating
       */
     PRTime getWatchdogTimestamp(in AString aCategory);
+
+    [implicit_jscontext]
+    jsval getJSEngineTelemetryValue();
 };
 
 /**
 * Interface for the 'Components' object.
 *
 * The first interface contains things that are available to non-chrome XBL code
 * that runs in a scope with an nsExpandedPrincipal. The second interface
 * includes members that are only exposed to chrome.
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3437,16 +3437,39 @@ nsXPCComponents_Utils::GetWatchdogTimest
     else if (aCategory.EqualsLiteral("WatchdogHibernateStop"))
         category = TimestampWatchdogHibernateStop;
     else
         return NS_ERROR_INVALID_ARG;
     *aOut = XPCJSRuntime::Get()->GetWatchdogTimestamp(category);
     return NS_OK;
 }
 
+NS_IMETHODIMP
+nsXPCComponents_Utils::GetJSEngineTelemetryValue(JSContext *cx, MutableHandleValue rval)
+{
+    RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
+    if (!obj)
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    unsigned attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
+
+    size_t i = JS_SetProtoCalled(cx);
+    RootedValue v(cx, DoubleValue(i));
+    if (!JS_DefineProperty(cx, obj, "setProto", v, nullptr, nullptr, attrs))
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    i = JS_GetCustomIteratorCount(cx);
+    v.setDouble(i);
+    if (!JS_DefineProperty(cx, obj, "customIter", v, nullptr, nullptr, attrs))
+        return NS_ERROR_OUT_OF_MEMORY;
+
+    rval.setObject(*obj);
+    return NS_OK;
+}
+
 /***************************************************************************/
 /***************************************************************************/
 /***************************************************************************/
 
 
 nsXPCComponentsBase::nsXPCComponentsBase(XPCWrappedNativeScope* aScope)
     :   mScope(aScope)
 {
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -44,22 +44,21 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace xpc;
 using namespace JS;
 
 using mozilla::dom::indexedDB::IndexedDatabaseManager;
 
-NS_IMPL_ISUPPORTS5(nsXPConnect,
+NS_IMPL_ISUPPORTS4(nsXPConnect,
                    nsIXPConnect,
                    nsISupportsWeakReference,
                    nsIThreadObserver,
-                   nsIJSRuntimeService,
-                   nsIJSEngineTelemetryStats)
+                   nsIJSRuntimeService)
 
 nsXPConnect* nsXPConnect::gSelf = nullptr;
 bool         nsXPConnect::gOnceAliveNowDead = false;
 uint32_t     nsXPConnect::gReportAllJSExceptions = 0;
 
 bool         xpc::gDebugMode = false;
 bool         xpc::gDesiredDebugMode = false;
 
@@ -1403,39 +1402,16 @@ nsXPConnect::SetDebugModeWhenPossible(bo
 {
     gDesiredDebugMode = mode;
     if (!mode && allowSyncDisable)
         CheckForDebugMode(mRuntime->Runtime());
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXPConnect::GetTelemetryValue(JSContext *cx, MutableHandleValue rval)
-{
-    RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
-    if (!obj)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    unsigned attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
-
-    size_t i = JS_SetProtoCalled(cx);
-    RootedValue v(cx, DoubleValue(i));
-    if (!JS_DefineProperty(cx, obj, "setProto", v, nullptr, nullptr, attrs))
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    i = JS_GetCustomIteratorCount(cx);
-    v.setDouble(i);
-    if (!JS_DefineProperty(cx, obj, "customIter", v, nullptr, nullptr, attrs))
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    rval.setObject(*obj);
-    return NS_OK;
-}
-
-NS_IMETHODIMP
 nsXPConnect::NotifyDidPaint()
 {
     JS::NotifyDidPaint(GetRuntime()->Runtime());
     return NS_OK;
 }
 
 static const uint8_t HAS_PRINCIPALS_FLAG               = 1;
 static const uint8_t HAS_ORIGIN_PRINCIPALS_FLAG        = 2;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -120,17 +120,16 @@
 #include "prclist.h"
 #include "prcvar.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsXPIDLString.h"
 #include "nsAutoJSValHolder.h"
 
 #include "MainThreadUtils.h"
-#include "nsIJSEngineTelemetryStats.h"
 
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIException.h"
 
 #include "nsVariant.h"
 #include "nsIPropertyBag.h"
 #include "nsIProperty.h"
@@ -264,26 +263,24 @@ inline bool
 AddToCCKind(JSGCTraceKind kind)
 {
     return kind == JSTRACE_OBJECT || kind == JSTRACE_SCRIPT;
 }
 
 class nsXPConnect : public nsIXPConnect,
                     public nsIThreadObserver,
                     public nsSupportsWeakReference,
-                    public nsIJSRuntimeService,
-                    public nsIJSEngineTelemetryStats
+                    public nsIJSRuntimeService
 {
 public:
     // all the interface method declarations...
     NS_DECL_ISUPPORTS
     NS_DECL_NSIXPCONNECT
     NS_DECL_NSITHREADOBSERVER
     NS_DECL_NSIJSRUNTIMESERVICE
-    NS_DECL_NSIJSENGINETELEMETRYSTATS
 
     // non-interface implementation
 public:
     // These get non-addref'd pointers
     static nsXPConnect*  XPConnect()
     {
         // Do a release-mode assert that we're not doing anything significant in
         // XPConnect off the main thread. If you're an extension developer hitting
--- a/toolkit/components/telemetry/TelemetryPing.jsm
+++ b/toolkit/components/telemetry/TelemetryPing.jsm
@@ -264,19 +264,17 @@ let Impl = {
     ret.startupInterrupted = new Number(Services.startup.interrupted);
 
     // Update debuggerAttached flag
     let debugService = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
     let isDebuggerAttached = debugService.isDebuggerAttached;
     gWasDebuggerAttached = gWasDebuggerAttached || isDebuggerAttached;
     ret.debuggerAttached = new Number(gWasDebuggerAttached);
 
-    ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
-      .getService(Ci.nsIJSEngineTelemetryStats)
-      .telemetryValue;
+    ret.js = Cu.getJSEngineTelemetryValue();
 
     let shutdownDuration = Telemetry.lastShutdownDuration;
     if (shutdownDuration)
       ret.shutdownDuration = shutdownDuration;
 
     let failedProfileLockCount = Telemetry.failedProfileLockCount;
     if (failedProfileLockCount)
       ret.failedProfileLockCount = failedProfileLockCount;