summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-01-18 19:19:17 +0100
committerJan Kotas <jkotas@microsoft.com>2019-01-18 10:19:17 -0800
commiteca41b2123b21d887748528b83d4bfcffe1ac68f (patch)
treee9cdb00013f755df323baa124502fd659d193e5f
parent40ac403fb3028af50f7287838f4c1009fecad69c (diff)
downloadcoreclr-eca41b2123b21d887748528b83d4bfcffe1ac68f.tar.gz
coreclr-eca41b2123b21d887748528b83d4bfcffe1ac68f.tar.bz2
coreclr-eca41b2123b21d887748528b83d4bfcffe1ac68f.zip
Move AsyncCausality to shared partition (#22062)
* Move AsyncCausality to shared partition * Set FeatureAsyncCausalityTracer property
-rw-r--r--src/System.Private.CoreLib/System.Private.CoreLib.csproj6
-rw-r--r--src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs (renamed from src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs)17
-rw-r--r--src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems4
-rw-r--r--src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs4
-rw-r--r--src/System.Private.CoreLib/shared/System/Threading/Tasks/AsyncCausalityTracer.Noop.cs77
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs53
6 files changed, 87 insertions, 74 deletions
diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
index b68a2bc21c..53ec3043fb 100644
--- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -121,7 +121,6 @@
<Compile Include="$(BclSourcesRoot)\Internal\Resources\WindowsRuntimeResourceManagerBase.cs" Condition="'$(FeatureAppX)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\EnvironmentAugments.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\RuntimeThread.cs" />
- <Compile Include="$(BclSourcesRoot)\Internal\Threading\Tasks\AsyncCausalitySupport.cs" />
<Compile Include="$(BclSourcesRoot)\Microsoft\Win32\UnsafeNativeMethods.cs" />
<Compile Include="$(BclSourcesRoot)\Microsoft\Win32\Win32Native.cs" />
<Compile Include="$(BclSourcesRoot)\System\__Canon.cs" />
@@ -278,7 +277,6 @@
<Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Overlapped.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationContext.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\AsyncCausalityTracer.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\FutureFactory.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\Task.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TaskContinuation.cs" />
@@ -366,6 +364,7 @@
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeMarshal.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeMetadata.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\IAsyncCausalityTracerStatics.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\AsyncCausalityTracer.cs" />
<Compile Include="$(BclSourcesRoot)\System\Variant.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
@@ -428,6 +427,9 @@
<OSGroup>Windows_NT</OSGroup>
</PropertyGroup>
<PropertyGroup>
+ <FeatureAsyncCausalityTracer Condition="'$(FeatureCominterop)' == 'true'">true</FeatureAsyncCausalityTracer>
+ </PropertyGroup>
+ <PropertyGroup>
<StrongNameSig>Silverlight</StrongNameSig>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)Tools\Versioning\GenerateVersionInfo.targets" />
diff --git a/src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs b/src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs
index df34a64eff..35f4dfe18c 100644
--- a/src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs
+++ b/src/System.Private.CoreLib/shared/Internal/Threading/Tasks/AsyncCausalitySupport.cs
@@ -2,13 +2,8 @@
// 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;
-using System.Diagnostics;
using System.Threading.Tasks;
-using System.Collections.Generic;
using System.Runtime.CompilerServices;
-using AsyncCausalityStatus = System.Threading.Tasks.AsyncCausalityStatus;
-using CausalityTraceLevel = System.Threading.Tasks.CausalityTraceLevel;
namespace Internal.Threading.Tasks
{
@@ -57,18 +52,6 @@ namespace Internal.Threading.Tasks
{
AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Error);
}
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal static void TraceSynchronousWorkStart(Task task)
- {
- AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, task.Id, CausalitySynchronousWork.Execution);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal static void TraceSynchronousWorkCompletion()
- {
- AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
- }
}
}
diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
index 263214af5e..9a94bdf536 100644
--- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
+++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
@@ -22,6 +22,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Padding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\CompilerServices\Unsafe.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Internal\Threading\Tasks\AsyncCausalitySupport.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleMinusOneIsInvalid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs" />
@@ -973,6 +974,9 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SafeBSTRHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Windows.cs" />
</ItemGroup>
+ <ItemGroup Condition="'$(FeatureAsyncCausalityTracer)' != 'true'">
+ <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\AsyncCausalityTracer.Noop.cs" />
+ </ItemGroup>
<ItemGroup Condition="$(TargetsWindows) and '$(EnableWinRT)' != 'true'">
<Compile Include="$(MSBuildThisFileDirectory)Internal\Win32\RegistryKey.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" />
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
index b44df7a0cd..f6692e8b43 100644
--- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
+++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
@@ -578,7 +578,7 @@ namespace System.Runtime.CompilerServices
bool loggingOn = AsyncCausalitySupport.LoggingOn;
if (loggingOn)
{
- AsyncCausalitySupport.TraceSynchronousWorkStart(this);
+ AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, this.Id, CausalitySynchronousWork.Execution);
}
ExecutionContext context = Context;
@@ -619,7 +619,7 @@ namespace System.Runtime.CompilerServices
if (loggingOn)
{
- AsyncCausalitySupport.TraceSynchronousWorkCompletion();
+ AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/AsyncCausalityTracer.Noop.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/AsyncCausalityTracer.Noop.cs
new file mode 100644
index 0000000000..c3f787b36b
--- /dev/null
+++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/AsyncCausalityTracer.Noop.cs
@@ -0,0 +1,77 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// 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;
+
+namespace System.Threading.Tasks
+{
+ internal enum CausalityTraceLevel
+ {
+ Required = 0,
+ Important = 1,
+ Verbose = 2,
+ }
+
+ internal enum AsyncCausalityStatus
+ {
+ Started = 0,
+ Completed = 1,
+ Canceled = 2,
+ Error = 3,
+ }
+
+ internal enum CausalityRelation
+ {
+ AssignDelegate = 0,
+ Join = 1,
+ Choice = 2,
+ Cancel = 3,
+ Error = 4,
+ }
+
+ internal enum CausalitySynchronousWork
+ {
+ CompletionNotification = 0,
+ ProgressNotification = 1,
+ Execution = 2,
+ }
+
+ //
+ // Empty implementation of AsyncCausality events
+ //
+ internal static class AsyncCausalityTracer
+ {
+ public static bool LoggingOn => false;
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void EnableToETW(bool enabled)
+ {
+ }
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void TraceOperationCreation(CausalityTraceLevel traceLevel, int taskId, string operationName, ulong relatedContext)
+ {
+ }
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status)
+ {
+ }
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void TraceOperationRelation(CausalityTraceLevel traceLevel, int taskId, CausalityRelation relation)
+ {
+ }
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void TraceSynchronousWorkStart(CausalityTraceLevel traceLevel, int taskId, CausalitySynchronousWork work)
+ {
+ }
+
+ [Conditional("NOOP_ASYNCCASUALITYTRACER")]
+ public static void TraceSynchronousWorkCompletion(CausalityTraceLevel traceLevel, CausalitySynchronousWork work)
+ {
+ }
+ }
+}
diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
index b942ecbc28..a06b3b8a07 100644
--- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs
@@ -2,107 +2,67 @@
// 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;
using System.Security;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-#if FEATURE_COMINTEROP
using System.Runtime.InteropServices.WindowsRuntime;
using WFD = Windows.Foundation.Diagnostics;
-#endif
namespace System.Threading.Tasks
{
internal enum CausalityTraceLevel
{
-#if FEATURE_COMINTEROP
Required = WFD.CausalityTraceLevel.Required,
Important = WFD.CausalityTraceLevel.Important,
Verbose = WFD.CausalityTraceLevel.Verbose
-#else
- Required,
- Important,
- Verbose
-#endif
}
internal enum AsyncCausalityStatus
{
-#if FEATURE_COMINTEROP
Canceled = WFD.AsyncCausalityStatus.Canceled,
Completed = WFD.AsyncCausalityStatus.Completed,
Error = WFD.AsyncCausalityStatus.Error,
Started = WFD.AsyncCausalityStatus.Started
-#else
- Started,
- Completed,
- Canceled,
- Error
-#endif
}
internal enum CausalityRelation
{
-#if FEATURE_COMINTEROP
AssignDelegate = WFD.CausalityRelation.AssignDelegate,
Join = WFD.CausalityRelation.Join,
Choice = WFD.CausalityRelation.Choice,
Cancel = WFD.CausalityRelation.Cancel,
Error = WFD.CausalityRelation.Error
-#else
- AssignDelegate,
- Join,
- Choice,
- Cancel,
- Error
-#endif
}
internal enum CausalitySynchronousWork
{
-#if FEATURE_COMINTEROP
CompletionNotification = WFD.CausalitySynchronousWork.CompletionNotification,
ProgressNotification = WFD.CausalitySynchronousWork.ProgressNotification,
Execution = WFD.CausalitySynchronousWork.Execution
-#else
- CompletionNotification,
- ProgressNotification,
- Execution
-#endif
}
internal static class AsyncCausalityTracer
{
internal static void EnableToETW(bool enabled)
{
-#if FEATURE_COMINTEROP
if (enabled)
f_LoggingOn |= Loggers.ETW;
else
f_LoggingOn &= ~Loggers.ETW;
-#endif
}
internal static bool LoggingOn
{
get
{
-#if FEATURE_COMINTEROP
return f_LoggingOn != 0;
-#else
- return false;
-#endif
}
}
-#if FEATURE_COMINTEROP
//s_PlatformId = {4B0171A6-F3D0-41A0-9B33-02550652B995}
private static readonly Guid s_PlatformId = new Guid(0x4B0171A6, 0xF3D0, 0x41A0, 0x9B, 0x33, 0x02, 0x55, 0x06, 0x52, 0xB9, 0x95);
@@ -164,7 +124,6 @@ namespace System.Threading.Tasks
else
f_LoggingOn &= ~Loggers.CausalityTracer;
}
-#endif
//
// The TraceXXX methods should be called only if LoggingOn property returned true
@@ -172,7 +131,6 @@ namespace System.Threading.Tasks
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Tracking is slow path. Disable inlining for it.
internal static void TraceOperationCreation(CausalityTraceLevel traceLevel, int taskId, string operationName, ulong relatedContext)
{
-#if FEATURE_COMINTEROP
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
@@ -185,13 +143,11 @@ namespace System.Threading.Tasks
//view function comment
LogAndDisable(ex);
}
-#endif
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status)
{
-#if FEATURE_COMINTEROP
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
@@ -204,13 +160,11 @@ namespace System.Threading.Tasks
//view function comment
LogAndDisable(ex);
}
-#endif
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal static void TraceOperationRelation(CausalityTraceLevel traceLevel, int taskId, CausalityRelation relation)
{
-#if FEATURE_COMINTEROP
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
@@ -223,13 +177,11 @@ namespace System.Threading.Tasks
//view function comment
LogAndDisable(ex);
}
-#endif
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal static void TraceSynchronousWorkStart(CausalityTraceLevel traceLevel, int taskId, CausalitySynchronousWork work)
{
-#if FEATURE_COMINTEROP
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
@@ -242,13 +194,11 @@ namespace System.Threading.Tasks
//view function comment
LogAndDisable(ex);
}
-#endif
}
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal static void TraceSynchronousWorkCompletion(CausalityTraceLevel traceLevel, CausalitySynchronousWork work)
{
-#if FEATURE_COMINTEROP
try
{
if ((f_LoggingOn & Loggers.ETW) != 0)
@@ -261,10 +211,8 @@ namespace System.Threading.Tasks
//view function comment
LogAndDisable(ex);
}
-#endif
}
-#if FEATURE_COMINTEROP
//fix for 796185: leaking internal exceptions to customers,
//we should catch and log exceptions but never propagate them.
private static void LogAndDisable(Exception ex)
@@ -272,7 +220,6 @@ namespace System.Threading.Tasks
f_LoggingOn = 0;
Debugger.Log(0, "AsyncCausalityTracer", ex.ToString());
}
-#endif
private static ulong GetOperationId(uint taskId)
{