-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: Non-void ThrowHelpers #48589
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
Merged
Merged
JIT: Non-void ThrowHelpers #48589
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
07dc0bf
handle non-void noreturns
EgorBo 6b2ea29
Introduce AlwaysThrow
EgorBo d44b5bc
remove assert
EgorBo d3c2fe1
Merge branch 'master' of github.com:dotnet/runtime into jit-throw-hel…
EgorBo 4498366
Add a test
EgorBo ceee3ce
Update NonVoidThrowHelper.csproj
EgorBo 49a7d84
Update NonVoidThrowHelper.cs
EgorBo 8e9f5c2
Disable the test for wasm
EgorBo 587a40e
Merge branch 'jit-throw-helpers-cold' of github.com:EgorBo/runtime-1 …
EgorBo aa35051
Merge branch 'master' of github.com:dotnet/runtime into jit-throw-hel…
EgorBo 0a518c0
Merge branch 'master' of github.com:dotnet/runtime into jit-throw-hel…
EgorBo 682c6dd
Merge branch 'main' of github.com:dotnet/runtime into jit-throw-helpe…
EgorBo da2e142
Update morph.cpp
EgorBo aff7e76
Update morph.cpp
EgorBo 7f35f0c
Merge branch 'main' of github.com:dotnet/runtime into jit-throw-helpe…
EgorBo ef79f74
Merge branch 'jit-throw-helpers-cold' of github.com:EgorBo/runtime-1 …
EgorBo 2d580d6
ci test
EgorBo 32c276e
ci test2
EgorBo a78c0af
Clean up
EgorBo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| // 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.Linq; | ||
| using System.Reflection; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| public class ProgramException : Exception {} | ||
|
|
||
| public sealed class ProgramSubclass : Program | ||
| { | ||
| public static readonly object s_Obj = new object(); | ||
| } | ||
|
|
||
| public unsafe class Program | ||
| { | ||
| private static int s_ReturnCode = 100; | ||
|
|
||
| private Guid field; | ||
|
|
||
| private static Program s_Instance = new (); | ||
|
|
||
| private static Program GetClass() => throw new ProgramException(); | ||
|
|
||
| private static Guid GetGuid() => throw new ProgramException(); | ||
|
|
||
| private static IntPtr GetIntPtr() => throw new ProgramException(); | ||
|
|
||
| private static int* GetPtr() => throw new ProgramException(); | ||
|
|
||
| private static Span<byte> GetSpan() => throw new ProgramException(); | ||
|
|
||
| private static int GetInt(object obj) => throw new ProgramException(); | ||
|
|
||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static void DoWork() => s_ReturnCode++; | ||
|
|
||
| private static void TestCond0() | ||
| { | ||
| if (GetClass() == default) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond1() | ||
| { | ||
| if (GetClass() is ProgramSubclass) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond2() | ||
| { | ||
| if (GetInt(ProgramSubclass.s_Obj) != 42) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond3() | ||
| { | ||
| if (GetClass() == s_Instance) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond4() | ||
| { | ||
| if (GetClass().field == Guid.NewGuid()) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond5() | ||
| { | ||
| if (GetGuid() == default) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond6() | ||
| { | ||
| if (GetIntPtr() == (IntPtr)42) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond7() | ||
| { | ||
| if (*GetPtr() == 42) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static void TestCond8() | ||
| { | ||
| if (GetSpan()[4] == 42) | ||
| DoWork(); | ||
| } | ||
|
|
||
| private static bool TestRet1() | ||
| { | ||
| return GetClass() == default; | ||
| } | ||
|
|
||
| private static bool TestRet2() | ||
| { | ||
| return GetClass() == s_Instance; | ||
| } | ||
|
|
||
| private static bool TestRet3() | ||
| { | ||
| return GetClass() is ProgramSubclass; | ||
| } | ||
|
|
||
| private static bool TestRet4() | ||
| { | ||
| return GetInt(ProgramSubclass.s_Obj) == 42; | ||
| } | ||
|
|
||
| private static bool TestRet5() | ||
| { | ||
| return GetClass().field == Guid.NewGuid(); | ||
| } | ||
|
|
||
| private static bool TestRet6() | ||
| { | ||
| return GetGuid() == default; | ||
| } | ||
|
|
||
| private static bool TestRet7() | ||
| { | ||
| return GetIntPtr() == (IntPtr)42; | ||
| } | ||
|
|
||
| private static bool TestRet8() | ||
| { | ||
| return *GetPtr() == 42; | ||
| } | ||
|
|
||
| private static bool TestRet9() | ||
| { | ||
| return GetSpan()[100] == 42; | ||
| } | ||
|
|
||
| private static Program TestTailCall1() | ||
| { | ||
| return GetClass(); | ||
| } | ||
|
|
||
| private static Guid TestTailCall2() | ||
| { | ||
| return GetGuid(); | ||
| } | ||
|
|
||
| private static IntPtr TestTailCall3() | ||
| { | ||
| return GetIntPtr(); | ||
| } | ||
|
|
||
| private static int* TestTailCall4() | ||
| { | ||
| return GetPtr(); | ||
| } | ||
|
|
||
| public static int Main() | ||
| { | ||
| foreach (var method in typeof(Program) | ||
| .GetMethods(BindingFlags.Static | BindingFlags.NonPublic) | ||
| .Where(m => m.Name.StartsWith("Test"))) | ||
| { | ||
| try | ||
| { | ||
| method.Invoke(null, null); | ||
| } | ||
| catch (TargetInvocationException tie) | ||
| { | ||
| if (tie.InnerException is ProgramException) | ||
| { | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| s_ReturnCode++; | ||
| } | ||
| return s_ReturnCode; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <Optimize>True</Optimize> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="NonVoidThrowHelper.cs" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.