提交 1f7d2145 编写于 作者: T TomasMatousek

Use a dedicated dispenser for awaiter slot ids instead of...

Use a dedicated dispenser for awaiter slot ids instead of CompilationState.GenerateTempNumber() and avoid possibility of duplicate awaiter fields. (changeset 1368084)
上级 e080dd7e
......@@ -181,6 +181,7 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
IReadOnlyDictionary<EncLocalInfo, string> previousHoistedLocalMap;
IReadOnlyDictionary<Cci.ITypeReference, string> awaiterMap;
int hoistedLocalSlotCount;
int awaiterSlotCount;
string previousStateMachineTypeNameOpt;
uint methodIndex = (uint)MetadataTokens.GetRowNumber(handle);
......@@ -194,6 +195,7 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
previousHoistedLocalMap = null;
awaiterMap = null;
hoistedLocalSlotCount = 0;
awaiterSlotCount = 0;
previousStateMachineTypeNameOpt = null;
}
else
......@@ -208,7 +210,7 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
var localSlotDebugInfo = debugInfo.LocalSlots.NullToEmpty();
// method is async/iterator kickoff method
GetStateMachineFieldMap(stateMachineType, localSlotDebugInfo, out previousHoistedLocalMap, out awaiterMap);
GetStateMachineFieldMap(stateMachineType, localSlotDebugInfo, out previousHoistedLocalMap, out awaiterMap, out awaiterSlotCount);
// Kickoff method has no interesting locals on its own.
// We use the EnC method debug infromation for hoisted locals.
......@@ -229,26 +231,38 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
previousLocals = CreateLocalSlotMap(debugInfo, slotMetadata);
Debug.Assert(previousLocals.Length == slotMetadata.Length);
hoistedLocalSlotCount = 0;
previousHoistedLocalMap = null;
awaiterMap = null;
hoistedLocalSlotCount = 0;
awaiterSlotCount = 0;
previousStateMachineTypeNameOpt = null;
}
symbolMap = this.mapToMetadata;
}
return new EncVariableSlotAllocator(symbolMap, methodEntry.SyntaxMap, methodEntry.PreviousMethod, previousLocals, previousStateMachineTypeNameOpt, hoistedLocalSlotCount, previousHoistedLocalMap, awaiterMap);
return new EncVariableSlotAllocator(
symbolMap,
methodEntry.SyntaxMap,
methodEntry.PreviousMethod,
previousLocals,
previousStateMachineTypeNameOpt,
hoistedLocalSlotCount,
previousHoistedLocalMap,
awaiterSlotCount,
awaiterMap);
}
private void GetStateMachineFieldMap(
TypeSymbol stateMachineType,
ImmutableArray<LocalSlotDebugInfo> localSlotDebugInfo,
out IReadOnlyDictionary<EncLocalInfo, string> hoistedLocalMap,
out IReadOnlyDictionary<Cci.ITypeReference, string> awaiterMap)
out IReadOnlyDictionary<Cci.ITypeReference, string> awaiterMap,
out int awaiterSlotCount)
{
var hoistedLocals = new Dictionary<EncLocalInfo, string>();
var awaiters = new Dictionary<Cci.ITypeReference, string>();
int maxAwaiterSlotIndex = -1;
foreach (var member in stateMachineType.GetMembers())
{
......@@ -260,17 +274,24 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
switch (GeneratedNames.GetKind(name))
{
case GeneratedNameKind.AwaiterField:
if (GeneratedNames.TryParseSlotIndex(name, out slotIndex))
{
var field = (FieldSymbol)member;
// correct metadata won't contain duplicates, but malformed might, ignore the duplicate:
awaiters[(Cci.ITypeReference)field.Type] = field.Name;
break;
awaiters[(Cci.ITypeReference)field.Type] = name;
if (slotIndex > maxAwaiterSlotIndex)
{
maxAwaiterSlotIndex = slotIndex;
}
}
break;
case GeneratedNameKind.HoistedLocalField:
case GeneratedNameKind.HoistedSynthesizedLocalField:
if (GeneratedNames.TryParseHoistedLocalSlotIndex(name, out slotIndex))
if (GeneratedNames.TryParseSlotIndex(name, out slotIndex))
{
var field = (FieldSymbol)member;
if (slotIndex >= localSlotDebugInfo.Length)
......@@ -297,6 +318,7 @@ internal override VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBasel
hoistedLocalMap = hoistedLocals;
awaiterMap = awaiters;
awaiterSlotCount = maxAwaiterSlotIndex + 1;
}
private TypeSymbol TryGetStateMachineType(Handle methodHandle)
......
......@@ -53,6 +53,7 @@ internal sealed class AsyncMethodToStateMachineRewriter : MethodToStateMachineRe
private readonly LoweredDynamicOperationFactory dynamicFactory;
private readonly Dictionary<TypeSymbol, FieldSymbol> awaiterFields;
private int nextAwaiterId;
internal AsyncMethodToStateMachineRewriter(
MethodSymbol method,
......@@ -80,6 +81,7 @@ internal sealed class AsyncMethodToStateMachineRewriter : MethodToStateMachineRe
this.dynamicFactory = new LoweredDynamicOperationFactory(F);
this.awaiterFields = new Dictionary<TypeSymbol, FieldSymbol>(TypeSymbol.EqualsIgnoringDynamicComparer);
this.nextAwaiterId = slotAllocatorOpt?.PreviousAwaiterSlotCount ?? 0;
}
private FieldSymbol GetAwaiterField(TypeSymbol awaiterType)
......@@ -96,7 +98,7 @@ private FieldSymbol GetAwaiterField(TypeSymbol awaiterType)
if (fieldName == null)
{
fieldName = GeneratedNames.AsyncAwaiterFieldName(CompilationState.GenerateTempNumber());
fieldName = GeneratedNames.AsyncAwaiterFieldName(nextAwaiterId++);
}
result = F.StateMachineField(awaiterType, fieldName);
......
......@@ -535,7 +535,7 @@ private BoundExpression HoistRefInitialization(SynthesizedLocal local, BoundAssi
}
else
{
GeneratedNames.TryParseHoistedLocalSlotIndex(fieldName, out slotIndex);
GeneratedNames.TryParseSlotIndex(fieldName, out slotIndex);
}
hoistedField = F.StateMachineField(expr.Type, fieldName, new LocalSlotDebugInfo(kind, id), slotIndex);
......
......@@ -119,7 +119,7 @@ protected BoundStatement Rewrite()
bool isDebugBuild = F.Compilation.Options.OptimizationLevel == OptimizationLevel.Debug;
bool mapToPreviousFields = isDebugBuild && slotAllocatorOpt != null;
nextFreeHoistedLocalSlot = mapToPreviousFields ? slotAllocatorOpt.HoistedLocalSlotCount : 0;
nextFreeHoistedLocalSlot = mapToPreviousFields ? slotAllocatorOpt.PreviousHoistedLocalSlotCount : 0;
foreach (var variable in variablesToHoist)
{
......@@ -178,7 +178,7 @@ protected BoundStatement Rewrite()
if (fieldName != null)
{
GeneratedNames.TryParseHoistedLocalSlotIndex(fieldName, out slotIndex);
GeneratedNames.TryParseSlotIndex(fieldName, out slotIndex);
}
}
}
......
......@@ -176,10 +176,15 @@ internal static string MakeHoistedLocalFieldName(SynthesizedLocalKind kind, int
return result.ToStringAndFree();
}
// Extracts the slot index from a name of a field that stores hoisted variables.
// Such a name ends with "__{slot index}".
internal static string AsyncAwaiterFieldName(int slotIndex)
{
return "<>u__" + (slotIndex + 1);
}
// Extracts the slot index from a name of a field that stores hoisted variables or awaiters.
// Such a name ends with "__{slot index + 1}".
// Returned slot index is >= 0.
internal static bool TryParseHoistedLocalSlotIndex(string fieldName, out int slotIndex)
internal static bool TryParseSlotIndex(string fieldName, out int slotIndex)
{
int lastUnder = fieldName.LastIndexOf('_');
if (lastUnder - 1 < 0 || lastUnder == fieldName.Length || fieldName[lastUnder - 1] != '_')
......@@ -318,11 +323,6 @@ internal static string AsyncBuilderFieldName()
return "<>t__builder";
}
internal static string AsyncAwaiterFieldName(int number)
{
return "<>u__" + number;
}
internal static string ReusableHoistedLocalFieldName(int number)
{
return "<>7__wrap" + number;
......
......@@ -350,7 +350,7 @@ .maxstack 3
IL_003c: stfld ""int Test.<G>d__1.<>1__state""
IL_0041: ldarg.0
IL_0042: ldloc.3
IL_0043: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0043: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0048: ldarg.0
IL_0049: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<G>d__1.<>t__builder""
IL_004e: ldloca.s V_3
......@@ -358,10 +358,10 @@ .maxstack 3
IL_0051: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, Test.<G>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref Test.<G>d__1)""
IL_0056: leave IL_00dc
IL_005b: ldarg.0
IL_005c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_005c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0061: stloc.3
IL_0062: ldarg.0
IL_0063: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0063: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0068: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_006e: ldarg.0
IL_006f: ldc.i4.m1
......@@ -514,7 +514,7 @@ public static void Main()
"<>s__5", // spill
"<>s__6", // spill
"<>s__7", // spill
"<>u__0", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("Test.<G>d__1"));
});
......@@ -598,7 +598,7 @@ .maxstack 3
IL_0050: stfld ""int Test.<G>d__1.<>1__state""
IL_0055: ldarg.0
IL_0056: ldloc.2
IL_0057: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0057: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_005c: ldarg.0
IL_005d: stloc.s V_4
IL_005f: ldarg.0
......@@ -609,10 +609,10 @@ .maxstack 3
IL_006e: nop
IL_006f: leave IL_01de
IL_0074: ldarg.0
IL_0075: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0075: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_007a: stloc.2
IL_007b: ldarg.0
IL_007c: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_007c: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0081: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0087: ldarg.0
IL_0088: ldc.i4.m1
......@@ -667,7 +667,7 @@ .maxstack 3
IL_00fb: stfld ""int Test.<G>d__1.<>1__state""
IL_0100: ldarg.0
IL_0101: ldloc.2
IL_0102: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0102: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0107: ldarg.0
IL_0108: stloc.s V_4
IL_010a: ldarg.0
......@@ -678,10 +678,10 @@ .maxstack 3
IL_0119: nop
IL_011a: leave IL_01de
IL_011f: ldarg.0
IL_0120: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0120: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0125: stloc.2
IL_0126: ldarg.0
IL_0127: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0127: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_012c: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0132: ldarg.0
IL_0133: ldc.i4.m1
......@@ -1105,7 +1105,7 @@ .maxstack 3
IL_0036: stfld ""int Test.<G>d__1.<>1__state""
IL_003b: ldarg.0
IL_003c: ldloc.s V_4
IL_003e: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_003e: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0043: ldarg.0
IL_0044: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<G>d__1.<>t__builder""
IL_0049: ldloca.s V_4
......@@ -1113,10 +1113,10 @@ .maxstack 3
IL_004c: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, Test.<G>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref Test.<G>d__1)""
IL_0051: leave.s IL_00b1
IL_0053: ldarg.0
IL_0054: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_0054: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0059: stloc.s V_4
IL_005b: ldarg.0
IL_005c: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__0""
IL_005c: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<G>d__1.<>u__1""
IL_0061: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0067: ldarg.0
IL_0068: ldc.i4.m1
......
......@@ -167,7 +167,7 @@ public static async Task M(int x, int y, int z)
"x",
"z",
"y",
"<>u__0",
"<>u__1",
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -180,7 +180,7 @@ public static async Task M(int x, int y, int z)
"x",
"y",
"z",
"<>u__0",
"<>u__1",
}, module.GetFieldNames("C.<M>d__1"));
});
}
......@@ -221,7 +221,7 @@ public async Task M(IDisposable disposable)
"<>7__wrap1",
"<>7__wrap2",
"<>7__wrap3",
"<>u__0",
"<>u__1",
"<>7__wrap4",
"<>7__wrap5",
"<>7__wrap6",
......@@ -255,7 +255,7 @@ public async Task M(IDisposable disposable)
"<>s__17",
"<>s__18",
"<>s__19",
"<>u__0",
"<>u__1",
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -547,13 +547,13 @@ class Test<U>
IL_005b: stloc.0
IL_005c: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_0062: ldloc.1
IL_0063: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0063: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0068: ldarg.0
IL_0069: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test<U>.<M>d__1<S, T>.<>t__builder""
IL_007b: ldarg.0
IL_007c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_007c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0082: ldarg.0
IL_0083: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0083: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0091: stloc.0
IL_0092: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_00a7: ldarg.0
......@@ -571,13 +571,13 @@ class Test<U>
IL_0110: stloc.0
IL_0111: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_0117: ldloc.1
IL_0118: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0118: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_011d: ldarg.0
IL_011e: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test<U>.<M>d__1<S, T>.<>t__builder""
IL_0130: ldarg.0
IL_0131: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0131: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0137: ldarg.0
IL_0138: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0138: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0146: stloc.0
IL_0147: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_015c: ldarg.0
......@@ -595,13 +595,13 @@ class Test<U>
IL_01c5: stloc.0
IL_01c6: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_01cc: ldloc.1
IL_01cd: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_01cd: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_01d2: ldarg.0
IL_01d3: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test<U>.<M>d__1<S, T>.<>t__builder""
IL_01e5: ldarg.0
IL_01e6: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_01e6: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_01ec: ldarg.0
IL_01ed: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_01ed: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_01fb: stloc.0
IL_01fc: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_0211: ldarg.0
......@@ -619,13 +619,13 @@ class Test<U>
IL_027a: stloc.0
IL_027b: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_0281: ldloc.1
IL_0282: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0282: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0287: ldarg.0
IL_0288: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test<U>.<M>d__1<S, T>.<>t__builder""
IL_029a: ldarg.0
IL_029b: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_029b: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_02a1: ldarg.0
IL_02a2: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_02a2: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_02b0: stloc.0
IL_02b1: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_02c6: ldarg.0
......@@ -643,13 +643,13 @@ class Test<U>
IL_032f: stloc.0
IL_0330: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_0336: ldloc.1
IL_0337: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0337: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_033c: ldarg.0
IL_033d: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test<U>.<M>d__1<S, T>.<>t__builder""
IL_034f: ldarg.0
IL_0350: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0350: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0356: ldarg.0
IL_0357: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__0""
IL_0357: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test<U>.<M>d__1<S, T>.<>u__1""
IL_0365: stloc.0
IL_0366: stfld ""int Test<U>.<M>d__1<S, T>.<>1__state""
IL_037b: ldarg.0
......@@ -705,13 +705,13 @@ public static async void M()
IL_004b: stloc.0
IL_004c: stfld ""int Test.<M>d__1.<>1__state""
IL_0052: ldloc.1
IL_0053: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_0053: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_0058: ldarg.0
IL_0059: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test.<M>d__1.<>t__builder""
IL_006b: ldarg.0
IL_006c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_006c: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_0072: ldarg.0
IL_0073: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_0073: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_0081: stloc.0
IL_0082: stfld ""int Test.<M>d__1.<>1__state""
IL_0097: ldarg.0
......@@ -729,13 +729,13 @@ public static async void M()
IL_0100: stloc.0
IL_0101: stfld ""int Test.<M>d__1.<>1__state""
IL_0107: ldloc.1
IL_0108: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_0108: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_010d: ldarg.0
IL_010e: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test.<M>d__1.<>t__builder""
IL_0120: ldarg.0
IL_0121: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_0121: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_0127: ldarg.0
IL_0128: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__0""
IL_0128: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<M>d__1.<>u__1""
IL_0136: stloc.0
IL_0137: stfld ""int Test.<M>d__1.<>1__state""
IL_014c: ldarg.0
......
......@@ -664,7 +664,7 @@ .maxstack 5
IL_006f: stfld ""int Test.<F>d__1.<>1__state""
IL_0074: ldarg.0
IL_0075: ldloc.s V_5
IL_0077: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_0077: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_007c: ldarg.0
IL_007d: stloc.s V_6
IL_007f: ldarg.0
......@@ -675,10 +675,10 @@ .maxstack 5
IL_008e: nop
IL_008f: leave IL_0134
IL_0094: ldarg.0
IL_0095: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_0095: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_009a: stloc.s V_5
IL_009c: ldarg.0
IL_009d: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_009d: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_00a2: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_00a8: ldarg.0
IL_00a9: ldc.i4.m1
......@@ -814,7 +814,7 @@ public static async Task<int> F(int[] array)
"array",
"<>7__wrap1",
"<>7__wrap2",
"<>u__0",
"<>u__1",
"<>7__wrap3",
"<>7__wrap4",
}, module.GetFieldNames("C.<F>d__1"));
......@@ -834,7 +834,7 @@ public static async Task<int> F(int[] array)
"<>s__5",
"<>s__6",
"<>s__7",
"<>u__0",
"<>u__1",
"<>s__8"
}, module.GetFieldNames("C.<F>d__1"));
});
......
......@@ -2113,7 +2113,7 @@ .maxstack 3
IL_0046: stfld ""int Test.<F>d__1.<>1__state""
IL_004b: ldarg.0
IL_004c: ldloc.2
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0052: ldarg.0
IL_0053: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> Test.<F>d__1.<>t__builder""
IL_0058: ldloca.s V_2
......@@ -2121,10 +2121,10 @@ .maxstack 3
IL_005b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, Test.<F>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref Test.<F>d__1)""
IL_0060: leave.s IL_00bb
IL_0062: ldarg.0
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0068: stloc.2
IL_0069: ldarg.0
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_006f: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0075: ldarg.0
IL_0076: ldc.i4.m1
......@@ -2270,7 +2270,7 @@ .maxstack 3
IL_004b: stfld ""int Test.<F>d__1.<>1__state""
IL_0050: ldarg.0
IL_0051: ldloc.2
IL_0052: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_0052: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0057: ldarg.0
IL_0058: stloc.s V_4
IL_005a: ldarg.0
......@@ -2281,10 +2281,10 @@ .maxstack 3
IL_0069: nop
IL_006a: leave.s IL_00d8
IL_006c: ldarg.0
IL_006d: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_006d: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0072: stloc.2
IL_0073: ldarg.0
IL_0074: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_0074: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0079: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_007f: ldarg.0
IL_0080: ldc.i4.m1
......@@ -2423,7 +2423,7 @@ .maxstack 3
IL_0046: stfld ""int Test.<F>d__1.<>1__state""
IL_004b: ldarg.0
IL_004c: ldloc.1
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0052: ldarg.0
IL_0053: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Test.<F>d__1.<>t__builder""
IL_0058: ldloca.s V_1
......@@ -2431,10 +2431,10 @@ .maxstack 3
IL_005b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, Test.<F>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref Test.<F>d__1)""
IL_0060: leave.s IL_00c1
IL_0062: ldarg.0
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0068: stloc.1
IL_0069: ldarg.0
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__3""
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_006f: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0075: ldarg.0
IL_0076: ldc.i4.m1
......@@ -2562,7 +2562,7 @@ .maxstack 3
IL_0046: stfld ""int Test.<F>d__1.<>1__state""
IL_004b: ldarg.0
IL_004c: ldloc.1
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__3""
IL_004d: stfld ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__1""
IL_0052: ldarg.0
IL_0053: ldflda ""System.Runtime.CompilerServices.AsyncVoidMethodBuilder Test.<F>d__1.<>t__builder""
IL_0058: ldloca.s V_1
......@@ -2570,10 +2570,10 @@ .maxstack 3
IL_005b: call ""void System.Runtime.CompilerServices.AsyncVoidMethodBuilder.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter, Test.<F>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter, ref Test.<F>d__1)""
IL_0060: leave.s IL_00c5
IL_0062: ldarg.0
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__3""
IL_0063: ldfld ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__1""
IL_0068: stloc.1
IL_0069: ldarg.0
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__3""
IL_006a: ldflda ""System.Runtime.CompilerServices.TaskAwaiter Test.<F>d__1.<>u__1""
IL_006f: initobj ""System.Runtime.CompilerServices.TaskAwaiter""
IL_0075: ldarg.0
IL_0076: ldc.i4.m1
......@@ -3222,7 +3222,7 @@ .maxstack 3
IL_004d: stfld ""int Test.<F>d__1.<>1__state""
IL_0052: ldarg.0
IL_0053: ldloc.3
IL_0054: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_0054: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0059: ldarg.0
IL_005a: stloc.s V_5
IL_005c: ldarg.0
......@@ -3233,10 +3233,10 @@ .maxstack 3
IL_006b: nop
IL_006c: leave.s IL_00ed
IL_006e: ldarg.0
IL_006f: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_006f: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_0074: stloc.3
IL_0075: ldarg.0
IL_0076: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__0""
IL_0076: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> Test.<F>d__1.<>u__1""
IL_007b: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0081: ldarg.0
IL_0082: ldc.i4.m1
......
......@@ -14534,7 +14534,7 @@ .maxstack 10
IL_00f6: stfld ""int C.<M>d__1.<>1__state""
IL_00fb: ldarg.0
IL_00fc: ldloc.2
IL_00fd: stfld ""object C.<M>d__1.<>u__4""
IL_00fd: stfld ""object C.<M>d__1.<>u__1""
IL_0102: ldloc.2
IL_0103: isinst ""System.Runtime.CompilerServices.ICriticalNotifyCompletion""
IL_0108: stloc.3
......@@ -14560,17 +14560,17 @@ .maxstack 10
IL_0136: stloc.3
IL_0137: leave IL_035a
IL_013c: ldarg.0
IL_013d: ldfld ""object C.<M>d__1.<>u__4""
IL_013d: ldfld ""object C.<M>d__1.<>u__1""
IL_0142: stloc.2
IL_0143: ldarg.0
IL_0144: ldnull
IL_0145: stfld ""object C.<M>d__1.<>u__4""
IL_0145: stfld ""object C.<M>d__1.<>u__1""
IL_014a: ldarg.0
IL_014b: ldc.i4.m1
IL_014c: dup
IL_014d: stloc.0
IL_014e: stfld ""int C.<M>d__1.<>1__state""
IL_0153: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_0153: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site4""
IL_0158: brtrue.s IL_018a
IL_015a: ldc.i4.0
IL_015b: ldstr ""GetResult""
......@@ -14587,16 +14587,16 @@ .maxstack 10
IL_017a: stelem.ref
IL_017b: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0180: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0185: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_018a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_0185: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site4""
IL_018a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site4""
IL_018f: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, object, object> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Target""
IL_0194: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_0194: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site4""
IL_0199: ldloc.2
IL_019a: callvirt ""object System.Func<System.Runtime.CompilerServices.CallSite, object, object>.Invoke(System.Runtime.CompilerServices.CallSite, object)""
IL_019f: ldnull
IL_01a0: stloc.2
IL_01a1: stloc.1
IL_01a2: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_01a2: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_01a7: brtrue.s IL_01d9
IL_01a9: ldc.i4.0
IL_01aa: ldstr ""GetAwaiter""
......@@ -14613,14 +14613,14 @@ .maxstack 10
IL_01c9: stelem.ref
IL_01ca: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_01cf: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_01d4: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_01d9: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_01d4: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_01d9: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_01de: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, object, object> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Target""
IL_01e3: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_01e3: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site5""
IL_01e8: ldloc.1
IL_01e9: callvirt ""object System.Func<System.Runtime.CompilerServices.CallSite, object, object>.Invoke(System.Runtime.CompilerServices.CallSite, object)""
IL_01ee: stloc.2
IL_01ef: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_01ef: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_01f4: brtrue.s IL_021b
IL_01f6: ldc.i4.s 16
IL_01f8: ldtoken ""bool""
......@@ -14629,11 +14629,11 @@ .maxstack 10
IL_0207: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_020c: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.Convert(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, System.Type, System.Type)""
IL_0211: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_0216: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_021b: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_0216: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_021b: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_0220: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, object, bool> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>>.Target""
IL_0225: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_022a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_0225: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, bool>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_022a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_022f: brtrue.s IL_0260
IL_0231: ldc.i4.0
IL_0232: ldstr ""IsCompleted""
......@@ -14649,10 +14649,10 @@ .maxstack 10
IL_0250: stelem.ref
IL_0251: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.GetMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_0256: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_025b: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_0260: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_025b: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_0260: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_0265: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, object, object> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Target""
IL_026a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site7""
IL_026a: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site6""
IL_026f: ldloc.2
IL_0270: callvirt ""object System.Func<System.Runtime.CompilerServices.CallSite, object, object>.Invoke(System.Runtime.CompilerServices.CallSite, object)""
IL_0275: callvirt ""bool System.Func<System.Runtime.CompilerServices.CallSite, object, bool>.Invoke(System.Runtime.CompilerServices.CallSite, object)""
......@@ -14664,7 +14664,7 @@ .maxstack 10
IL_0280: stfld ""int C.<M>d__1.<>1__state""
IL_0285: ldarg.0
IL_0286: ldloc.2
IL_0287: stfld ""object C.<M>d__1.<>u__4""
IL_0287: stfld ""object C.<M>d__1.<>u__1""
IL_028c: ldloc.2
IL_028d: isinst ""System.Runtime.CompilerServices.ICriticalNotifyCompletion""
IL_0292: stloc.3
......@@ -14690,17 +14690,17 @@ .maxstack 10
IL_02c0: stloc.3
IL_02c1: leave IL_035a
IL_02c6: ldarg.0
IL_02c7: ldfld ""object C.<M>d__1.<>u__4""
IL_02c7: ldfld ""object C.<M>d__1.<>u__1""
IL_02cc: stloc.2
IL_02cd: ldarg.0
IL_02ce: ldnull
IL_02cf: stfld ""object C.<M>d__1.<>u__4""
IL_02cf: stfld ""object C.<M>d__1.<>u__1""
IL_02d4: ldarg.0
IL_02d5: ldc.i4.m1
IL_02d6: dup
IL_02d7: stloc.0
IL_02d8: stfld ""int C.<M>d__1.<>1__state""
IL_02dd: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site9""
IL_02dd: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_02e2: brtrue.s IL_0314
IL_02e4: ldc.i4.0
IL_02e5: ldstr ""GetResult""
......@@ -14717,10 +14717,10 @@ .maxstack 10
IL_0304: stelem.ref
IL_0305: call ""System.Runtime.CompilerServices.CallSiteBinder Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, string, System.Collections.Generic.IEnumerable<System.Type>, System.Type, System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>)""
IL_030a: call ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Create(System.Runtime.CompilerServices.CallSiteBinder)""
IL_030f: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site9""
IL_0314: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site9""
IL_030f: stsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_0314: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_0319: ldfld ""System.Func<System.Runtime.CompilerServices.CallSite, object, object> System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>>.Target""
IL_031e: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site9""
IL_031e: ldsfld ""System.Runtime.CompilerServices.CallSite<System.Func<System.Runtime.CompilerServices.CallSite, object, object>> C.<M>d__1.<>o__SiteContainer0.<>p__Site8""
IL_0323: ldloc.2
IL_0324: callvirt ""object System.Func<System.Runtime.CompilerServices.CallSite, object, object>.Invoke(System.Runtime.CompilerServices.CallSite, object)""
IL_0329: ldnull
......
......@@ -294,7 +294,7 @@ static async Task<int> F()
// - Method 'SetStateMachine'
// - Field '<>1__state'
// - Field '<>t__builder'
// - Field '<>u__0'
// - Field '<>u__1'
// Add method F()
CheckEncLogDefinitions(reader1,
Row(1, TableIndex.StandAloneSig, EditAndContinueOperation.Default),
......@@ -920,7 +920,7 @@ .maxstack 3
IL_0029: stfld ""int C.<F>d__1.<>1__state""
IL_002e: ldarg.0
IL_002f: ldloc.2
IL_0030: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_0030: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_0035: ldarg.0
IL_0036: stloc.3
IL_0037: ldarg.0
......@@ -931,10 +931,10 @@ .maxstack 3
IL_0046: nop
IL_0047: leave.s IL_00aa
IL_0049: ldarg.0
IL_004a: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_004a: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_004f: stloc.2
IL_0050: ldarg.0
IL_0051: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_0051: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_0056: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_005c: ldarg.0
IL_005d: ldc.i4.m1
......@@ -1008,7 +1008,7 @@ .maxstack 3
IL_0028: stfld ""int C.<F>d__1.<>1__state""
IL_002d: ldarg.0
IL_002e: ldloc.2
IL_002f: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_002f: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_0034: ldarg.0
IL_0035: stloc.3
IL_0036: ldarg.0
......@@ -1019,10 +1019,10 @@ .maxstack 3
IL_0045: nop
IL_0046: leave.s IL_00a8
IL_0048: ldarg.0
IL_0049: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_0049: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_004e: stloc.2
IL_004f: ldarg.0
IL_0050: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_0050: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_0055: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_005b: ldarg.0
IL_005c: ldc.i4.m1
......@@ -1698,6 +1698,267 @@ .maxstack 5
IL_00a4: stloc.1
IL_00a5: br IL_0018
}
");
}
}
}
[Fact]
public void Awaiters1()
{
var source0 = @"
using System.Threading.Tasks;
class C
{
static Task<bool> A1() => null;
static Task<int> A2() => null;
static Task<double> A3() => null;
static async Task<int> F()
{
await A1();
await A2();
return 1;
}
static async Task<int> G()
{
await A2();
await A1();
return 1;
}
}";
var compilation0 = CreateCompilationWithMscorlib45(source0, options: ComSafeDebugDll.WithMetadataImportOptions(MetadataImportOptions.All));
CompileAndVerify(compilation0, symbolValidator: module =>
{
Assert.Equal(new[]
{
"<>1__state: int",
"<>t__builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>",
"<>u__1: System.Runtime.CompilerServices.TaskAwaiter<bool>",
"<>u__2: System.Runtime.CompilerServices.TaskAwaiter<int>"
}, module.GetFieldNamesAndTypes("C.<F>d__1"));
Assert.Equal(new[]
{
"<>1__state: int",
"<>t__builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>",
"<>u__1: System.Runtime.CompilerServices.TaskAwaiter<int>",
"<>u__2: System.Runtime.CompilerServices.TaskAwaiter<bool>"
}, module.GetFieldNamesAndTypes("C.<G>d__1"));
});
}
[Fact]
public void Awaiters2()
{
var source0 = @"
using System.Threading.Tasks;
class C
{
static Task<bool> A1() => null;
static Task<int> A2() => null;
static Task<double> A3() => null;
static async Task<int> F()
{
await A1();
await A2();
return 1;
}
}";
var source1 = @"
using System.Threading.Tasks;
class C
{
static Task<bool> A1() => null;
static Task<int> A2() => null;
static Task<double> A3() => null;
static async Task<int> F()
{
await A3();
await A2();
return 1;
}
}";
// Rude edit but the compiler should handle it.
var compilation0 = CreateCompilationWithMscorlib45(source0, options: ComSafeDebugDll.WithMetadataImportOptions(MetadataImportOptions.All));
var compilation1 = CreateCompilationWithMscorlib45(source1, options: ComSafeDebugDll.WithMetadataImportOptions(MetadataImportOptions.All));
var v0 = CompileAndVerify(compilation0, symbolValidator: module =>
{
Assert.Equal(new[]
{
"<>1__state: int",
"<>t__builder: System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>",
"<>u__1: System.Runtime.CompilerServices.TaskAwaiter<bool>",
"<>u__2: System.Runtime.CompilerServices.TaskAwaiter<int>"
}, module.GetFieldNamesAndTypes("C.<F>d__1"));
});
var debugInfoProvider = v0.CreatePdbInfoProvider();
using (var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData))
{
var method0 = compilation0.GetMember<MethodSymbol>("C.F");
var method1 = compilation1.GetMember<MethodSymbol>("C.F");
var generation0 = EmitBaseline.CreateInitialBaseline(md0, debugInfoProvider.GetEncMethodDebugInfo);
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, method0, method1, GetSyntaxMapByKind(method0, SyntaxKind.ForEachStatement), preserveLocalVariables: true)));
// Verify delta metadata contains expected rows.
using (var md1 = diff1.GetMetadata())
{
// 1 field def added & 2 methods updated
CheckEncLogDefinitions(md1.Reader,
Row(6, TableIndex.StandAloneSig, EditAndContinueOperation.Default),
Row(7, TableIndex.StandAloneSig, EditAndContinueOperation.Default),
Row(3, TableIndex.TypeDef, EditAndContinueOperation.AddField),
Row(5, TableIndex.Field, EditAndContinueOperation.Default),
Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default),
Row(7, TableIndex.MethodDef, EditAndContinueOperation.Default),
Row(7, TableIndex.CustomAttribute, EditAndContinueOperation.Default));
// Note that the new awaiter is allocated slot <>u__3 since <>u__1 and <>u__2 are taken.
diff1.VerifyIL("C.<F>d__1.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext", @"
{
// Code size 285 (0x11d)
.maxstack 3
.locals init (int V_0,
int V_1,
System.Runtime.CompilerServices.TaskAwaiter<double> V_2,
C.<F>d__1 V_3,
System.Runtime.CompilerServices.TaskAwaiter<int> V_4,
System.Exception V_5)
IL_0000: ldarg.0
IL_0001: ldfld ""int C.<F>d__1.<>1__state""
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0012
IL_000a: br.s IL_000c
IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: beq.s IL_0014
IL_0010: br.s IL_0019
IL_0012: br.s IL_0055
IL_0014: br IL_00bb
IL_0019: nop
IL_001a: call ""System.Threading.Tasks.Task<double> C.A3()""
IL_001f: callvirt ""System.Runtime.CompilerServices.TaskAwaiter<double> System.Threading.Tasks.Task<double>.GetAwaiter()""
IL_0024: stloc.2
IL_0025: ldloca.s V_2
IL_0027: call ""bool System.Runtime.CompilerServices.TaskAwaiter<double>.IsCompleted.get""
IL_002c: brtrue.s IL_0071
IL_002e: ldarg.0
IL_002f: ldc.i4.0
IL_0030: dup
IL_0031: stloc.0
IL_0032: stfld ""int C.<F>d__1.<>1__state""
IL_0037: ldarg.0
IL_0038: ldloc.2
IL_0039: stfld ""System.Runtime.CompilerServices.TaskAwaiter<double> C.<F>d__1.<>u__3""
IL_003e: ldarg.0
IL_003f: stloc.3
IL_0040: ldarg.0
IL_0041: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__1.<>t__builder""
IL_0046: ldloca.s V_2
IL_0048: ldloca.s V_3
IL_004a: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<double>, C.<F>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<double>, ref C.<F>d__1)""
IL_004f: nop
IL_0050: leave IL_011c
IL_0055: ldarg.0
IL_0056: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<double> C.<F>d__1.<>u__3""
IL_005b: stloc.2
IL_005c: ldarg.0
IL_005d: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<double> C.<F>d__1.<>u__3""
IL_0062: initobj ""System.Runtime.CompilerServices.TaskAwaiter<double>""
IL_0068: ldarg.0
IL_0069: ldc.i4.m1
IL_006a: dup
IL_006b: stloc.0
IL_006c: stfld ""int C.<F>d__1.<>1__state""
IL_0071: ldloca.s V_2
IL_0073: call ""double System.Runtime.CompilerServices.TaskAwaiter<double>.GetResult()""
IL_0078: pop
IL_0079: ldloca.s V_2
IL_007b: initobj ""System.Runtime.CompilerServices.TaskAwaiter<double>""
IL_0081: call ""System.Threading.Tasks.Task<int> C.A2()""
IL_0086: callvirt ""System.Runtime.CompilerServices.TaskAwaiter<int> System.Threading.Tasks.Task<int>.GetAwaiter()""
IL_008b: stloc.s V_4
IL_008d: ldloca.s V_4
IL_008f: call ""bool System.Runtime.CompilerServices.TaskAwaiter<int>.IsCompleted.get""
IL_0094: brtrue.s IL_00d8
IL_0096: ldarg.0
IL_0097: ldc.i4.1
IL_0098: dup
IL_0099: stloc.0
IL_009a: stfld ""int C.<F>d__1.<>1__state""
IL_009f: ldarg.0
IL_00a0: ldloc.s V_4
IL_00a2: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__2""
IL_00a7: ldarg.0
IL_00a8: stloc.3
IL_00a9: ldarg.0
IL_00aa: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__1.<>t__builder""
IL_00af: ldloca.s V_4
IL_00b1: ldloca.s V_3
IL_00b3: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.AwaitUnsafeOnCompleted<System.Runtime.CompilerServices.TaskAwaiter<int>, C.<F>d__1>(ref System.Runtime.CompilerServices.TaskAwaiter<int>, ref C.<F>d__1)""
IL_00b8: nop
IL_00b9: leave.s IL_011c
IL_00bb: ldarg.0
IL_00bc: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__2""
IL_00c1: stloc.s V_4
IL_00c3: ldarg.0
IL_00c4: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__2""
IL_00c9: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_00cf: ldarg.0
IL_00d0: ldc.i4.m1
IL_00d1: dup
IL_00d2: stloc.0
IL_00d3: stfld ""int C.<F>d__1.<>1__state""
IL_00d8: ldloca.s V_4
IL_00da: call ""int System.Runtime.CompilerServices.TaskAwaiter<int>.GetResult()""
IL_00df: pop
IL_00e0: ldloca.s V_4
IL_00e2: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_00e8: ldc.i4.1
IL_00e9: stloc.1
IL_00ea: leave.s IL_0107
}
catch System.Exception
{
IL_00ec: stloc.s V_5
IL_00ee: nop
IL_00ef: ldarg.0
IL_00f0: ldc.i4.s -2
IL_00f2: stfld ""int C.<F>d__1.<>1__state""
IL_00f7: ldarg.0
IL_00f8: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__1.<>t__builder""
IL_00fd: ldloc.s V_5
IL_00ff: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetException(System.Exception)""
IL_0104: nop
IL_0105: leave.s IL_011c
}
IL_0107: ldarg.0
IL_0108: ldc.i4.s -2
IL_010a: stfld ""int C.<F>d__1.<>1__state""
IL_010f: ldarg.0
IL_0110: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int> C.<F>d__1.<>t__builder""
IL_0115: ldloc.1
IL_0116: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder<int>.SetResult(int)""
IL_011b: nop
IL_011c: ret
}
");
}
}
......
......@@ -2911,7 +2911,7 @@ .maxstack 3
IL_007e: stfld ""int C.<F>d__1.<>1__state""
IL_0083: ldarg.0
IL_0084: ldloc.2
IL_0085: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_0085: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_008a: ldarg.0
IL_008b: stloc.3
IL_008c: ldarg.0
......@@ -2922,10 +2922,10 @@ .maxstack 3
IL_009b: nop
IL_009c: leave.s IL_00fe
IL_009e: ldarg.0
IL_009f: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_009f: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_00a4: stloc.2
IL_00a5: ldarg.0
IL_00a6: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__0""
IL_00a6: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<F>d__1.<>u__1""
IL_00ab: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_00b1: ldarg.0
IL_00b2: ldc.i4.m1
......
......@@ -468,7 +468,7 @@ static async Task M(int b)
{
"<>1__state",
"<>t__builder",
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -558,7 +558,7 @@ static async Task M(int b)
"<>t__builder",
"b",
"<>8__1", // display class
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -652,7 +652,7 @@ static async Task M(int b)
"<>1__state",
"<>t__builder",
"<>8__1", // display class
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -738,7 +738,7 @@ static async Task M(int b)
"<>t__builder",
"b",
"<>8__1", // display class
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -826,7 +826,7 @@ static async Task M()
"<>1__state",
"<>t__builder",
"<d>5__1",
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -913,7 +913,7 @@ static async Task M()
{
"<>1__state",
"<>t__builder",
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -997,7 +997,7 @@ static async Task M()
"<>1__state",
"<>t__builder",
"<d>5__1",
"<>u__2", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
......@@ -1095,7 +1095,7 @@ static async Task M()
"<>1__state",
"<>t__builder",
"<x>5__1",
"<>u__0", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<M>d__1"));
});
}
......@@ -1136,7 +1136,7 @@ static async Task<int> G()
"<>s__2",
"<>s__3",
"<>s__4",
"<>u__0", // awaiter
"<>u__1", // awaiter
}, module.GetFieldNames("C.<G>d__1"));
});
......@@ -1217,7 +1217,7 @@ .maxstack 3
IL_004c: stfld ""int C.<G>d__1.<>1__state""
IL_0051: ldarg.0
IL_0052: ldloc.3
IL_0053: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__0""
IL_0053: stfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__1""
IL_0058: ldarg.0
IL_0059: stloc.s V_5
IL_005b: ldarg.0
......@@ -1228,10 +1228,10 @@ .maxstack 3
IL_006a: nop
IL_006b: leave IL_011e
IL_0070: ldarg.0
IL_0071: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__0""
IL_0071: ldfld ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__1""
IL_0076: stloc.3
IL_0077: ldarg.0
IL_0078: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__0""
IL_0078: ldflda ""System.Runtime.CompilerServices.TaskAwaiter<int> C.<G>d__1.<>u__1""
IL_007d: initobj ""System.Runtime.CompilerServices.TaskAwaiter<int>""
IL_0083: ldarg.0
IL_0084: ldc.i4.m1
......@@ -1389,7 +1389,7 @@ static async Task<int> G()
"<>s__8",
"<>s__9",
"<>s__10",
"<>u__0", // awaiter
"<>u__1", // awaiter
"<>s__11", // ref-spills
"<>s__12",
"<>s__13",
......
......@@ -28,7 +28,23 @@ internal abstract class VariableSlotAllocator
public abstract string PreviousStateMachineTypeName { get; }
public abstract int HoistedLocalSlotCount { get; }
/// <summary>
/// Number of slots reserved for hoisted local variables.
/// </summary>
/// <remarks>
/// Some of the slots might not be used anymore (a variable might have been deleted or its type changed).
/// Still, new hoisted variables are assigned slots starting with <see cref="PreviousHoistedLocalSlotCount"/>.
/// </remarks>
public abstract int PreviousHoistedLocalSlotCount { get; }
/// <summary>
/// Number of slots reserved for awaiters.
/// </summary>
/// <remarks>
/// Some of the slots might not be used anymore (the type of an awaiter might have changed).
/// Still, new awaiters are assigned slots starting with <see cref="PreviousAwaiterSlotCount"/>.
/// </remarks>
public abstract int PreviousAwaiterSlotCount { get; }
public abstract string GetPreviousAwaiter(Cci.ITypeReference currentType);
}
......
......@@ -28,6 +28,7 @@ internal sealed class EncVariableSlotAllocator : VariableSlotAllocator
private readonly string previousStateMachineTypeNameOpt;
private readonly int hoistedLocalSlotCount;
private readonly IReadOnlyDictionary<EncLocalInfo, string> previousHoistedLocalSlotsOpt;
private readonly int awaiterCount;
private readonly IReadOnlyDictionary<Cci.ITypeReference, string> awaiterMapOpt;
public EncVariableSlotAllocator(
......@@ -38,6 +39,7 @@ internal sealed class EncVariableSlotAllocator : VariableSlotAllocator
string previousStateMachineTypeNameOpt,
int hoistedLocalSlotCount,
IReadOnlyDictionary<EncLocalInfo, string> previousHoistedLocalSlotsOpt,
int awaiterCount,
IReadOnlyDictionary<Cci.ITypeReference, string> awaiterMapOpt)
{
Debug.Assert(symbolMap != null);
......@@ -49,9 +51,10 @@ internal sealed class EncVariableSlotAllocator : VariableSlotAllocator
this.previousLocals = previousLocals;
this.previousMethod = previousMethod;
this.previousHoistedLocalSlotsOpt = previousHoistedLocalSlotsOpt;
this.awaiterMapOpt = awaiterMapOpt;
this.hoistedLocalSlotCount = hoistedLocalSlotCount;
this.previousStateMachineTypeNameOpt = previousStateMachineTypeNameOpt;
this.awaiterCount = awaiterCount;
this.awaiterMapOpt = awaiterMapOpt;
// Create a map from local info to slot.
var previousLocalInfoToSlot = new Dictionary<EncLocalInfo, int>();
......@@ -180,14 +183,20 @@ public override string GetPreviousHoistedLocal(SyntaxNode currentDeclarator, Cci
return fieldName;
}
public override string PreviousStateMachineTypeName
{
get { return previousStateMachineTypeNameOpt; }
}
public override int HoistedLocalSlotCount
public override int PreviousHoistedLocalSlotCount
{
get { return hoistedLocalSlotCount; }
}
public override int PreviousAwaiterSlotCount
{
get { return this.hoistedLocalSlotCount; }
get { return awaiterCount; }
}
public override string GetPreviousAwaiter(Cci.ITypeReference currentType)
......
......@@ -147,6 +147,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Dim previousHoistedLocalMap As IReadOnlyDictionary(Of EncLocalInfo, String) = Nothing
Dim awaiterMap As IReadOnlyDictionary(Of Cci.ITypeReference, String) = Nothing
Dim hoistedLocalSlotCount As Integer = 0
Dim awaiterSlotCount As Integer = 0
Dim previousStateMachineTypeNameOpt As String = Nothing
Dim methodIndex As UInteger = CUInt(MetadataTokens.GetRowNumber(handle))
......@@ -173,7 +174,16 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
End If
' TODO
Return New EncVariableSlotAllocator(symbolMap, methodEntry.SyntaxMap, methodEntry.PreviousMethod, previousLocals, previousStateMachineTypeNameOpt, hoistedLocalSlotCount, previousHoistedLocalMap, awaiterMap)
Return New EncVariableSlotAllocator(
symbolMap,
methodEntry.SyntaxMap,
methodEntry.PreviousMethod,
previousLocals,
previousStateMachineTypeNameOpt,
hoistedLocalSlotCount,
previousHoistedLocalMap,
awaiterSlotCount,
awaiterMap)
End Function
''' <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册