From 0ed2256ae58e523c3d9885d8037927594f10e5d8 Mon Sep 17 00:00:00 2001 From: Neal Gafter Date: Mon, 19 Aug 2019 14:18:51 -0700 Subject: [PATCH] Permit stackalloc to be used in an async method as long as it need not be spilled. (#37711) Fixes #37461 --- .../LocalRewriter/LocalRewriter_Await.cs | 19 +- ...writer_NullCoalescingAssignmentOperator.cs | 5 +- .../LocalRewriter/LocalRewriter_StackAlloc.cs | 10 +- .../Portable/Lowering/SpillSequenceSpiller.cs | 1 - .../StateMachineRewriter.cs | 6 + .../Emit/CodeGen/CodeGenAsyncLocalsTests.cs | 2 +- .../Emit/CodeGen/CodeGenAsyncSpillTests.cs | 295 +++-- .../CSharp/Test/Emit/CodeGen/CodeGenTests.cs | 516 ++++---- .../CSharp/Test/Emit/CodeGen/PatternTests.cs | 145 ++- .../EditAndContinue/LocalSlotMappingTests.cs | 258 ++-- .../CSharp/Test/Emit/PDB/PDBTests.cs | 1077 ++++++++--------- 11 files changed, 1214 insertions(+), 1120 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Await.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Await.cs index cb8a4bf088b..33f6d40dc6b 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Await.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Await.cs @@ -36,16 +36,21 @@ private BoundExpression RewriteAwaitExpression(BoundExpression rewrittenAwait, b } // The await expression will be lowered to code that involves the use of side-effects - // such as jumps and labels, therefore it is represented by a BoundSpillSequence. - // The resulting nodes will be "spilled" to move such statements to the top - // level (i.e. into the enclosing statement list). + // such as jumps and labels, which we can only emit with an empty stack, so we require + // that the await expression itself is produced only when the stack is empty. + // Therefore it is represented by a BoundSpillSequence. The resulting nodes will be "spilled" to move + // such statements to the top level (i.e. into the enclosing statement list). Here we ensure + // that the await result itself is stored into a temp at the statement level, as that is + // the form handled by async lowering. _needsSpilling = true; + var tempAccess = _factory.StoreToTemp(rewrittenAwait, out BoundAssignmentOperator tempAssignment, syntaxOpt: rewrittenAwait.Syntax, + kind: SynthesizedLocalKind.Spill); return new BoundSpillSequence( syntax: rewrittenAwait.Syntax, - locals: ImmutableArray.Empty, - sideEffects: ImmutableArray.Empty, - value: rewrittenAwait, - type: rewrittenAwait.Type); + locals: ImmutableArray.Create(tempAccess.LocalSymbol), + sideEffects: ImmutableArray.Create(tempAssignment), + value: tempAccess, + type: tempAccess.Type); } } } diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_NullCoalescingAssignmentOperator.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_NullCoalescingAssignmentOperator.cs index d7ad660466d..88fd88b5318 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_NullCoalescingAssignmentOperator.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_NullCoalescingAssignmentOperator.cs @@ -86,7 +86,7 @@ BoundExpression rewriteNullCoalescingAssignmentForValueType() // the standard ??= case because it only uses lhsRead once. if (lhsRead.Kind == BoundKind.Call) { - var lhsTemp = _factory.StoreToTemp(lhsRead, out var store, kind: SynthesizedLocalKind.Spill); + var lhsTemp = _factory.StoreToTemp(lhsRead, out var store); stores.Add(store); temps.Add(lhsTemp.LocalSymbol); lhsRead = lhsTemp; @@ -94,8 +94,7 @@ BoundExpression rewriteNullCoalescingAssignmentForValueType() // tmp = lhsRead.GetValueOrDefault(); var tmp = _factory.StoreToTemp(BoundCall.Synthesized(leftOperand.Syntax, lhsRead, getValueOrDefault), - out var getValueOrDefaultStore, - kind: SynthesizedLocalKind.Spill); + out var getValueOrDefaultStore); stores.Add(getValueOrDefaultStore); temps.Add(tmp.LocalSymbol); diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StackAlloc.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StackAlloc.cs index de8717001b4..37e61e66ba4 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StackAlloc.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StackAlloc.cs @@ -64,12 +64,20 @@ public override BoundNode VisitStackAllocArrayCreation(BoundStackAllocArrayCreat type: ErrorTypeSymbol.UnknownResultType); } + // The stackalloc instruction requires that the evaluation stack contains only its parameter when executed. + // We arrange to clear the stack by wrapping it in a SpillSequence, which will cause pending computations + // to be spilled, and also by storing the result in a temporary local, so that the result does not get + // hoisted/spilled into some state machine. If that temp local needs to be spilled that will result in an + // error. _needsSpilling = true; + var tempAccess = _factory.StoreToTemp(constructorCall, out BoundAssignmentOperator tempAssignment, syntaxOpt: stackAllocNode.Syntax); + sideEffects.Add(tempAssignment); + locals.Add(tempAccess.LocalSymbol); return new BoundSpillSequence( syntax: stackAllocNode.Syntax, locals: locals.ToImmutableAndFree(), sideEffects: sideEffects.ToImmutableAndFree(), - value: constructorCall, + value: tempAccess, type: spanType); } else diff --git a/src/Compilers/CSharp/Portable/Lowering/SpillSequenceSpiller.cs b/src/Compilers/CSharp/Portable/Lowering/SpillSequenceSpiller.cs index 209c8eed4ae..325cac90725 100644 --- a/src/Compilers/CSharp/Portable/Lowering/SpillSequenceSpiller.cs +++ b/src/Compilers/CSharp/Portable/Lowering/SpillSequenceSpiller.cs @@ -551,7 +551,6 @@ public override BoundNode VisitSpillSequence(BoundSpillSequence node) builder.AddStatements(VisitList(node.SideEffects)); builder.AddLocals(node.Locals); var value = VisitExpression(ref builder, node.Value); - value = Spill(builder, value); return builder.Update(value); } diff --git a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineRewriter.cs index bd971f62975..6d53fbd5126 100644 --- a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/StateMachineRewriter.cs @@ -107,6 +107,12 @@ protected BoundStatement Rewrite() // fields for the captured variables of the method var variablesToHoist = IteratorAndAsyncCaptureWalker.Analyze(F.Compilation, method, body, diagnostics); + if (diagnostics.HasAnyErrors()) + { + // Avoid triggering assertions in further lowering. + return new BoundBadStatement(F.Syntax, ImmutableArray.Empty, hasErrors: true); + } + CreateNonReusableLocalProxies(variablesToHoist, out this.nonReusableLocalProxies, out this.nextFreeHoistedLocalSlot); this.hoistedVariables = variablesToHoist; diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncLocalsTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncLocalsTests.cs index 8caf3a95739..3d9dcf4ed94 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncLocalsTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncLocalsTests.cs @@ -351,10 +351,10 @@ public async Task M(IDisposable disposable) + - diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs index bafb124d8c8..8fba315f11e 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncSpillTests.cs @@ -3,12 +3,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; -using Microsoft.CodeAnalysis.CSharp.Symbols; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; -using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen @@ -3391,95 +3389,212 @@ public sealed class JsonSerializerOptions var v = CompileAndVerify(source, options: TestOptions.DebugExe); v.VerifyIL("Program.d__1.System.Runtime.CompilerServices.IAsyncStateMachine.MoveNext()", @" + { + // Code size 184 (0xb8) + .maxstack 3 + .locals init (int V_0, + System.Runtime.CompilerServices.TaskAwaiter V_1, + Program.d__1 V_2, + System.Exception V_3) + IL_0000: ldarg.0 + IL_0001: ldfld ""int Program.d__1.<>1__state"" + IL_0006: stloc.0 + .try + { + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_000c + IL_000a: br.s IL_000e + IL_000c: br.s IL_0047 + IL_000e: nop + IL_000f: call ""System.Threading.Tasks.Task Program.TestAsync()"" + IL_0014: callvirt ""System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()"" + IL_0019: stloc.1 + IL_001a: ldloca.s V_1 + IL_001c: call ""bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get"" + IL_0021: brtrue.s IL_0063 + IL_0023: ldarg.0 + IL_0024: ldc.i4.0 + IL_0025: dup + IL_0026: stloc.0 + IL_0027: stfld ""int Program.d__1.<>1__state"" + IL_002c: ldarg.0 + IL_002d: ldloc.1 + IL_002e: stfld ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" + IL_0033: ldarg.0 + IL_0034: stloc.2 + IL_0035: ldarg.0 + IL_0036: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" + IL_003b: ldloca.s V_1 + IL_003d: ldloca.s V_2 + IL_003f: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, Program.d__1>(ref System.Runtime.CompilerServices.TaskAwaiter, ref Program.d__1)"" + IL_0044: nop + IL_0045: leave.s IL_00b7 + IL_0047: ldarg.0 + IL_0048: ldfld ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" + IL_004d: stloc.1 + IL_004e: ldarg.0 + IL_004f: ldflda ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" + IL_0054: initobj ""System.Runtime.CompilerServices.TaskAwaiter"" + IL_005a: ldarg.0 + IL_005b: ldc.i4.m1 + IL_005c: dup + IL_005d: stloc.0 + IL_005e: stfld ""int Program.d__1.<>1__state"" + IL_0063: ldarg.0 + IL_0064: ldloca.s V_1 + IL_0066: call ""byte[] System.Runtime.CompilerServices.TaskAwaiter.GetResult()"" + IL_006b: stfld ""byte[] Program.d__1.<>s__1"" + IL_0070: ldarg.0 + IL_0071: ldfld ""byte[] Program.d__1.<>s__1"" + IL_0076: call ""System.ReadOnlySpan System.ReadOnlySpan.op_Implicit(byte[])"" + IL_007b: ldnull + IL_007c: call ""string System.Text.Json.Serialization.JsonSerializer.Parse(System.ReadOnlySpan, System.Text.Json.Serialization.JsonSerializerOptions)"" + IL_0081: pop + IL_0082: ldarg.0 + IL_0083: ldnull + IL_0084: stfld ""byte[] Program.d__1.<>s__1"" + IL_0089: leave.s IL_00a3 + } + catch System.Exception + { + IL_008b: stloc.3 + IL_008c: ldarg.0 + IL_008d: ldc.i4.s -2 + IL_008f: stfld ""int Program.d__1.<>1__state"" + IL_0094: ldarg.0 + IL_0095: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" + IL_009a: ldloc.3 + IL_009b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)"" + IL_00a0: nop + IL_00a1: leave.s IL_00b7 + } + IL_00a3: ldarg.0 + IL_00a4: ldc.i4.s -2 + IL_00a6: stfld ""int Program.d__1.<>1__state"" + IL_00ab: ldarg.0 + IL_00ac: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" + IL_00b1: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()"" + IL_00b6: nop + IL_00b7: ret + } +", sequencePoints: "Program.Serialize"); + } + + [Fact, WorkItem(37461, "https://github.com/dotnet/roslyn/issues/37461")] + public void ShouldNotSpillStackallocToField_01() + { + var source = @" +using System; +using System.Threading.Tasks; + +public class P { - // Code size 184 (0xb8) - .maxstack 3 - .locals init (int V_0, - System.Runtime.CompilerServices.TaskAwaiter V_1, - Program.d__1 V_2, - System.Exception V_3) - IL_0000: ldarg.0 - IL_0001: ldfld ""int Program.d__1.<>1__state"" - IL_0006: stloc.0 - .try - { - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_000c - IL_000a: br.s IL_000e - IL_000c: br.s IL_0047 - IL_000e: nop - IL_000f: call ""System.Threading.Tasks.Task Program.TestAsync()"" - IL_0014: callvirt ""System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()"" - IL_0019: stloc.1 - IL_001a: ldloca.s V_1 - IL_001c: call ""bool System.Runtime.CompilerServices.TaskAwaiter.IsCompleted.get"" - IL_0021: brtrue.s IL_0063 - IL_0023: ldarg.0 - IL_0024: ldc.i4.0 - IL_0025: dup - IL_0026: stloc.0 - IL_0027: stfld ""int Program.d__1.<>1__state"" - IL_002c: ldarg.0 - IL_002d: ldloc.1 - IL_002e: stfld ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" - IL_0033: ldarg.0 - IL_0034: stloc.2 - IL_0035: ldarg.0 - IL_0036: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" - IL_003b: ldloca.s V_1 - IL_003d: ldloca.s V_2 - IL_003f: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.AwaitUnsafeOnCompleted, Program.d__1>(ref System.Runtime.CompilerServices.TaskAwaiter, ref Program.d__1)"" - IL_0044: nop - IL_0045: leave.s IL_00b7 - IL_0047: ldarg.0 - IL_0048: ldfld ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" - IL_004d: stloc.1 - IL_004e: ldarg.0 - IL_004f: ldflda ""System.Runtime.CompilerServices.TaskAwaiter Program.d__1.<>u__1"" - IL_0054: initobj ""System.Runtime.CompilerServices.TaskAwaiter"" - IL_005a: ldarg.0 - IL_005b: ldc.i4.m1 - IL_005c: dup - IL_005d: stloc.0 - IL_005e: stfld ""int Program.d__1.<>1__state"" - IL_0063: ldarg.0 - IL_0064: ldloca.s V_1 - IL_0066: call ""byte[] System.Runtime.CompilerServices.TaskAwaiter.GetResult()"" - IL_006b: stfld ""byte[] Program.d__1.<>s__1"" - IL_0070: ldarg.0 - IL_0071: ldfld ""byte[] Program.d__1.<>s__1"" - IL_0076: call ""System.ReadOnlySpan System.ReadOnlySpan.op_Implicit(byte[])"" - IL_007b: ldnull - IL_007c: call ""string System.Text.Json.Serialization.JsonSerializer.Parse(System.ReadOnlySpan, System.Text.Json.Serialization.JsonSerializerOptions)"" - IL_0081: pop - IL_0082: ldarg.0 - IL_0083: ldnull - IL_0084: stfld ""byte[] Program.d__1.<>s__1"" - IL_0089: leave.s IL_00a3 - } - catch System.Exception - { - IL_008b: stloc.3 - IL_008c: ldarg.0 - IL_008d: ldc.i4.s -2 - IL_008f: stfld ""int Program.d__1.<>1__state"" - IL_0094: ldarg.0 - IL_0095: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" - IL_009a: ldloc.3 - IL_009b: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException(System.Exception)"" - IL_00a0: nop - IL_00a1: leave.s IL_00b7 - } - IL_00a3: ldarg.0 - IL_00a4: ldc.i4.s -2 - IL_00a6: stfld ""int Program.d__1.<>1__state"" - IL_00ab: ldarg.0 - IL_00ac: ldflda ""System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program.d__1.<>t__builder"" - IL_00b1: call ""void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()"" - IL_00b6: nop - IL_00b7: ret + static async Task Main() + { + await Async1(F1(), G(F2(), stackalloc int[] { 40, 500, 6000 })); + } + + static int F1() => 70000; + static int F2() => 800000; + static int G(int k, Span span) => k + span.Length + span[0] + span[1] + span[2]; + static Task Async1(int k, int i) + { + Console.WriteLine(k + i); + return Task.Delay(1); + } } -", sequencePoints: "Program.Serialize"); +"; + var expectedOutput = @"876543"; + + var comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.DebugExe); + comp.VerifyDiagnostics(); + var v = CompileAndVerify( + compilation: comp, + expectedOutput: expectedOutput, + verify: Verification.Fails // localloc is not verifiable. + ); + comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.ReleaseExe); + comp.VerifyDiagnostics(); + v = CompileAndVerify( + compilation: comp, + expectedOutput: expectedOutput, + verify: Verification.Fails // localloc is not verifiable. + ); + } + + [Fact, WorkItem(37461, "https://github.com/dotnet/roslyn/issues/37461")] + public void ShouldNotSpillStackallocToField_02() + { + var source = @" +using System; +using System.Threading.Tasks; + +public class P +{ + static async Task Main() + { + await Async1(F1(), G(F2(), stackalloc int[] { 40, await Task.FromResult(500), 6000 })); + } + + static int F1() => 70000; + static int F2() => 800000; + static int G(int k, Span span) => k + span.Length + span[0] + span[1] + span[2]; + static Task Async1(int k, int i) + { + Console.WriteLine(k + i); + return Task.Delay(1); + } +} +"; + var expectedOutput = @"876543"; + + var comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.DebugExe); + comp.VerifyDiagnostics(); + var v = CompileAndVerify( + compilation: comp, + expectedOutput: expectedOutput, + verify: Verification.Fails // localloc is not verifiable. + ); + comp = CreateCompilationWithMscorlibAndSpan(source, options: TestOptions.ReleaseExe); + comp.VerifyDiagnostics(); + v = CompileAndVerify( + compilation: comp, + expectedOutput: expectedOutput, + verify: Verification.Fails // localloc is not verifiable. + ); + } + + [Fact, WorkItem(37461, "https://github.com/dotnet/roslyn/issues/37461")] + public void ShouldNotSpillStackallocToField_03() + { + var source = @" +using System; +using System.Threading.Tasks; + +public class P +{ + static async Task Main() + { + await Async1(F1(), G(F2(), stackalloc int[] { 1, 2, 3 }, await F3())); + } + + static object F1() => 1; + static object F2() => 1; + static Task F3() => Task.FromResult(1); + static int G(object obj, Span span, object o2) => span.Length; + static async Task Async1(Object obj, int i) { await Task.Delay(1); } +} +"; + foreach (var options in new[] { TestOptions.DebugExe, TestOptions.ReleaseExe }) + { + var comp = CreateCompilationWithMscorlibAndSpan(source, options: options); + comp.VerifyDiagnostics(); + comp.VerifyEmitDiagnostics( + // (9,66): error CS4007: 'await' cannot be used in an expression containing the type 'System.Span' + // await Async1(F1(), G(F2(), stackalloc int[] { 1, 2, 3 }, await F3())); + Diagnostic(ErrorCode.ERR_ByRefTypeAndAwait, "await F3()").WithArguments("System.Span").WithLocation(9, 66) + ); + } } } } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs index 8cd7fe29ec3..d052842eac8 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs @@ -16211,32 +16211,33 @@ .maxstack 2 }"); comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: expectedOutput, verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 54 (0x36) - .maxstack 2 - .locals init (System.Span V_0, //x - System.Span V_1) - IL_0000: nop - IL_0001: ldc.i4 0x84 - IL_0006: conv.u - IL_0007: localloc - IL_0009: ldc.i4.s 33 - IL_000b: newobj ""System.Span..ctor(void*, int)"" - IL_0010: stloc.1 - IL_0011: ldloc.1 - IL_0012: stloc.0 - IL_0013: ldloca.s V_0 - IL_0015: call ""int System.Span.Length.get"" - IL_001a: call ""void System.Console.Write(int)"" - IL_001f: nop - IL_0020: ldloca.s V_0 - IL_0022: initobj ""System.Span"" - IL_0028: ldloca.s V_0 - IL_002a: call ""int System.Span.Length.get"" - IL_002f: call ""void System.Console.Write(int)"" - IL_0034: nop - IL_0035: ret -}"); + { + // Code size 54 (0x36) + .maxstack 2 + .locals init (System.Span V_0, //x + System.Span V_1) + IL_0000: nop + IL_0001: ldc.i4 0x84 + IL_0006: conv.u + IL_0007: localloc + IL_0009: ldc.i4.s 33 + IL_000b: newobj ""System.Span..ctor(void*, int)"" + IL_0010: stloc.1 + IL_0011: ldloc.1 + IL_0012: stloc.0 + IL_0013: ldloca.s V_0 + IL_0015: call ""int System.Span.Length.get"" + IL_001a: call ""void System.Console.Write(int)"" + IL_001f: nop + IL_0020: ldloca.s V_0 + IL_0022: initobj ""System.Span"" + IL_0028: ldloca.s V_0 + IL_002a: call ""int System.Span.Length.get"" + IL_002f: call ""void System.Console.Write(int)"" + IL_0034: nop + IL_0035: ret + } +"); } [Fact] @@ -16297,48 +16298,49 @@ .maxstack 2 }"); comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: "12345", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 56 (0x38) - .maxstack 2 - .locals init (int V_0, //i - System.Span V_1, //x - int V_2, - System.Span V_3, - bool V_4) - IL_0000: nop - IL_0001: ldc.i4.0 - IL_0002: stloc.0 - IL_0003: br.s IL_002d - IL_0005: nop - IL_0006: call ""int Test.GetLength()"" - IL_000b: stloc.2 - IL_000c: ldloc.2 - IL_000d: conv.u - IL_000e: ldc.i4.4 - IL_000f: mul.ovf.un - IL_0010: localloc - IL_0012: ldloc.2 - IL_0013: newobj ""System.Span..ctor(void*, int)"" - IL_0018: stloc.3 - IL_0019: ldloc.3 - IL_001a: stloc.1 - IL_001b: ldloca.s V_1 - IL_001d: call ""int System.Span.Length.get"" - IL_0022: call ""void System.Console.Write(int)"" - IL_0027: nop - IL_0028: nop - IL_0029: ldloc.0 - IL_002a: ldc.i4.1 - IL_002b: add - IL_002c: stloc.0 - IL_002d: ldloc.0 - IL_002e: ldc.i4.5 - IL_002f: clt - IL_0031: stloc.s V_4 - IL_0033: ldloc.s V_4 - IL_0035: brtrue.s IL_0005 - IL_0037: ret -}"); + { + // Code size 56 (0x38) + .maxstack 2 + .locals init (int V_0, //i + System.Span V_1, //x + int V_2, + System.Span V_3, + bool V_4) + IL_0000: nop + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + IL_0003: br.s IL_002d + IL_0005: nop + IL_0006: call ""int Test.GetLength()"" + IL_000b: stloc.2 + IL_000c: ldloc.2 + IL_000d: conv.u + IL_000e: ldc.i4.4 + IL_000f: mul.ovf.un + IL_0010: localloc + IL_0012: ldloc.2 + IL_0013: newobj ""System.Span..ctor(void*, int)"" + IL_0018: stloc.3 + IL_0019: ldloc.3 + IL_001a: stloc.1 + IL_001b: ldloca.s V_1 + IL_001d: call ""int System.Span.Length.get"" + IL_0022: call ""void System.Console.Write(int)"" + IL_0027: nop + IL_0028: nop + IL_0029: ldloc.0 + IL_002a: ldc.i4.1 + IL_002b: add + IL_002c: stloc.0 + IL_002d: ldloc.0 + IL_002e: ldc.i4.5 + IL_002f: clt + IL_0031: stloc.s V_4 + IL_0033: ldloc.s V_4 + IL_0035: brtrue.s IL_0005 + IL_0037: ret + } +"); } [Fact] @@ -16356,42 +16358,44 @@ public static void Main() }"; var comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 25 (0x19) - .maxstack 2 - .locals init (System.Span V_0) - IL_0000: ldc.i4.s 12 - IL_0002: conv.u - IL_0003: localloc - IL_0005: ldc.i4.3 - IL_0006: newobj ""System.Span..ctor(void*, int)"" - IL_000b: stloc.0 - IL_000c: ldc.i4.2 - IL_000d: ldloc.0 - IL_000e: call ""int Test.M(int, System.Span)"" - IL_0013: call ""void System.Console.WriteLine(int)"" - IL_0018: ret -}"); + { + // Code size 25 (0x19) + .maxstack 2 + .locals init (System.Span V_0) + IL_0000: ldc.i4.s 12 + IL_0002: conv.u + IL_0003: localloc + IL_0005: ldc.i4.3 + IL_0006: newobj ""System.Span..ctor(void*, int)"" + IL_000b: stloc.0 + IL_000c: ldc.i4.2 + IL_000d: ldloc.0 + IL_000e: call ""int Test.M(int, System.Span)"" + IL_0013: call ""void System.Console.WriteLine(int)"" + IL_0018: ret + } +"); comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 27 (0x1b) - .maxstack 2 - .locals init (System.Span V_0) - IL_0000: nop - IL_0001: ldc.i4.s 12 - IL_0003: conv.u - IL_0004: localloc - IL_0006: ldc.i4.3 - IL_0007: newobj ""System.Span..ctor(void*, int)"" - IL_000c: stloc.0 - IL_000d: ldc.i4.2 - IL_000e: ldloc.0 - IL_000f: call ""int Test.M(int, System.Span)"" - IL_0014: call ""void System.Console.WriteLine(int)"" - IL_0019: nop - IL_001a: ret -}"); + { + // Code size 27 (0x1b) + .maxstack 2 + .locals init (System.Span V_0) + IL_0000: nop + IL_0001: ldc.i4.s 12 + IL_0003: conv.u + IL_0004: localloc + IL_0006: ldc.i4.3 + IL_0007: newobj ""System.Span..ctor(void*, int)"" + IL_000c: stloc.0 + IL_000d: ldc.i4.2 + IL_000e: ldloc.0 + IL_000f: call ""int Test.M(int, System.Span)"" + IL_0014: call ""void System.Console.WriteLine(int)"" + IL_0019: nop + IL_001a: ret + } +"); } [Fact] @@ -16410,51 +16414,53 @@ public static void Main() }"; var comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 27 (0x1b) - .maxstack 2 - .locals init (int V_0, - System.Span V_1) - IL_0000: ldc.i4.2 - IL_0001: stloc.0 - IL_0002: ldc.i4.s 12 - IL_0004: conv.u - IL_0005: localloc - IL_0007: ldc.i4.3 - IL_0008: newobj ""System.Span..ctor(void*, int)"" - IL_000d: stloc.1 - IL_000e: ldloc.0 - IL_000f: ldloc.1 - IL_0010: call ""int Test.M(int, System.Span)"" - IL_0015: call ""void System.Console.WriteLine(int)"" - IL_001a: ret -}"); + { + // Code size 27 (0x1b) + .maxstack 2 + .locals init (int V_0, + System.Span V_1) + IL_0000: ldc.i4.2 + IL_0001: stloc.0 + IL_0002: ldc.i4.s 12 + IL_0004: conv.u + IL_0005: localloc + IL_0007: ldc.i4.3 + IL_0008: newobj ""System.Span..ctor(void*, int)"" + IL_000d: stloc.1 + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: call ""int Test.M(int, System.Span)"" + IL_0015: call ""void System.Console.WriteLine(int)"" + IL_001a: ret + } +"); comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 31 (0x1f) - .maxstack 2 - .locals init (int V_0, //z - int V_1, - System.Span V_2) - IL_0000: nop - IL_0001: ldc.i4.2 - IL_0002: stloc.0 - IL_0003: ldloc.0 - IL_0004: stloc.1 - IL_0005: ldc.i4.s 12 - IL_0007: conv.u - IL_0008: localloc - IL_000a: ldc.i4.3 - IL_000b: newobj ""System.Span..ctor(void*, int)"" - IL_0010: stloc.2 - IL_0011: ldloc.1 - IL_0012: ldloc.2 - IL_0013: call ""int Test.M(int, System.Span)"" - IL_0018: call ""void System.Console.WriteLine(int)"" - IL_001d: nop - IL_001e: ret -}"); + { + // Code size 31 (0x1f) + .maxstack 2 + .locals init (int V_0, //z + int V_1, + System.Span V_2) + IL_0000: nop + IL_0001: ldc.i4.2 + IL_0002: stloc.0 + IL_0003: ldloc.0 + IL_0004: stloc.1 + IL_0005: ldc.i4.s 12 + IL_0007: conv.u + IL_0008: localloc + IL_000a: ldc.i4.3 + IL_000b: newobj ""System.Span..ctor(void*, int)"" + IL_0010: stloc.2 + IL_0011: ldloc.1 + IL_0012: ldloc.2 + IL_0013: call ""int Test.M(int, System.Span)"" + IL_0018: call ""void System.Console.WriteLine(int)"" + IL_001d: nop + IL_001e: ret + } +"); } [Fact] @@ -16473,117 +16479,119 @@ public static void Main() }"; var comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 70 (0x46) - .maxstack 4 - .locals init (int V_0, - System.Span V_1, - System.Span V_2) - IL_0000: ldc.i4.2 - IL_0001: stloc.0 - IL_0002: ldc.i4.8 - IL_0003: conv.u - IL_0004: localloc - IL_0006: dup - IL_0007: ldc.i4.4 - IL_0008: stind.i4 - IL_0009: dup - IL_000a: ldc.i4.4 - IL_000b: add - IL_000c: ldc.i4.5 - IL_000d: stind.i4 - IL_000e: ldc.i4.2 - IL_000f: newobj ""System.Span..ctor(void*, int)"" - IL_0014: stloc.1 - IL_0015: ldc.i4.s 12 - IL_0017: conv.u - IL_0018: localloc - IL_001a: dup - IL_001b: ldc.i4.1 - IL_001c: stind.i4 - IL_001d: dup - IL_001e: ldc.i4.4 - IL_001f: add - IL_0020: ldloca.s V_1 - IL_0022: call ""int System.Span.Length.get"" - IL_0027: stind.i4 - IL_0028: dup - IL_0029: ldc.i4.2 - IL_002a: conv.i - IL_002b: ldc.i4.4 - IL_002c: mul - IL_002d: add - IL_002e: ldc.i4.3 - IL_002f: stind.i4 - IL_0030: ldc.i4.3 - IL_0031: newobj ""System.Span..ctor(void*, int)"" - IL_0036: stloc.2 - IL_0037: ldloc.0 - IL_0038: ldloca.s V_2 - IL_003a: call ""int System.Span.Length.get"" - IL_003f: mul - IL_0040: call ""void System.Console.WriteLine(int)"" - IL_0045: ret -}"); + { + // Code size 70 (0x46) + .maxstack 4 + .locals init (int V_0, + System.Span V_1, + System.Span V_2) + IL_0000: ldc.i4.2 + IL_0001: stloc.0 + IL_0002: ldc.i4.8 + IL_0003: conv.u + IL_0004: localloc + IL_0006: dup + IL_0007: ldc.i4.4 + IL_0008: stind.i4 + IL_0009: dup + IL_000a: ldc.i4.4 + IL_000b: add + IL_000c: ldc.i4.5 + IL_000d: stind.i4 + IL_000e: ldc.i4.2 + IL_000f: newobj ""System.Span..ctor(void*, int)"" + IL_0014: stloc.2 + IL_0015: ldc.i4.s 12 + IL_0017: conv.u + IL_0018: localloc + IL_001a: dup + IL_001b: ldc.i4.1 + IL_001c: stind.i4 + IL_001d: dup + IL_001e: ldc.i4.4 + IL_001f: add + IL_0020: ldloca.s V_2 + IL_0022: call ""int System.Span.Length.get"" + IL_0027: stind.i4 + IL_0028: dup + IL_0029: ldc.i4.2 + IL_002a: conv.i + IL_002b: ldc.i4.4 + IL_002c: mul + IL_002d: add + IL_002e: ldc.i4.3 + IL_002f: stind.i4 + IL_0030: ldc.i4.3 + IL_0031: newobj ""System.Span..ctor(void*, int)"" + IL_0036: stloc.1 + IL_0037: ldloc.0 + IL_0038: ldloca.s V_1 + IL_003a: call ""int System.Span.Length.get"" + IL_003f: mul + IL_0040: call ""void System.Console.WriteLine(int)"" + IL_0045: ret + } +"); comp = CreateCompilationWithMscorlibAndSpan(source, TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: "6", verify: Verification.Fails).VerifyIL("Test.Main", @" -{ - // Code size 74 (0x4a) - .maxstack 4 - .locals init (int V_0, //z - int V_1, - System.Span V_2, - System.Span V_3) - IL_0000: nop - IL_0001: ldc.i4.2 - IL_0002: stloc.0 - IL_0003: ldloc.0 - IL_0004: stloc.1 - IL_0005: ldc.i4.8 - IL_0006: conv.u - IL_0007: localloc - IL_0009: dup - IL_000a: ldc.i4.4 - IL_000b: stind.i4 - IL_000c: dup - IL_000d: ldc.i4.4 - IL_000e: add - IL_000f: ldc.i4.5 - IL_0010: stind.i4 - IL_0011: ldc.i4.2 - IL_0012: newobj ""System.Span..ctor(void*, int)"" - IL_0017: stloc.2 - IL_0018: ldc.i4.s 12 - IL_001a: conv.u - IL_001b: localloc - IL_001d: dup - IL_001e: ldc.i4.1 - IL_001f: stind.i4 - IL_0020: dup - IL_0021: ldc.i4.4 - IL_0022: add - IL_0023: ldloca.s V_2 - IL_0025: call ""int System.Span.Length.get"" - IL_002a: stind.i4 - IL_002b: dup - IL_002c: ldc.i4.2 - IL_002d: conv.i - IL_002e: ldc.i4.4 - IL_002f: mul - IL_0030: add - IL_0031: ldc.i4.3 - IL_0032: stind.i4 - IL_0033: ldc.i4.3 - IL_0034: newobj ""System.Span..ctor(void*, int)"" - IL_0039: stloc.3 - IL_003a: ldloc.1 - IL_003b: ldloca.s V_3 - IL_003d: call ""int System.Span.Length.get"" - IL_0042: mul - IL_0043: call ""void System.Console.WriteLine(int)"" - IL_0048: nop - IL_0049: ret -}"); + { + // Code size 74 (0x4a) + .maxstack 4 + .locals init (int V_0, //z + int V_1, + System.Span V_2, + System.Span V_3) + IL_0000: nop + IL_0001: ldc.i4.2 + IL_0002: stloc.0 + IL_0003: ldloc.0 + IL_0004: stloc.1 + IL_0005: ldc.i4.8 + IL_0006: conv.u + IL_0007: localloc + IL_0009: dup + IL_000a: ldc.i4.4 + IL_000b: stind.i4 + IL_000c: dup + IL_000d: ldc.i4.4 + IL_000e: add + IL_000f: ldc.i4.5 + IL_0010: stind.i4 + IL_0011: ldc.i4.2 + IL_0012: newobj ""System.Span..ctor(void*, int)"" + IL_0017: stloc.3 + IL_0018: ldc.i4.s 12 + IL_001a: conv.u + IL_001b: localloc + IL_001d: dup + IL_001e: ldc.i4.1 + IL_001f: stind.i4 + IL_0020: dup + IL_0021: ldc.i4.4 + IL_0022: add + IL_0023: ldloca.s V_3 + IL_0025: call ""int System.Span.Length.get"" + IL_002a: stind.i4 + IL_002b: dup + IL_002c: ldc.i4.2 + IL_002d: conv.i + IL_002e: ldc.i4.4 + IL_002f: mul + IL_0030: add + IL_0031: ldc.i4.3 + IL_0032: stind.i4 + IL_0033: ldc.i4.3 + IL_0034: newobj ""System.Span..ctor(void*, int)"" + IL_0039: stloc.2 + IL_003a: ldloc.1 + IL_003b: ldloca.s V_2 + IL_003d: call ""int System.Span.Length.get"" + IL_0042: mul + IL_0043: call ""void System.Console.WriteLine(int)"" + IL_0048: nop + IL_0049: ret + } +"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs index 012c38d23ef..28e093ece68 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/PatternTests.cs @@ -3165,48 +3165,45 @@ public static void Main() } "; var v = CompileAndVerify(source, options: TestOptions.DebugExe); - v.VerifyIL(qualifiedMethodName: "Program.Main", -@"{ - // Code size 55 (0x37) - .maxstack 2 - .locals init (int V_0, //i - Program V_1, //y - Program V_2, - Program V_3) - // sequence point: { - IL_0000: nop - // sequence point: int i = 0; - IL_0001: ldc.i4.0 - IL_0002: stloc.0 - // sequence point: var y = (i s ... }).Chain() - IL_0003: ldloc.0 - IL_0004: brfalse.s IL_000e - IL_0006: br.s IL_0008 - IL_0008: ldloc.0 - IL_0009: ldc.i4.1 - IL_000a: beq.s IL_0016 - IL_000c: br.s IL_001e - IL_000e: newobj ""Program..ctor()"" - IL_0013: stloc.2 - IL_0014: br.s IL_0026 - IL_0016: newobj ""Program..ctor()"" - IL_001b: stloc.2 - IL_001c: br.s IL_0026 - IL_001e: newobj ""Program..ctor()"" - IL_0023: stloc.2 - IL_0024: br.s IL_0026 - IL_0026: ldloc.2 - IL_0027: stloc.3 - IL_0028: ldloc.3 - IL_0029: callvirt ""Program Program.Chain()"" - IL_002e: stloc.1 - // sequence point: y.Chain2(); - IL_002f: ldloc.1 - IL_0030: callvirt ""Program Program.Chain2()"" - IL_0035: pop - // sequence point: } - IL_0036: ret -} + v.VerifyIL(qualifiedMethodName: "Program.Main", @" + { + // Code size 53 (0x35) + .maxstack 2 + .locals init (int V_0, //i + Program V_1, //y + Program V_2) + // sequence point: { + IL_0000: nop + // sequence point: int i = 0; + IL_0001: ldc.i4.0 + IL_0002: stloc.0 + // sequence point: var y = (i s ... }).Chain() + IL_0003: ldloc.0 + IL_0004: brfalse.s IL_000e + IL_0006: br.s IL_0008 + IL_0008: ldloc.0 + IL_0009: ldc.i4.1 + IL_000a: beq.s IL_0016 + IL_000c: br.s IL_001e + IL_000e: newobj ""Program..ctor()"" + IL_0013: stloc.2 + IL_0014: br.s IL_0026 + IL_0016: newobj ""Program..ctor()"" + IL_001b: stloc.2 + IL_001c: br.s IL_0026 + IL_001e: newobj ""Program..ctor()"" + IL_0023: stloc.2 + IL_0024: br.s IL_0026 + IL_0026: ldloc.2 + IL_0027: callvirt ""Program Program.Chain()"" + IL_002c: stloc.1 + // sequence point: y.Chain2(); + IL_002d: ldloc.1 + IL_002e: callvirt ""Program Program.Chain2()"" + IL_0033: pop + // sequence point: } + IL_0034: ret + } ", sequencePoints: "Program.Main", source: source); } @@ -3236,39 +3233,37 @@ static bool M(object o) var compVerifier = CompileAndVerify(compilation, expectedOutput: expectedOutput); if (options.OptimizationLevel == OptimizationLevel.Debug) { - compVerifier.VerifyIL("Class1.M", -@"{ - // Code size 39 (0x27) - .maxstack 2 - .locals init (bool V_0, - int V_1, - bool V_2, - bool V_3) - IL_0000: nop - IL_0001: ldarg.0 - IL_0002: isinst ""int"" - IL_0007: brfalse.s IL_001b - IL_0009: ldarg.0 - IL_000a: unbox.any ""int"" - IL_000f: stloc.1 - IL_0010: ldloc.1 - IL_0011: ldc.i4.s 42 - IL_0013: beq.s IL_0017 - IL_0015: br.s IL_001b - IL_0017: ldc.i4.1 - IL_0018: stloc.0 - IL_0019: br.s IL_001f - IL_001b: ldc.i4.0 - IL_001c: stloc.0 - IL_001d: br.s IL_001f - IL_001f: ldloc.0 - IL_0020: stloc.2 - IL_0021: ldloc.2 - IL_0022: stloc.3 - IL_0023: br.s IL_0025 - IL_0025: ldloc.3 - IL_0026: ret -}"); + compVerifier.VerifyIL("Class1.M", @" +{ + // Code size 37 (0x25) + .maxstack 2 + .locals init (bool V_0, + int V_1, + bool V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: isinst ""int"" + IL_0007: brfalse.s IL_001b + IL_0009: ldarg.0 + IL_000a: unbox.any ""int"" + IL_000f: stloc.1 + IL_0010: ldloc.1 + IL_0011: ldc.i4.s 42 + IL_0013: beq.s IL_0017 + IL_0015: br.s IL_001b + IL_0017: ldc.i4.1 + IL_0018: stloc.0 + IL_0019: br.s IL_001f + IL_001b: ldc.i4.0 + IL_001c: stloc.0 + IL_001d: br.s IL_001f + IL_001f: ldloc.0 + IL_0020: stloc.2 + IL_0021: br.s IL_0023 + IL_0023: ldloc.2 + IL_0024: ret + } +"); } else { diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs index b859e3dd25c..941feacfd48 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/LocalSlotMappingTests.cs @@ -4052,46 +4052,42 @@ static object G(object o1, object o2) ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); diff1.VerifyIL("C.G", @" -{ - // Code size 58 (0x3a) - .maxstack 1 - .locals init (int V_0, //a - string V_1, //b - [int] V_2, - [int] V_3, - [object] V_4, - int V_5, - int V_6, - object V_7) - -IL_0000: nop - -IL_0001: ldarg.0 - IL_0002: isinst ""int"" - IL_0007: brfalse.s IL_0023 - IL_0009: ldarg.0 - IL_000a: unbox.any ""int"" - IL_000f: stloc.0 - IL_0010: ldarg.1 - IL_0011: isinst ""string"" - IL_0016: stloc.1 - IL_0017: ldloc.1 - IL_0018: brtrue.s IL_001c - IL_001a: br.s IL_0023 - IL_001c: br.s IL_001e - IL_001e: ldloc.0 - IL_001f: stloc.s V_5 - IL_0021: br.s IL_0028 - IL_0023: ldc.i4.0 - IL_0024: stloc.s V_5 - IL_0026: br.s IL_0028 - IL_0028: ldloc.s V_5 - IL_002a: stloc.s V_6 - IL_002c: ldloc.s V_6 - IL_002e: box ""int"" - IL_0033: stloc.s V_7 - IL_0035: br.s IL_0037 - -IL_0037: ldloc.s V_7 - IL_0039: ret -} + { + // Code size 54 (0x36) + .maxstack 1 + .locals init (int V_0, //a + string V_1, //b + [int] V_2, + [object] V_3, + int V_4, + object V_5) + -IL_0000: nop + -IL_0001: ldarg.0 + IL_0002: isinst ""int"" + IL_0007: brfalse.s IL_0023 + IL_0009: ldarg.0 + IL_000a: unbox.any ""int"" + IL_000f: stloc.0 + IL_0010: ldarg.1 + IL_0011: isinst ""string"" + IL_0016: stloc.1 + IL_0017: ldloc.1 + IL_0018: brtrue.s IL_001c + IL_001a: br.s IL_0023 + IL_001c: br.s IL_001e + IL_001e: ldloc.0 + IL_001f: stloc.s V_4 + IL_0021: br.s IL_0028 + IL_0023: ldc.i4.0 + IL_0024: stloc.s V_4 + IL_0026: br.s IL_0028 + IL_0028: ldloc.s V_4 + IL_002a: box ""int"" + IL_002f: stloc.s V_5 + IL_0031: br.s IL_0033 + -IL_0033: ldloc.s V_5 + IL_0035: ret + } ", methodToken: diff1.UpdatedMethods.Single()); } @@ -4130,55 +4126,47 @@ static object G(object o) ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); diff1.VerifyIL("C.G", @" -{ - // Code size 68 (0x44) - .maxstack 1 - .locals init (int V_0, //i - [int] V_1, - [int] V_2, - [int] V_3, - [int] V_4, - [object] V_5, - int V_6, - int V_7, - int V_8, - int V_9, - object V_10) - -IL_0000: nop - -IL_0001: ldarg.0 - IL_0002: isinst ""int"" - IL_0007: brfalse.s IL_002d - IL_0009: ldarg.0 - IL_000a: unbox.any ""int"" - IL_000f: stloc.0 - IL_0010: br.s IL_0012 - IL_0012: br.s IL_0014 - IL_0014: ldloc.0 - IL_0015: brfalse.s IL_0019 - IL_0017: br.s IL_001e - IL_0019: ldc.i4.1 - IL_001a: stloc.s V_8 - IL_001c: br.s IL_0023 - IL_001e: ldc.i4.2 - IL_001f: stloc.s V_8 - IL_0021: br.s IL_0023 - IL_0023: ldloc.s V_8 - IL_0025: stloc.s V_9 - IL_0027: ldloc.s V_9 - IL_0029: stloc.s V_6 - IL_002b: br.s IL_0032 - IL_002d: ldc.i4.3 - IL_002e: stloc.s V_6 - IL_0030: br.s IL_0032 - IL_0032: ldloc.s V_6 - IL_0034: stloc.s V_7 - IL_0036: ldloc.s V_7 - IL_0038: box ""int"" - IL_003d: stloc.s V_10 - IL_003f: br.s IL_0041 - -IL_0041: ldloc.s V_10 - IL_0043: ret -} + { + // Code size 60 (0x3c) + .maxstack 1 + .locals init (int V_0, //i + [int] V_1, + [int] V_2, + [object] V_3, + int V_4, + int V_5, + object V_6) + -IL_0000: nop + -IL_0001: ldarg.0 + IL_0002: isinst ""int"" + IL_0007: brfalse.s IL_0029 + IL_0009: ldarg.0 + IL_000a: unbox.any ""int"" + IL_000f: stloc.0 + IL_0010: br.s IL_0012 + IL_0012: br.s IL_0014 + IL_0014: ldloc.0 + IL_0015: brfalse.s IL_0019 + IL_0017: br.s IL_001e + IL_0019: ldc.i4.1 + IL_001a: stloc.s V_5 + IL_001c: br.s IL_0023 + IL_001e: ldc.i4.2 + IL_001f: stloc.s V_5 + IL_0021: br.s IL_0023 + IL_0023: ldloc.s V_5 + IL_0025: stloc.s V_4 + IL_0027: br.s IL_002e + IL_0029: ldc.i4.3 + IL_002a: stloc.s V_4 + IL_002c: br.s IL_002e + IL_002e: ldloc.s V_4 + IL_0030: box ""int"" + IL_0035: stloc.s V_6 + IL_0037: br.s IL_0039 + -IL_0039: ldloc.s V_6 + IL_003b: ret + } ", methodToken: diff1.UpdatedMethods.Single()); } @@ -4345,56 +4333,48 @@ static object G() ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, method0, method1, GetEquivalentNodesMap(method1, method0), preserveLocalVariables: true))); diff1.VerifyIL("C.G", @" -{ - // Code size 65 (0x41) - .maxstack 2 - .locals init (int V_0, //x - [int] V_1, - [object] V_2, - [int] V_3, - [int] V_4, - [int] V_5, - [object] V_6, - int V_7, - object V_8, - int V_9, - int V_10, - int V_11, - object V_12) - -IL_0000: nop - -IL_0001: ldloca.s V_0 - IL_0003: call ""object C.N(out int)"" - IL_0008: stloc.s V_8 - IL_000a: ldloc.s V_8 - IL_000c: brfalse.s IL_0010 - IL_000e: br.s IL_002a - IL_0010: ldloc.0 - IL_0011: ldc.i4.1 - IL_0012: beq.s IL_0016 - IL_0014: br.s IL_001b - IL_0016: ldc.i4.1 - IL_0017: stloc.s V_10 - IL_0019: br.s IL_0020 - IL_001b: ldc.i4.2 - IL_001c: stloc.s V_10 - IL_001e: br.s IL_0020 - IL_0020: ldloc.s V_10 - IL_0022: stloc.s V_11 - IL_0024: ldloc.s V_11 - IL_0026: stloc.s V_7 - IL_0028: br.s IL_002f - IL_002a: ldc.i4.1 - IL_002b: stloc.s V_7 - IL_002d: br.s IL_002f - IL_002f: ldloc.s V_7 - IL_0031: stloc.s V_9 - IL_0033: ldloc.s V_9 - IL_0035: box ""int"" - IL_003a: stloc.s V_12 - IL_003c: br.s IL_003e - -IL_003e: ldloc.s V_12 - IL_0040: ret -} + { + // Code size 57 (0x39) + .maxstack 2 + .locals init (int V_0, //x + [int] V_1, + [object] V_2, + [int] V_3, + [object] V_4, + int V_5, + object V_6, + int V_7, + object V_8) + -IL_0000: nop + -IL_0001: ldloca.s V_0 + IL_0003: call ""object C.N(out int)"" + IL_0008: stloc.s V_6 + IL_000a: ldloc.s V_6 + IL_000c: brfalse.s IL_0010 + IL_000e: br.s IL_0026 + IL_0010: ldloc.0 + IL_0011: ldc.i4.1 + IL_0012: beq.s IL_0016 + IL_0014: br.s IL_001b + IL_0016: ldc.i4.1 + IL_0017: stloc.s V_7 + IL_0019: br.s IL_0020 + IL_001b: ldc.i4.2 + IL_001c: stloc.s V_7 + IL_001e: br.s IL_0020 + IL_0020: ldloc.s V_7 + IL_0022: stloc.s V_5 + IL_0024: br.s IL_002b + IL_0026: ldc.i4.1 + IL_0027: stloc.s V_5 + IL_0029: br.s IL_002b + IL_002b: ldloc.s V_5 + IL_002d: box ""int"" + IL_0032: stloc.s V_8 + IL_0034: br.s IL_0036 + -IL_0036: ldloc.s V_8 + IL_0038: ret + } ", methodToken: diff1.UpdatedMethods.Single()); } diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs index 83c4917739e..d85fa1b64b0 100644 --- a/src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs +++ b/src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs @@ -8245,273 +8245,269 @@ static void Main() // note no sequence points emitted within the switch expression verifier.VerifyIL("Program.Main", sequencePoints: "Program.Main", expectedIL: @" -{ - // Code size 454 (0x1c6) - .maxstack 3 - .locals init (int V_0, //a - int V_1, //x - object V_2, //y - object V_3, //z - int V_4, //p - int V_5, //q - int V_6, //p - int V_7, //z - int V_8, - object V_9, - System.Runtime.CompilerServices.ITuple V_10, - int V_11, - D V_12, - double V_13, - C V_14, - object V_15, - C V_16, - int V_17, - D V_18, - int V_19, - C V_20, - int V_21) - -IL_0000: nop - -IL_0001: call ""object Program.F()"" - IL_0006: stloc.s V_9 - IL_0008: ldloc.s V_9 - IL_000a: isinst ""int"" - IL_000f: brfalse.s IL_001e - IL_0011: ldloc.s V_9 - IL_0013: unbox.any ""int"" - IL_0018: stloc.1 - IL_0019: br IL_015e - IL_001e: ldloc.s V_9 - IL_0020: isinst ""bool"" - IL_0025: brtrue IL_016f - IL_002a: ldloc.s V_9 - IL_002c: isinst ""System.Runtime.CompilerServices.ITuple"" - IL_0031: stloc.s V_10 - IL_0033: ldloc.s V_10 - IL_0035: brfalse.s IL_008f - IL_0037: ldloc.s V_10 - IL_0039: callvirt ""int System.Runtime.CompilerServices.ITuple.Length.get"" - IL_003e: stloc.s V_11 - IL_0040: ldloc.s V_11 - IL_0042: ldc.i4.2 - IL_0043: bne.un.s IL_005c - IL_0045: ldloc.s V_10 - IL_0047: ldc.i4.0 - IL_0048: callvirt ""object System.Runtime.CompilerServices.ITuple.this[int].get"" - IL_004d: stloc.2 - IL_004e: ldloc.s V_10 - IL_0050: ldc.i4.1 - IL_0051: callvirt ""object System.Runtime.CompilerServices.ITuple.this[int].get"" - IL_0056: stloc.3 - IL_0057: br IL_0174 - IL_005c: ldloc.s V_9 - IL_005e: isinst ""C"" - IL_0063: brtrue IL_0180 - IL_0068: br.s IL_0073 - IL_006a: ldloc.s V_11 - IL_006c: brfalse IL_019d - IL_0071: br.s IL_00c4 - IL_0073: ldloc.s V_11 - IL_0075: brfalse IL_019d - IL_007a: ldloc.s V_9 - IL_007c: isinst ""D"" - IL_0081: stloc.s V_12 - IL_0083: ldloc.s V_12 - IL_0085: brtrue IL_0116 - IL_008a: br IL_01b8 - IL_008f: ldloc.s V_9 - IL_0091: isinst ""double"" - IL_0096: brfalse.s IL_00b6 - IL_0098: ldloc.s V_9 - IL_009a: unbox.any ""double"" - IL_009f: stloc.s V_13 - IL_00a1: ldloc.s V_13 - IL_00a3: ldc.r8 4 - IL_00ac: beq IL_017b - IL_00b1: br IL_01b8 - IL_00b6: ldloc.s V_9 - IL_00b8: isinst ""C"" - IL_00bd: brtrue IL_018c - IL_00c2: br.s IL_0104 - IL_00c4: ldloc.s V_9 - IL_00c6: castclass ""C"" - IL_00cb: stloc.s V_14 - IL_00cd: ldloc.s V_14 - IL_00cf: ldloca.s V_4 - IL_00d1: ldloca.s V_15 - IL_00d3: callvirt ""void C.Deconstruct(out int, out object)"" - IL_00d8: nop - IL_00d9: ldloc.s V_15 - IL_00db: isinst ""C"" - IL_00e0: stloc.s V_16 - IL_00e2: ldloc.s V_16 - IL_00e4: brfalse.s IL_00f5 - IL_00e6: ldloc.s V_16 - IL_00e8: ldloca.s V_5 - IL_00ea: callvirt ""void C.Deconstruct(out int)"" - IL_00ef: nop - IL_00f0: br IL_01a2 - IL_00f5: ldloc.s V_14 - IL_00f7: ldloca.s V_6 - IL_00f9: callvirt ""void C.Deconstruct(out int)"" - IL_00fe: nop - IL_00ff: br IL_01a9 - IL_0104: ldloc.s V_9 - IL_0106: isinst ""D"" - IL_010b: stloc.s V_12 - IL_010d: ldloc.s V_12 - IL_010f: brtrue.s IL_0116 - IL_0111: br IL_01b8 - IL_0116: ldloc.s V_12 - IL_0118: callvirt ""int D.P.get"" - IL_011d: stloc.s V_17 - IL_011f: ldloc.s V_17 - IL_0121: ldc.i4.1 - IL_0122: bne.un IL_01b8 - IL_0127: ldloc.s V_12 - IL_0129: callvirt ""D D.Q.get"" - IL_012e: stloc.s V_18 - IL_0130: ldloc.s V_18 - IL_0132: brfalse IL_01b8 - IL_0137: ldloc.s V_18 - IL_0139: callvirt ""int D.P.get"" - IL_013e: stloc.s V_19 - IL_0140: ldloc.s V_19 - IL_0142: ldc.i4.2 - IL_0143: bne.un.s IL_01b8 - IL_0145: ldloc.s V_12 - IL_0147: callvirt ""C D.R.get"" - IL_014c: stloc.s V_20 - IL_014e: ldloc.s V_20 - IL_0150: brfalse.s IL_01b8 - IL_0152: ldloc.s V_20 - IL_0154: ldloca.s V_7 - IL_0156: callvirt ""void C.Deconstruct(out int)"" - IL_015b: nop - IL_015c: br.s IL_01b0 - IL_015e: ldloc.1 - IL_015f: call ""int Program.G(int)"" - IL_0164: ldc.i4.s 10 - IL_0166: bgt.s IL_016a - IL_0168: br.s IL_01b8 - IL_016a: ldc.i4.1 - IL_016b: stloc.s V_8 - IL_016d: br.s IL_01be - IL_016f: ldc.i4.2 - IL_0170: stloc.s V_8 - IL_0172: br.s IL_01be - IL_0174: br.s IL_0176 - IL_0176: ldc.i4.3 - IL_0177: stloc.s V_8 - IL_0179: br.s IL_01be - IL_017b: ldc.i4.4 - IL_017c: stloc.s V_8 - IL_017e: br.s IL_01be - IL_0180: call ""bool Program.B()"" - IL_0185: brtrue.s IL_0198 - IL_0187: br IL_006a - IL_018c: call ""bool Program.B()"" - IL_0191: brtrue.s IL_0198 - IL_0193: br IL_00c4 - IL_0198: ldc.i4.5 - IL_0199: stloc.s V_8 - IL_019b: br.s IL_01be - IL_019d: ldc.i4.6 - IL_019e: stloc.s V_8 - IL_01a0: br.s IL_01be - IL_01a2: br.s IL_01a4 - IL_01a4: ldc.i4.7 - IL_01a5: stloc.s V_8 - IL_01a7: br.s IL_01be - IL_01a9: br.s IL_01ab - IL_01ab: ldc.i4.8 - IL_01ac: stloc.s V_8 - IL_01ae: br.s IL_01be - IL_01b0: br.s IL_01b2 - IL_01b2: ldc.i4.s 9 - IL_01b4: stloc.s V_8 - IL_01b6: br.s IL_01be - IL_01b8: ldc.i4.s 10 - IL_01ba: stloc.s V_8 - IL_01bc: br.s IL_01be - IL_01be: ldloc.s V_8 - IL_01c0: stloc.s V_21 - IL_01c2: ldloc.s V_21 - IL_01c4: stloc.0 - -IL_01c5: ret -} + { + // Code size 450 (0x1c2) + .maxstack 3 + .locals init (int V_0, //a + int V_1, //x + object V_2, //y + object V_3, //z + int V_4, //p + int V_5, //q + int V_6, //p + int V_7, //z + int V_8, + object V_9, + System.Runtime.CompilerServices.ITuple V_10, + int V_11, + D V_12, + double V_13, + C V_14, + object V_15, + C V_16, + int V_17, + D V_18, + int V_19, + C V_20) + -IL_0000: nop + -IL_0001: call ""object Program.F()"" + IL_0006: stloc.s V_9 + IL_0008: ldloc.s V_9 + IL_000a: isinst ""int"" + IL_000f: brfalse.s IL_001e + IL_0011: ldloc.s V_9 + IL_0013: unbox.any ""int"" + IL_0018: stloc.1 + IL_0019: br IL_015e + IL_001e: ldloc.s V_9 + IL_0020: isinst ""bool"" + IL_0025: brtrue IL_016f + IL_002a: ldloc.s V_9 + IL_002c: isinst ""System.Runtime.CompilerServices.ITuple"" + IL_0031: stloc.s V_10 + IL_0033: ldloc.s V_10 + IL_0035: brfalse.s IL_008f + IL_0037: ldloc.s V_10 + IL_0039: callvirt ""int System.Runtime.CompilerServices.ITuple.Length.get"" + IL_003e: stloc.s V_11 + IL_0040: ldloc.s V_11 + IL_0042: ldc.i4.2 + IL_0043: bne.un.s IL_005c + IL_0045: ldloc.s V_10 + IL_0047: ldc.i4.0 + IL_0048: callvirt ""object System.Runtime.CompilerServices.ITuple.this[int].get"" + IL_004d: stloc.2 + IL_004e: ldloc.s V_10 + IL_0050: ldc.i4.1 + IL_0051: callvirt ""object System.Runtime.CompilerServices.ITuple.this[int].get"" + IL_0056: stloc.3 + IL_0057: br IL_0174 + IL_005c: ldloc.s V_9 + IL_005e: isinst ""C"" + IL_0063: brtrue IL_0180 + IL_0068: br.s IL_0073 + IL_006a: ldloc.s V_11 + IL_006c: brfalse IL_019d + IL_0071: br.s IL_00c4 + IL_0073: ldloc.s V_11 + IL_0075: brfalse IL_019d + IL_007a: ldloc.s V_9 + IL_007c: isinst ""D"" + IL_0081: stloc.s V_12 + IL_0083: ldloc.s V_12 + IL_0085: brtrue IL_0116 + IL_008a: br IL_01b8 + IL_008f: ldloc.s V_9 + IL_0091: isinst ""double"" + IL_0096: brfalse.s IL_00b6 + IL_0098: ldloc.s V_9 + IL_009a: unbox.any ""double"" + IL_009f: stloc.s V_13 + IL_00a1: ldloc.s V_13 + IL_00a3: ldc.r8 4 + IL_00ac: beq IL_017b + IL_00b1: br IL_01b8 + IL_00b6: ldloc.s V_9 + IL_00b8: isinst ""C"" + IL_00bd: brtrue IL_018c + IL_00c2: br.s IL_0104 + IL_00c4: ldloc.s V_9 + IL_00c6: castclass ""C"" + IL_00cb: stloc.s V_14 + IL_00cd: ldloc.s V_14 + IL_00cf: ldloca.s V_4 + IL_00d1: ldloca.s V_15 + IL_00d3: callvirt ""void C.Deconstruct(out int, out object)"" + IL_00d8: nop + IL_00d9: ldloc.s V_15 + IL_00db: isinst ""C"" + IL_00e0: stloc.s V_16 + IL_00e2: ldloc.s V_16 + IL_00e4: brfalse.s IL_00f5 + IL_00e6: ldloc.s V_16 + IL_00e8: ldloca.s V_5 + IL_00ea: callvirt ""void C.Deconstruct(out int)"" + IL_00ef: nop + IL_00f0: br IL_01a2 + IL_00f5: ldloc.s V_14 + IL_00f7: ldloca.s V_6 + IL_00f9: callvirt ""void C.Deconstruct(out int)"" + IL_00fe: nop + IL_00ff: br IL_01a9 + IL_0104: ldloc.s V_9 + IL_0106: isinst ""D"" + IL_010b: stloc.s V_12 + IL_010d: ldloc.s V_12 + IL_010f: brtrue.s IL_0116 + IL_0111: br IL_01b8 + IL_0116: ldloc.s V_12 + IL_0118: callvirt ""int D.P.get"" + IL_011d: stloc.s V_17 + IL_011f: ldloc.s V_17 + IL_0121: ldc.i4.1 + IL_0122: bne.un IL_01b8 + IL_0127: ldloc.s V_12 + IL_0129: callvirt ""D D.Q.get"" + IL_012e: stloc.s V_18 + IL_0130: ldloc.s V_18 + IL_0132: brfalse IL_01b8 + IL_0137: ldloc.s V_18 + IL_0139: callvirt ""int D.P.get"" + IL_013e: stloc.s V_19 + IL_0140: ldloc.s V_19 + IL_0142: ldc.i4.2 + IL_0143: bne.un.s IL_01b8 + IL_0145: ldloc.s V_12 + IL_0147: callvirt ""C D.R.get"" + IL_014c: stloc.s V_20 + IL_014e: ldloc.s V_20 + IL_0150: brfalse.s IL_01b8 + IL_0152: ldloc.s V_20 + IL_0154: ldloca.s V_7 + IL_0156: callvirt ""void C.Deconstruct(out int)"" + IL_015b: nop + IL_015c: br.s IL_01b0 + IL_015e: ldloc.1 + IL_015f: call ""int Program.G(int)"" + IL_0164: ldc.i4.s 10 + IL_0166: bgt.s IL_016a + IL_0168: br.s IL_01b8 + IL_016a: ldc.i4.1 + IL_016b: stloc.s V_8 + IL_016d: br.s IL_01be + IL_016f: ldc.i4.2 + IL_0170: stloc.s V_8 + IL_0172: br.s IL_01be + IL_0174: br.s IL_0176 + IL_0176: ldc.i4.3 + IL_0177: stloc.s V_8 + IL_0179: br.s IL_01be + IL_017b: ldc.i4.4 + IL_017c: stloc.s V_8 + IL_017e: br.s IL_01be + IL_0180: call ""bool Program.B()"" + IL_0185: brtrue.s IL_0198 + IL_0187: br IL_006a + IL_018c: call ""bool Program.B()"" + IL_0191: brtrue.s IL_0198 + IL_0193: br IL_00c4 + IL_0198: ldc.i4.5 + IL_0199: stloc.s V_8 + IL_019b: br.s IL_01be + IL_019d: ldc.i4.6 + IL_019e: stloc.s V_8 + IL_01a0: br.s IL_01be + IL_01a2: br.s IL_01a4 + IL_01a4: ldc.i4.7 + IL_01a5: stloc.s V_8 + IL_01a7: br.s IL_01be + IL_01a9: br.s IL_01ab + IL_01ab: ldc.i4.8 + IL_01ac: stloc.s V_8 + IL_01ae: br.s IL_01be + IL_01b0: br.s IL_01b2 + IL_01b2: ldc.i4.s 9 + IL_01b4: stloc.s V_8 + IL_01b6: br.s IL_01be + IL_01b8: ldc.i4.s 10 + IL_01ba: stloc.s V_8 + IL_01bc: br.s IL_01be + IL_01be: ldloc.s V_8 + IL_01c0: stloc.0 + -IL_01c1: ret + } "); verifier.VerifyPdb("Program.Main", @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + "); } @@ -8806,267 +8802,252 @@ static int M() // The values of the closure offsets are incorrect. verifier.VerifyIL("C.M", sequencePoints: "C.M", expectedIL: @" -{ - // Code size 459 (0x1cb) - .maxstack 2 - .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 - int V_1, - int V_2, - C.<>c__DisplayClass0_1 V_3, //CS$<>8__locals1 - int V_4, - object V_5, - int V_6, - C V_7, - object V_8, - int V_9, - C.<>c__DisplayClass0_2 V_10, //CS$<>8__locals2 - int V_11, - object V_12, - C V_13, - object V_14, - object V_15, - C V_16, - object V_17, - int V_18, - C.<>c__DisplayClass0_3 V_19, //CS$<>8__locals3 - int V_20, - int V_21) - -IL_0000: nop - ~IL_0001: newobj ""C.<>c__DisplayClass0_0..ctor()"" - IL_0006: stloc.0 - ~IL_0007: newobj ""C.<>c__DisplayClass0_1..ctor()"" - IL_000c: stloc.3 - IL_000d: call ""object C.F()"" - IL_0012: stloc.s V_5 - IL_0014: ldloc.s V_5 - IL_0016: isinst ""int"" - IL_001b: brfalse.s IL_003a - IL_001d: ldloc.s V_5 - IL_001f: unbox.any ""int"" - IL_0024: stloc.s V_6 - IL_0026: ldloc.s V_6 - IL_0028: ldc.i4.1 - IL_0029: beq.s IL_0071 - IL_002b: br.s IL_002d - IL_002d: ldloc.s V_6 - IL_002f: ldc.i4.2 - IL_0030: beq IL_010f - IL_0035: br IL_018b - IL_003a: ldloc.s V_5 - IL_003c: isinst ""C"" - IL_0041: stloc.s V_7 - IL_0043: ldloc.s V_7 - IL_0045: brfalse IL_018b - IL_004a: ldloc.s V_7 - IL_004c: callvirt ""object C.Q.get"" - IL_0051: stloc.s V_8 - IL_0053: ldloc.s V_8 - IL_0055: isinst ""int"" - IL_005a: brfalse IL_018b - IL_005f: ldloc.3 - IL_0060: ldloc.s V_8 - IL_0062: unbox.any ""int"" - IL_0067: stfld ""int C.<>c__DisplayClass0_1.5__3"" - IL_006c: br IL_0174 - ~IL_0071: newobj ""C.<>c__DisplayClass0_2..ctor()"" - IL_0076: stloc.s V_10 - IL_0078: call ""object C.F()"" - IL_007d: stloc.s V_12 - IL_007f: ldloc.s V_12 - IL_0081: isinst ""C"" - IL_0086: stloc.s V_13 - IL_0088: ldloc.s V_13 - IL_008a: brfalse.s IL_00fc - IL_008c: ldloc.s V_13 - IL_008e: callvirt ""object C.P.get"" - IL_0093: stloc.s V_14 - IL_0095: ldloc.s V_14 - IL_0097: isinst ""int"" - IL_009c: brfalse.s IL_00fc - IL_009e: ldloc.s V_10 - IL_00a0: ldloc.s V_14 - IL_00a2: unbox.any ""int"" - IL_00a7: stfld ""int C.<>c__DisplayClass0_2.

5__4"" - IL_00ac: ldloc.s V_13 - IL_00ae: callvirt ""object C.Q.get"" - IL_00b3: stloc.s V_15 - IL_00b5: ldloc.s V_15 - IL_00b7: isinst ""C"" - IL_00bc: stloc.s V_16 - IL_00be: ldloc.s V_16 - IL_00c0: brfalse.s IL_00fc - IL_00c2: ldloc.s V_16 - IL_00c4: callvirt ""object C.P.get"" - IL_00c9: stloc.s V_17 - IL_00cb: ldloc.s V_17 - IL_00cd: isinst ""int"" - IL_00d2: brfalse.s IL_00fc - IL_00d4: ldloc.s V_10 - IL_00d6: ldloc.s V_17 - IL_00d8: unbox.any ""int"" - IL_00dd: stfld ""int C.<>c__DisplayClass0_2.5__5"" - IL_00e2: br.s IL_00e4 - IL_00e4: br.s IL_00e6 - IL_00e6: ldloc.s V_10 - IL_00e8: ldftn ""int C.<>c__DisplayClass0_2.b__2()"" - IL_00ee: newobj ""System.Func..ctor(object, System.IntPtr)"" - IL_00f3: call ""int C.G(System.Func)"" - IL_00f8: stloc.s V_11 - IL_00fa: br.s IL_0102 - IL_00fc: ldc.i4.s 10 - IL_00fe: stloc.s V_11 - IL_0100: br.s IL_0102 - IL_0102: ldloc.s V_11 - IL_0104: stloc.s V_18 - IL_0106: ldloc.s V_18 - IL_0108: stloc.s V_4 - IL_010a: br IL_0190 - ~IL_010f: newobj ""C.<>c__DisplayClass0_3..ctor()"" - IL_0114: stloc.s V_19 - IL_0116: call ""object C.F()"" - IL_011b: stloc.s V_17 - IL_011d: ldloc.s V_17 - IL_011f: isinst ""C"" - IL_0124: stloc.s V_16 - IL_0126: ldloc.s V_16 - IL_0128: brfalse.s IL_0164 - IL_012a: ldloc.s V_16 - IL_012c: callvirt ""object C.P.get"" - IL_0131: stloc.s V_15 - IL_0133: ldloc.s V_15 - IL_0135: isinst ""int"" - IL_013a: brfalse.s IL_0164 - IL_013c: ldloc.s V_19 - IL_013e: ldloc.s V_15 - IL_0140: unbox.any ""int"" - IL_0145: stfld ""int C.<>c__DisplayClass0_3.5__6"" - IL_014a: br.s IL_014c - IL_014c: br.s IL_014e - IL_014e: ldloc.s V_19 - IL_0150: ldftn ""int C.<>c__DisplayClass0_3.b__3()"" - IL_0156: newobj ""System.Func..ctor(object, System.IntPtr)"" - IL_015b: call ""int C.G(System.Func)"" - IL_0160: stloc.s V_11 - IL_0162: br.s IL_016a - IL_0164: ldc.i4.s 20 - IL_0166: stloc.s V_11 - IL_0168: br.s IL_016a - IL_016a: ldloc.s V_11 - IL_016c: stloc.s V_20 - IL_016e: ldloc.s V_20 - IL_0170: stloc.s V_4 - IL_0172: br.s IL_0190 - IL_0174: br.s IL_0176 - IL_0176: ldloc.3 - IL_0177: ldftn ""int C.<>c__DisplayClass0_1.b__1()"" - IL_017d: newobj ""System.Func..ctor(object, System.IntPtr)"" - IL_0182: call ""int C.G(System.Func)"" - IL_0187: stloc.s V_4 - IL_0189: br.s IL_0190 - IL_018b: ldc.i4.0 - IL_018c: stloc.s V_4 - IL_018e: br.s IL_0190 - IL_0190: ldloc.s V_4 - IL_0192: stloc.s V_9 - IL_0194: ldloc.0 - IL_0195: ldloc.s V_9 - IL_0197: stfld ""int C.<>c__DisplayClass0_0.5__2"" - IL_019c: br.s IL_019e - IL_019e: ldloc.0 - IL_019f: ldfld ""int C.<>c__DisplayClass0_0.5__2"" - IL_01a4: ldc.i4.0 - IL_01a5: bgt.s IL_01a9 - IL_01a7: br.s IL_01bd - IL_01a9: ldloc.0 - IL_01aa: ldftn ""int C.<>c__DisplayClass0_0.b__0()"" - IL_01b0: newobj ""System.Func..ctor(object, System.IntPtr)"" - IL_01b5: call ""int C.G(System.Func)"" - IL_01ba: stloc.1 - IL_01bb: br.s IL_01c1 - IL_01bd: ldc.i4.0 - IL_01be: stloc.1 - IL_01bf: br.s IL_01c1 - IL_01c1: ldloc.1 - IL_01c2: stloc.2 - IL_01c3: ldloc.2 - IL_01c4: stloc.s V_21 - IL_01c6: br.s IL_01c8 - -IL_01c8: ldloc.s V_21 - IL_01ca: ret -}"); + { + // Code size 437 (0x1b5) + .maxstack 2 + .locals init (C.<>c__DisplayClass0_0 V_0, //CS$<>8__locals0 + int V_1, + C.<>c__DisplayClass0_1 V_2, //CS$<>8__locals1 + int V_3, + object V_4, + int V_5, + C V_6, + object V_7, + C.<>c__DisplayClass0_2 V_8, //CS$<>8__locals2 + int V_9, + object V_10, + C V_11, + object V_12, + object V_13, + C V_14, + object V_15, + C.<>c__DisplayClass0_3 V_16, //CS$<>8__locals3 + int V_17) + -IL_0000: nop + ~IL_0001: newobj ""C.<>c__DisplayClass0_0..ctor()"" + IL_0006: stloc.0 + ~IL_0007: newobj ""C.<>c__DisplayClass0_1..ctor()"" + IL_000c: stloc.2 + IL_000d: call ""object C.F()"" + IL_0012: stloc.s V_4 + IL_0014: ldloc.s V_4 + IL_0016: isinst ""int"" + IL_001b: brfalse.s IL_003a + IL_001d: ldloc.s V_4 + IL_001f: unbox.any ""int"" + IL_0024: stloc.s V_5 + IL_0026: ldloc.s V_5 + IL_0028: ldc.i4.1 + IL_0029: beq.s IL_0071 + IL_002b: br.s IL_002d + IL_002d: ldloc.s V_5 + IL_002f: ldc.i4.2 + IL_0030: beq IL_0107 + IL_0035: br IL_017d + IL_003a: ldloc.s V_4 + IL_003c: isinst ""C"" + IL_0041: stloc.s V_6 + IL_0043: ldloc.s V_6 + IL_0045: brfalse IL_017d + IL_004a: ldloc.s V_6 + IL_004c: callvirt ""object C.Q.get"" + IL_0051: stloc.s V_7 + IL_0053: ldloc.s V_7 + IL_0055: isinst ""int"" + IL_005a: brfalse IL_017d + IL_005f: ldloc.2 + IL_0060: ldloc.s V_7 + IL_0062: unbox.any ""int"" + IL_0067: stfld ""int C.<>c__DisplayClass0_1.5__3"" + IL_006c: br IL_0167 + ~IL_0071: newobj ""C.<>c__DisplayClass0_2..ctor()"" + IL_0076: stloc.s V_8 + IL_0078: call ""object C.F()"" + IL_007d: stloc.s V_10 + IL_007f: ldloc.s V_10 + IL_0081: isinst ""C"" + IL_0086: stloc.s V_11 + IL_0088: ldloc.s V_11 + IL_008a: brfalse.s IL_00fc + IL_008c: ldloc.s V_11 + IL_008e: callvirt ""object C.P.get"" + IL_0093: stloc.s V_12 + IL_0095: ldloc.s V_12 + IL_0097: isinst ""int"" + IL_009c: brfalse.s IL_00fc + IL_009e: ldloc.s V_8 + IL_00a0: ldloc.s V_12 + IL_00a2: unbox.any ""int"" + IL_00a7: stfld ""int C.<>c__DisplayClass0_2.

