Move activity tracking helpers for assembly loads out of ActivityTracker
authorElinor Fung <elfung@microsoft.com>
Tue, 29 Oct 2019 22:11:50 +0000 (15:11 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 30 Oct 2019 03:55:59 +0000 (20:55 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/139e79c08485866fdf5f6245e49a4f65acc7968f

src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs
src/coreclr/src/binder/activitytracker.cpp
src/coreclr/src/vm/metasig.h
src/coreclr/src/vm/mscorlib.h
src/coreclr/src/vm/namespace.h

index 672702d..dd19011 100644 (file)
@@ -2,6 +2,7 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+using System.Diagnostics.Tracing;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
@@ -196,5 +197,24 @@ namespace System.Runtime.Loader
                 asm is System.Reflection.Emit.AssemblyBuilder ab ? ab.InternalAssembly :
                 null;
         }
+
+        // Assembly load runtime activity name
+        private const string AssemblyLoadName = "AssemblyLoad";
+
+        /// <summary>
+        /// Called by the runtime to start an assembly load activity for tracing
+        /// </summary>
+        private static void StartAssemblyLoad(ref Guid activityId, ref Guid relatedActivityId)
+        {
+            ActivityTracker.Instance.OnStart(NativeRuntimeEventSource.Log.Name, AssemblyLoadName, 0, ref activityId, ref relatedActivityId, EventActivityOptions.Recursive);
+        }
+
+        /// <summary>
+        /// Called by the runtime to stop an assembly load activity for tracing
+        /// </summary>
+        private static void StopAssemblyLoad(ref Guid activityId)
+        {
+            ActivityTracker.Instance.OnStop(NativeRuntimeEventSource.Log.Name, AssemblyLoadName, 0, ref activityId);
+        }
     }
 }
index d971d9c..ce50872 100644 (file)
@@ -19,7 +19,7 @@ void ActivityTracker::Start(/*out*/ GUID *activityId, /*out*/ GUID *relatedActiv
 {
     GCX_COOP();
 
-    PREPARE_NONVIRTUAL_CALLSITE(METHOD__ACTIVITY_TRACKER__START_ASSEMBLY_LOAD);
+    PREPARE_NONVIRTUAL_CALLSITE(METHOD__ASSEMBLYLOADCONTEXT__START_ASSEMBLY_LOAD);
     DECLARE_ARGHOLDER_ARRAY(args, 2);
     args[ARGNUM_0] = PTR_TO_ARGHOLDER(activityId);
     args[ARGNUM_1] = PTR_TO_ARGHOLDER(relatedActivityId);
@@ -31,7 +31,7 @@ void ActivityTracker::Stop(/*out*/ GUID *activityId)
 {
     GCX_COOP();
 
-    PREPARE_NONVIRTUAL_CALLSITE(METHOD__ACTIVITY_TRACKER__STOP_ASSEMBLY_LOAD);
+    PREPARE_NONVIRTUAL_CALLSITE(METHOD__ASSEMBLYLOADCONTEXT__STOP_ASSEMBLY_LOAD);
     DECLARE_ARGHOLDER_ARRAY(args, 1);
     args[ARGNUM_0] = PTR_TO_ARGHOLDER(activityId);
 
index 886a7c0..13d6778 100644 (file)
@@ -560,7 +560,7 @@ DEFINE_METASIG_T(SM(SyncCtx_ArrIntPtr_Bool_Int_RetInt, C(SYNCHRONIZATION_CONTEXT
 DEFINE_METASIG_T(IM(RefGuid_OutIntPtr_RetCustomQueryInterfaceResult, r(g(GUID)) r(I), g(CUSTOMQUERYINTERFACERESULT)))
 #endif //FEATURE_COMINTEROP
 
-// Activity Tracker
+// Assembly Load Context
 DEFINE_METASIG_T(SM(RefGuid_RefGuid_RetVoid, r(g(GUID)) r(g(GUID)) , v))
 DEFINE_METASIG_T(SM(RefGuid_RetVoid, r(g(GUID)), v))
 
index c0f1ea0..98830a8 100644 (file)
@@ -908,6 +908,8 @@ DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  ON_ASSEMBLY_LOAD,       OnAssemblyLoad, SM_A
 DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  ON_RESOURCE_RESOLVE,    OnResourceResolve, SM_Assembly_Str_RetAssembly)
 DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  ON_TYPE_RESOLVE,        OnTypeResolve, SM_Assembly_Str_RetAssembly)
 DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  ON_ASSEMBLY_RESOLVE,    OnAssemblyResolve, SM_Assembly_Str_RetAssembly)
+DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  START_ASSEMBLY_LOAD,    StartAssemblyLoad,    SM_RefGuid_RefGuid_RetVoid)
+DEFINE_METHOD(ASSEMBLYLOADCONTEXT,  STOP_ASSEMBLY_LOAD,     StopAssemblyLoad,     SM_RefGuid_RetVoid)
 
 #ifdef FEATURE_COMINTEROP
 DEFINE_CLASS(WINDOWSRUNTIMEMETATADA, WinRT, WindowsRuntimeMetadata) 
@@ -1378,10 +1380,6 @@ DEFINE_FIELD_U(_kind,               ContractExceptionObject,    _Kind)
 DEFINE_FIELD_U(_userMessage,        ContractExceptionObject,    _UserMessage)
 DEFINE_FIELD_U(_condition,          ContractExceptionObject,    _Condition)
 
-DEFINE_CLASS(ACTIVITY_TRACKER,      Tracing,                ActivityTracker)
-DEFINE_METHOD(ACTIVITY_TRACKER,     START_ASSEMBLY_LOAD,    StartAssemblyLoad,    SM_RefGuid_RefGuid_RetVoid)
-DEFINE_METHOD(ACTIVITY_TRACKER,     STOP_ASSEMBLY_LOAD,     StopAssemblyLoad,     SM_RefGuid_RetVoid)
-
 #ifdef FEATURE_COMINTEROP
 DEFINE_CLASS(CAUSALITY_TRACE_LEVEL, WindowsFoundationDiag,   CausalityTraceLevel)
 DEFINE_CLASS(ASYNC_TRACING_EVENT_ARGS,       WindowsFoundationDiag,         TracingStatusChangedEventArgs)
index d21df17..ce40247 100644 (file)
@@ -21,7 +21,6 @@
 #define g_ResourcesNS       g_SystemNS ".Resources"
 #define g_DiagnosticsNS     g_SystemNS ".Diagnostics"
 #define g_CodeContractsNS   g_DiagnosticsNS ".Contracts"
-#define g_TracingNS         g_DiagnosticsNS ".Tracing"
 #define g_AssembliesNS      g_SystemNS ".Configuration.Assemblies"
 #define g_GlobalizationNS   g_SystemNS ".Globalization"
 #define g_IsolatedStorageNS g_SystemNS ".IO.IsolatedStorage"