Bug 1147604 - Inverted call trees should list (root) as leaves. r=jsantell
authorNick Fitzgerald <fitzgen@gmail.com>
Tue, 28 Apr 2015 11:59:00 -0400
changeset 273359 bf89860e49f730929b85be6f2583a178fcd53120
parent 273358 84674e2bfcb26da2720d070e0f6d5113d2af19da
child 273360 e7f4e5602c67d0a90a5d5fac25467e8fc58239a5
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell
bugs1147604
milestone40.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 1147604 - Inverted call trees should list (root) as leaves. r=jsantell
browser/devtools/shared/profiler/frame-utils.js
browser/devtools/shared/profiler/tree-model.js
--- a/browser/devtools/shared/profiler/frame-utils.js
+++ b/browser/devtools/shared/profiler/frame-utils.js
@@ -49,25 +49,40 @@ exports.parseLocation = function parseLo
     hostName: hostName,
     url: url,
     line: line,
     column: column
   };
 },
 
 /**
+ * Determines if the given frame is the (root) frame.
+ *
+ * @param object frame
+ * @return boolean
+ */
+exports.isRoot = function isRoot({ location }) {
+  return location === "(root)";
+};
+
+/**
 * Checks if the specified function represents a chrome or content frame.
 *
 * @param object frame
 *        The { category, location } properties of the frame.
 * @return boolean
 *         True if a content frame, false if a chrome frame.
 */
-exports.isContent = function isContent ({ category, location }) {
+exports.isContent = function isContent (frame) {
+  if (exports.isRoot(frame)) {
+    return true;
+  }
+
   // Only C++ stack frames have associated category information.
+  const { category, location } = frame;
   return !!(!category &&
     !CHROME_SCHEMES.find(e => location.includes(e)) &&
     CONTENT_SCHEMES.find(e => location.includes(e)));
 }
 
 /**
  * This filters out platform data frames in a sample. With latest performance
  * tool in Fx40, when displaying only content, we still filter out all platform data,
--- a/browser/devtools/shared/profiler/tree-model.js
+++ b/browser/devtools/shared/profiler/tree-model.js
@@ -88,25 +88,30 @@ ThreadNode.prototype = {
     let optimizations = options.optimizations;
     let sampleTime = sample.time;
     if (!sampleTime || sampleTime < startTime || sampleTime > endTime) {
       return;
     }
 
     let sampleFrames = sample.frames;
 
+    if (!options.invertTree) {
+      // Remove the (root) node if the tree is not inverted: we will synthesize
+      // our own root in the view. However, for inverted trees, we wish to be
+      // able to differentiate between (root)->A->B->C and (root)->B->C stacks,
+      // so we need the root node in that case.
+      sampleFrames = sampleFrames.slice(1);
+    }
+
     // Filter out platform frames if only content-related function calls
     // should be taken into consideration.
     if (options.contentOnly) {
-      // The (root) node is not considered a content function, it'll be removed.
       sampleFrames = FrameUtils.filterPlatformData(sampleFrames);
-    } else {
-      // Remove the (root) node manually.
-      sampleFrames = sampleFrames.slice(1);
     }
+
     // If no frames remain after filtering, then this is a leaf node, no need
     // to continue.
     if (!sampleFrames.length) {
       return;
     }
     // Invert the tree after filtering, if preferred.
     if (options.invertTree) {
       sampleFrames.reverse();