Skip to content

Commit a42bb00

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Rename ProfileNode functionName to originalFunctionName
Also removed some unused code in buildDetailsNodeForTraceEvent. Bug: 456242397 Change-Id: Idc70296362be4abea68772dfbafeb564c370b82a Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7098669 Auto-Submit: Connor Clark <[email protected]> Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent 9d3a62e commit a42bb00

File tree

6 files changed

+28
-57
lines changed

6 files changed

+28
-57
lines changed

front_end/models/cpu_profile/ProfileTreeModel.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ProfileNode {
1313
id: number;
1414
parent: ProfileNode|null;
1515
children: this[];
16-
functionName: string;
16+
originalFunctionName: string|null = null;
1717
depth!: number;
1818
deoptReason!: string|null;
1919
constructor(callFrame: Protocol.Runtime.CallFrame) {
@@ -22,7 +22,6 @@ export class ProfileNode {
2222
this.self = 0;
2323
this.total = 0;
2424
this.id = 0;
25-
this.functionName = callFrame.functionName;
2625
this.parent = null;
2726
this.children = [];
2827
}
@@ -43,11 +42,12 @@ export class ProfileNode {
4342
return this.callFrame.columnNumber;
4443
}
4544

46-
setFunctionName(name: string|null): void {
47-
if (name === null) {
48-
return;
49-
}
50-
this.functionName = name;
45+
get functionName(): string {
46+
return this.originalFunctionName ?? this.callFrame.functionName;
47+
}
48+
49+
setOriginalFunctionName(name: string|null): void {
50+
this.originalFunctionName = name;
5151
}
5252
}
5353

front_end/models/trace/Name.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,21 @@ describeWithEnvironment('Name', () => {
117117
it('uses the profile name for a ProfileCall if it has been set', async function() {
118118
const parsedTrace = await TraceLoader.traceEngine(this, 'react-hello-world.json.gz');
119119
const {entry, profileNode} = getProfileEventAndNodeForReactTrace(parsedTrace);
120-
// Store and then reset this: we are doing this to test the fallback to
121-
// the entry callFrame.functionName property. After the assertion we
122-
// reset this to avoid impacting other tests.
123-
const originalProfileNodeName = profileNode.functionName;
124-
profileNode.setFunctionName('testing-profile-name');
120+
assert.isNull(profileNode.originalFunctionName);
121+
profileNode.setOriginalFunctionName('testing-profile-name');
125122
const name = Trace.Name.forEntry(entry, parsedTrace);
126123
assert.strictEqual(name, 'testing-profile-name');
127-
profileNode.setFunctionName(originalProfileNodeName);
124+
125+
// Don't impact other tests.
126+
profileNode.setOriginalFunctionName(null);
128127
});
129128

130129
it('falls back to the call frame name if a specific name has not been set', async function() {
131130
const parsedTrace = await TraceLoader.traceEngine(this, 'react-hello-world.json.gz');
132131
const {entry, profileNode} = getProfileEventAndNodeForReactTrace(parsedTrace);
133-
// Store and then reset this: we are doing this to test the fallback to
134-
// the entry callFrame.functionName property. After the assertion we
135-
// reset this to avoid impacting other tests.
136-
const originalProfileNodeName = profileNode.functionName;
137-
profileNode.setFunctionName('');
132+
assert.isNull(profileNode.originalFunctionName);
138133
const name = Trace.Name.forEntry(entry, parsedTrace);
139134
assert.strictEqual(name, 'performConcurrentWorkOnRoot');
140-
profileNode.setFunctionName(originalProfileNodeName);
141135
});
142136

143137
/** Finds a particular event from the react-hello-world trace which is used for our test example. **/

front_end/models/trace/handlers/SamplesHandler.test.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,32 +325,25 @@ describeWithEnvironment('SamplesHandler', function() {
325325
};
326326
}
327327

328-
it('falls back to the call frame name if the ProfileNode name is empty', async function() {
328+
it('falls back to the call frame name if the ProfileNode originalFunctionName is empty', async function() {
329329
const {data} = await TraceLoader.traceEngine(this, 'react-hello-world.json.gz');
330330
const {entry, profileNode} = getProfileEventAndNode(data);
331-
// Store and then reset this: we are doing this to test the fallback to
332-
// the entry callFrame.functionName property. After the assertion we
333-
// reset this to avoid impacting other tests.
334-
const originalProfileNodeName = profileNode.functionName;
335-
profileNode.setFunctionName('');
331+
assert.isNull(profileNode.originalFunctionName);
336332
assert.strictEqual(
337333
Trace.Handlers.ModelHandlers.Samples.getProfileCallFunctionName(data.Samples, entry),
338334
'performConcurrentWorkOnRoot');
339-
// St
340-
profileNode.setFunctionName(originalProfileNodeName);
341335
});
342336

343-
it('uses the profile name if it has been set', async function() {
337+
it('uses the profile originalFunctionName if it has been set', async function() {
344338
const {data} = await TraceLoader.traceEngine(this, 'react-hello-world.json.gz');
345339
const {entry, profileNode} = getProfileEventAndNode(data);
346-
// Store and then reset this: we are doing this to test the fallback to
347-
// the entry callFrame.functionName property. After the assertion we
348-
// reset this to avoid impacting other tests.
349-
const originalProfileNodeName = profileNode.functionName;
350-
profileNode.setFunctionName('testing-profile-name');
340+
assert.isNull(profileNode.originalFunctionName);
341+
profileNode.setOriginalFunctionName('testing-profile-name');
351342
assert.strictEqual(
352343
Trace.Handlers.ModelHandlers.Samples.getProfileCallFunctionName(data.Samples, entry), 'testing-profile-name');
353-
profileNode.setFunctionName(originalProfileNodeName);
344+
345+
// Don't impact other tests.
346+
profileNode.setOriginalFunctionName(null);
354347
});
355348
});
356349
});

front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class SourceMapsResolver extends EventTarget {
173173
const resolvedFunctionName =
174174
await SourceMapScopes.NamesResolver.resolveProfileFrameFunctionName(node.callFrame, target);
175175
updatedMappings ||= Boolean(resolvedFunctionName);
176-
node.setFunctionName(resolvedFunctionName);
176+
node.setOriginalFunctionName(resolvedFunctionName);
177177

178178
const debuggerModel = target.model(SDK.DebuggerModel.DebuggerModel);
179179
const script = debuggerModel?.scriptForId(node.scriptId) || null;

front_end/panels/timeline/TimelineUIUtils.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -732,26 +732,6 @@ export class TimelineUIUtils {
732732
break;
733733
}
734734

735-
case Trace.Types.Events.Name.COMPILE_SCRIPT:
736-
case Trace.Types.Events.Name.CACHE_SCRIPT:
737-
case Trace.Types.Events.Name.EVALUATE_SCRIPT: {
738-
const url = unsafeEventData['url'];
739-
if (url) {
740-
const {lineNumber} = Trace.Helpers.Trace.getZeroIndexedLineAndColumnForEvent(event);
741-
details = this.linkifyLocation({
742-
scriptId: null,
743-
url,
744-
lineNumber: lineNumber || 0,
745-
columnNumber: 0,
746-
target,
747-
isFreshOrEnhanced,
748-
linkifier,
749-
omitOrigin: true,
750-
});
751-
}
752-
break;
753-
}
754-
755735
case Trace.Types.Events.Name.BACKGROUND_DESERIALIZE:
756736
case Trace.Types.Events.Name.STREAMING_COMPILE_SCRIPT: {
757737
const url = unsafeEventData['url'];
@@ -1710,6 +1690,7 @@ export class TimelineUIUtils {
17101690
return {callFrames} as Protocol.Runtime.StackTrace;
17111691
}
17121692

1693+
/** This renders a stack trace... and other cool stuff. */
17131694
static async generateCauses(
17141695
event: Trace.Types.Events.Event, contentHelper: TimelineDetailsContentHelper,
17151696
parsedTrace: Trace.TraceModel.ParsedTrace): Promise<void> {
@@ -2478,6 +2459,9 @@ export class TimelineDetailsContentHelper {
24782459
if (!this.#linkifier) {
24792460
return;
24802461
}
2462+
2463+
// We resolve the original function name here. StackTracePreviewContent uses
2464+
// Linkifier to resolve the source code location.
24812465
const resolvedStackTrace: Protocol.Runtime.StackTrace = structuredClone(stackTrace);
24822466
let currentResolvedStackTrace: Protocol.Runtime.StackTrace|undefined = resolvedStackTrace;
24832467
while (currentResolvedStackTrace) {

front_end/panels/timeline/track_appenders/ThreadAppender.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ describeWithEnvironment('ThreadAppender', function() {
255255
const anonymousCall = threadAppenders[0].titleForEvent(entry);
256256
assert.strictEqual(anonymousCall, '(anonymous)');
257257
const originalName = cpuProfileNode.functionName;
258-
cpuProfileNode.setFunctionName('new-resolved-function-name');
258+
cpuProfileNode.setOriginalFunctionName('new-resolved-function-name');
259259
assert.strictEqual(threadAppenders[0].titleForEvent(entry), 'new-resolved-function-name');
260260
// Reset the value for future tests.
261-
cpuProfileNode.setFunctionName(originalName);
261+
cpuProfileNode.setOriginalFunctionName(originalName);
262262
});
263263

264264
function getDefaultInfo() {

0 commit comments

Comments
 (0)