Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DebuggerHidden to managed JitHelpers #106167

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

<!-- Sources -->
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\CompilerHelpers\ThrowHelpers.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\ComActivationContextInternal.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\ComponentActivator.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\__Canon.cs" />
Expand Down Expand Up @@ -231,7 +232,6 @@
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Type.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\ThrowHelper.cs" />
<Compile Include="$(BclSourcesRoot)\System\TypedReference.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\TypeLoadException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace System
namespace Internal.Runtime.CompilerHelpers
{
internal static unsafe partial class ThrowHelper
[StackTraceHidden]
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
[DebuggerStepThrough]
internal static unsafe partial class ThrowHelpers
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
{
[DoesNotReturn]
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ExceptionNative_ThrowAmbiguousResolutionException")]
private static partial void ThrowAmbiguousResolutionException(MethodTable* targetType, MethodTable* interfaceType, void* methodDesc);

[DoesNotReturn]
[DebuggerHidden]
internal static void ThrowAmbiguousResolutionException(
void* method, // MethodDesc*
void* interfaceType, // MethodTable*
Expand All @@ -27,6 +31,7 @@ internal static void ThrowAmbiguousResolutionException(
private static partial void ThrowEntryPointNotFoundException(MethodTable* targetType, MethodTable* interfaceType, void* methodDesc);

[DoesNotReturn]
[DebuggerHidden]
internal static void ThrowEntryPointNotFoundException(
void* method, // MethodDesc*
void* interfaceType, // MethodTable*
Expand Down
24 changes: 12 additions & 12 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@
DYNAMICJITHELPER(CORINFO_HELP_THROW, IL_Throw, METHOD__NIL)
DYNAMICJITHELPER(CORINFO_HELP_RETHROW, IL_Rethrow, METHOD__NIL)
JITHELPER(CORINFO_HELP_USER_BREAKPOINT, JIT_UserBreakpoint, METHOD__NIL)
DYNAMICJITHELPER(CORINFO_HELP_RNGCHKFAIL, NULL, METHOD__THROWHELPER__THROWINDEXOUTOFRANGEEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_OVERFLOW, NULL, METHOD__THROWHELPER__THROWOVERFLOWEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROWDIVZERO, NULL, METHOD__THROWHELPER__THROWDIVIDEBYZEROEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROWNULLREF, NULL, METHOD__THROWHELPER__THROWNULLREFEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_VERIFICATION, NULL, METHOD__THROWHELPER__THROWVERIFICATIONEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_RNGCHKFAIL, NULL, METHOD__THROWHELPERS__THROWINDEXOUTOFRANGEEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_OVERFLOW, NULL, METHOD__THROWHELPERS__THROWOVERFLOWEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROWDIVZERO, NULL, METHOD__THROWHELPERS__THROWDIVIDEBYZEROEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROWNULLREF, NULL, METHOD__THROWHELPERS__THROWNULLREFEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_VERIFICATION, NULL, METHOD__THROWHELPERS__THROWVERIFICATIONEXCEPTION)
JITHELPER(CORINFO_HELP_FAIL_FAST, JIT_FailFast, METHOD__NIL)
JITHELPER(CORINFO_HELP_METHOD_ACCESS_EXCEPTION,JIT_ThrowMethodAccessException, METHOD__NIL)
JITHELPER(CORINFO_HELP_FIELD_ACCESS_EXCEPTION,JIT_ThrowFieldAccessException, METHOD__NIL)
Expand Down Expand Up @@ -291,13 +291,13 @@
JITHELPER(CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, JIT_LoopCloneChoiceAddr, METHOD__NIL)
JITHELPER(CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, JIT_DebugLogLoopCloning, METHOD__NIL)

DYNAMICJITHELPER(CORINFO_HELP_THROW_ARGUMENTEXCEPTION, NULL, METHOD__THROWHELPER__THROWARGUMENTEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION, NULL, METHOD__THROWHELPER__THROWARGUMENTOUTOFRANGEEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_NOT_IMPLEMENTED, NULL, METHOD__THROWHELPER__THROWNOTIMPLEMENTEDEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, NULL, METHOD__THROWHELPER__THROWPLATFORMNOTSUPPORTEDEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, NULL, METHOD__THROWHELPER__THROWTYPENOTSUPPORTED)
DYNAMICJITHELPER(CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION, NULL, METHOD__THROWHELPER__THROWAMBIGUOUSRESOLUTIONEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION, NULL, METHOD__THROWHELPER__THROWENTRYPOINTNOTFOUNDEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_ARGUMENTEXCEPTION, NULL, METHOD__THROWHELPERS__THROWARGUMENTEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION, NULL, METHOD__THROWHELPERS__THROWARGUMENTOUTOFRANGEEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_NOT_IMPLEMENTED, NULL, METHOD__THROWHELPERS__THROWNOTIMPLEMENTEDEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, NULL, METHOD__THROWHELPERS__THROWPLATFORMNOTSUPPORTEDEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, NULL, METHOD__THROWHELPERS__THROWTYPENOTSUPPORTED)
DYNAMICJITHELPER(CORINFO_HELP_THROW_AMBIGUOUS_RESOLUTION_EXCEPTION, NULL, METHOD__THROWHELPERS__THROWAMBIGUOUSRESOLUTIONEXCEPTION)
DYNAMICJITHELPER(CORINFO_HELP_THROW_ENTRYPOINT_NOT_FOUND_EXCEPTION, NULL, METHOD__THROWHELPERS__THROWENTRYPOINTNOTFOUNDEXCEPTION)

JITHELPER(CORINFO_HELP_JIT_PINVOKE_BEGIN, JIT_PInvokeBegin, METHOD__NIL)
JITHELPER(CORINFO_HELP_JIT_PINVOKE_END, JIT_PInvokeEnd, METHOD__NIL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Internal.Runtime.CompilerHelpers
/// These methods are used to throw exceptions from generated code. The type and methods
/// need to be public as they constitute a public contract with the NativeAOT toolchain.
/// </summary>
public static class ThrowHelpers
public static partial class ThrowHelpers
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
{
internal static void ThrowBodyRemoved()
{
Expand All @@ -33,46 +33,6 @@ internal static void ThrowUnavailableType()
throw new TypeLoadException(SR.Arg_UnavailableTypeLoadException);
}

public static void ThrowOverflowException()
{
throw new OverflowException();
}

public static void ThrowIndexOutOfRangeException()
{
throw new IndexOutOfRangeException();
}

public static void ThrowNullReferenceException()
{
throw new NullReferenceException();
}

public static void ThrowDivideByZeroException()
{
throw new DivideByZeroException();
}

public static void ThrowArrayTypeMismatchException()
{
throw new ArrayTypeMismatchException();
}

public static void ThrowPlatformNotSupportedException()
{
throw new PlatformNotSupportedException();
}

public static void ThrowNotImplementedException()
{
throw NotImplemented.ByDesign;
}

public static void ThrowNotSupportedException()
{
throw new NotSupportedException();
}

public static void ThrowBadImageFormatException(ExceptionStringID id)
{
throw TypeLoaderExceptionHelper.CreateBadImageFormatException(id);
Expand Down Expand Up @@ -123,16 +83,6 @@ public static void ThrowAmbiguousMatchException(ExceptionStringID id)
throw TypeLoaderExceptionHelper.CreateAmbiguousMatchException(id);
}

public static void ThrowArgumentException()
{
throw new ArgumentException();
}

public static void ThrowArgumentOutOfRangeException()
{
throw new ArgumentOutOfRangeException();
}

public static void ThrowNotSupportedInlineArrayEqualsGetHashCode()
{
throw new NotSupportedException(SR.NotSupported_InlineArrayEqualsGetHashCode);
Expand Down
26 changes: 13 additions & 13 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,19 +642,19 @@ DEFINE_METHOD(SPAN_HELPERS, MEMSET, Fill, SM_RefByte_Byt
DEFINE_METHOD(SPAN_HELPERS, MEMZERO, ClearWithoutReferences, SM_RefByte_UIntPtr_RetVoid)
DEFINE_METHOD(SPAN_HELPERS, MEMCOPY, Memmove, SM_RefByte_RefByte_UIntPtr_RetVoid)

DEFINE_CLASS(THROWHELPER, System, ThrowHelper)
DEFINE_METHOD(THROWHELPER, THROWARGUMENTEXCEPTION, ThrowArgumentException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWARGUMENTOUTOFRANGEEXCEPTION, ThrowArgumentOutOfRangeException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWINDEXOUTOFRANGEEXCEPTION, ThrowIndexOutOfRangeException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWNOTIMPLEMENTEDEXCEPTION, ThrowNotImplementedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWPLATFORMNOTSUPPORTEDEXCEPTION, ThrowPlatformNotSupportedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWTYPENOTSUPPORTED, ThrowTypeNotSupportedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWOVERFLOWEXCEPTION, ThrowOverflowException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWDIVIDEBYZEROEXCEPTION, ThrowDivideByZeroException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWNULLREFEXCEPTION, ThrowNullReferenceException, SM_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWVERIFICATIONEXCEPTION, ThrowVerificationException, SM_Int_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWAMBIGUOUSRESOLUTIONEXCEPTION, ThrowAmbiguousResolutionException, SM_PtrVoid_PtrVoid_PtrVoid_RetVoid)
DEFINE_METHOD(THROWHELPER, THROWENTRYPOINTNOTFOUNDEXCEPTION, ThrowEntryPointNotFoundException, SM_PtrVoid_PtrVoid_PtrVoid_RetVoid)
DEFINE_CLASS(THROWHELPERS, InternalCompilerHelpers, ThrowHelpers)
DEFINE_METHOD(THROWHELPERS, THROWARGUMENTEXCEPTION, ThrowArgumentException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWARGUMENTOUTOFRANGEEXCEPTION, ThrowArgumentOutOfRangeException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWINDEXOUTOFRANGEEXCEPTION, ThrowIndexOutOfRangeException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWNOTIMPLEMENTEDEXCEPTION, ThrowNotImplementedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWPLATFORMNOTSUPPORTEDEXCEPTION, ThrowPlatformNotSupportedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWTYPENOTSUPPORTED, ThrowTypeNotSupportedException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWOVERFLOWEXCEPTION, ThrowOverflowException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWDIVIDEBYZEROEXCEPTION, ThrowDivideByZeroException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWNULLREFEXCEPTION, ThrowNullReferenceException, SM_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWVERIFICATIONEXCEPTION, ThrowVerificationException, SM_Int_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWAMBIGUOUSRESOLUTIONEXCEPTION, ThrowAmbiguousResolutionException, SM_PtrVoid_PtrVoid_PtrVoid_RetVoid)
DEFINE_METHOD(THROWHELPERS, THROWENTRYPOINTNOTFOUNDEXCEPTION, ThrowEntryPointNotFoundException, SM_PtrVoid_PtrVoid_PtrVoid_RetVoid)

DEFINE_CLASS(UNSAFE, CompilerServices, Unsafe)
DEFINE_METHOD(UNSAFE, AS_POINTER, AsPointer, NoSig)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define g_IntrinsicsNS g_RuntimeNS ".Intrinsics"
#define g_NumericsNS g_SystemNS ".Numerics"

#define g_InternalCompilerHelpersNS "Internal.Runtime.CompilerHelpers"
#define g_CompilerServicesNS g_RuntimeNS ".CompilerServices"

#define g_ConstrainedExecutionNS g_RuntimeNS ".ConstrainedExecution"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Internal.Runtime.CompilerHelpers
{
/// <summary>
/// These methods are used to throw exceptions from generated code.
/// For NativeAOT, the type and methods used need to be public
/// as they constitute a public contract.
/// For CoreCLR, the type and methods are used as JIT helpers.
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
#if NATIVEAOT
public
#else
internal
#endif
static unsafe partial class ThrowHelpers
{
[DoesNotReturn]
[DebuggerHidden]
public static void ThrowNullReferenceException()
{
throw new NullReferenceException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowArgumentException()
{
throw new ArgumentException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowArgumentOutOfRangeException()
{
throw new ArgumentOutOfRangeException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowDivideByZeroException()
{
throw new DivideByZeroException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowIndexOutOfRangeException()
{
throw new IndexOutOfRangeException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowOverflowException()
{
throw new OverflowException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowPlatformNotSupportedException()
{
throw new PlatformNotSupportedException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowNotImplementedException()
{
throw new NotImplementedException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowArrayTypeMismatchException()
{
throw new ArrayTypeMismatchException();
}

[DoesNotReturn]
[DebuggerHidden]
public static void ThrowNotSupportedException()
{
throw new NotSupportedException();
}

[DoesNotReturn]
[DebuggerHidden]
internal static void ThrowTypeNotSupportedException()
{
throw new NotSupportedException(SR.Arg_TypeNotSupported);
}

[DoesNotReturn]
[DebuggerHidden]
internal static void ThrowVerificationException(int ilOffset)
{
throw new System.Security.VerificationException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Internal\AssemblyAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Padding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\CompilerHelpers\ThrowHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\InteropServices\ComponentActivator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\InteropServices\IsolatedComponentLoadContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleMinusOneIsInvalid.cs" />
Expand Down
32 changes: 1 addition & 31 deletions src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
namespace System
{
[StackTraceHidden]
internal static partial class ThrowHelper
internal static class ThrowHelper
{
[DoesNotReturn]
internal static void ThrowArithmeticException(string message)
Expand All @@ -71,12 +71,6 @@ internal static void ThrowArrayTypeMismatchException()
throw new ArrayTypeMismatchException();
}

[DoesNotReturn]
internal static void ThrowArgumentException()
{
throw new ArgumentException();
}

[DoesNotReturn]
internal static void ThrowInvalidTypeWithPointersNotSupported(Type targetType)
{
Expand All @@ -95,30 +89,6 @@ internal static void ThrowArgumentOutOfRangeException()
throw new ArgumentOutOfRangeException();
}

[DoesNotReturn]
internal static void ThrowNotImplementedException()
{
throw new NotImplementedException();
}

[DoesNotReturn]
internal static void ThrowPlatformNotSupportedException()
{
throw new PlatformNotSupportedException();
}

[DoesNotReturn]
internal static void ThrowTypeNotSupportedException()
{
throw new NotSupportedException(SR.Arg_TypeNotSupported);
}

[DoesNotReturn]
internal static void ThrowVerificationException(int ilOffset)
{
throw new System.Security.VerificationException();
}

[DoesNotReturn]
internal static void ThrowArgumentException_DestinationTooShort()
{
Expand Down
Loading