-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Rename AsyncMethodDesc to AsyncMethodVariant, add "AsyncVariant" flag to MethodWithToken and MethodWithGCInfo #121218
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
27bef54
f54a832
f072d09
3ff1a3c
f22ed2d
c4523a0
442b6eb
eee7c72
3c6854a
d574847
62b9652
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| /// <summary> | ||
| /// Represents the async-callable (CORINFO_CALLCONV_ASYNCCALL) variant of a Task/ValueTask returning method. | ||
| /// </summary> | ||
| public sealed partial class AsyncMethodThunk : MethodDelegator | ||
| { | ||
| public override MethodDesc GetCanonMethodTarget(CanonicalFormKind kind) | ||
| { | ||
| return _wrappedMethod.GetCanonMethodTarget(kind).GetAsyncOtherVariant(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| /// <summary> | ||
| /// Represents the Task-returning variant of an async call convention method. | ||
| /// </summary> | ||
| public sealed partial class TaskReturningAsyncThunk : MethodDelegator | ||
| { | ||
| public override MethodDesc GetCanonMethodTarget(CanonicalFormKind kind) | ||
| { | ||
| return _wrappedMethod.GetCanonMethodTarget(kind).GetAsyncOtherVariant(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // 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; | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| /// <summary> | ||
| /// Represents the async-callable (CORINFO_CALLCONV_ASYNCCALL) variant of a Task/ValueTask returning method. | ||
| /// </summary> | ||
| public sealed partial class AsyncMethodThunk : MethodDelegator | ||
| { | ||
| public override string DiagnosticName | ||
| { | ||
| get | ||
| { | ||
| return "Async thunk: " + _wrappedMethod.DiagnosticName; | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // 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; | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| /// <summary> | ||
| /// Represents the async-callable (CORINFO_CALLCONV_ASYNCCALL) variant of a Task/ValueTask returning method. | ||
| /// </summary> | ||
| public sealed partial class AsyncMethodThunk : MethodDelegator | ||
| { | ||
| private readonly AsyncMethodData _asyncMethodData; | ||
|
|
||
| public AsyncMethodThunk(MethodDesc wrappedMethod) | ||
| : base(wrappedMethod) | ||
| { | ||
| Debug.Assert(wrappedMethod.IsTaskReturning); | ||
| Debug.Assert(!wrappedMethod.IsAsync); | ||
| _asyncMethodData = new AsyncMethodData() | ||
| { | ||
| Kind = AsyncMethodKind.AsyncVariantThunk, | ||
| Signature = _wrappedMethod.Signature.CreateAsyncSignature() | ||
| }; | ||
| } | ||
|
|
||
| public override AsyncMethodData AsyncMethodData | ||
| { | ||
| get | ||
| { | ||
| return _asyncMethodData; | ||
| } | ||
| } | ||
|
|
||
| public override MethodDesc GetMethodDefinition() | ||
| { | ||
| return _wrappedMethod.GetMethodDefinition(); | ||
| } | ||
|
|
||
| public override MethodDesc GetTypicalMethodDefinition() | ||
| { | ||
| return _wrappedMethod.GetTypicalMethodDefinition(); | ||
| } | ||
|
|
||
| public override MethodDesc GetAsyncOtherVariant() | ||
| { | ||
| return _wrappedMethod; | ||
| } | ||
|
|
||
| public override MethodDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) | ||
| { | ||
| MethodDesc real = _wrappedMethod.InstantiateSignature(typeInstantiation, methodInstantiation); | ||
| return real.GetAsyncOtherVariant(); | ||
| } | ||
|
|
||
| public override MethodSignature Signature | ||
| { | ||
| get | ||
| { | ||
| return _asyncMethodData.Signature; | ||
| } | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return "Async thunk: " + _wrappedMethod.ToString(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // 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.Threading; | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| public sealed partial class InstantiatedMethod | ||
| { | ||
| private AsyncMethodData _asyncMethodData; | ||
| private MethodDesc _asyncOtherVariant; | ||
|
|
||
| public override AsyncMethodData AsyncMethodData | ||
| { | ||
| get | ||
| { | ||
| if (!_asyncMethodData.Equals(default(AsyncMethodData))) | ||
| return _asyncMethodData; | ||
|
|
||
| if (IsAsync) | ||
| { | ||
| // If the method is already async, the template signature should already have been updated to reflect the AsyncCallConv | ||
| Debug.Assert(!Signature.ReturnsTaskOrValueTask() && Signature.IsAsyncCallConv); | ||
| _asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.AsyncVariantImpl, Signature = Signature }; | ||
| } | ||
| else if (Signature.ReturnsTaskOrValueTask()) | ||
| { | ||
| _asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.TaskReturning, Signature = Signature }; | ||
| } | ||
| else | ||
| { | ||
| _asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.NotAsync, Signature = Signature }; | ||
| } | ||
|
|
||
| return _asyncMethodData; | ||
| } | ||
| } | ||
|
|
||
| public override MethodDesc GetAsyncOtherVariant() | ||
| { | ||
| if (_asyncOtherVariant is null) | ||
| { | ||
| MethodDesc otherVariant = IsAsync ? | ||
| new TaskReturningAsyncThunk(this, InstantiateSignature(_methodDef.GetAsyncOtherVariant().Signature)) | ||
| : new AsyncMethodThunk(this); | ||
| Interlocked.CompareExchange(ref _asyncOtherVariant, otherVariant, null); | ||
| } | ||
| return _asyncOtherVariant; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Threading; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the changes in this file still needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, shouldn't be needed |
||
| using Internal.NativeFormat; | ||
|
|
||
| namespace Internal.TypeSystem | ||
|
|
@@ -58,21 +59,27 @@ private TypeDesc Instantiate(TypeDesc type) | |
| return type.InstantiateSignature(default(Instantiation), _instantiation); | ||
| } | ||
|
|
||
| private void InitializeSignature() | ||
| { | ||
| var template = _methodDef.Signature; | ||
| _signature = InstantiateSignature(template); | ||
| } | ||
|
|
||
| private MethodSignature InstantiateSignature(MethodSignature template) | ||
| { | ||
| var builder = new MethodSignatureBuilder(template); | ||
| builder.ReturnType = Instantiate(template.ReturnType); | ||
| for (int i = 0; i < template.Length; i++) | ||
| builder[i] = Instantiate(template[i]); | ||
| return builder.ToSignature(); | ||
| } | ||
|
|
||
| public override MethodSignature Signature | ||
| { | ||
| get | ||
| { | ||
| if (_signature == null) | ||
| { | ||
| MethodSignature template = _methodDef.Signature; | ||
| MethodSignatureBuilder builder = new MethodSignatureBuilder(template); | ||
|
|
||
| builder.ReturnType = Instantiate(template.ReturnType); | ||
| for (int i = 0; i < template.Length; i++) | ||
| builder[i] = Instantiate(template[i]); | ||
|
|
||
| _signature = builder.ToSignature(); | ||
| } | ||
| InitializeSignature(); | ||
|
|
||
| return _signature; | ||
| } | ||
|
|
@@ -134,7 +141,6 @@ public override bool IsAsync | |
| } | ||
| } | ||
|
|
||
|
|
||
| public override bool HasCustomAttribute(string attributeNamespace, string attributeName) | ||
| { | ||
| return _methodDef.HasCustomAttribute(attributeNamespace, attributeName); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Internal.TypeSystem | ||
| { | ||
| /// <summary> | ||
| /// Wraps a <see cref="MethodDesc"/> object and delegates methods to that <see cref="MethodDesc"/>. | ||
| /// </summary> | ||
| public abstract partial class MethodDelegator : MethodDesc | ||
| { | ||
| public abstract override AsyncMethodData AsyncMethodData { get; } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.