Skip to content

Commit

Permalink
Backed out 18 changesets (bug 1462784) for ESlint failure on FlameGra…
Browse files Browse the repository at this point in the history
…ph.js:1297. CLOSED TREE

Backed out changeset 79556798ff9f (bug 1462784)
Backed out changeset 88321efb673b (bug 1462784)
Backed out changeset 7880f9dc7023 (bug 1462784)
Backed out changeset 71fe35fd1f7e (bug 1462784)
Backed out changeset a543b94b049a (bug 1462784)
Backed out changeset d1ca8b0f2221 (bug 1462784)
Backed out changeset 68eabfbf3c16 (bug 1462784)
Backed out changeset 34e71c789903 (bug 1462784)
Backed out changeset 6fe79d1ca1bd (bug 1462784)
Backed out changeset e5ad2e525ea9 (bug 1462784)
Backed out changeset 329645ff1e23 (bug 1462784)
Backed out changeset e09c38853172 (bug 1462784)
Backed out changeset 0663d1a6d2da (bug 1462784)
Backed out changeset 106967fc29d2 (bug 1462784)
Backed out changeset 99b4a433a8e5 (bug 1462784)
Backed out changeset 1d38a4cf5a4a (bug 1462784)
Backed out changeset 692017229de6 (bug 1462784)
Backed out changeset c2911a626671 (bug 1462784)
  • Loading branch information
ncsoregi committed Jun 1, 2018
1 parent c9db70e commit fc2ed6e
Show file tree
Hide file tree
Showing 55 changed files with 338 additions and 363 deletions.
6 changes: 3 additions & 3 deletions devtools/client/locales/en-US/performance.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ graphs.memory=MB
# as the legend for each block in every bar. These labels should be kept
# AS SHORT AS POSSIBLE so they don't obstruct important parts of the graph.
category.other=Gecko
category.layout=Layout
category.css=Styles
category.js=JIT
category.gc=GC
category.network=Network
category.graphics=Graphics
category.dom=DOM
category.idle=Idle
category.storage=Storage
category.events=Input & Events
category.tools=Tools

# LOCALIZATION NOTE (table.bytes):
Expand Down
105 changes: 80 additions & 25 deletions devtools/client/performance/modules/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ const { L10N } = require("devtools/client/performance/modules/global");

