Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/actions/profile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
getInvertCallstack,
getHash,
} from 'firefox-profiler/selectors/url-state';
import { getCallNodePathFromIndex } from 'firefox-profiler/profile-logic/profile-data';
import {
assertExhaustiveCheck,
getFirstItemFromSet,
Expand Down Expand Up @@ -176,10 +175,7 @@ export function selectLeafCallNode(
dispatch(
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(
newSelectedCallNode,
callNodeInfo.callNodeTable
)
callNodeInfo.getCallNodePathFromIndex(newSelectedCallNode)
)
);
};
Expand Down Expand Up @@ -207,13 +203,12 @@ export function selectRootCallNode(
dispatch(changeSelectedCallNode(threadsKey, []));
return;
}
const newSelectedCallNode =
callNodeInfo.stackIndexToCallNodeIndex[newSelectedStack];
const stackIndexToCallNodeIndex =
callNodeInfo.getStackIndexToCallNodeIndex();
const newSelectedCallNode = stackIndexToCallNodeIndex[newSelectedStack];

const selectedCallNodePath = getCallNodePathFromIndex(
newSelectedCallNode,
callNodeInfo.callNodeTable
);
const selectedCallNodePath =
callNodeInfo.getCallNodePathFromIndex(newSelectedCallNode);
const rootCallNodePath = [selectedCallNodePath[0]];

dispatch(
Expand Down Expand Up @@ -1634,7 +1629,7 @@ export function expandAllCallNodeDescendants(
});