5__4"" + IL_00ac: ldloc.s V_11 + IL_00ae: callvirt ""object C.Q.get"" + IL_00b3: stloc.s V_13 + IL_00b5: ldloc.s V_13 + IL_00b7: isinst ""C"" + IL_00bc: stloc.s V_14 + IL_00be: ldloc.s V_14 + IL_00c0: brfalse.s IL_00fc + IL_00c2: ldloc.s V_14 + IL_00c4: callvirt ""object C.P.get"" + IL_00c9: stloc.s V_15 + IL_00cb: ldloc.s V_15 + IL_00cd: isinst ""int"" + IL_00d2: brfalse.s IL_00fc + IL_00d4: ldloc.s V_8 + IL_00d6: ldloc.s V_15 + IL_00d8: unbox.any ""int"" + IL_00dd: stfld ""int C.<>c__DisplayClass0_2.5__5"" + IL_00e2: br.s IL_00e4 + IL_00e4: br.s IL_00e6 + IL_00e6: ldloc.s V_8 + IL_00e8: ldftn ""int C.<>c__DisplayClass0_2.b__2()"" + IL_00ee: newobj ""System.Func..ctor(object, System.IntPtr)"" + IL_00f3: call ""int C.G(System.Func)"" + IL_00f8: stloc.s V_9 + IL_00fa: br.s IL_0102 + IL_00fc: ldc.i4.s 10 + IL_00fe: stloc.s V_9 + IL_0100: br.s IL_0102 + IL_0102: ldloc.s V_9 + IL_0104: stloc.3 + IL_0105: br.s IL_0181 + ~IL_0107: newobj ""C.<>c__DisplayClass0_3..ctor()"" + IL_010c: stloc.s V_16 + IL_010e: call ""object C.F()"" + IL_0113: stloc.s V_15 + IL_0115: ldloc.s V_15 + IL_0117: isinst ""C"" + IL_011c: stloc.s V_14 + IL_011e: ldloc.s V_14 + IL_0120: brfalse.s IL_015c + IL_0122: ldloc.s V_14 + IL_0124: callvirt ""object C.P.get"" + IL_0129: stloc.s V_13 + IL_012b: ldloc.s V_13 + IL_012d: isinst ""int"" + IL_0132: brfalse.s IL_015c + IL_0134: ldloc.s V_16 + IL_0136: ldloc.s V_13 + IL_0138: unbox.any ""int"" + IL_013d: stfld ""int C.<>c__DisplayClass0_3.5__6"" + IL_0142: br.s IL_0144 + IL_0144: br.s IL_0146 + IL_0146: ldloc.s V_16 + IL_0148: ldftn ""int C.<>c__DisplayClass0_3.b__3()"" + IL_014e: newobj ""System.Func..ctor(object, System.IntPtr)"" + IL_0153: call ""int C.G(System.Func)"" + IL_0158: stloc.s V_9 + IL_015a: br.s IL_0162 + IL_015c: ldc.i4.s 20 + IL_015e: stloc.s V_9 + IL_0160: br.s IL_0162 + IL_0162: ldloc.s V_9 + IL_0164: stloc.3 + IL_0165: br.s IL_0181 + IL_0167: br.s IL_0169 + IL_0169: ldloc.2 + IL_016a: ldftn ""int C.<>c__DisplayClass0_1.b__1()"" + IL_0170: newobj ""System.Func..ctor(object, System.IntPtr)"" + IL_0175: call ""int C.G(System.Func)"" + IL_017a: stloc.3 + IL_017b: br.s IL_0181 + IL_017d: ldc.i4.0 + IL_017e: stloc.3 + IL_017f: br.s IL_0181 + IL_0181: ldloc.0 + IL_0182: ldloc.3 + IL_0183: stfld ""int C.<>c__DisplayClass0_0.5__2"" + IL_0188: br.s IL_018a + IL_018a: ldloc.0 + IL_018b: ldfld ""int C.<>c__DisplayClass0_0.5__2"" + IL_0190: ldc.i4.0 + IL_0191: bgt.s IL_0195 + IL_0193: br.s IL_01a9 + IL_0195: ldloc.0 + IL_0196: ldftn ""int C.<>c__DisplayClass0_0.b__0()"" + IL_019c: newobj ""System.Func..ctor(object, System.IntPtr)"" + IL_01a1: call ""int C.G(System.Func)"" + IL_01a6: stloc.1 + IL_01a7: br.s IL_01ad + IL_01a9: ldc.i4.0 + IL_01aa: stloc.1 + IL_01ab: br.s IL_01ad + IL_01ad: ldloc.1 + IL_01ae: stloc.s V_17 + IL_01b0: br.s IL_01b2 + -IL_01b2: ldloc.s V_17 + IL_01b4: ret + } +"); verifier.VerifyPdb("C.M", @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + "); } @@ -10426,34 +10407,32 @@ public void SyntaxOffset_OutVarInSwitchExpresison() var c = CreateCompilationWithMscorlib40AndSystemCore(source, options: TestOptions.DebugDll); c.VerifyPdb("C.G", @" - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + "); } -- GitLab