/**
* Details about each label stack frame category.
* To be kept in sync with the js::ProfilingStackFrame::Category in ProfilingStack.h
* @see CATEGORY_MAPPINGS.
*/
const CATEGORIES = [{
color: "#d99b28",
abbrev: "idle",
label: L10N.getStr("category.idle")
}, {
color: "#5e88b0",
abbrev: "other",
label: L10N.getStr("category.other")
}, {
color: "#46afe3",
abbrev: "layout",
label: L10N.getStr("category.layout")
abbrev: "css",
label: L10N.getStr("category.css")
}, {
color: "#d96629",
abbrev: "js",
Expand All @@ -39,35 +35,94 @@ const CATEGORIES = [{
label: L10N.getStr("category.graphics")
}, {
color: "#8fa1b2",
abbrev: "dom",
label: L10N.getStr("category.dom")
abbrev: "storage",
label: L10N.getStr("category.storage")
}, {
color: "#d99b28",
abbrev: "events",
label: L10N.getStr("category.events")
}, {
// The devtools-only "tools" category which gets computed by
// computeIsContentAndCategory and is not part of the category list in
// ProfilingStack.h.
color: "#8fa1b2",
abbrev: "tools",
label: L10N.getStr("category.tools")
}];

/**
* Get the numeric index for the given category abbreviation.
* See `CATEGORIES` above.
* Mapping from category bitmasks in the profiler data to additional details.
* To be kept in sync with the js::ProfilingStackFrame::Category in ProfilingStack.h
*/
const CATEGORY_INDEX = (() => {
const indexForCategory = {};
for (let categoryIndex = 0; categoryIndex < CATEGORIES.length; categoryIndex++) {
const category = CATEGORIES[categoryIndex];
indexForCategory[category.abbrev] = categoryIndex;
const CATEGORY_MAPPINGS = {
// js::ProfilingStackFrame::Category::OTHER
"16": CATEGORIES[0],
// js::ProfilingStackFrame::Category::CSS
"32": CATEGORIES[1],
// js::ProfilingStackFrame::Category::JS
"64": CATEGORIES[2],
// js::ProfilingStackFrame::Category::GC
"128": CATEGORIES[3],
// js::ProfilingStackFrame::Category::CC
"256": CATEGORIES[3],
// js::ProfilingStackFrame::Category::NETWORK
"512": CATEGORIES[4],
// js::ProfilingStackFrame::Category::GRAPHICS
"1024": CATEGORIES[5],
// js::ProfilingStackFrame::Category::STORAGE
"2048": CATEGORIES[6],
// js::ProfilingStackFrame::Category::EVENTS
"4096": CATEGORIES[7],
// non-bitmasks for specially-assigned categories
"9000": CATEGORIES[8],
};

/**
* Get the numeric bitmask (or set of masks) for the given category
* abbreviation. See `CATEGORIES` and `CATEGORY_MAPPINGS` above.
*
* CATEGORY_MASK can be called with just a name if it is expected that the
* category is mapped to by exactly one bitmask. If the category is mapped
* to by multiple masks, CATEGORY_MASK for that name must be called with
* an additional argument specifying the desired id (in ascending order).
*/
const [CATEGORY_MASK, CATEGORY_MASK_LIST] = (() => {
const bitmasksForCategory = {};
const all = Object.keys(CATEGORY_MAPPINGS);

for (const category of CATEGORIES) {
bitmasksForCategory[category.abbrev] = all
.filter(mask => CATEGORY_MAPPINGS[mask] == category)
.map(mask => +mask)
.sort();
}

return function(name) {
if (!(name in indexForCategory)) {
throw new Error(`Category abbreviation "${name}" does not exist.`);
return [
function(name, index) {
if (!(name in bitmasksForCategory)) {
throw new Error(`Category abbreviation "${name}" does not exist.`);
}
if (arguments.length == 1) {
if (bitmasksForCategory[name].length != 1) {
throw new Error(`Expected exactly one category number for "${name}".`);
} else {
return bitmasksForCategory[name][0];
}
} else {
if (index > bitmasksForCategory[name].length) {
throw new Error(`Index "${index}" too high for category "${name}".`);
}
return bitmasksForCategory[name][index - 1];
}
},

function(name) {
if (!(name in bitmasksForCategory)) {
throw new Error(`Category abbreviation "${name}" does not exist.`);
}
return bitmasksForCategory[name];
}
return indexForCategory[name];
};
];
})();

exports.CATEGORIES = CATEGORIES;
exports.CATEGORY_INDEX = CATEGORY_INDEX;
exports.CATEGORY_MAPPINGS = CATEGORY_MAPPINGS;
exports.CATEGORY_MASK = CATEGORY_MASK;
exports.CATEGORY_MASK_LIST = CATEGORY_MASK_LIST;
15 changes: 6 additions & 9 deletions devtools/client/performance/modules/logic/frame-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { assert } = require("devtools/shared/DevToolsUtils");
const { isChromeScheme, isContentScheme, isWASM, parseURL } =
require("devtools/client/shared/source-utils");

const { CATEGORY_INDEX, CATEGORIES } = require("devtools/client/performance/modules/categories");
const { CATEGORY_MASK, CATEGORY_MAPPINGS } = require("devtools/client/performance/modules/categories");

// Character codes used in various parsing helper functions.
const CHAR_CODE_R = "r".charCodeAt(0);
Expand Down Expand Up @@ -190,7 +190,7 @@ function parseLocation(location, fallbackLine, fallbackColumn) {
*/
function computeIsContentAndCategory(frame) {
// Only C++ stack frames have associated category information.
if (frame.category !== null && frame.category !== undefined) {
if (frame.category) {
return;
}

Expand Down Expand Up @@ -234,18 +234,18 @@ function computeIsContentAndCategory(frame) {
isChromeScheme(location, j) &&
(location.includes("resource://devtools") ||
location.includes("resource://devtools"))) {
frame.category = CATEGORY_INDEX("tools");
frame.category = CATEGORY_MASK("tools");
return;
}
}
}

if (location === "EnterJIT") {
frame.category = CATEGORY_INDEX("js");
frame.category = CATEGORY_MASK("js");
return;
}

frame.category = CATEGORY_INDEX("other");
frame.category = CATEGORY_MASK("other");
}

/**
Expand Down Expand Up @@ -393,10 +393,7 @@ function getFrameInfo(node, options) {
data.isMetaCategory = node.isMetaCategory;
}
data.samples = node.youngestFrameSamples;
const hasCategory = node.category !== null && node.category !== undefined;
data.categoryData = hasCategory
? (CATEGORIES[node.category] || CATEGORIES[CATEGORY_INDEX("other")])
: {};
data.categoryData = CATEGORY_MAPPINGS[node.category] || {};
data.nodeType = node.nodeType;

// Frame name (function location or some meta information)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ add_task(function() {
"The .A.B node's function cell displays the correct line.");
is($fun(".call-tree-host", $$(".call-tree-item")[2]).textContent.trim(), "foo",
"The .A.B node's function cell displays the correct host.");
is($fun(".call-tree-category", $$(".call-tree-item")[2]).textContent.trim(), "Layout",
is($fun(".call-tree-category", $$(".call-tree-item")[2]).textContent.trim(), "Styles",
"The .A.B node's function cell displays the correct category.");

is($$dur(3).textContent.trim(), "5 ms",
Expand Down
8 changes: 4 additions & 4 deletions devtools/client/performance/test/browser_perf-tree-view-08.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

const { ThreadNode } = require("devtools/client/performance/modules/logic/tree-model");
const { CallView } = require("devtools/client/performance/modules/widgets/tree-view");
const { CATEGORY_INDEX } = require("devtools/client/performance/modules/categories");
const { CATEGORY_MASK } = require("devtools/client/performance/modules/categories");
const RecordingUtils = require("devtools/shared/performance/recording-utils");

add_task(function() {
Expand Down Expand Up @@ -89,20 +89,20 @@ const gProfile = RecordingUtils.deflateProfile({
{ location: "http://content/A" },
{ location: "http://content/E" },
{ location: "http://content/F" },
{ location: "platform_JS", category: CATEGORY_INDEX("js") },
{ location: "platform_JS", category: CATEGORY_MASK("js") },
]
}, {
time: 1 + 1 + 2 + 3,
frames: [
{ location: "(root)" },
{ location: "platform_JS2", category: CATEGORY_INDEX("js") },
{ location: "platform_JS2", category: CATEGORY_MASK("js") },
]
}, {
time: 1 + 1 + 2 + 3 + 5,
frames: [
{ location: "(root)" },
{ location: "http://content/A" },
{ location: "platform_GC", category: CATEGORY_INDEX("gc") },
{ location: "platform_GC", category: CATEGORY_MASK("gc", 1) },
]
}]
}]
Expand Down
34 changes: 17 additions & 17 deletions devtools/client/performance/test/helpers/synth-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Generates a generalized profile with some samples.
*/
exports.synthesizeProfile = () => {
const { CATEGORY_INDEX } = require("devtools/client/performance/modules/categories");
const { CATEGORY_MASK } = require("devtools/client/performance/modules/categories");
const RecordingUtils = require("devtools/shared/performance/recording-utils");

return RecordingUtils.deflateProfile({
Expand All @@ -15,34 +15,34 @@ exports.synthesizeProfile = () => {
samples: [{
time: 1,
frames: [
{ category: CATEGORY_INDEX("other"), location: "(root)" },
{ category: CATEGORY_INDEX("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_INDEX("layout"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_INDEX("js"), location: "C (http://foo/bar/baz:56)" }
{ category: CATEGORY_MASK("other"), location: "(root)" },
{ category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_MASK("js"), location: "C (http://foo/bar/baz:56)" }
]
}, {
time: 1 + 1,
frames: [
{ category: CATEGORY_INDEX("other"), location: "(root)" },
{ category: CATEGORY_INDEX("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_INDEX("layout"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_INDEX("gc"), location: "D (http://foo/bar/baz:78:9)" }
{ category: CATEGORY_MASK("other"), location: "(root)" },
{ category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_MASK("gc", 1), location: "D (http://foo/bar/baz:78:9)" }
]
}, {
time: 1 + 1 + 2,
frames: [
{ category: CATEGORY_INDEX("other"), location: "(root)" },
{ category: CATEGORY_INDEX("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_INDEX("layout"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_INDEX("gc"), location: "D (http://foo/bar/baz:78:9)" }
{ category: CATEGORY_MASK("other"), location: "(root)" },
{ category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
{ category: CATEGORY_MASK("gc", 1), location: "D (http://foo/bar/baz:78:9)" }
]
}, {
time: 1 + 1 + 2 + 3,
frames: [
{ category: CATEGORY_INDEX("other"), location: "(root)" },
{ category: CATEGORY_INDEX("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_INDEX("gc"), location: "E (http://foo/bar/baz:90)" },
{ category: CATEGORY_INDEX("network"), location: "F (http://foo/bar/baz:99)" }
{ category: CATEGORY_MASK("other"), location: "(root)" },
{ category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
{ category: CATEGORY_MASK("gc", 2), location: "E (http://foo/bar/baz:90)" },
{ category: CATEGORY_MASK("network"), location: "F (http://foo/bar/baz:99)" }
]
}]
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

add_task(function() {
const { CATEGORIES } = require("devtools/client/performance/modules/categories");
const { CATEGORIES, CATEGORY_MAPPINGS } = require("devtools/client/performance/modules/categories");
const { L10N } = require("devtools/client/performance/modules/global");
const count = CATEGORIES.length;

Expand All @@ -22,4 +22,12 @@ add_task(function() {

ok(CATEGORIES.every(e => e.label === L10N.getStr("category." + e.abbrev)),
"All categories have a correctly localized label.");

ok(Object.keys(CATEGORY_MAPPINGS).every(e => (Number(e) >= 9000 && Number(e) <= 9999) ||
Number.isInteger(Math.log2(e))),
"All bitmask mappings keys are powers of 2, or between 9000-9999 for special " +
"categories.");

ok(Object.keys(CATEGORY_MAPPINGS).every(e => CATEGORIES.includes(CATEGORY_MAPPINGS[e])),
"All bitmask mappings point to a category.");
});
Loading

0 comments on commit fc2ed6e

Please sign in to comment.