diff --git a/src/profile-logic/call-tree.js b/src/profile-logic/call-tree.js index 89fd02beb1..87aa791147 100644 --- a/src/profile-logic/call-tree.js +++ b/src/profile-logic/call-tree.js @@ -12,13 +12,9 @@ import { } from './profile-data'; import { resourceTypes } from './data-structures'; import { getFunctionName } from './function-info'; -import { UniqueStringArray } from '../utils/unique-string-array'; import type { CategoryList, Thread, - FuncTable, - ResourceTable, - NativeSymbolTable, IndexIntoFuncTable, SamplesLikeTable, WeightType, @@ -73,10 +69,7 @@ export class CallTree { _callNodeTable: CallNodeTable; _callNodeSummary: CallNodeSummary; _callNodeChildCount: Uint32Array; // A table column matching the callNodeTable - _funcTable: FuncTable; - _resourceTable: ResourceTable; - _nativeSymbols: NativeSymbolTable; - _stringTable: UniqueStringArray; + _thread: Thread; _rootTotalSummary: number; _rootCount: number; _displayDataByIndex: Map; @@ -89,7 +82,7 @@ export class CallTree { _weightType: WeightType; constructor( - { funcTable, resourceTable, nativeSymbols, stringTable }: Thread, + thread: Thread, categories: CategoryList, callNodeTable: CallNodeTable, callNodeSummary: CallNodeSummary, @@ -105,10 +98,7 @@ export class CallTree { this._callNodeTable = callNodeTable; this._callNodeSummary = callNodeSummary; this._callNodeChildCount = callNodeChildCount; - this._funcTable = funcTable; - this._resourceTable = resourceTable; - this._nativeSymbols = nativeSymbols; - this._stringTable = stringTable; + this._thread = thread; this._rootTotalSummary = rootTotalSummary; this._rootCount = rootCount; this._displayDataByIndex = new Map(); @@ -197,8 +187,8 @@ export class CallTree { getNodeData(callNodeIndex: IndexIntoCallNodeTable): CallNodeData { const funcIndex = this._callNodeTable.func[callNodeIndex]; - const funcName = this._stringTable.getString( - this._funcTable.name[funcIndex] + const funcName = this._thread.stringTable.getString( + this._thread.funcTable.name[funcIndex] ); const total = this._callNodeSummary.total[callNodeIndex]; const totalRelative = total / this._rootTotalSummary; @@ -236,8 +226,8 @@ export class CallTree { } const outerFunction = getFunctionName( - this._stringTable.getString( - this._nativeSymbols.name[inlinedIntoNativeSymbol] + this._thread.stringTable.getString( + this._thread.nativeSymbols.name[inlinedIntoNativeSymbol] ) ); return { @@ -259,8 +249,8 @@ export class CallTree { const categoryIndex = this._callNodeTable.category[callNodeIndex]; const subcategoryIndex = this._callNodeTable.subcategory[callNodeIndex]; const badge = this._getInliningBadge(callNodeIndex, funcName); - const resourceIndex = this._funcTable.resource[funcIndex]; - const resourceType = this._resourceTable.type[resourceIndex]; + const resourceIndex = this._thread.funcTable.resource[funcIndex]; + const resourceType = this._thread.resourceTable.type[resourceIndex]; const isFrameLabel = resourceIndex === -1; const libName = this._getOriginAnnotation(funcIndex); const weightType = this._weightType; @@ -273,8 +263,9 @@ export class CallTree { } else if (resourceType === resourceTypes.addon) { iconSrc = ExtensionIcon; - const resourceNameIndex = this._resourceTable.name[resourceIndex]; - const iconText = this._stringTable.getString(resourceNameIndex); + const resourceNameIndex = + this._thread.resourceTable.name[resourceIndex]; + const iconText = this._thread.stringTable.getString(resourceNameIndex); icon = iconText; } @@ -362,9 +353,9 @@ export class CallTree { _getOriginAnnotation(funcIndex: IndexIntoFuncTable): string { return getOriginAnnotationForFunc( funcIndex, - this._funcTable, - this._resourceTable, - this._stringTable + this._thread.funcTable, + this._thread.resourceTable, + this._thread.stringTable ); } @@ -372,11 +363,11 @@ export class CallTree { callNodeIndex: IndexIntoCallNodeTable ): string | null { const funcIndex = this._callNodeTable.func[callNodeIndex]; - const fileName = this._funcTable.fileName[funcIndex]; + const fileName = this._thread.funcTable.fileName[funcIndex]; if (fileName === null) { return null; } - return this._stringTable.getString(fileName); + return this._thread.stringTable.getString(fileName); } } diff --git a/src/test/store/__snapshots__/profile-view.test.js.snap b/src/test/store/__snapshots__/profile-view.test.js.snap index 2720749467..66f614406b 100644 --- a/src/test/store/__snapshots__/profile-view.test.js.snap +++ b/src/test/store/__snapshots__/profile-view.test.js.snap @@ -2499,128 +2499,322 @@ CallTree { ], "_children": Array [], "_displayDataByIndex": Map {}, - "_funcTable": Object { - "columnNumber": Array [ - null, - null, - null, - null, - null, - null, - null, - null, - null, - ], - "fileName": Array [ - null, - null, - null, - null, - null, - null, - null, - null, - null, - ], - "isJS": Array [ - false, - false, - false, - false, - false, - false, - false, - false, - false, - ], - "length": 9, - "lineNumber": Array [ - null, - null, - null, - null, - null, - null, - null, - null, - null, - ], - "name": Array [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - ], - "relevantForJS": Array [ - false, - false, - false, - false, - false, - false, - false, - false, - false, - ], - "resource": Array [ - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - ], - }, "_interval": 1, "_isHighPrecision": false, "_jsOnly": false, - "_nativeSymbols": Object { - "address": Array [], - "functionSize": Array [], - "length": 0, - "libIndex": Array [], - "name": Array [], - }, - "_resourceTable": Object { - "host": Array [], - "length": 0, - "lib": Array [], - "name": Array [], - "type": Array [], - }, "_rootCount": 1, "_rootTotalSummary": 2, - "_stringTable": UniqueStringArray { - "_array": Array [ - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - ], - "_stringToIndex": Map { - "A" => 0, - "B" => 1, - "C" => 2, - "D" => 3, - "E" => 4, - "F" => 5, - "G" => 6, - "H" => 7, - "I" => 8, + "_thread": Object { + "frameTable": Object { + "address": Array [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + ], + "category": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "column": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "func": Array [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + ], + "implementation": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "inlineDepth": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "innerWindowID": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + ], + "length": 9, + "line": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "nativeSymbol": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "subcategory": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], }, + "funcTable": Object { + "columnNumber": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "fileName": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "isJS": Array [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + ], + "length": 9, + "lineNumber": Array [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + ], + "name": Array [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + ], + "relevantForJS": Array [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + ], + "resource": Array [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + ], + }, + "isMainThread": false, + "markers": Object { + "category": Array [], + "data": Array [], + "endTime": Array [], + "length": 0, + "name": Array [], + "phase": Array [], + "startTime": Array [], + }, + "name": "Thread with samples", + "nativeSymbols": Object { + "address": Array [], + "functionSize": Array [], + "length": 0, + "libIndex": Array [], + "name": Array [], + }, + "pausedRanges": Array [], + "pid": 0, + "processShutdownTime": null, + "processStartupTime": 0, + "processType": "default", + "registerTime": 0, + "resourceTable": Object { + "host": Array [], + "length": 0, + "lib": Array [], + "name": Array [], + "type": Array [], + }, + "samples": Object { + "eventDelay": Array [ + 0, + 0, + ], + "length": 2, + "stack": Array [ + 5, + 5, + ], + "time": Array [ + 4, + 5, + ], + "weight": null, + "weightType": "samples", + }, + "stackTable": Object { + "category": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "frame": Array [ + 0, + 1, + 3, + 4, + 5, + 6, + 7, + 8, + ], + "length": 8, + "prefix": Array [ + null, + 0, + 1, + 2, + 1, + 4, + 1, + 6, + ], + "subcategory": Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + }, + "stringTable": UniqueStringArray { + "_array": Array [ + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + ], + "_stringToIndex": Map { + "A" => 0, + "B" => 1, + "C" => 2, + "D" => 3, + "E" => 4, + "F" => 5, + "G" => 6, + "H" => 7, + "I" => 8, + }, + }, + "tid": 0, + "unregisterTime": null, }, "_weightType": "samples", }