From: Ben Adams Date: Wed, 26 Jun 2019 12:55:14 +0000 (+0200) Subject: Don't show AggressiveInlining items in exception stacks (#25408) X-Git-Tag: accepted/tizen/unified/20190813.215958~40^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3063e668d045d5bc2fbdbbc99e68fac0d771190e;p=platform%2Fupstream%2Fcoreclr.git Don't show AggressiveInlining items in exception stacks (#25408) --- diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs index 8365c48..3855a5c 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs @@ -339,7 +339,32 @@ namespace System.Diagnostics private static bool ShowInStackTrace(MethodBase mb) { Debug.Assert(mb != null); - return !(mb.IsDefined(typeof(StackTraceHiddenAttribute)) || (mb.DeclaringType?.IsDefined(typeof(StackTraceHiddenAttribute)) ?? false)); + + if (mb.MethodImplementationFlags.HasFlag(MethodImplAttributes.AggressiveInlining)) + { + // Aggressive Inlines won't normally show in the StackTrace; however for Tier0 Jit and + // cross-assembly AoT/R2R these inlines will be blocked until Tier1 Jit re-Jits + // them when they will inline. We don't show them in the StackTrace to bring consitency + // between this first-pass asm and fully optimized asm. + return false; + } + + if (mb.IsDefined(typeof(StackTraceHiddenAttribute), inherit: false)) + { + // Don't show where StackTraceHidden is applied to the method. + return false; + } + + Type? declaringType = mb.DeclaringType; + // Methods don't always have containing types, for example dynamic RefEmit generated methods. + if (declaringType != null && + declaringType.IsDefined(typeof(StackTraceHiddenAttribute), inherit: false)) + { + // Don't show where StackTraceHidden is applied to the containing Type of the method. + return false; + } + + return true; } private static bool TryResolveStateMachineMethod(ref MethodBase method, out Type declaringType) diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs index 9a153ae..f3b63c5 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs @@ -51,7 +51,6 @@ namespace System.Runtime.CompilerServices /// Gets the result of the ValueTask. [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] public void GetResult() => _value.ThrowIfCompletedUnsuccessfully(); /// Schedules the continuation action for the . @@ -157,7 +156,6 @@ namespace System.Runtime.CompilerServices /// Gets the result of the ValueTask. [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] public TResult GetResult() => _value.Result; /// Schedules the continuation action for the . diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs index d7bc41b..db63f7f 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs @@ -43,7 +43,6 @@ namespace System.Runtime.CompilerServices } /// Gets the result of the ValueTask. - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] public void GetResult() => _value.ThrowIfCompletedUnsuccessfully(); @@ -126,7 +125,6 @@ namespace System.Runtime.CompilerServices } /// Gets the result of the ValueTask. - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] public TResult GetResult() => _value.Result; diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs index 75c6fd9..cfb8040 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs @@ -350,7 +350,6 @@ namespace System.Threading.Tasks /// Throws the exception that caused the to fail. If it completed successfully, nothing is thrown. [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] internal void ThrowIfCompletedUnsuccessfully() { object? obj = _obj; diff --git a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs index 6fcdf17..bd71883 100644 --- a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs +++ b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs @@ -82,8 +82,6 @@ namespace System [ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)] public Utf8String Slice(int startIndex, int length) => Substring(startIndex, length); - - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidateStartIndexAndLength(int startIndex, int length) {