Bug 1234600 - executeSoon async stacks only when DEBUG_JS_MODULES enabled. r=fitzgen
authorJ. Ryan Stinnett <jryans@gmail.com>
Thu, 07 Jan 2016 18:37:12 -0600
changeset 279154 92cb3865720d4b52244774b2d08d77d3a4fdf5c2
parent 279153 22557c6ebe30ec70e64666c2ec5f6343076cbe6a
child 279155 22e911e48008d437706ef270a8cfa43ed6d2c777
push id69998
push userjryans@gmail.com
push dateFri, 08 Jan 2016 20:12:42 +0000
treeherdermozilla-inbound@92cb3865720d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1234600
milestone46.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 1234600 - executeSoon async stacks only when DEBUG_JS_MODULES enabled. r=fitzgen
devtools/shared/DevToolsUtils.js
devtools/shared/tests/unit/head_devtools.js
--- a/devtools/shared/DevToolsUtils.js
+++ b/devtools/shared/DevToolsUtils.js
@@ -184,20 +184,27 @@ exports.compose = function compose(...fu
 
 /**
  * Waits for the next tick in the event loop to execute a callback.
  */
 exports.executeSoon = function executeSoon(aFn) {
   if (isWorker) {
     setImmediate(aFn);
   } else {
-    let stack = components.stack;
-    let executor = () => {
-      Cu.callFunctionWithAsyncStack(aFn, stack, "DevToolsUtils.executeSoon");
-    };
+    let executor;
+    // Only enable async stack reporting when DEBUG_JS_MODULES is set
+    // (customized local builds) to avoid a performance penalty.
+    if (AppConstants.DEBUG_JS_MODULES || exports.testing) {
+      let stack = components.stack;
+      executor = () => {
+        Cu.callFunctionWithAsyncStack(aFn, stack, "DevToolsUtils.executeSoon");
+      };
+    } else {
+      executor = aFn;
+    }
     Services.tm.mainThread.dispatch({
       run: exports.makeInfallible(executor)
     }, Ci.nsIThread.DISPATCH_NORMAL);
   }
 };
 
 /**
  * Waits for the next tick in the event loop.
--- a/devtools/shared/tests/unit/head_devtools.js
+++ b/devtools/shared/tests/unit/head_devtools.js
@@ -2,16 +2,21 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cu = Components.utils;
 var Cr = Components.results;
 
 var {require} = Cu.import("resource://devtools/shared/Loader.jsm");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 
+DevToolsUtils.testing = true;
+do_register_cleanup(() => {
+  DevToolsUtils.testing = false;
+});
+
 // Register a console listener, so console messages don't just disappear
 // into the ether.
 
 // If for whatever reason the test needs to post console errors that aren't
 // failures, set this to true.
 var ALLOW_CONSOLE_ERRORS = false;
 
 var errorCount = 0;