-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix crossgen2 OverflowException emitting inlining info for runtime-async inliners #134697
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3780092
Fix crossgen2 overflow emitting inlining info for async-variant inliners
lewing 692227c
Never prefer a compiler-generated async thunk as the reported inliner
lewing 020d61f
Skip async thunks as cross-module inliners and cover variant dedup
lewing eba14fc
Share the IL body fixup identity between CompileMethod and InliningIn…
lewing f1d85b4
Add license header to AsyncCrossModuleGenericLib.cs
lewing e4a292c
Add license comments to AsyncGenericInlinerConsumer.cs
lewing ef4ce5f
Detect runtime-async and synchronized flag changes in IL body fixups
lewing 957b384
Name IL body flag values and cover the synchronized flag in the test
lewing b504d98
Fix readytorun merged runner build and compute inliner identity lazily
lewing 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
37 changes: 37 additions & 0 deletions
37
.../ILCompiler.ReadyToRun.Tests/TestCases/CrossModuleInlining/AsyncGenericInlinerConsumer.cs
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,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
| using System.Threading.Tasks; | ||
|
|
||
| /// <summary> | ||
| /// Consumer that awaits a runtime-async method on a generic type from AsyncCrossModuleGenericLib, | ||
| /// instantiated over a value type defined in this assembly so that the async variant of | ||
| /// AsyncGenericWrapper<LocalAsyncStruct>.InvokeGetValueAsync() is compiled into this image. | ||
| /// </summary> | ||
|
|
||
| public struct LocalAsyncStruct { public int Value; } | ||
|
|
||
| public static class AsyncGenericInlinerConsumer | ||
| { | ||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static async Task<int> UseAsync() | ||
| { | ||
| var wrapper = new AsyncGenericWrapper<LocalAsyncStruct>(new LocalAsyncStruct { Value = 1 }); | ||
| return await wrapper.InvokeGetValueAsync(); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static async Task<int> AwaitValueTask() | ||
| { | ||
| var wrapper = new AsyncGenericWrapper<LocalAsyncStruct>(new LocalAsyncStruct { Value = 2 }); | ||
| return await wrapper.GetValueTask(); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static Task<int> ReturnValueTask() | ||
| { | ||
| var wrapper = new AsyncGenericWrapper<LocalAsyncStruct>(new LocalAsyncStruct { Value = 3 }); | ||
| return wrapper.GetValueTask(); | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
...ReadyToRun.Tests/TestCases/CrossModuleInlining/Dependencies/AsyncCrossModuleGenericLib.cs
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,41 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
|
Copilot marked this conversation as resolved.
|
||
| using System.Threading.Tasks; | ||
|
|
||
| /// <summary> | ||
| /// Library with a generic type whose runtime-async method inlines a utility method. | ||
| /// When the consumer awaits the method on an instantiation over one of its own value types, | ||
| /// crossgen2 compiles the async variant of the method into the consumer as a CrossModuleCompileable | ||
| /// generic, making the async variant a cross-module inliner of AsyncGenericUtility.GetAsyncGenericValue. | ||
| /// </summary> | ||
| public static class AsyncGenericUtility | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static int GetAsyncGenericValue() => 42; | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public static int GetSharedInlineeValue() => 43; | ||
| } | ||
|
|
||
| public class AsyncGenericWrapper<T> | ||
| { | ||
| private T _value; | ||
|
|
||
| public AsyncGenericWrapper(T value) => _value = value; | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public async Task<int> InvokeGetValueAsync() | ||
| { | ||
| await Task.Yield(); | ||
| return AsyncGenericUtility.GetAsyncGenericValue(); | ||
| } | ||
|
|
||
| // Not async, so both the task-returning method and its async variant are compiled from this IL. | ||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public Task<int> GetValueTask() | ||
| { | ||
| return Task.FromResult(AsyncGenericUtility.GetSharedInlineeValue()); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.