提交 7fd5341e 编写于 作者: V Vladimir Sadov 提交者: GitHub

Merge pull request #18721 from VSadov/asyncTweak

Removed some unnecessary codegen from async state machine.
......@@ -298,30 +298,15 @@ private BoundBlock VisitAwaitExpression(BoundAwaitExpression node, BoundExpressi
WellKnownMemberNames.GetResult,
resultsDiscarded: resultPlace == null);
var nullAwaiter = F.AssignmentExpression(F.Local(awaiterTemp), F.NullOrDefault(awaiterTemp.Type));
if (resultPlace != null && type.SpecialType != SpecialType.System_Void)
{
// $resultTemp = $awaiterTemp.GetResult();
// $awaiterTemp = null;
// $resultTemp
LocalSymbol resultTemp = F.SynthesizedLocal(type);
return F.Block(
ImmutableArray.Create(awaiterTemp, resultTemp),
awaitIfIncomplete,
F.Assignment(F.Local(resultTemp), getResultCall),
F.ExpressionStatement(nullAwaiter),
F.Assignment(resultPlace, F.Local(resultTemp)));
}
else
{
// $awaiterTemp.GetResult();
// $awaiterTemp = null;
return F.Block(
ImmutableArray.Create(awaiterTemp),
awaitIfIncomplete,
F.ExpressionStatement(getResultCall),
F.ExpressionStatement(nullAwaiter));
}
// [$resultPlace = ] $awaiterTemp.GetResult();
BoundStatement getResultStatement = resultPlace != null && type.SpecialType != SpecialType.System_Void ?
F.Assignment(resultPlace, getResultCall):
F.ExpressionStatement(getResultCall);
return F.Block(
ImmutableArray.Create(awaiterTemp),
awaitIfIncomplete,
getResultStatement);
}
private BoundExpression MakeCallMaybeDynamic(
......
......@@ -599,7 +599,7 @@ public static async Task<int> F(int[] array)
v.VerifyIL("Test.<F>d__2.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @"
{
// Code size 300 (0x12c)
// Code size 290 (0x122)
.maxstack 5
.locals init (int V_0,
int V_1,
......@@ -671,7 +671,7 @@ .maxstack 5
IL_007f: ldloca.s V_5
IL_0081: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, Test.<F>d__2>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref Test.<F>d__2)""
IL_0086: nop
IL_0087: leave IL_012b
IL_0087: leave IL_0121
>IL_008c: ldarg.0
IL_008d: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__2.<>u__1""
IL_0092: stloc.s V_4
......@@ -683,64 +683,60 @@ .maxstack 5
IL_00a2: dup
IL_00a3: stloc.0
IL_00a4: stfld ""int Test.<F>d__2.<>1__state""
IL_00a9: ldloca.s V_4
IL_00ab: call ""int System.Runtime.CompilerServices.TaskAwaiter<int>.GetResult()""
IL_00b0: stloc.3
IL_00b1: ldloca.s V_4
IL_00b3: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_00b9: ldarg.0
IL_00ba: ldloc.3
IL_00bb: stfld ""int Test.<F>d__2.<>s__3""
IL_00c0: ldarg.0
IL_00c1: ldarg.0
IL_00c2: ldfld ""int[] Test.<F>d__2.<>s__5""
IL_00c7: ldc.i4.3
IL_00c8: ldarg.0
IL_00c9: ldfld ""int Test.<F>d__2.<>s__2""
IL_00ce: ldarg.0
IL_00cf: ldfld ""int Test.<F>d__2.<>s__3""
IL_00d4: add
IL_00d5: dup
IL_00d6: stloc.3
IL_00d7: stelem.i4
IL_00d8: ldloc.3
IL_00d9: stfld ""int Test.<F>d__2.<>s__4""
IL_00de: ldarg.0
IL_00df: ldfld ""int Test.<F>d__2.<>s__1""
IL_00e4: ldarg.0
IL_00e5: ldfld ""int Test.<F>d__2.<>s__4""
IL_00ea: ldc.i4.4
IL_00eb: call ""int Test.H(int, int, int)""
IL_00f0: pop
IL_00f1: ldarg.0
IL_00f2: ldnull
IL_00f3: stfld ""int[] Test.<F>d__2.<>s__5""
-IL_00f8: ldc.i4.1
IL_00f9: stloc.1
IL_00fa: leave.s IL_0116
IL_00a9: ldarg.0
IL_00aa: ldloca.s V_4
IL_00ac: call ""int System.Runtime.CompilerServices.TaskAwaiter<int>.GetResult()""
IL_00b1: stfld ""int Test.<F>d__2.<>s__3""
IL_00b6: ldarg.0
IL_00b7: ldarg.0
IL_00b8: ldfld ""int[] Test.<F>d__2.<>s__5""
IL_00bd: ldc.i4.3
IL_00be: ldarg.0
IL_00bf: ldfld ""int Test.<F>d__2.<>s__2""
IL_00c4: ldarg.0
IL_00c5: ldfld ""int Test.<F>d__2.<>s__3""
IL_00ca: add
IL_00cb: dup
IL_00cc: stloc.3
IL_00cd: stelem.i4
IL_00ce: ldloc.3
IL_00cf: stfld ""int Test.<F>d__2.<>s__4""
IL_00d4: ldarg.0
IL_00d5: ldfld ""int Test.<F>d__2.<>s__1""
IL_00da: ldarg.0
IL_00db: ldfld ""int Test.<F>d__2.<>s__4""
IL_00e0: ldc.i4.4
IL_00e1: call ""int Test.H(int, int, int)""
IL_00e6: pop
IL_00e7: ldarg.0
IL_00e8: ldnull
IL_00e9: stfld ""int[] Test.<F>d__2.<>s__5""
-IL_00ee: ldc.i4.1
IL_00ef: stloc.1
IL_00f0: leave.s IL_010c
}
catch System.Exception
{
~IL_00fc: stloc.s V_6
IL_00fe: ldarg.0
IL_00ff: ldc.i4.s -2
IL_0101: stfld ""int Test.<F>d__2.<>1__state""
IL_0106: ldarg.0
IL_0107: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<F>d__2.<>t__builder""
IL_010c: ldloc.s V_6
IL_010e: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetException(System.Exception)""
IL_0113: nop
IL_0114: leave.s IL_012b
~IL_00f2: stloc.s V_6
IL_00f4: ldarg.0
IL_00f5: ldc.i4.s -2
IL_00f7: stfld ""int Test.<F>d__2.<>1__state""
IL_00fc: ldarg.0
IL_00fd: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<F>d__2.<>t__builder""
IL_0102: ldloc.s V_6
IL_0104: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetException(System.Exception)""
IL_0109: nop
IL_010a: leave.s IL_0121
}
-IL_0116: ldarg.0
IL_0117: ldc.i4.s -2
IL_0119: stfld ""int Test.<F>d__2.<>1__state""
~IL_011e: ldarg.0
IL_011f: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<F>d__2.<>t__builder""
IL_0124: ldloc.1
IL_0125: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetResult(int)""
IL_012a: nop
IL_012b: ret
-IL_010c: ldarg.0
IL_010d: ldc.i4.s -2
IL_010f: stfld ""int Test.<F>d__2.<>1__state""
~IL_0114: ldarg.0
IL_0115: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<F>d__2.<>t__builder""
IL_011a: ldloc.1
IL_011b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetResult(int)""
IL_0120: nop
IL_0121: ret
}", sequencePoints: "Test+<F>d__2.MoveNext");
}
......
......@@ -2090,7 +2090,7 @@ public static async Task<T> Test<T>(T a)
verifier.VerifyDiagnostics();
verifier.VerifyIL("C.<Test>d__1<T>.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @"
{
// Code size 191 (0xbf)
// Code size 183 (0xb7)
.maxstack 3
.locals init (int V_0,
T V_1,
......@@ -2132,7 +2132,7 @@ .maxstack 3
IL_004e: ldloca.s V_2
IL_0050: ldarg.0
IL_0051: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, C.<Test>d__1<T>>(ref System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, ref C.<Test>d__1<T>)""
IL_0056: leave.s IL_00be
IL_0056: leave.s IL_00b6
IL_0058: ldarg.0
IL_0059: ldfld ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter C.<Test>d__1<T>.<>u__1""
IL_005e: stloc.2
......@@ -2146,34 +2146,32 @@ .maxstack 3
IL_006f: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0074: ldloca.s V_2
IL_0076: call ""void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()""
IL_007b: ldloca.s V_2
IL_007d: initobj ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter""
IL_0083: ldarg.0
IL_0084: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0089: ldfld ""T System.ValueTuple<T, T>.Item1""
IL_008e: stloc.1
IL_008f: leave.s IL_00aa
IL_007b: ldarg.0
IL_007c: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0081: ldfld ""T System.ValueTuple<T, T>.Item1""
IL_0086: stloc.1
IL_0087: leave.s IL_00a2
}
catch System.Exception
{
IL_0091: stloc.s V_4
IL_0089: stloc.s V_4
IL_008b: ldarg.0
IL_008c: ldc.i4.s -2
IL_008e: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0093: ldarg.0
IL_0094: ldc.i4.s -2
IL_0096: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_009b: ldarg.0
IL_009c: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00a1: ldloc.s V_4
IL_00a3: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_00a8: leave.s IL_00be
IL_0094: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_0099: ldloc.s V_4
IL_009b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_00a0: leave.s IL_00b6
}
IL_00a2: ldarg.0
IL_00a3: ldc.i4.s -2
IL_00a5: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00aa: ldarg.0
IL_00ab: ldc.i4.s -2
IL_00ad: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00b2: ldarg.0
IL_00b3: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00b8: ldloc.1
IL_00b9: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00be: ret
IL_00ab: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00b0: ldloc.1
IL_00b1: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00b6: ret
}
");
}
......@@ -2206,7 +2204,7 @@ public static async Task<string> Test<T>(T a)
verifier.VerifyDiagnostics();
verifier.VerifyIL("C.<Test>d__1<T>.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @"
{
// Code size 197 (0xc5)
// Code size 189 (0xbd)
.maxstack 3
.locals init (int V_0,
string V_1,
......@@ -2248,7 +2246,7 @@ .maxstack 3
IL_004e: ldloca.s V_2
IL_0050: ldarg.0
IL_0051: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, C.<Test>d__1<T>>(ref System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, ref C.<Test>d__1<T>)""
IL_0056: leave.s IL_00c4
IL_0056: leave.s IL_00bc
IL_0058: ldarg.0
IL_0059: ldfld ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter C.<Test>d__1<T>.<>u__1""
IL_005e: stloc.2
......@@ -2262,35 +2260,33 @@ .maxstack 3
IL_006f: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0074: ldloca.s V_2
IL_0076: call ""void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()""
IL_007b: ldloca.s V_2
IL_007d: initobj ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter""
IL_0083: ldarg.0
IL_0084: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0089: constrained. ""System.ValueTuple<T, T>""
IL_008f: callvirt ""string object.ToString()""
IL_0094: stloc.1
IL_0095: leave.s IL_00b0
IL_007b: ldarg.0
IL_007c: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0081: constrained. ""System.ValueTuple<T, T>""
IL_0087: callvirt ""string object.ToString()""
IL_008c: stloc.1
IL_008d: leave.s IL_00a8
}
catch System.Exception
{
IL_0097: stloc.s V_4
IL_008f: stloc.s V_4
IL_0091: ldarg.0
IL_0092: ldc.i4.s -2
IL_0094: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0099: ldarg.0
IL_009a: ldc.i4.s -2
IL_009c: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00a1: ldarg.0
IL_00a2: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string> C.<Test>d__1<T>.<>t__builder""
IL_00a7: ldloc.s V_4
IL_00a9: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string>.SetException(System.Exception)""
IL_00ae: leave.s IL_00c4
IL_009a: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string> C.<Test>d__1<T>.<>t__builder""
IL_009f: ldloc.s V_4
IL_00a1: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string>.SetException(System.Exception)""
IL_00a6: leave.s IL_00bc
}
IL_00a8: ldarg.0
IL_00a9: ldc.i4.s -2
IL_00ab: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00b0: ldarg.0
IL_00b1: ldc.i4.s -2
IL_00b3: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00b8: ldarg.0
IL_00b9: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string> C.<Test>d__1<T>.<>t__builder""
IL_00be: ldloc.1
IL_00bf: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string>.SetResult(string)""
IL_00c4: ret
IL_00b1: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string> C.<Test>d__1<T>.<>t__builder""
IL_00b6: ldloc.1
IL_00b7: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<string>.SetResult(string)""
IL_00bc: ret
}
");
}
......@@ -2349,7 +2345,7 @@ public U Test<U>(U val)
verifier.VerifyDiagnostics();
verifier.VerifyIL("C.<Test>d__1<T>.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @"
{
// Code size 197 (0xc5)
// Code size 189 (0xbd)
.maxstack 3
.locals init (int V_0,
T V_1,
......@@ -2391,7 +2387,7 @@ .maxstack 3
IL_004e: ldloca.s V_2
IL_0050: ldarg.0
IL_0051: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, C.<Test>d__1<T>>(ref System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, ref C.<Test>d__1<T>)""
IL_0056: leave.s IL_00c4
IL_0056: leave.s IL_00bc
IL_0058: ldarg.0
IL_0059: ldfld ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter C.<Test>d__1<T>.<>u__1""
IL_005e: stloc.2
......@@ -2405,36 +2401,34 @@ .maxstack 3
IL_006f: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0074: ldloca.s V_2
IL_0076: call ""void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()""
IL_007b: ldloca.s V_2
IL_007d: initobj ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter""
IL_0083: ldarg.0
IL_0084: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0089: ldarg.0
IL_008a: ldfld ""T C.<Test>d__1<T>.a""
IL_008f: call ""T System.ValueTuple<T, T>.Test<T>(T)""
IL_0094: stloc.1
IL_0095: leave.s IL_00b0
IL_007b: ldarg.0
IL_007c: ldflda ""(T f1, T f2) C.<Test>d__1<T>.<x>5__1""
IL_0081: ldarg.0
IL_0082: ldfld ""T C.<Test>d__1<T>.a""
IL_0087: call ""T System.ValueTuple<T, T>.Test<T>(T)""
IL_008c: stloc.1
IL_008d: leave.s IL_00a8
}
catch System.Exception
{
IL_0097: stloc.s V_4
IL_008f: stloc.s V_4
IL_0091: ldarg.0
IL_0092: ldc.i4.s -2
IL_0094: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0099: ldarg.0
IL_009a: ldc.i4.s -2
IL_009c: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00a1: ldarg.0
IL_00a2: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00a7: ldloc.s V_4
IL_00a9: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_00ae: leave.s IL_00c4
IL_009a: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_009f: ldloc.s V_4
IL_00a1: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_00a6: leave.s IL_00bc
}
IL_00a8: ldarg.0
IL_00a9: ldc.i4.s -2
IL_00ab: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00b0: ldarg.0
IL_00b1: ldc.i4.s -2
IL_00b3: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00b8: ldarg.0
IL_00b9: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00be: ldloc.1
IL_00bf: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00c4: ret
IL_00b1: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00b6: ldloc.1
IL_00b7: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00bc: ret
}
");
}
......@@ -2493,7 +2487,7 @@ public U Test<U>(U val)
verifier.VerifyDiagnostics();
verifier.VerifyIL("C.<Test>d__1<T>.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @"
{
// Code size 187 (0xbb)
// Code size 179 (0xb3)
.maxstack 3
.locals init (int V_0,
T V_1,
......@@ -2533,7 +2527,7 @@ .maxstack 3
IL_0044: ldloca.s V_2
IL_0046: ldarg.0
IL_0047: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, C.<Test>d__1<T>>(ref System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, ref C.<Test>d__1<T>)""
IL_004c: leave.s IL_00ba
IL_004c: leave.s IL_00b2
IL_004e: ldarg.0
IL_004f: ldfld ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter C.<Test>d__1<T>.<>u__1""
IL_0054: stloc.2
......@@ -2547,36 +2541,34 @@ .maxstack 3
IL_0065: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_006a: ldloca.s V_2
IL_006c: call ""void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()""
IL_0071: ldloca.s V_2
IL_0073: initobj ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter""
IL_0079: ldarg.0
IL_007a: ldflda ""(int f1, int f2) C.<Test>d__1<T>.<x>5__1""
IL_007f: ldarg.0
IL_0080: ldfld ""T C.<Test>d__1<T>.a""
IL_0085: call ""T System.ValueTuple<int, int>.Test<T>(T)""
IL_008a: stloc.1
IL_008b: leave.s IL_00a6
IL_0071: ldarg.0
IL_0072: ldflda ""(int f1, int f2) C.<Test>d__1<T>.<x>5__1""
IL_0077: ldarg.0
IL_0078: ldfld ""T C.<Test>d__1<T>.a""
IL_007d: call ""T System.ValueTuple<int, int>.Test<T>(T)""
IL_0082: stloc.1
IL_0083: leave.s IL_009e
}
catch System.Exception
{
IL_008d: stloc.s V_4
IL_0085: stloc.s V_4
IL_0087: ldarg.0
IL_0088: ldc.i4.s -2
IL_008a: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_008f: ldarg.0
IL_0090: ldc.i4.s -2
IL_0092: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_0097: ldarg.0
IL_0098: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_009d: ldloc.s V_4
IL_009f: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_00a4: leave.s IL_00ba
IL_0090: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_0095: ldloc.s V_4
IL_0097: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetException(System.Exception)""
IL_009c: leave.s IL_00b2
}
IL_009e: ldarg.0
IL_009f: ldc.i4.s -2
IL_00a1: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00a6: ldarg.0
IL_00a7: ldc.i4.s -2
IL_00a9: stfld ""int C.<Test>d__1<T>.<>1__state""
IL_00ae: ldarg.0
IL_00af: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00b4: ldloc.1
IL_00b5: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00ba: ret
IL_00a7: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T> C.<Test>d__1<T>.<>t__builder""
IL_00ac: ldloc.1
IL_00ad: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<T>.SetResult(T)""
IL_00b2: ret
}
");
}
......@@ -19264,7 +19256,7 @@ static async Task<long> Test()
// NOTE: !!! There should be an IL local for " (byte x, int y) v2 " , it should not be captured
verifier.VerifyIL("C.<Test>d__1.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @"
{
// Code size 201 (0xc9)
// Code size 193 (0xc1)
.maxstack 3
.locals init (int V_0,
long V_1,
......@@ -19311,7 +19303,7 @@ .maxstack 3
IL_0058: ldloca.s V_3
IL_005a: ldarg.0
IL_005b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, C.<Test>d__1>(ref System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter, ref C.<Test>d__1)""
IL_0060: leave.s IL_00c8
IL_0060: leave.s IL_00c0
IL_0062: ldarg.0
IL_0063: ldfld ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter C.<Test>d__1.<>u__1""
IL_0068: stloc.3
......@@ -19325,34 +19317,32 @@ .maxstack 3
IL_0079: stfld ""int C.<Test>d__1.<>1__state""
IL_007e: ldloca.s V_3
IL_0080: call ""void System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.GetResult()""
IL_0085: ldloca.s V_3
IL_0087: initobj ""System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter""
IL_008d: ldarg.0
IL_008e: ldflda ""(long a, int b) C.<Test>d__1.<v1>5__1""
IL_0093: ldfld ""long System.ValueTuple<long, int>.Item1""
IL_0098: stloc.1
IL_0099: leave.s IL_00b4
IL_0085: ldarg.0
IL_0086: ldflda ""(long a, int b) C.<Test>d__1.<v1>5__1""
IL_008b: ldfld ""long System.ValueTuple<long, int>.Item1""
IL_0090: stloc.1
IL_0091: leave.s IL_00ac
}
catch System.Exception
{
IL_009b: stloc.s V_5
IL_0093: stloc.s V_5
IL_0095: ldarg.0
IL_0096: ldc.i4.s -2
IL_0098: stfld ""int C.<Test>d__1.<>1__state""
IL_009d: ldarg.0
IL_009e: ldc.i4.s -2
IL_00a0: stfld ""int C.<Test>d__1.<>1__state""
IL_00a5: ldarg.0
IL_00a6: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long> C.<Test>d__1.<>t__builder""
IL_00ab: ldloc.s V_5
IL_00ad: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long>.SetException(System.Exception)""
IL_00b2: leave.s IL_00c8
IL_009e: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long> C.<Test>d__1.<>t__builder""
IL_00a3: ldloc.s V_5
IL_00a5: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long>.SetException(System.Exception)""
IL_00aa: leave.s IL_00c0
}
IL_00ac: ldarg.0
IL_00ad: ldc.i4.s -2
IL_00af: stfld ""int C.<Test>d__1.<>1__state""
IL_00b4: ldarg.0
IL_00b5: ldc.i4.s -2
IL_00b7: stfld ""int C.<Test>d__1.<>1__state""
IL_00bc: ldarg.0
IL_00bd: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long> C.<Test>d__1.<>t__builder""
IL_00c2: ldloc.1
IL_00c3: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long>.SetResult(long)""
IL_00c8: ret
IL_00b5: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long> C.<Test>d__1.<>t__builder""
IL_00ba: ldloc.1
IL_00bb: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<long>.SetResult(long)""
IL_00c0: ret
}
");
}
......
......@@ -2969,7 +2969,7 @@ public async Task<int> F()
v0.VerifyIL("C.<F>d__0.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @"
{
// Code size 254 (0xfe)
// Code size 246 (0xf6)
.maxstack 3
.locals init (int V_0,
int V_1,
......@@ -3047,7 +3047,7 @@ .maxstack 3
IL_0094: ldloca.s V_3
IL_0096: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, C.<F>d__0>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref C.<F>d__0)""
IL_009b: nop
IL_009c: leave.s IL_00fd
IL_009c: leave.s IL_00f5
>IL_009e: ldarg.0
IL_009f: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__0.<>u__1""
IL_00a4: stloc.2
......@@ -3062,34 +3062,32 @@ .maxstack 3
IL_00ba: ldloca.s V_2
IL_00bc: call ""int System.Runtime.CompilerServices.TaskAwaiter<int>.GetResult()""
IL_00c1: pop
IL_00c2: ldloca.s V_2
IL_00c4: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
-IL_00ca: ldc.i4.1
IL_00cb: stloc.1
IL_00cc: leave.s IL_00e8
-IL_00c2: ldc.i4.1
IL_00c3: stloc.1
IL_00c4: leave.s IL_00e0
}
catch System.Exception
{
~IL_00ce: stloc.s V_4
~IL_00c6: stloc.s V_4
IL_00c8: ldarg.0
IL_00c9: ldc.i4.s -2
IL_00cb: stfld ""int C.<F>d__0.<>1__state""
IL_00d0: ldarg.0
IL_00d1: ldc.i4.s -2
IL_00d3: stfld ""int C.<F>d__0.<>1__state""
IL_00d8: ldarg.0
IL_00d9: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__0.<>t__builder""
IL_00de: ldloc.s V_4
IL_00e0: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetException(System.Exception)""
IL_00e5: nop
IL_00e6: leave.s IL_00fd
IL_00d1: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__0.<>t__builder""
IL_00d6: ldloc.s V_4
IL_00d8: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetException(System.Exception)""
IL_00dd: nop
IL_00de: leave.s IL_00f5
}
-IL_00e8: ldarg.0
IL_00e9: ldc.i4.s -2
IL_00eb: stfld ""int C.<F>d__0.<>1__state""
~IL_00f0: ldarg.0
IL_00f1: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__0.<>t__builder""
IL_00f6: ldloc.1
IL_00f7: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetResult(int)""
IL_00fc: nop
IL_00fd: ret
-IL_00e0: ldarg.0
IL_00e1: ldc.i4.s -2
IL_00e3: stfld ""int C.<F>d__0.<>1__state""
~IL_00e8: ldarg.0
IL_00e9: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__0.<>t__builder""
IL_00ee: ldloc.1
IL_00ef: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetResult(int)""
IL_00f4: nop
IL_00f5: ret
}
", sequencePoints: "C+<F>d__0.MoveNext");
......
......@@ -1894,11 +1894,11 @@ class C
var calls = actualIL.Split(new[] { '\n', '\r' }, System.StringSplitOptions.RemoveEmptyEntries).Where(s => s.Contains("OnCompleted")).ToArray();
Assert.Equal(calls.Length, 6);
Assert.Equal(" IL_0056: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitOnCompleted<T1, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T1, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[0]);
Assert.Equal(" IL_00c1: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T2, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T2, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[1]);
Assert.Equal(" IL_012c: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T3, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T3, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[2]);
Assert.Equal(" IL_019a: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitOnCompleted<T4, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T4, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[3]);
Assert.Equal(" IL_020a: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T5, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T5, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[4]);
Assert.Equal(" IL_027a: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T6, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T6, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[5]);
Assert.Equal(" IL_00b9: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T2, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T2, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[1]);
Assert.Equal(" IL_011c: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T3, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T3, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[2]);
Assert.Equal(" IL_0182: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitOnCompleted<T4, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T4, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[3]);
Assert.Equal(" IL_01ea: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T5, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T5, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[4]);
Assert.Equal(" IL_0252: call \"void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<T6, C.<F>d__0<T1, T2, T3, T4, T5, T6>>(ref T6, ref C.<F>d__0<T1, T2, T3, T4, T5, T6>)\"", calls[5]);
}
[Fact]
......
......@@ -1050,7 +1050,7 @@ static void G(Func<Task<object>> f)
var methodData = testData.GetMethodData("<>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()");
methodData.VerifyIL(@"
{
// Code size 544 (0x220)
// Code size 542 (0x21e)
.maxstack 10
.locals init (int V_0,
<>x.<>c__DisplayClass0_0 V_1,
......@@ -1183,7 +1183,7 @@ .maxstack 10
IL_017d: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.ICriticalNotifyCompletion, <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d>(ref System.Runtime.CompilerServices.ICriticalNotifyCompletion, ref <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d)""
IL_0182: ldnull
IL_0183: stloc.s V_4
IL_0185: leave IL_021f
IL_0185: leave IL_021d
IL_018a: ldarg.0
IL_018b: ldfld ""object <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>u__1""
IL_0190: stloc.3
......@@ -1218,31 +1218,29 @@ .maxstack 10
IL_01e2: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>o.<>p__3""
IL_01e7: ldloc.3
IL_01e8: callvirt ""dynamic System.Func<System.Runtime.CompilerServices.CallSite, dynamic, dynamic>.Invoke(System.Runtime.CompilerServices.CallSite, dynamic)""
IL_01ed: ldnull
IL_01ee: stloc.3
IL_01ef: stloc.2
IL_01f0: leave.s IL_020b
IL_01ed: stloc.2
IL_01ee: leave.s IL_0209
}
catch System.Exception
{
IL_01f2: stloc.s V_6
IL_01f4: ldarg.0
IL_01f5: ldc.i4.s -2
IL_01f7: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_01fc: ldarg.0
IL_01fd: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0202: ldloc.s V_6
IL_0204: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetException(System.Exception)""
IL_0209: leave.s IL_021f
IL_01f0: stloc.s V_6
IL_01f2: ldarg.0
IL_01f3: ldc.i4.s -2
IL_01f5: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_01fa: ldarg.0
IL_01fb: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0200: ldloc.s V_6
IL_0202: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetException(System.Exception)""
IL_0207: leave.s IL_021d
}
IL_020b: ldarg.0
IL_020c: ldc.i4.s -2
IL_020e: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_0213: ldarg.0
IL_0214: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0219: ldloc.2
IL_021a: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetResult(object)""
IL_021f: ret
IL_0209: ldarg.0
IL_020a: ldc.i4.s -2
IL_020c: stfld ""int <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>1__state""
IL_0211: ldarg.0
IL_0212: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object> <>x.<>c__DisplayClass0_0.<<<>m0>b__0>d.<>t__builder""
IL_0217: ldloc.2
IL_0218: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<object>.SetResult(object)""
IL_021d: ret
}
");
});
......
......@@ -2090,10 +2090,9 @@ static async Task M(object x)
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Exception V_5)
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Exception V_4)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.x""
IL_0006: ret
......@@ -2104,10 +2103,9 @@ .maxstack 1
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Exception V_5)
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Exception V_4)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.<y>5__1""
IL_0006: ret
......@@ -2162,12 +2160,11 @@ static async Task M(object x)
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
System.Exception V_7)
System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.x""
IL_0006: ret
......@@ -2178,12 +2175,11 @@ .maxstack 1
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
System.Exception V_7)
System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld ""int C.<M>d__1.<y>5__1""
IL_0006: ret
......@@ -2203,28 +2199,27 @@ .maxstack 1
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
System.Exception V_7)
System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.x""
IL_0006: ret
}");
}
");
VerifyLocal(testData, "<>x", locals[1], "<>m1", "y", expectedILOpt:
@"{
// Code size 7 (0x7)
.maxstack 1
.locals init (int V_0,
System.Runtime.CompilerServices.TaskAwaiter<object> V_1,
object V_2,
C.<M>d__1 V_3,
C.<M>d__1 V_2,
System.Runtime.CompilerServices.TaskAwaiter<object> V_3,
System.Runtime.CompilerServices.TaskAwaiter<object> V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
System.Exception V_7)
System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld ""long C.<M>d__1.<y>5__3""
IL_0006: ret
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册