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
25 changes: 18 additions & 7 deletions src/actions/profile-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1920,19 +1920,30 @@ export function updateBottomBoxContentsAndMaybeOpen(
currentTab: TabSlug,
{ libIndex, sourceIndex, nativeSymbols, lineNumber }: BottomBoxInfo
): Action {
// TODO: If the set has more than one element, pick the native symbol with
// the highest total sample count
const nativeSymbol = nativeSymbols.length !== 0 ? nativeSymbols[0] : null;
const haveSource = sourceIndex !== null;
const haveAssembly = nativeSymbols.length !== 0;

const shouldOpenBottomBox = haveSource || haveAssembly;

// By default, only open the source view and keep the assembly
// view closed - unless the only thing we have is assembly.
const shouldOpenAssemblyView = !haveSource && haveAssembly;

// If we have at least one native symbol to show assembly for, pick
// the first one arbitrarily.
// TODO: If we have more than one native symbol, pick the one
// with the highest total sample count.
const currentNativeSymbol = nativeSymbols.length !== 0 ? 0 : null;

return {
type: 'UPDATE_BOTTOM_BOX',
libIndex,
sourceIndex,
nativeSymbol,
allNativeSymbolsForInitiatingCallNode: nativeSymbols,
nativeSymbols,
currentNativeSymbol,
currentTab,
shouldOpenBottomBox: sourceIndex !== null || nativeSymbol !== null,
shouldOpenAssemblyView: sourceIndex === null && nativeSymbol !== null,
shouldOpenBottomBox,
shouldOpenAssemblyView,
lineNumber,
};
}
Expand Down
13 changes: 7 additions & 6 deletions src/app-logic/url-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
if (sourceView.sourceIndex !== null) {
query.sourceViewIndex = sourceView.sourceIndex;
}
if (assemblyView.isOpen && assemblyView.nativeSymbol !== null) {
if (assemblyView.isOpen && assemblyView.currentNativeSymbol !== null) {
const { currentNativeSymbol, nativeSymbols } = assemblyView;
query.assemblyView = stringifyAssemblyViewSymbol(
assemblyView.nativeSymbol
nativeSymbols[currentNativeSymbol]
);
}
}
Expand Down Expand Up @@ -514,8 +515,8 @@ export function stateFromLocation(
const assemblyView: AssemblyViewState = {
isOpen: false,
scrollGeneration: 0,
nativeSymbol: null,
allNativeSymbolsForInitiatingCallNode: [],
nativeSymbols: [],
currentNativeSymbol: null,
};
const isBottomBoxOpenPerPanel: any = {};
tabSlugs.forEach((tabSlug) => (isBottomBoxOpenPerPanel[tabSlug] = false));
Expand All @@ -526,8 +527,8 @@ export function stateFromLocation(
if (query.assemblyView) {
const symbol = parseAssemblyViewSymbol(query.assemblyView);
if (symbol !== null) {
assemblyView.nativeSymbol = symbol;
assemblyView.allNativeSymbolsForInitiatingCallNode = [symbol];
assemblyView.nativeSymbols = [symbol];
assemblyView.currentNativeSymbol = 0;
assemblyView.isOpen = true;
isBottomBoxOpenPerPanel[selectedTab] = true;
}
Expand Down
13 changes: 7 additions & 6 deletions src/reducers/url-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,20 +585,21 @@ const sourceView: Reducer<SourceViewState> = (
const assemblyView: Reducer<AssemblyViewState> = (
state = {
scrollGeneration: 0,
nativeSymbol: null,
allNativeSymbolsForInitiatingCallNode: [],
nativeSymbols: [],
currentNativeSymbol: null,
isOpen: false,
},
action
) => {
switch (action.type) {
case 'UPDATE_BOTTOM_BOX': {
const { nativeSymbols, currentNativeSymbol, shouldOpenAssemblyView } =
action;
return {
scrollGeneration: state.scrollGeneration + 1,
nativeSymbol: action.nativeSymbol,
allNativeSymbolsForInitiatingCallNode:
action.allNativeSymbolsForInitiatingCallNode,
isOpen: state.isOpen || action.shouldOpenAssemblyView,
nativeSymbols,
currentNativeSymbol,
isOpen: state.isOpen || shouldOpenAssemblyView,
};
}
case 'OPEN_ASSEMBLY_VIEW': {
Expand Down
8 changes: 7 additions & 1 deletion src/selectors/url-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ export const getAssemblyViewIsOpen: Selector<boolean> = (state) =>
getProfileSpecificState(state).assemblyView.isOpen;
export const getAssemblyViewNativeSymbol: Selector<NativeSymbolInfo | null> = (
state
) => getProfileSpecificState(state).assemblyView.nativeSymbol;
) => {
const { nativeSymbols, currentNativeSymbol } =
getProfileSpecificState(state).assemblyView;
return currentNativeSymbol !== null
? nativeSymbols[currentNativeSymbol]
: null;
};
export const getAssemblyViewScrollGeneration: Selector<number> = (state) =>
getProfileSpecificState(state).assemblyView.scrollGeneration;
export const getShowJsTracerSummary: Selector<boolean> = (state) =>
Expand Down
4 changes: 2 additions & 2 deletions src/types/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ type ProfileAction =
readonly type: 'UPDATE_BOTTOM_BOX';
readonly libIndex: IndexIntoLibs | null;
readonly sourceIndex: IndexIntoSourceTable | null;
readonly nativeSymbol: NativeSymbolInfo | null;
readonly allNativeSymbolsForInitiatingCallNode: NativeSymbolInfo[];
readonly nativeSymbols: NativeSymbolInfo[];
readonly currentNativeSymbol: number | null;
readonly currentTab: TabSlug;
readonly shouldOpenBottomBox: boolean;
readonly shouldOpenAssemblyView: boolean;
Expand Down
16 changes: 7 additions & 9 deletions src/types/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,13 @@ export type AssemblyViewState = {
isOpen: boolean;
// When this is incremented, the assembly view scrolls to the "hotspot" line.
scrollGeneration: number;
// The native symbol for which the assembly code is being shown at the moment.
// Null if the initiating call node did not have a native symbol.
nativeSymbol: NativeSymbolInfo | null;
// The set of native symbols which contributed samples to the initiating call
// node. Often, this will just be one element (the same as `nativeSymbol`),
// but it can also be multiple elements, for example when double-clicking a
// function like `Vec::push` in an inverted call tree, if that function has
// been inlined into multiple different callers.
allNativeSymbolsForInitiatingCallNode: NativeSymbolInfo[];
// The list of native symbols whose assembly code should be accessible in the
// assembly view. Often empty or just one element, but sometimes this can have
// multiple elements, for example the different JIT compilations of one JS function.
nativeSymbols: NativeSymbolInfo[];
// The index in `nativeSymbols` for the symbol whose assembly code is being shown at the moment.
// Null if nativeSymbols is empty.
currentNativeSymbol: number | null;
};

export type DecodedInstruction = {
Expand Down