@@ -55,6 +55,7 @@ struct IncompleteActionDesc
5555
5656 Dictionary < IdOfIncompleteAction , IncompleteActionDesc > _incompleteJitEvents = new Dictionary < IdOfIncompleteAction , IncompleteActionDesc > ( ) ;
5757 Dictionary < IdOfIncompleteAction , IncompleteActionDesc > _incompleteR2REvents = new Dictionary < IdOfIncompleteAction , IncompleteActionDesc > ( ) ;
58+ Dictionary < IdOfIncompleteAction , IncompleteActionDesc > _incompleteTypeLoadEvents = new Dictionary < IdOfIncompleteAction , IncompleteActionDesc > ( ) ;
5859
5960 public Dictionary < int , List < StartStopStackMingledComputer . StartStopThreadEventData > > StartStopEvents { get ; } = new Dictionary < int , List < StartStopStackMingledComputer . StartStopThreadEventData > > ( ) ;
6061
@@ -65,12 +66,18 @@ public CLRRuntimeActivityComputer(TraceLogEventSource source)
6566 source . Clr . MethodLoadVerbose += Clr_MethodLoadVerbose ;
6667 source . Clr . MethodLoad += Clr_MethodLoad ;
6768 source . Clr . LoaderAssemblyLoad += Clr_LoaderAssemblyLoad ;
69+ source . Clr . MethodR2RGetEntryPointStarted += Clr_R2RGetEntryPointStarted ;
70+ source . Clr . TypeLoadStart += Clr_TypeLoadStart ;
71+ source . Clr . TypeLoadStop += Clr_TypeLoadStop ;
6872 source . Process ( ) ;
6973 source . Clr . MethodJittingStarted -= Clr_MethodJittingStarted ;
74+ source . Clr . MethodR2RGetEntryPointStarted -= Clr_R2RGetEntryPointStarted ;
7075 source . Clr . MethodR2RGetEntryPoint -= Clr_MethodR2RGetEntryPoint ;
7176 source . Clr . MethodLoadVerbose -= Clr_MethodLoadVerbose ;
7277 source . Clr . MethodLoad -= Clr_MethodLoad ;
7378 source . Clr . LoaderAssemblyLoad -= Clr_LoaderAssemblyLoad ;
79+ source . Clr . TypeLoadStart -= Clr_TypeLoadStart ;
80+ source . Clr . TypeLoadStop -= Clr_TypeLoadStop ;
7481 }
7582
7683 private void AddStartStopData ( int threadId , StartStopStackMingledComputer . EventUID start , StartStopStackMingledComputer . EventUID end , string name )
@@ -127,6 +134,20 @@ private void Clr_MethodJittingStarted(MethodJittingStartedTraceData obj)
127134 _incompleteJitEvents [ id ] = incompleteDesc ;
128135 }
129136
137+ private void Clr_R2RGetEntryPointStarted ( R2RGetEntryPointStartedTraceData obj )
138+ {
139+ IncompleteActionDesc incompleteDesc = new IncompleteActionDesc ( ) ;
140+ incompleteDesc . Start = new StartStopStackMingledComputer . EventUID ( obj ) ;
141+ incompleteDesc . Name = "" ;
142+ incompleteDesc . OperationType = "R2R" ;
143+
144+ IdOfIncompleteAction id = new IdOfIncompleteAction ( ) ;
145+ id . Identifier = obj . MethodID ;
146+ id . ThreadID = obj . ThreadID ;
147+
148+ _incompleteR2REvents [ id ] = incompleteDesc ;
149+ }
150+
130151 private void Clr_MethodR2RGetEntryPoint ( R2RGetEntryPointTraceData obj )
131152 {
132153 IdOfIncompleteAction id = new IdOfIncompleteAction ( ) ;
@@ -139,7 +160,7 @@ private void Clr_MethodR2RGetEntryPoint(R2RGetEntryPointTraceData obj)
139160 if ( _incompleteR2REvents . TryGetValue ( id , out IncompleteActionDesc r2rStartData ) )
140161 {
141162 startUID = r2rStartData . Start ;
142- _incompleteJitEvents . Remove ( id ) ;
163+ _incompleteR2REvents . Remove ( id ) ;
143164 }
144165
145166 if ( obj . EntryPoint == 0 )
@@ -152,5 +173,37 @@ private void Clr_MethodR2RGetEntryPoint(R2RGetEntryPointTraceData obj)
152173 AddStartStopData ( id . ThreadID , startUID , new StartStopStackMingledComputer . EventUID ( obj ) , "R2R_Found" + "(" + JITStats . GetMethodName ( obj ) + ")" ) ;
153174 }
154175 }
176+
177+ private void Clr_TypeLoadStart ( TypeLoadStartTraceData obj )
178+ {
179+ IncompleteActionDesc incompleteDesc = new IncompleteActionDesc ( ) ;
180+ incompleteDesc . Start = new StartStopStackMingledComputer . EventUID ( obj ) ;
181+ incompleteDesc . Name = "" ;
182+ incompleteDesc . OperationType = "TypeLoad" ;
183+
184+ IdOfIncompleteAction id = new IdOfIncompleteAction ( ) ;
185+ id . Identifier = obj . TypeLoadStartID ;
186+ id . ThreadID = obj . ThreadID ;
187+
188+ _incompleteTypeLoadEvents [ id ] = incompleteDesc ;
189+ }
190+
191+ private void Clr_TypeLoadStop ( TypeLoadStopTraceData obj )
192+ {
193+ IdOfIncompleteAction id = new IdOfIncompleteAction ( ) ;
194+ id . Identifier = obj . TypeLoadStartID ;
195+ id . ThreadID = obj . ThreadID ;
196+
197+ // If we had a TypeLoad start lookup event, capture that start time, otherwise, use the TypeLoadStop
198+ // data as both start and stop
199+ StartStopStackMingledComputer . EventUID startUID = new StartStopStackMingledComputer . EventUID ( obj ) ;
200+ if ( _incompleteTypeLoadEvents . TryGetValue ( id , out IncompleteActionDesc typeLoadStartData ) )
201+ {
202+ startUID = typeLoadStartData . Start ;
203+ _incompleteTypeLoadEvents . Remove ( id ) ;
204+ }
205+
206+ AddStartStopData ( id . ThreadID , startUID , new StartStopStackMingledComputer . EventUID ( obj ) , $ "TypeLoad ({ obj . TypeName } , { obj . LoadLevel } )") ;
207+ }
155208 }
156209}
0 commit comments