const expandedCallNodePaths = [...descendants].map((callNodeIndex) =>
getCallNodePathFromIndex(callNodeIndex, callNodeInfo.callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
);
dispatch(changeExpandedCallNodes(threadsKey, expandedCallNodePaths));
};
Expand Down Expand Up @@ -1878,13 +1873,13 @@ export function addTransformToStack(
const transformedThread =
threadSelectors.getRangeAndTransformFilteredThread(getState());

const { callNodeTable } = threadSelectors.getCallNodeInfo(getState());
const callNodeInfo = threadSelectors.getCallNodeInfo(getState());
dispatch({
type: 'ADD_TRANSFORM_TO_STACK',
threadsKey,
transform,
transformedThread,
callNodeTable,
callNodeInfo,
});
sendAnalytics({
hitType: 'event',
Expand Down Expand Up @@ -2041,10 +2036,11 @@ export function handleCallNodeTransformShortcut(
}
const threadSelectors = getThreadSelectorsFromThreadsKey(threadsKey);
const unfilteredThread = threadSelectors.getThread(getState());
const { callNodeTable } = threadSelectors.getCallNodeInfo(getState());
const callNodeInfo = threadSelectors.getCallNodeInfo(getState());
const callNodeTable = callNodeInfo.getCallNodeTable();
const implementation = getImplementationFilter(getState());
const inverted = getInvertCallstack(getState());
const callNodePath = getCallNodePathFromIndex(callNodeIndex, callNodeTable);
const callNodePath = callNodeInfo.getCallNodePathFromIndex(callNodeIndex);
const funcIndex = callNodeTable.func[callNodeIndex];
const category = callNodeTable.category[callNodeIndex];

Expand Down
10 changes: 5 additions & 5 deletions src/components/calltree/CallTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import explicitConnect from 'firefox-profiler/utils/connect';
import { TreeView } from 'firefox-profiler/components/shared/TreeView';
import { CallTreeEmptyReasons } from './CallTreeEmptyReasons';
import { Icon } from 'firefox-profiler/components/shared/Icon';
import { getCallNodePathFromIndex } from 'firefox-profiler/profile-logic/profile-data';
import {
getInvertCallstack,
getImplementationFilter,
Expand Down Expand Up @@ -246,7 +245,7 @@ class CallTreeImpl extends PureComponent<Props> {
const { callNodeInfo, threadsKey, changeSelectedCallNode } = this.props;
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(newSelectedCallNode, callNodeInfo.callNodeTable),
callNodeInfo.getCallNodePathFromIndex(newSelectedCallNode),
context
);
};
Expand All @@ -255,7 +254,7 @@ class CallTreeImpl extends PureComponent<Props> {
const { callNodeInfo, threadsKey, changeRightClickedCallNode } = this.props;
changeRightClickedCallNode(
threadsKey,
getCallNodePathFromIndex(newSelectedCallNode, callNodeInfo.callNodeTable)
callNodeInfo.getCallNodePathFromIndex(newSelectedCallNode)
);
};

Expand All @@ -266,7 +265,7 @@ class CallTreeImpl extends PureComponent<Props> {
changeExpandedCallNodes(
threadsKey,
newExpandedCallNodeIndexes.map((callNodeIndex) =>
getCallNodePathFromIndex(callNodeIndex, callNodeInfo.callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
)
);
};
Expand Down Expand Up @@ -301,7 +300,7 @@ class CallTreeImpl extends PureComponent<Props> {
tree,
expandedCallNodeIndexes,
selectedCallNodeIndex,
callNodeInfo: { callNodeTable },
callNodeInfo,
categories,
} = this.props;

Expand All @@ -321,6 +320,7 @@ class CallTreeImpl extends PureComponent<Props> {
// This tree is empty.
return;
}
const callNodeTable = callNodeInfo.getCallNodeTable();
newExpandedCallNodeIndexes.push(currentCallNodeIndex);
for (let i = 0; i < maxInterestingDepth; i++) {
const children = tree.getChildren(currentCallNodeIndex);
Expand Down
12 changes: 6 additions & 6 deletions src/components/flame-graph/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,14 @@ class FlameGraphCanvasImpl extends React.PureComponent<Props> {
}

_scrollSelectionIntoView = () => {
const {
selectedCallNodeIndex,
maxStackDepthPlusOne,
callNodeInfo: { callNodeTable },
} = this.props;
const { selectedCallNodeIndex, maxStackDepthPlusOne, callNodeInfo } =
this.props;

if (selectedCallNodeIndex === null) {
return;
}

const callNodeTable = callNodeInfo.getCallNodeTable();
const depth = callNodeTable.depth[selectedCallNodeIndex];
const y = (maxStackDepthPlusOne - depth - 1) * ROW_HEIGHT;

Expand All @@ -185,7 +183,7 @@ class FlameGraphCanvasImpl extends React.PureComponent<Props> {
const {
thread,
flameGraphTiming,
callNodeInfo: { callNodeTable },
callNodeInfo,
stackFrameHeight,
maxStackDepthPlusOne,
rightClickedCallNodeIndex,
Expand Down Expand Up @@ -237,6 +235,8 @@ class FlameGraphCanvasImpl extends React.PureComponent<Props> {
fastFillStyle.set('#ffffff');
ctx.fillRect(0, 0, deviceContainerWidth, deviceContainerHeight);

const callNodeTable = callNodeInfo.getCallNodeTable();

const startDepth = Math.floor(
maxStackDepthPlusOne - viewportBottom / stackFrameHeight
);
Expand Down
35 changes: 14 additions & 21 deletions src/components/flame-graph/FlameGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
getInvertCallstack,
} from '../../selectors/url-state';
import { ContextMenuTrigger } from 'firefox-profiler/components/shared/ContextMenuTrigger';
import { getCallNodePathFromIndex } from 'firefox-profiler/profile-logic/profile-data';
import {
changeSelectedCallNode,
changeRightClickedCallNode,
Expand Down Expand Up @@ -117,7 +116,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
const { callNodeInfo, threadsKey, changeSelectedCallNode } = this.props;
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(callNodeIndex, callNodeInfo.callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
);
};

Expand All @@ -127,7 +126,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
const { callNodeInfo, threadsKey, changeRightClickedCallNode } = this.props;
changeRightClickedCallNode(
threadsKey,
getCallNodePathFromIndex(callNodeIndex, callNodeInfo.callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
);
};

Expand Down Expand Up @@ -160,11 +159,9 @@ class FlameGraphImpl extends React.PureComponent<Props> {
* Is the box for this call node wide enough to be selected?
*/
_wideEnough = (callNodeIndex: IndexIntoCallNodeTable): boolean => {
const {
flameGraphTiming,
callNodeInfo: { callNodeTable },
} = this.props;
const { flameGraphTiming, callNodeInfo } = this.props;

const callNodeTable = callNodeInfo.getCallNodeTable();
const depth = callNodeTable.depth[callNodeIndex];
const row = flameGraphTiming[depth];
const columnIndex = row.callNode.indexOf(callNodeIndex);
Expand All @@ -185,13 +182,11 @@ class FlameGraphImpl extends React.PureComponent<Props> {
startingCallNodeIndex: IndexIntoCallNodeTable,
direction: 1 | -1
): IndexIntoCallNodeTable | void => {
const {
flameGraphTiming,
callNodeInfo: { callNodeTable },
} = this.props;
const { flameGraphTiming, callNodeInfo } = this.props;

let callNodeIndex = startingCallNodeIndex;

const callNodeTable = callNodeInfo.getCallNodeTable();
const depth = callNodeTable.depth[callNodeIndex];
const row = flameGraphTiming[depth];
let columnIndex = row.callNode.indexOf(callNodeIndex);
Expand All @@ -216,12 +211,13 @@ class FlameGraphImpl extends React.PureComponent<Props> {
const {
threadsKey,
callTree,
callNodeInfo: { callNodeTable },
callNodeInfo,
selectedCallNodeIndex,
rightClickedCallNodeIndex,
changeSelectedCallNode,
handleCallNodeTransformShortcut,
} = this.props;
const callNodeTable = callNodeInfo.getCallNodeTable();

if (
// Please do not forget to update the switch/case below if changing the array to allow more keys.
Expand All @@ -231,7 +227,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
// Just select the "root" node if we've got no prior selection.
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(0, callNodeTable)
callNodeInfo.getCallNodePathFromIndex(0)
);
return;
}
Expand All @@ -242,7 +238,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
if (prefix !== -1) {
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(prefix, callNodeTable)
callNodeInfo.getCallNodePathFromIndex(prefix)
);
}
break;
Expand All @@ -257,7 +253,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
if (callNodeIndex !== undefined && this._wideEnough(callNodeIndex)) {
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(callNodeIndex, callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
);
}
break;
Expand All @@ -272,7 +268,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
if (callNodeIndex !== undefined) {
changeSelectedCallNode(
threadsKey,
getCallNodePathFromIndex(callNodeIndex, callNodeTable)
callNodeInfo.getCallNodePathFromIndex(callNodeIndex)
);
}
break;
Expand Down Expand Up @@ -306,11 +302,8 @@ class FlameGraphImpl extends React.PureComponent<Props> {
_onCopy = (event: ClipboardEvent) => {
if (document.activeElement === this._viewport) {
event.preventDefault();
const {
callNodeInfo: { callNodeTable },
selectedCallNodeIndex,
thread,
} = this.props;
const { callNodeInfo, selectedCallNodeIndex, thread } = this.props;
const callNodeTable = callNodeInfo.getCallNodeTable();
if (selectedCallNodeIndex !== null) {
const funcIndex = callNodeTable.func[selectedCallNodeIndex];
const funcName = thread.stringTable.getString(
Expand Down
29 changes: 13 additions & 16 deletions src/components/shared/CallNodeContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { getFunctionName } from 'firefox-profiler/profile-logic/function-info';
import {
getBottomBoxInfoForCallNode,
getOriginAnnotationForFunc,
getCallNodePathFromIndex,
} from 'firefox-profiler/profile-logic/profile-data';
import { getCategories } from 'firefox-profiler/selectors';

Expand Down Expand Up @@ -136,9 +135,10 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
const {
callNodeIndex,
thread: { stringTable, funcTable },
callNodeInfo: { callNodeTable },
callNodeInfo,
} = rightClickedCallNodeInfo;

const callNodeTable = callNodeInfo.getCallNodeTable();
const funcIndex = callNodeTable.func[callNodeIndex];
const isJS = funcTable.isJS[funcIndex];
const stringIndex = funcTable.name[funcIndex];
Expand Down Expand Up @@ -173,9 +173,10 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
const {
callNodeIndex,
thread: { stringTable, funcTable },
callNodeInfo: { callNodeTable },
callNodeInfo,
} = rightClickedCallNodeInfo;

const callNodeTable = callNodeInfo.getCallNodeTable();
const funcIndex = callNodeTable.func[callNodeIndex];
const stringIndex = funcTable.fileName[funcIndex];
if (stringIndex === null) {
Expand Down Expand Up @@ -223,13 +224,12 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
const {
callNodeIndex,
thread: { funcTable, resourceTable, stringTable },
callNodeInfo: { callNodeTable },
callNodeInfo,
} = rightClickedCallNodeInfo;

const callPath = getCallNodePathFromIndex(
callNodeIndex,
callNodeTable
).reverse();
const callPath = callNodeInfo
.getCallNodePathFromIndex(callNodeIndex)
.reverse();

const stack = callPath
.map((funcIndex) => {
Expand Down Expand Up @@ -300,14 +300,10 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
);
}

const {
threadsKey,
callNodePath,
thread,
callNodeIndex,
callNodeInfo: { callNodeTable },
} = rightClickedCallNodeInfo;
const { threadsKey, callNodePath, thread, callNodeIndex, callNodeInfo } =
rightClickedCallNodeInfo;
const selectedFunc = callNodePath[callNodePath.length - 1];
const callNodeTable = callNodeInfo.getCallNodeTable();
const category = callNodeTable.category[callNodeIndex];
switch (type) {
case 'focus-subtree':
Expand Down Expand Up @@ -489,9 +485,10 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
const {
callNodeIndex,
thread: { funcTable },
callNodeInfo: { callNodeTable },
callNodeInfo,
} = rightClickedCallNodeInfo;

const callNodeTable = callNodeInfo.getCallNodeTable();
const categoryIndex = callNodeTable.category[callNodeIndex];
const funcIndex = callNodeTable.func[callNodeIndex];
const isJS = funcTable.isJS[funcIndex];
Expand Down
6 changes: 3 additions & 3 deletions src/components/shared/thread/StackGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class ThreadStackGraph extends PureComponent<Props> {
if (callNodeIndex === null) {
return null;
}

return callNodeInfo.callNodeTable.depth[callNodeIndex];
const callNodeTable = callNodeInfo.getCallNodeTable();
return callNodeTable.depth[callNodeIndex];
};

render() {
Expand All @@ -60,7 +60,7 @@ export class ThreadStackGraph extends PureComponent<Props> {
trackName,
onSampleClick,
} = this.props;
const { callNodeTable } = callNodeInfo;
const callNodeTable = callNodeInfo.getCallNodeTable();

let maxDepth = 0;
for (let i = 0; i < callNodeTable.depth.length; i++) {
Expand Down
Loading