@@ -26,12 +26,8 @@ export class SourceMappingsUpdated extends Event {
2626 }
2727}
2828
29- // Resolved code location data is keyed based on
30- // ProcessID=>ThreadID=> Call frame key.
3129// The code location key is created as a concatenation of its fields.
32- export const resolvedCodeLocationDataNames :
33- Map < Trace . Types . Events . ProcessID , Map < Trace . Types . Events . ThreadID , Map < string , ResolvedCodeLocationData | null > > > =
34- new Map ( ) ;
30+ export const resolvedCodeLocationDataNames : Map < string , ResolvedCodeLocationData | null > = new Map ( ) ;
3531
3632export class SourceMapsResolver extends EventTarget {
3733 #parsedTrace: Trace . Handlers . Types . ParsedTrace ;
@@ -71,6 +67,11 @@ export class SourceMapsResolver extends EventTarget {
7167 *
7268 * TODO(andoli): This can return incorrect scripts if the target page has been reloaded since the trace.
7369 */
70+ static resolvedCodeLocationForCallFrame ( callFrame : Protocol . Runtime . CallFrame ) : ResolvedCodeLocationData | null {
71+ const codeLocationKey = this . keyForCodeLocation ( callFrame as Protocol . Runtime . CallFrame ) ;
72+ return resolvedCodeLocationDataNames . get ( codeLocationKey ) ?? null ;
73+ }
74+
7475 static resolvedCodeLocationForEntry ( entry : Trace . Types . Events . Event ) : ResolvedCodeLocationData | null {
7576 let callFrame = null ;
7677 if ( Trace . Types . Events . isProfileCall ( entry ) ) {
@@ -82,8 +83,7 @@ export class SourceMapsResolver extends EventTarget {
8283 }
8384 callFrame = stackTrace [ 0 ] ;
8485 }
85- const codeLocationKey = this . keyForCodeLocation ( callFrame as Protocol . Runtime . CallFrame ) ;
86- return resolvedCodeLocationDataNames . get ( entry . pid ) ?. get ( entry . tid ) ?. get ( codeLocationKey ) ?? null ;
86+ return SourceMapsResolver . resolvedCodeLocationForCallFrame ( callFrame as Protocol . Runtime . CallFrame ) ;
8787 }
8888
8989 static resolvedURLForEntry ( parsedTrace : Trace . Handlers . Types . ParsedTrace , entry : Trace . Types . Events . Event ) :
@@ -102,16 +102,10 @@ export class SourceMapsResolver extends EventTarget {
102102 return null ;
103103 }
104104
105- static storeResolvedNodeDataForEntry (
106- pid : Trace . Types . Events . ProcessID , tid : Trace . Types . Events . ThreadID , callFrame : Protocol . Runtime . CallFrame ,
107- resolvedCodeLocationData : ResolvedCodeLocationData ) : void {
108- const resolvedForPid = resolvedCodeLocationDataNames . get ( pid ) ||
109- new Map < Trace . Types . Events . ThreadID , Map < string , ResolvedCodeLocationData | null > > ( ) ;
110- const resolvedForTid = resolvedForPid . get ( tid ) || new Map < string , ResolvedCodeLocationData | null > ( ) ;
105+ static storeResolvedCodeDataForCallFrame (
106+ callFrame : Protocol . Runtime . CallFrame , resolvedCodeLocationData : ResolvedCodeLocationData ) : void {
111107 const keyForCallFrame = this . keyForCodeLocation ( callFrame ) ;
112- resolvedForTid . set ( keyForCallFrame , resolvedCodeLocationData ) ;
113- resolvedForPid . set ( tid , resolvedForTid ) ;
114- resolvedCodeLocationDataNames . set ( pid , resolvedForPid ) ;
108+ resolvedCodeLocationDataNames . set ( keyForCallFrame , resolvedCodeLocationData ) ;
115109 }
116110
117111 async install ( ) : Promise < void > {
@@ -167,7 +161,7 @@ export class SourceMapsResolver extends EventTarget {
167161 // is attach. If not, we do not notify the flamechart that mappings
168162 // were updated, since that would trigger a rerender.
169163 let updatedMappings = false ;
170- for ( const [ pid , threadsInProcess ] of this . #parsedTrace. Samples . profilesInProcess ) {
164+ for ( const [ , threadsInProcess ] of this . #parsedTrace. Samples . profilesInProcess ) {
171165 for ( const [ tid , threadProfile ] of threadsInProcess ) {
172166 const nodes = threadProfile . parsedProfile . nodes ( ) ?? [ ] ;
173167 const target = this . #targetForThread( tid ) ;
@@ -190,8 +184,8 @@ export class SourceMapsResolver extends EventTarget {
190184 location ) ;
191185 updatedMappings ||= Boolean ( uiLocation ) ;
192186
193- SourceMapsResolver . storeResolvedNodeDataForEntry (
194- pid , tid , node . callFrame , { name : resolvedFunctionName , devtoolsLocation : uiLocation , script} ) ;
187+ SourceMapsResolver . storeResolvedCodeDataForCallFrame (
188+ node . callFrame , { name : resolvedFunctionName , devtoolsLocation : uiLocation , script} ) ;
195189 }
196190 }
197191 }
0 commit comments