提交 4d92b18a 编写于 作者: A Alireza Habibi 提交者: Neal Gafter

Simplify codegen for struct declaration patterns (#23635)

* Simplify codegen for struct declaration patterns
* Move box to perform the conversion only when the test succeeds
上级 c44f53f0
......@@ -243,30 +243,22 @@ BoundExpression MakeIsDeclarationPattern(SyntaxNode syntax, BoundExpression lowe
}
else // type parameter or value type
{
// bool Is<T>(this object i, out T o)
// bool Is<T>(this object i, ref T o)
// {
// // inefficient because it performs the type test twice, and also because it boxes the input.
// bool s;
// o = (s = i is T) ? (T)i : default(T);
// return s;
// return i is T && (o = (T)i; true);
// }
var i = _factory.SynthesizedLocal(loweredInput.Type, syntax); // we copy the input to avoid double evaluation
// Because a cast involving a type parameter is not necessarily a valid conversion (or, if it is, it might not
// be of a kind appropriate for pattern-matching), we use `object` as an intermediate type for the input expression.
var objectType = _factory.SpecialType(SpecialType.System_Object);
var s = _factory.SynthesizedLocal(_factory.SpecialType(SpecialType.System_Boolean), syntax);
var i = _factory.SynthesizedLocal(objectType, syntax); // we copy the input to avoid double evaluation
return _factory.Sequence(
ImmutableArray.Create(s, i),
ImmutableArray.Create<BoundExpression>(
_factory.AssignmentExpression(_factory.Local(i), _factory.Convert(objectType, loweredInput)),
_factory.AssignmentExpression(loweredTarget, _factory.Conditional(
_factory.AssignmentExpression(_factory.Local(s), _factory.Is(_factory.Local(i), type)),
_factory.Convert(type, _factory.Local(i)),
_factory.Default(type), type))
),
_factory.Local(s)
);
var convertedInput = _factory.Convert(type, _factory.Convert(_factory.SpecialType(SpecialType.System_Object), _factory.Local(i)));
return _factory.MakeSequence(i,
_factory.LogicalAnd(
_factory.Is(_factory.AssignmentExpression(_factory.Local(i), loweredInput), type),
_factory.MakeSequence(_factory.AssignmentExpression(loweredTarget, convertedInput), _factory.Literal(true))));
}
}
}
......
......@@ -240,12 +240,11 @@ public Guid GetId(T t)
var compVerifier = CompileAndVerify(compilation);
compVerifier.VerifyIL("X<T>.Y<U>",
@"{
// Code size 67 (0x43)
// Code size 61 (0x3d)
.maxstack 3
.locals init (U V_0, //u
bool V_1,
object V_2,
U V_3)
T V_2)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: call ""System.Collections.Generic.IEnumerable<T> X<T>.GetT()""
......@@ -253,27 +252,24 @@ .maxstack 3
IL_0008: ldftn ""bool X<T>.<Y>b__1_0<U>(T)""
IL_000e: newobj ""System.Func<T, bool>..ctor(object, System.IntPtr)""
IL_0013: call ""T System.Linq.Enumerable.FirstOrDefault<T>(System.Collections.Generic.IEnumerable<T>, System.Func<T, bool>)""
IL_0018: box ""T""
IL_001d: stloc.2
IL_001e: ldloc.2
IL_0018: dup
IL_0019: stloc.2
IL_001a: box ""T""
IL_001f: isinst ""U""
IL_0024: ldnull
IL_0025: cgt.un
IL_0027: dup
IL_0028: brtrue.s IL_0035
IL_002a: ldloca.s V_3
IL_002c: initobj ""U""
IL_0032: ldloc.3
IL_0033: br.s IL_003b
IL_0035: ldloc.2
IL_0036: unbox.any ""U""
IL_003b: stloc.0
IL_003c: stloc.1
IL_003d: ldloc.1
IL_003e: brfalse.s IL_0042
IL_0040: nop
IL_0041: nop
IL_0042: ret
IL_0024: brfalse.s IL_0035
IL_0026: ldloc.2
IL_0027: box ""T""
IL_002c: unbox.any ""U""
IL_0031: stloc.0
IL_0032: ldc.i4.1
IL_0033: br.s IL_0036
IL_0035: ldc.i4.0
IL_0036: stloc.1
IL_0037: ldloc.1
IL_0038: brfalse.s IL_003c
IL_003a: nop
IL_003b: nop
IL_003c: ret
}");
}
}
......
......@@ -7616,7 +7616,7 @@ class C
var v0 = CompileAndVerify(compilation0);
v0.VerifyIL("C.F", @"
{
// Code size 40 (0x28)
// Code size 37 (0x25)
.maxstack 2
.locals init (int V_0, //i
bool V_1,
......@@ -7624,30 +7624,28 @@ .maxstack 2
int V_3)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.2
IL_0003: ldloc.2
IL_0002: dup
IL_0003: stloc.2
IL_0004: isinst ""int""
IL_0009: ldnull
IL_000a: cgt.un
IL_000c: dup
IL_000d: brtrue.s IL_0012
IL_000f: ldc.i4.0
IL_0010: br.s IL_0018
IL_0012: ldloc.2
IL_0013: unbox.any ""int""
IL_0018: stloc.0
IL_0019: stloc.1
IL_001a: ldloc.1
IL_001b: brfalse.s IL_0022
IL_001d: nop
IL_001e: ldloc.0
IL_001f: stloc.3
IL_0020: br.s IL_0026
IL_0022: ldc.i4.0
IL_0023: stloc.3
IL_0024: br.s IL_0026
IL_0026: ldloc.3
IL_0027: ret
IL_0009: brfalse.s IL_0015
IL_000b: ldloc.2
IL_000c: unbox.any ""int""
IL_0011: stloc.0
IL_0012: ldc.i4.1
IL_0013: br.s IL_0016
IL_0015: ldc.i4.0
IL_0016: stloc.1
IL_0017: ldloc.1
IL_0018: brfalse.s IL_001f
IL_001a: nop
IL_001b: ldloc.0
IL_001c: stloc.3
IL_001d: br.s IL_0023
IL_001f: ldc.i4.0
IL_0020: stloc.3
IL_0021: br.s IL_0023
IL_0023: ldloc.3
IL_0024: ret
}");
var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData);
......@@ -7660,7 +7658,7 @@ .maxstack 2
diff1.VerifyIL("C.F", @"
{
// Code size 56 (0x38)
// Code size 52 (0x34)
.maxstack 2
.locals init ([int] V_0,
[bool] V_1,
......@@ -7672,34 +7670,32 @@ .maxstack 2
int V_7)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.s V_6
IL_0004: ldloc.s V_6
IL_0006: isinst ""bool""
IL_000b: ldnull
IL_000c: cgt.un
IL_000e: dup
IL_000f: brtrue.s IL_0014
IL_0011: ldc.i4.0
IL_0012: br.s IL_001b
IL_0014: ldloc.s V_6
IL_0016: unbox.any ""bool""
IL_001b: stloc.s V_4
IL_001d: stloc.s V_5
IL_001f: ldloc.s V_5
IL_0021: brfalse.s IL_0030
IL_0023: nop
IL_0024: ldloc.s V_4
IL_0026: brtrue.s IL_002b
IL_0028: ldc.i4.0
IL_0029: br.s IL_002c
IL_002b: ldc.i4.1
IL_002c: stloc.s V_7
IL_002e: br.s IL_0035
IL_0030: ldc.i4.0
IL_0031: stloc.s V_7
IL_0033: br.s IL_0035
IL_0035: ldloc.s V_7
IL_0037: ret
IL_0002: dup
IL_0003: stloc.s V_6
IL_0005: isinst ""bool""
IL_000a: brfalse.s IL_0018
IL_000c: ldloc.s V_6
IL_000e: unbox.any ""bool""
IL_0013: stloc.s V_4
IL_0015: ldc.i4.1
IL_0016: br.s IL_0019
IL_0018: ldc.i4.0
IL_0019: stloc.s V_5
IL_001b: ldloc.s V_5
IL_001d: brfalse.s IL_002c
IL_001f: nop
IL_0020: ldloc.s V_4
IL_0022: brtrue.s IL_0027
IL_0024: ldc.i4.0
IL_0025: br.s IL_0028
IL_0027: ldc.i4.1
IL_0028: stloc.s V_7
IL_002a: br.s IL_0031
IL_002c: ldc.i4.0
IL_002d: stloc.s V_7
IL_002f: br.s IL_0031
IL_0031: ldloc.s V_7
IL_0033: ret
}");
var diff2 = compilation2.EmitDifference(
......@@ -7709,7 +7705,7 @@ .maxstack 2
diff2.VerifyIL("C.F", @"
{
// Code size 50 (0x32)
// Code size 46 (0x2e)
.maxstack 2
.locals init ([int] V_0,
[bool] V_1,
......@@ -7725,30 +7721,28 @@ .maxstack 2
int V_11)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.s V_10
IL_0004: ldloc.s V_10
IL_0006: isinst ""int""
IL_000b: ldnull
IL_000c: cgt.un
IL_000e: dup
IL_000f: brtrue.s IL_0014
IL_0011: ldc.i4.0
IL_0012: br.s IL_001b
IL_0014: ldloc.s V_10
IL_0016: unbox.any ""int""
IL_001b: stloc.s V_8
IL_001d: stloc.s V_9
IL_001f: ldloc.s V_9
IL_0021: brfalse.s IL_002a
IL_0023: nop
IL_0024: ldloc.s V_8
IL_0026: stloc.s V_11
IL_0028: br.s IL_002f
IL_002a: ldc.i4.0
IL_002b: stloc.s V_11
IL_002d: br.s IL_002f
IL_002f: ldloc.s V_11
IL_0031: ret
IL_0002: dup
IL_0003: stloc.s V_10
IL_0005: isinst ""int""
IL_000a: brfalse.s IL_0018
IL_000c: ldloc.s V_10
IL_000e: unbox.any ""int""
IL_0013: stloc.s V_8
IL_0015: ldc.i4.1
IL_0016: br.s IL_0019
IL_0018: ldc.i4.0
IL_0019: stloc.s V_9
IL_001b: ldloc.s V_9
IL_001d: brfalse.s IL_0026
IL_001f: nop
IL_0020: ldloc.s V_8
IL_0022: stloc.s V_11
IL_0024: br.s IL_002b
IL_0026: ldc.i4.0
IL_0027: stloc.s V_11
IL_0029: br.s IL_002b
IL_002b: ldloc.s V_11
IL_002d: ret
}");
}
......@@ -7783,7 +7777,7 @@ class C
var v0 = CompileAndVerify(compilation0);
v0.VerifyIL("C.F", @"
{
// Code size 40 (0x28)
// Code size 37 (0x25)
.maxstack 2
.locals init (int V_0, //i
bool V_1,
......@@ -7791,30 +7785,28 @@ .maxstack 2
int V_3)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.2
IL_0003: ldloc.2
IL_0002: dup
IL_0003: stloc.2
IL_0004: isinst ""int""
IL_0009: ldnull
IL_000a: cgt.un
IL_000c: dup
IL_000d: brtrue.s IL_0012
IL_000f: ldc.i4.0
IL_0010: br.s IL_0018
IL_0012: ldloc.2
IL_0013: unbox.any ""int""
IL_0018: stloc.0
IL_0019: stloc.1
IL_001a: ldloc.1
IL_001b: brfalse.s IL_0022
IL_001d: nop
IL_001e: ldloc.0
IL_001f: stloc.3
IL_0020: br.s IL_0026
IL_0022: ldc.i4.0
IL_0023: stloc.3
IL_0024: br.s IL_0026
IL_0026: ldloc.3
IL_0027: ret
IL_0009: brfalse.s IL_0015
IL_000b: ldloc.2
IL_000c: unbox.any ""int""
IL_0011: stloc.0
IL_0012: ldc.i4.1
IL_0013: br.s IL_0016
IL_0015: ldc.i4.0
IL_0016: stloc.1
IL_0017: ldloc.1
IL_0018: brfalse.s IL_001f
IL_001a: nop
IL_001b: ldloc.0
IL_001c: stloc.3
IL_001d: br.s IL_0023
IL_001f: ldc.i4.0
IL_0020: stloc.3
IL_0021: br.s IL_0023
IL_0023: ldloc.3
IL_0024: ret
}");
var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData);
......@@ -7862,7 +7854,7 @@ .maxstack 2
diff2.VerifyIL("C.F", @"
{
// Code size 50 (0x32)
// Code size 46 (0x2e)
.maxstack 2
.locals init ([int] V_0,
[bool] V_1,
......@@ -7876,30 +7868,28 @@ .maxstack 2
int V_9)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.s V_8
IL_0004: ldloc.s V_8
IL_0006: isinst ""int""
IL_000b: ldnull
IL_000c: cgt.un
IL_000e: dup
IL_000f: brtrue.s IL_0014
IL_0011: ldc.i4.0
IL_0012: br.s IL_001b
IL_0014: ldloc.s V_8
IL_0016: unbox.any ""int""
IL_001b: stloc.s V_6
IL_001d: stloc.s V_7
IL_001f: ldloc.s V_7
IL_0021: brfalse.s IL_002a
IL_0023: nop
IL_0024: ldloc.s V_6
IL_0026: stloc.s V_9
IL_0028: br.s IL_002f
IL_002a: ldc.i4.0
IL_002b: stloc.s V_9
IL_002d: br.s IL_002f
IL_002f: ldloc.s V_9
IL_0031: ret
IL_0002: dup
IL_0003: stloc.s V_8
IL_0005: isinst ""int""
IL_000a: brfalse.s IL_0018
IL_000c: ldloc.s V_8
IL_000e: unbox.any ""int""
IL_0013: stloc.s V_6
IL_0015: ldc.i4.1
IL_0016: br.s IL_0019
IL_0018: ldc.i4.0
IL_0019: stloc.s V_7
IL_001b: ldloc.s V_7
IL_001d: brfalse.s IL_0026
IL_001f: nop
IL_0020: ldloc.s V_6
IL_0022: stloc.s V_9
IL_0024: br.s IL_002b
IL_0026: ldc.i4.0
IL_0027: stloc.s V_9
IL_0029: br.s IL_002b
IL_002b: ldloc.s V_9
IL_002d: ret
}");
}
......
......@@ -2419,7 +2419,7 @@ static void M()
v0.VerifyIL("C.M", @"
{
// Code size 230 (0xe6)
// Code size 200 (0xc8)
.maxstack 2
.locals init (object V_0,
int V_1,
......@@ -2437,107 +2437,89 @@ .maxstack 2
IL_000a: stloc.0
IL_000b: ldloc.0
IL_000c: brtrue.s IL_0010
IL_000e: br.s IL_0081
IL_000e: br.s IL_0063
IL_0010: ldloc.0
IL_0011: stloc.s V_8
IL_0013: ldloc.s V_8
IL_0015: isinst ""int""
IL_001a: ldnull
IL_001b: cgt.un
IL_001d: dup
IL_001e: brtrue.s IL_0023
IL_0020: ldc.i4.0
IL_0021: br.s IL_002a
IL_0023: ldloc.s V_8
IL_0025: unbox.any ""int""
IL_002a: stloc.1
IL_002b: brfalse.s IL_0035
IL_002d: ldloc.1
IL_002e: ldc.i4.1
IL_002f: beq.s IL_0033
IL_0031: br.s IL_0035
IL_0033: br.s IL_0083
IL_0035: ldloc.0
IL_0036: stloc.s V_8
IL_0038: ldloc.s V_8
IL_003a: isinst ""byte""
IL_003f: ldnull
IL_0040: cgt.un
IL_0042: dup
IL_0043: brtrue.s IL_0048
IL_0045: ldc.i4.0
IL_0046: br.s IL_004f
IL_0048: ldloc.s V_8
IL_004a: unbox.any ""byte""
IL_004f: stloc.2
IL_0050: brfalse.s IL_005c
IL_0052: br.s IL_0090
IL_0054: ldloc.2
IL_0055: ldc.i4.1
IL_0056: beq.s IL_005a
IL_0058: br.s IL_005c
IL_005a: br.s IL_00ba
IL_005c: ldloc.0
IL_005d: stloc.s V_8
IL_005f: ldloc.s V_8
IL_0061: isinst ""int""
IL_0066: ldnull
IL_0067: cgt.un
IL_0069: dup
IL_006a: brtrue.s IL_006f
IL_006c: ldc.i4.0
IL_006d: br.s IL_0076
IL_006f: ldloc.s V_8
IL_0071: unbox.any ""int""
IL_0076: stloc.1
IL_0077: brfalse.s IL_007d
IL_0079: br.s IL_00a4
IL_007b: br.s IL_00c7
IL_007d: ldloc.0
IL_007e: stloc.0
IL_007f: br.s IL_00d6
IL_0081: br.s IL_00e5
IL_0083: ldstr ""int 1""
IL_0088: call ""void System.Console.WriteLine(string)""
IL_008d: nop
IL_008e: br.s IL_00e5
IL_0090: ldloc.2
IL_0091: stloc.3
IL_0092: call ""bool C.P()""
IL_0097: brtrue.s IL_009b
IL_0099: br.s IL_0054
IL_009b: ldloc.3
IL_009c: call ""void System.Console.WriteLine(int)""
IL_00a1: nop
IL_00a2: br.s IL_00e5
IL_00a4: ldloc.1
IL_00a5: stloc.s V_4
IL_00a7: call ""bool C.P()""
IL_00ac: brtrue.s IL_00b0
IL_00ae: br.s IL_007b
IL_00b0: ldloc.s V_4
IL_00b2: call ""void System.Console.WriteLine(int)""
IL_00b7: nop
IL_00b8: br.s IL_00e5
IL_00ba: ldstr ""byte 1""
IL_00bf: call ""void System.Console.WriteLine(string)""
IL_0011: dup
IL_0012: stloc.s V_8
IL_0014: isinst ""int""
IL_0019: brfalse.s IL_002b
IL_001b: ldloc.s V_8
IL_001d: unbox.any ""int""
IL_0022: stloc.1
IL_0023: ldloc.1
IL_0024: ldc.i4.1
IL_0025: beq.s IL_0029
IL_0027: br.s IL_002b
IL_0029: br.s IL_0065
IL_002b: ldloc.0
IL_002c: dup
IL_002d: stloc.s V_8
IL_002f: isinst ""byte""
IL_0034: brfalse.s IL_0048
IL_0036: ldloc.s V_8
IL_0038: unbox.any ""byte""
IL_003d: stloc.2
IL_003e: br.s IL_0072
IL_0040: ldloc.2
IL_0041: ldc.i4.1
IL_0042: beq.s IL_0046
IL_0044: br.s IL_0048
IL_0046: br.s IL_009c
IL_0048: ldloc.0
IL_0049: dup
IL_004a: stloc.s V_8
IL_004c: isinst ""int""
IL_0051: brfalse.s IL_005f
IL_0053: ldloc.s V_8
IL_0055: unbox.any ""int""
IL_005a: stloc.1
IL_005b: br.s IL_0086
IL_005d: br.s IL_00a9
IL_005f: ldloc.0
IL_0060: stloc.0
IL_0061: br.s IL_00b8
IL_0063: br.s IL_00c7
IL_0065: ldstr ""int 1""
IL_006a: call ""void System.Console.WriteLine(string)""
IL_006f: nop
IL_0070: br.s IL_00c7
IL_0072: ldloc.2
IL_0073: stloc.3
IL_0074: call ""bool C.P()""
IL_0079: brtrue.s IL_007d
IL_007b: br.s IL_0040
IL_007d: ldloc.3
IL_007e: call ""void System.Console.WriteLine(int)""
IL_0083: nop
IL_0084: br.s IL_00c7
IL_0086: ldloc.1
IL_0087: stloc.s V_4
IL_0089: call ""bool C.P()""
IL_008e: brtrue.s IL_0092
IL_0090: br.s IL_005d
IL_0092: ldloc.s V_4
IL_0094: call ""void System.Console.WriteLine(int)""
IL_0099: nop
IL_009a: br.s IL_00c7
IL_009c: ldstr ""byte 1""
IL_00a1: call ""void System.Console.WriteLine(string)""
IL_00a6: nop
IL_00a7: br.s IL_00c7
IL_00a9: ldloc.1
IL_00aa: stloc.s V_5
IL_00ac: br.s IL_00ae
IL_00ae: ldloc.s V_5
IL_00b0: call ""void System.Console.WriteLine(int)""
IL_00b5: nop
IL_00b6: br.s IL_00c7
IL_00b8: ldloc.0
IL_00b9: stloc.s V_6
IL_00bb: br.s IL_00bd
IL_00bd: ldloc.s V_6
IL_00bf: call ""void System.Console.WriteLine(object)""
IL_00c4: nop
IL_00c5: br.s IL_00e5
IL_00c7: ldloc.1
IL_00c8: stloc.s V_5
IL_00ca: br.s IL_00cc
IL_00cc: ldloc.s V_5
IL_00ce: call ""void System.Console.WriteLine(int)""
IL_00d3: nop
IL_00d4: br.s IL_00e5
IL_00d6: ldloc.0
IL_00d7: stloc.s V_6
IL_00d9: br.s IL_00db
IL_00db: ldloc.s V_6
IL_00dd: call ""void System.Console.WriteLine(object)""
IL_00e2: nop
IL_00e3: br.s IL_00e5
IL_00e5: ret
IL_00c5: br.s IL_00c7
IL_00c7: ret
}");
var methodData0 = v0.TestData.GetMethodData("C.M");
var method0 = compilation0.GetMember<MethodSymbol>("C.M");
......@@ -2550,7 +2532,7 @@ .maxstack 2
diff1.VerifyIL("C.M", @"
{
// Code size 230 (0xe6)
// Code size 200 (0xc8)
.maxstack 2
.locals init (object V_0,
int V_1,
......@@ -2569,107 +2551,89 @@ .maxstack 2
IL_000a: stloc.0
IL_000b: ldloc.0
IL_000c: brtrue.s IL_0010
IL_000e: br.s IL_0081
IL_000e: br.s IL_0063
IL_0010: ldloc.0
IL_0011: stloc.s V_9
IL_0013: ldloc.s V_9
IL_0015: isinst ""int""
IL_001a: ldnull
IL_001b: cgt.un
IL_001d: dup
IL_001e: brtrue.s IL_0023
IL_0020: ldc.i4.0
IL_0021: br.s IL_002a
IL_0023: ldloc.s V_9
IL_0025: unbox.any ""int""
IL_002a: stloc.1
IL_002b: brfalse.s IL_0035
IL_002d: ldloc.1
IL_002e: ldc.i4.1
IL_002f: beq.s IL_0033
IL_0031: br.s IL_0035
IL_0033: br.s IL_0083
IL_0035: ldloc.0
IL_0036: stloc.s V_9
IL_0038: ldloc.s V_9
IL_003a: isinst ""byte""
IL_003f: ldnull
IL_0040: cgt.un
IL_0042: dup
IL_0043: brtrue.s IL_0048
IL_0045: ldc.i4.0
IL_0046: br.s IL_004f
IL_0048: ldloc.s V_9
IL_004a: unbox.any ""byte""
IL_004f: stloc.2
IL_0050: brfalse.s IL_005c
IL_0052: br.s IL_0090
IL_0054: ldloc.2
IL_0055: ldc.i4.1
IL_0056: beq.s IL_005a
IL_0058: br.s IL_005c
IL_005a: br.s IL_00ba
IL_005c: ldloc.0
IL_005d: stloc.s V_9
IL_005f: ldloc.s V_9
IL_0061: isinst ""int""
IL_0066: ldnull
IL_0067: cgt.un
IL_0069: dup
IL_006a: brtrue.s IL_006f
IL_006c: ldc.i4.0
IL_006d: br.s IL_0076
IL_006f: ldloc.s V_9
IL_0071: unbox.any ""int""
IL_0076: stloc.1
IL_0077: brfalse.s IL_007d
IL_0079: br.s IL_00a4
IL_007b: br.s IL_00c7
IL_007d: ldloc.0
IL_007e: stloc.0
IL_007f: br.s IL_00d6
IL_0081: br.s IL_00e5
IL_0083: ldstr ""int 1""
IL_0088: call ""void System.Console.WriteLine(string)""
IL_008d: nop
IL_008e: br.s IL_00e5
IL_0090: ldloc.2
IL_0091: stloc.3
IL_0092: call ""bool C.P()""
IL_0097: brtrue.s IL_009b
IL_0099: br.s IL_0054
IL_009b: ldloc.3
IL_009c: call ""void System.Console.WriteLine(int)""
IL_00a1: nop
IL_00a2: br.s IL_00e5
IL_00a4: ldloc.1
IL_00a5: stloc.s V_4
IL_00a7: call ""bool C.P()""
IL_00ac: brtrue.s IL_00b0
IL_00ae: br.s IL_007b
IL_00b0: ldloc.s V_4
IL_00b2: call ""void System.Console.WriteLine(int)""
IL_00b7: nop
IL_00b8: br.s IL_00e5
IL_00ba: ldstr ""byte 1""
IL_00bf: call ""void System.Console.WriteLine(string)""
IL_0011: dup
IL_0012: stloc.s V_9
IL_0014: isinst ""int""
IL_0019: brfalse.s IL_002b
IL_001b: ldloc.s V_9
IL_001d: unbox.any ""int""
IL_0022: stloc.1
IL_0023: ldloc.1
IL_0024: ldc.i4.1
IL_0025: beq.s IL_0029
IL_0027: br.s IL_002b
IL_0029: br.s IL_0065
IL_002b: ldloc.0
IL_002c: dup
IL_002d: stloc.s V_9
IL_002f: isinst ""byte""
IL_0034: brfalse.s IL_0048
IL_0036: ldloc.s V_9
IL_0038: unbox.any ""byte""
IL_003d: stloc.2
IL_003e: br.s IL_0072
IL_0040: ldloc.2
IL_0041: ldc.i4.1
IL_0042: beq.s IL_0046
IL_0044: br.s IL_0048
IL_0046: br.s IL_009c
IL_0048: ldloc.0
IL_0049: dup
IL_004a: stloc.s V_9
IL_004c: isinst ""int""
IL_0051: brfalse.s IL_005f
IL_0053: ldloc.s V_9
IL_0055: unbox.any ""int""
IL_005a: stloc.1
IL_005b: br.s IL_0086
IL_005d: br.s IL_00a9
IL_005f: ldloc.0
IL_0060: stloc.0
IL_0061: br.s IL_00b8
IL_0063: br.s IL_00c7
IL_0065: ldstr ""int 1""
IL_006a: call ""void System.Console.WriteLine(string)""
IL_006f: nop
IL_0070: br.s IL_00c7
IL_0072: ldloc.2
IL_0073: stloc.3
IL_0074: call ""bool C.P()""
IL_0079: brtrue.s IL_007d
IL_007b: br.s IL_0040
IL_007d: ldloc.3
IL_007e: call ""void System.Console.WriteLine(int)""
IL_0083: nop
IL_0084: br.s IL_00c7
IL_0086: ldloc.1
IL_0087: stloc.s V_4
IL_0089: call ""bool C.P()""
IL_008e: brtrue.s IL_0092
IL_0090: br.s IL_005d
IL_0092: ldloc.s V_4
IL_0094: call ""void System.Console.WriteLine(int)""
IL_0099: nop
IL_009a: br.s IL_00c7
IL_009c: ldstr ""byte 1""
IL_00a1: call ""void System.Console.WriteLine(string)""
IL_00a6: nop
IL_00a7: br.s IL_00c7
IL_00a9: ldloc.1
IL_00aa: stloc.s V_5
IL_00ac: br.s IL_00ae
IL_00ae: ldloc.s V_5
IL_00b0: call ""void System.Console.WriteLine(int)""
IL_00b5: nop
IL_00b6: br.s IL_00c7
IL_00b8: ldloc.0
IL_00b9: stloc.s V_6
IL_00bb: br.s IL_00bd
IL_00bd: ldloc.s V_6
IL_00bf: call ""void System.Console.WriteLine(object)""
IL_00c4: nop
IL_00c5: br.s IL_00e5
IL_00c7: ldloc.1
IL_00c8: stloc.s V_5
IL_00ca: br.s IL_00cc
IL_00cc: ldloc.s V_5
IL_00ce: call ""void System.Console.WriteLine(int)""
IL_00d3: nop
IL_00d4: br.s IL_00e5
IL_00d6: ldloc.0
IL_00d7: stloc.s V_6
IL_00d9: br.s IL_00db
IL_00db: ldloc.s V_6
IL_00dd: call ""void System.Console.WriteLine(object)""
IL_00e2: nop
IL_00e3: br.s IL_00e5
IL_00e5: ret
IL_00c5: br.s IL_00c7
IL_00c7: ret
}");
}
......@@ -3667,7 +3631,7 @@ class C
diff1.VerifyIL("C.F", @"
{
// Code size 46 (0x2e)
// Code size 42 (0x2a)
.maxstack 2
.locals init (int V_0, //i
bool V_1,
......@@ -3677,30 +3641,28 @@ .maxstack 2
int V_5)
-IL_0000: nop
-IL_0001: ldarg.0
IL_0002: stloc.s V_4
IL_0004: ldloc.s V_4
IL_0006: isinst ""int""
IL_000b: ldnull
IL_000c: cgt.un
IL_000e: dup
IL_000f: brtrue.s IL_0014
IL_0011: ldc.i4.0
IL_0012: br.s IL_001b
IL_0014: ldloc.s V_4
IL_0016: unbox.any ""int""
IL_001b: stloc.0
IL_001c: stloc.1
~IL_001d: ldloc.1
IL_001e: brfalse.s IL_0026
-IL_0020: nop
-IL_0021: ldloc.0
IL_0022: stloc.s V_5
IL_0024: br.s IL_002b
-IL_0026: ldc.i4.0
IL_0027: stloc.s V_5
IL_0029: br.s IL_002b
-IL_002b: ldloc.s V_5
IL_002d: ret
IL_0002: dup
IL_0003: stloc.s V_4
IL_0005: isinst ""int""
IL_000a: brfalse.s IL_0017
IL_000c: ldloc.s V_4
IL_000e: unbox.any ""int""
IL_0013: stloc.0
IL_0014: ldc.i4.1
IL_0015: br.s IL_0018
IL_0017: ldc.i4.0
IL_0018: stloc.1
~IL_0019: ldloc.1
IL_001a: brfalse.s IL_0022
-IL_001c: nop
-IL_001d: ldloc.0
IL_001e: stloc.s V_5
IL_0020: br.s IL_0027
-IL_0022: ldc.i4.0
IL_0023: stloc.s V_5
IL_0025: br.s IL_0027
-IL_0027: ldloc.s V_5
IL_0029: ret
}", methodToken: diff1.UpdatedMethods.Single());
}
......@@ -3836,7 +3798,7 @@ class C
diff1.VerifyIL("C.F", @"
{
// Code size 46 (0x2e)
// Code size 42 (0x2a)
.maxstack 2
.locals init (int V_0, //i
bool V_1,
......@@ -3846,30 +3808,28 @@ .maxstack 2
int V_5)
-IL_0000: nop
-IL_0001: ldarg.0
IL_0002: stloc.s V_4
IL_0004: ldloc.s V_4
IL_0006: isinst ""int""
IL_000b: ldnull
IL_000c: cgt.un
IL_000e: dup
IL_000f: brtrue.s IL_0014
IL_0011: ldc.i4.0
IL_0012: br.s IL_001b
IL_0014: ldloc.s V_4
IL_0016: unbox.any ""int""
IL_001b: stloc.0
IL_001c: stloc.1
~IL_001d: ldloc.1
IL_001e: brfalse.s IL_0026
-IL_0020: nop
-IL_0021: ldloc.0
IL_0022: stloc.s V_5
IL_0024: br.s IL_002b
-IL_0026: ldc.i4.0
IL_0027: stloc.s V_5
IL_0029: br.s IL_002b
-IL_002b: ldloc.s V_5
IL_002d: ret
IL_0002: dup
IL_0003: stloc.s V_4
IL_0005: isinst ""int""
IL_000a: brfalse.s IL_0017
IL_000c: ldloc.s V_4
IL_000e: unbox.any ""int""
IL_0013: stloc.0
IL_0014: ldc.i4.1
IL_0015: br.s IL_0018
IL_0017: ldc.i4.0
IL_0018: stloc.1
~IL_0019: ldloc.1
IL_001a: brfalse.s IL_0022
-IL_001c: nop
-IL_001d: ldloc.0
IL_001e: stloc.s V_5
IL_0020: br.s IL_0027
-IL_0022: ldc.i4.0
IL_0023: stloc.s V_5
IL_0025: br.s IL_0027
-IL_0027: ldloc.s V_5
IL_0029: ret
}", methodToken: diff1.UpdatedMethods.Single());
}
......
......@@ -3405,122 +3405,105 @@ static void M2<T>()
verifier.VerifyIL(qualifiedMethodName: "Program.M1<T>", sequencePoints: "Program.M1", source: source,
expectedIL: @"{
// Code size 80 (0x50)
// Code size 66 (0x42)
.maxstack 2
.locals init (T V_0,
int V_1,
T V_2, //t
int V_3, //i
int V_4,
object V_5,
T V_6)
int V_5)
// sequence point: {
IL_0000: nop
// sequence point: switch (1)
IL_0001: ldc.i4.1
IL_0002: stloc.s V_4
IL_0004: ldc.i4.1
IL_0005: box ""int""
IL_000a: stloc.s V_5
IL_000c: ldloc.s V_5
IL_000e: isinst ""T""
IL_0013: ldnull
IL_0014: cgt.un
IL_0016: dup
IL_0017: brtrue.s IL_0025
IL_0019: ldloca.s V_6
IL_001b: initobj ""T""
IL_0021: ldloc.s V_6
IL_0023: br.s IL_002c
IL_0025: ldloc.s V_5
IL_0027: unbox.any ""T""
IL_002c: stloc.0
IL_002d: brfalse.s IL_0031
IL_002f: br.s IL_0035
IL_0031: ldc.i4.1
IL_0032: stloc.1
IL_0033: br.s IL_0042
IL_0005: dup
IL_0006: stloc.s V_5
IL_0008: box ""int""
IL_000d: isinst ""T""
IL_0012: brfalse.s IL_0023
IL_0014: ldloc.s V_5
IL_0016: box ""int""
IL_001b: unbox.any ""T""
IL_0020: stloc.0
IL_0021: br.s IL_0027
IL_0023: ldc.i4.1
IL_0024: stloc.1
IL_0025: br.s IL_0034
// sequence point: <hidden>
IL_0035: ldloc.0
IL_0036: stloc.2
IL_0037: br.s IL_0039
IL_0027: ldloc.0
IL_0028: stloc.2
IL_0029: br.s IL_002b
// sequence point: Console.Write(1);
IL_0039: ldc.i4.1
IL_003a: call ""void System.Console.Write(int)""
IL_003f: nop
IL_002b: ldc.i4.1
IL_002c: call ""void System.Console.Write(int)""
IL_0031: nop
// sequence point: break;
IL_0040: br.s IL_004f
IL_0032: br.s IL_0041
// sequence point: <hidden>
IL_0042: ldloc.1
IL_0043: stloc.3
IL_0044: br.s IL_0046
IL_0034: ldloc.1
IL_0035: stloc.3
IL_0036: br.s IL_0038
// sequence point: Console.Write(2);
IL_0046: ldc.i4.2
IL_0047: call ""void System.Console.Write(int)""
IL_004c: nop
IL_0038: ldc.i4.2
IL_0039: call ""void System.Console.Write(int)""
IL_003e: nop
// sequence point: break;
IL_004d: br.s IL_004f
IL_003f: br.s IL_0041
// sequence point: }
IL_004f: ret
IL_0041: ret
}");
verifier.VerifyIL(qualifiedMethodName: "Program.M2<T>", sequencePoints: "Program.M2", source: source,
expectedIL: @"{
// Code size 87 (0x57)
// Code size 68 (0x44)
.maxstack 2
.locals init (T V_0,
string V_1,
T V_2, //t
string V_3, //s
string V_4,
object V_5,
T V_6)
string V_5)
// sequence point: {
IL_0000: nop
// sequence point: switch (nameof(M2))
IL_0001: ldstr ""M2""
IL_0006: stloc.s V_4
IL_0008: ldstr ""M2""
IL_000d: stloc.s V_5
IL_000f: ldloc.s V_5
IL_0011: isinst ""T""
IL_0016: ldnull
IL_0017: cgt.un
IL_0019: dup
IL_001a: brtrue.s IL_0028
IL_001c: ldloca.s V_6
IL_001e: initobj ""T""
IL_0024: ldloc.s V_6
IL_0026: br.s IL_002f
IL_0028: ldloc.s V_5
IL_002a: unbox.any ""T""
IL_002f: stloc.0
IL_0030: brfalse.s IL_0034
IL_0032: br.s IL_003c
IL_0034: ldstr ""M2""
IL_0039: stloc.1
IL_003a: br.s IL_0049
IL_000d: dup
IL_000e: stloc.s V_5
IL_0010: isinst ""T""
IL_0015: brfalse.s IL_0021
IL_0017: ldloc.s V_5
IL_0019: unbox.any ""T""
IL_001e: stloc.0
IL_001f: br.s IL_0029
IL_0021: ldstr ""M2""
IL_0026: stloc.1
IL_0027: br.s IL_0036
// sequence point: <hidden>
IL_003c: ldloc.0
IL_003d: stloc.2
IL_003e: br.s IL_0040
IL_0029: ldloc.0
IL_002a: stloc.2
IL_002b: br.s IL_002d
// sequence point: Console.Write(3);
IL_0040: ldc.i4.3
IL_0041: call ""void System.Console.Write(int)""
IL_0046: nop
IL_002d: ldc.i4.3
IL_002e: call ""void System.Console.Write(int)""
IL_0033: nop
// sequence point: break;
IL_0047: br.s IL_0056
IL_0034: br.s IL_0043
// sequence point: <hidden>
IL_0049: ldloc.1
IL_004a: stloc.3
IL_004b: br.s IL_004d
IL_0036: ldloc.1
IL_0037: stloc.3
IL_0038: br.s IL_003a
// sequence point: Console.Write(4);
IL_004d: ldc.i4.4
IL_004e: call ""void System.Console.Write(int)""
IL_0053: nop
IL_003a: ldc.i4.4
IL_003b: call ""void System.Console.Write(int)""
IL_0040: nop
// sequence point: break;
IL_0054: br.s IL_0056
IL_0041: br.s IL_0043
// sequence point: }
IL_0056: ret
IL_0043: ret
}");
// Check the release code generation too.
......@@ -3530,72 +3513,58 @@ .maxstack 2
verifier.VerifyIL("Program.M1<T>",
@"{
// Code size 57 (0x39)
// Code size 47 (0x2f)
.maxstack 2
.locals init (T V_0,
int V_1,
object V_2,
T V_3)
int V_2)
IL_0000: ldc.i4.1
IL_0001: box ""int""
IL_0006: stloc.2
IL_0007: ldloc.2
IL_0001: dup
IL_0002: stloc.2
IL_0003: box ""int""
IL_0008: isinst ""T""
IL_000d: ldnull
IL_000e: cgt.un
IL_0010: dup
IL_0011: brtrue.s IL_001e
IL_0013: ldloca.s V_3
IL_0015: initobj ""T""
IL_001b: ldloc.3
IL_001c: br.s IL_0024
IL_001e: ldloc.2
IL_001f: unbox.any ""T""
IL_0024: stloc.0
IL_0025: brtrue.s IL_002b
IL_0027: ldc.i4.1
IL_0028: stloc.1
IL_0029: br.s IL_0032
IL_002b: ldc.i4.1
IL_002c: call ""void System.Console.Write(int)""
IL_0031: ret
IL_0032: ldc.i4.2
IL_0033: call ""void System.Console.Write(int)""
IL_0038: ret
IL_000d: brfalse.s IL_001d
IL_000f: ldloc.2
IL_0010: box ""int""
IL_0015: unbox.any ""T""
IL_001a: stloc.0
IL_001b: br.s IL_0021
IL_001d: ldc.i4.1
IL_001e: stloc.1
IL_001f: br.s IL_0028
IL_0021: ldc.i4.1
IL_0022: call ""void System.Console.Write(int)""
IL_0027: ret
IL_0028: ldc.i4.2
IL_0029: call ""void System.Console.Write(int)""
IL_002e: ret
}");
verifier.VerifyIL("Program.M2<T>",
@"{
// Code size 60 (0x3c)
// Code size 45 (0x2d)
.maxstack 2
.locals init (T V_0,
string V_1,
object V_2,
T V_3)
string V_2)
IL_0000: ldstr ""M2""
IL_0005: stloc.2
IL_0006: ldloc.2
IL_0005: dup
IL_0006: stloc.2
IL_0007: isinst ""T""
IL_000c: ldnull
IL_000d: cgt.un
IL_000f: dup
IL_0010: brtrue.s IL_001d
IL_0012: ldloca.s V_3
IL_0014: initobj ""T""
IL_001a: ldloc.3
IL_001b: br.s IL_0023
IL_001d: ldloc.2
IL_001e: unbox.any ""T""
IL_0023: stloc.0
IL_0024: brtrue.s IL_002e
IL_0026: ldstr ""M2""
IL_002b: stloc.1
IL_002c: br.s IL_0035
IL_002e: ldc.i4.3
IL_002f: call ""void System.Console.Write(int)""
IL_0034: ret
IL_0035: ldc.i4.4
IL_0036: call ""void System.Console.Write(int)""
IL_003b: ret
IL_000c: brfalse.s IL_0017
IL_000e: ldloc.2
IL_000f: unbox.any ""T""
IL_0014: stloc.0
IL_0015: br.s IL_001f
IL_0017: ldstr ""M2""
IL_001c: stloc.1
IL_001d: br.s IL_0026
IL_001f: ldc.i4.3
IL_0020: call ""void System.Console.Write(int)""
IL_0025: ret
IL_0026: ldc.i4.4
IL_0027: call ""void System.Console.Write(int)""
IL_002c: ret
}");
}
......@@ -7209,8 +7178,8 @@ public void SyntaxOffset_Pattern()
<sequencePoints>
<entry offset=""0x0"" startLine=""1"" startColumn=""31"" endLine=""1"" endColumn=""64"" document=""1"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x35"">
<local name=""i"" il_index=""0"" il_start=""0x0"" il_end=""0x35"" attributes=""0"" />
<scope startOffset=""0x0"" endOffset=""0x2c"">
<local name=""i"" il_index=""0"" il_start=""0x0"" il_end=""0x2c"" attributes=""0"" />
</scope>
</method>
</methods>
......@@ -7658,7 +7627,7 @@ static void M(object o)
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll);
CompileAndVerify(c).VerifyIL("Program.M",
@"{
// Code size 188 (0xbc)
// Code size 170 (0xaa)
.maxstack 2
.locals init (object V_0,
int V_1,
......@@ -7676,96 +7645,84 @@ .maxstack 2
IL_0004: stloc.0
IL_0005: ldloc.0
IL_0006: brtrue.s IL_000a
IL_0008: br.s IL_0054
IL_0008: br.s IL_004b
IL_000a: ldloc.0
IL_000b: stloc.3
IL_000c: ldloc.3
IL_000b: dup
IL_000c: stloc.3
IL_000d: isinst ""int""
IL_0012: ldnull
IL_0013: cgt.un
IL_0015: dup
IL_0016: brtrue.s IL_001b
IL_0018: ldc.i4.0
IL_0019: br.s IL_0021
IL_001b: ldloc.3
IL_001c: unbox.any ""int""
IL_0021: stloc.1
IL_0022: brfalse.s IL_0054
IL_0024: ldloc.1
IL_0025: ldc.i4.1
IL_0026: sub
IL_0027: switch (
IL_0042,
IL_004a,
IL_0050,
IL_0048,
IL_004e)
IL_0040: br.s IL_0054
IL_0042: br.s IL_0056
IL_0044: br.s IL_0062
IL_0046: br.s IL_0070
IL_0048: br.s IL_0060
IL_004a: br.s IL_005b
IL_004c: br.s IL_0054
IL_004e: br.s IL_006c
IL_0050: br.s IL_0067
IL_0052: br.s IL_0054
IL_0054: br.s IL_006e
IL_0056: ldarg.0
IL_0057: brfalse.s IL_0060
IL_0059: br.s IL_0044
IL_005b: ldarg.0
IL_005c: brfalse.s IL_0060
IL_005e: br.s IL_004c
IL_0060: br.s IL_0072
IL_0062: ldarg.0
IL_0063: brtrue.s IL_006c
IL_0065: br.s IL_0046
IL_0067: ldarg.0
IL_0068: brtrue.s IL_006c
IL_006a: br.s IL_0052
IL_006c: br.s IL_0072
IL_006e: br.s IL_0072
IL_0070: br.s IL_0072
IL_0072: ldarg.0
IL_0073: stloc.s V_6
IL_0075: ldloc.s V_6
IL_0077: stloc.s V_4
IL_0079: ldloc.s V_4
IL_007b: brtrue.s IL_007f
IL_007d: br.s IL_00a4
IL_007f: ldloc.s V_4
IL_0081: stloc.3
IL_0082: ldloc.3
IL_0083: isinst ""int""
IL_0088: ldnull
IL_0089: cgt.un
IL_008b: dup
IL_008c: brtrue.s IL_0091
IL_008e: ldc.i4.0
IL_008f: br.s IL_0097
IL_0091: ldloc.3
IL_0092: unbox.any ""int""
IL_0097: stloc.s V_5
IL_0099: brfalse.s IL_00a4
IL_009b: ldloc.s V_5
IL_009d: ldc.i4.1
IL_009e: beq.s IL_00a2
IL_00a0: br.s IL_00a4
IL_00a2: br.s IL_00a6
IL_00a4: br.s IL_00a8
IL_00a6: br.s IL_00aa
IL_00a8: br.s IL_00aa
IL_00aa: ldarg.0
IL_00ab: stloc.s V_8
IL_00ad: ldloc.s V_8
IL_00af: stloc.s V_7
IL_00b1: ldloc.s V_7
IL_00b3: brtrue.s IL_00b7
IL_00b5: br.s IL_00b7
IL_00b7: br.s IL_00b9
IL_00b9: br.s IL_00bb
IL_00bb: ret
IL_0012: brfalse.s IL_004b
IL_0014: ldloc.3
IL_0015: unbox.any ""int""
IL_001a: stloc.1
IL_001b: ldloc.1
IL_001c: ldc.i4.1
IL_001d: sub
IL_001e: switch (
IL_0039,
IL_0041,
IL_0047,
IL_003f,
IL_0045)
IL_0037: br.s IL_004b
IL_0039: br.s IL_004d
IL_003b: br.s IL_0059
IL_003d: br.s IL_0067
IL_003f: br.s IL_0057
IL_0041: br.s IL_0052
IL_0043: br.s IL_004b
IL_0045: br.s IL_0063
IL_0047: br.s IL_005e
IL_0049: br.s IL_004b
IL_004b: br.s IL_0065
IL_004d: ldarg.0
IL_004e: brfalse.s IL_0057
IL_0050: br.s IL_003b
IL_0052: ldarg.0
IL_0053: brfalse.s IL_0057
IL_0055: br.s IL_0043
IL_0057: br.s IL_0069
IL_0059: ldarg.0
IL_005a: brtrue.s IL_0063
IL_005c: br.s IL_003d
IL_005e: ldarg.0
IL_005f: brtrue.s IL_0063
IL_0061: br.s IL_0049
IL_0063: br.s IL_0069
IL_0065: br.s IL_0069
IL_0067: br.s IL_0069
IL_0069: ldarg.0
IL_006a: stloc.s V_6
IL_006c: ldloc.s V_6
IL_006e: stloc.s V_4
IL_0070: ldloc.s V_4
IL_0072: brtrue.s IL_0076
IL_0074: br.s IL_0092
IL_0076: ldloc.s V_4
IL_0078: dup
IL_0079: stloc.3
IL_007a: isinst ""int""
IL_007f: brfalse.s IL_0092
IL_0081: ldloc.3
IL_0082: unbox.any ""int""
IL_0087: stloc.s V_5
IL_0089: ldloc.s V_5
IL_008b: ldc.i4.1
IL_008c: beq.s IL_0090
IL_008e: br.s IL_0092
IL_0090: br.s IL_0094
IL_0092: br.s IL_0096
IL_0094: br.s IL_0098
IL_0096: br.s IL_0098
IL_0098: ldarg.0
IL_0099: stloc.s V_8
IL_009b: ldloc.s V_8
IL_009d: stloc.s V_7
IL_009f: ldloc.s V_7
IL_00a1: brtrue.s IL_00a5
IL_00a3: br.s IL_00a5
IL_00a5: br.s IL_00a7
IL_00a7: br.s IL_00a9
IL_00a9: ret
}");
c.VerifyPdb(
@"<symbols>
......@@ -7794,22 +7751,22 @@ .maxstack 2
<entry offset=""0x0"" startLine=""4"" startColumn=""5"" endLine=""4"" endColumn=""6"" document=""1"" />
<entry offset=""0x1"" startLine=""5"" startColumn=""9"" endLine=""5"" endColumn=""19"" document=""1"" />
<entry offset=""0x3"" hidden=""true"" document=""1"" />
<entry offset=""0x56"" startLine=""7"" startColumn=""20"" endLine=""7"" endColumn=""34"" document=""1"" />
<entry offset=""0x5b"" startLine=""9"" startColumn=""20"" endLine=""9"" endColumn=""34"" document=""1"" />
<entry offset=""0x60"" startLine=""10"" startColumn=""17"" endLine=""10"" endColumn=""23"" document=""1"" />
<entry offset=""0x62"" startLine=""11"" startColumn=""20"" endLine=""11"" endColumn=""34"" document=""1"" />
<entry offset=""0x67"" startLine=""13"" startColumn=""20"" endLine=""13"" endColumn=""34"" document=""1"" />
<entry offset=""0x6c"" startLine=""14"" startColumn=""17"" endLine=""14"" endColumn=""23"" document=""1"" />
<entry offset=""0x6e"" startLine=""16"" startColumn=""17"" endLine=""16"" endColumn=""23"" document=""1"" />
<entry offset=""0x70"" startLine=""18"" startColumn=""17"" endLine=""18"" endColumn=""23"" document=""1"" />
<entry offset=""0x72"" startLine=""20"" startColumn=""9"" endLine=""20"" endColumn=""19"" document=""1"" />
<entry offset=""0x75"" hidden=""true"" document=""1"" />
<entry offset=""0xa6"" startLine=""23"" startColumn=""17"" endLine=""23"" endColumn=""23"" document=""1"" />
<entry offset=""0xa8"" startLine=""25"" startColumn=""17"" endLine=""25"" endColumn=""23"" document=""1"" />
<entry offset=""0xaa"" startLine=""27"" startColumn=""9"" endLine=""27"" endColumn=""19"" document=""1"" />
<entry offset=""0xad"" hidden=""true"" document=""1"" />
<entry offset=""0xb9"" startLine=""30"" startColumn=""17"" endLine=""30"" endColumn=""23"" document=""1"" />
<entry offset=""0xbb"" startLine=""32"" startColumn=""5"" endLine=""32"" endColumn=""6"" document=""1"" />
<entry offset=""0x4d"" startLine=""7"" startColumn=""20"" endLine=""7"" endColumn=""34"" document=""1"" />
<entry offset=""0x52"" startLine=""9"" startColumn=""20"" endLine=""9"" endColumn=""34"" document=""1"" />
<entry offset=""0x57"" startLine=""10"" startColumn=""17"" endLine=""10"" endColumn=""23"" document=""1"" />
<entry offset=""0x59"" startLine=""11"" startColumn=""20"" endLine=""11"" endColumn=""34"" document=""1"" />
<entry offset=""0x5e"" startLine=""13"" startColumn=""20"" endLine=""13"" endColumn=""34"" document=""1"" />
<entry offset=""0x63"" startLine=""14"" startColumn=""17"" endLine=""14"" endColumn=""23"" document=""1"" />
<entry offset=""0x65"" startLine=""16"" startColumn=""17"" endLine=""16"" endColumn=""23"" document=""1"" />
<entry offset=""0x67"" startLine=""18"" startColumn=""17"" endLine=""18"" endColumn=""23"" document=""1"" />
<entry offset=""0x69"" startLine=""20"" startColumn=""9"" endLine=""20"" endColumn=""19"" document=""1"" />
<entry offset=""0x6c"" hidden=""true"" document=""1"" />
<entry offset=""0x94"" startLine=""23"" startColumn=""17"" endLine=""23"" endColumn=""23"" document=""1"" />
<entry offset=""0x96"" startLine=""25"" startColumn=""17"" endLine=""25"" endColumn=""23"" document=""1"" />
<entry offset=""0x98"" startLine=""27"" startColumn=""9"" endLine=""27"" endColumn=""19"" document=""1"" />
<entry offset=""0x9b"" hidden=""true"" document=""1"" />
<entry offset=""0xa7"" startLine=""30"" startColumn=""17"" endLine=""30"" endColumn=""23"" document=""1"" />
<entry offset=""0xa9"" startLine=""32"" startColumn=""5"" endLine=""32"" endColumn=""6"" document=""1"" />
</sequencePoints>
</method>
</methods>
......
......@@ -9,9 +9,9 @@
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public class ExpressionParsingTexts : ParsingTests
public class ExpressionParsingTests : ParsingTests
{
public ExpressionParsingTexts(ITestOutputHelper output) : base(output) { }
public ExpressionParsingTests(ITestOutputHelper output) : base(output) { }
protected override SyntaxTree ParseTree(string text, CSharpParseOptions options)
{
......
......@@ -9,9 +9,9 @@
namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
[CompilerTrait(CompilerFeature.Patterns)]
public class PatternParsingTexts : ParsingTests
public class PatternParsingTests : ParsingTests
{
public PatternParsingTexts(ITestOutputHelper output) : base(output)
public PatternParsingTests(ITestOutputHelper output) : base(output)
{
}
......
......@@ -309,14 +309,13 @@ static void Test(bool x)
Assert.Equal(flags, DkmClrCompilationResultFlags.PotentialSideEffect | DkmClrCompilationResultFlags.ReadOnlyResult);
testData.GetMethodData("<>x.<>m0<T>").VerifyIL(
@"{
// Code size 77 (0x4d)
// Code size 69 (0x45)
.maxstack 4
.locals init (object V_0, //y
bool V_1,
object V_2,
System.Guid V_3,
bool V_4,
object V_5)
object V_4)
IL_0000: ldtoken ""int""
IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_000a: ldstr ""z""
......@@ -326,24 +325,20 @@ .maxstack 4
IL_0018: ldnull
IL_0019: call ""void Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, string, System.Guid, byte[])""
IL_001e: ldarg.0
IL_001f: stloc.s V_5
IL_0021: ldstr ""z""
IL_0026: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_002b: ldloc.s V_5
IL_002d: isinst ""int""
IL_0032: ldnull
IL_0033: cgt.un
IL_0035: dup
IL_0036: stloc.s V_4
IL_0038: brtrue.s IL_003d
IL_003a: ldc.i4.0
IL_003b: br.s IL_0044
IL_003d: ldloc.s V_5
IL_003f: unbox.any ""int""
IL_0044: stind.i4
IL_0045: ldloc.s V_4
IL_0047: call ""void C.Test(bool)""
IL_004c: ret
IL_001f: dup
IL_0020: stloc.s V_4
IL_0022: isinst ""int""
IL_0027: brfalse.s IL_003e
IL_0029: ldstr ""z""
IL_002e: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_0033: ldloc.s V_4
IL_0035: unbox.any ""int""
IL_003a: stind.i4
IL_003b: ldc.i4.1
IL_003c: br.s IL_003f
IL_003e: ldc.i4.0
IL_003f: call ""void C.Test(bool)""
IL_0044: ret
}");
});
}
......@@ -1777,15 +1772,14 @@ static object Test(bool x)
testData = new CompilationTestData();
context.CompileAssignment("x", "Test(x is int i)", out error, testData);
testData.GetMethodData("<>x.<>m0<T>").VerifyIL(
@"{
// Code size 79 (0x4f)
@"{
// Code size 71 (0x47)
.maxstack 4
.locals init (object V_0, //y
bool V_1,
object V_2,
System.Guid V_3,
bool V_4,
object V_5)
object V_4)
IL_0000: ldtoken ""int""
IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_000a: ldstr ""i""
......@@ -1795,25 +1789,21 @@ .maxstack 4
IL_0018: ldnull
IL_0019: call ""void Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.CreateVariable(System.Type, string, System.Guid, byte[])""
IL_001e: ldarg.0
IL_001f: stloc.s V_5
IL_0021: ldstr ""i""
IL_0026: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_002b: ldloc.s V_5
IL_002d: isinst ""int""
IL_0032: ldnull
IL_0033: cgt.un
IL_0035: dup
IL_0036: stloc.s V_4
IL_0038: brtrue.s IL_003d
IL_003a: ldc.i4.0
IL_003b: br.s IL_0044
IL_003d: ldloc.s V_5
IL_003f: unbox.any ""int""
IL_0044: stind.i4
IL_0045: ldloc.s V_4
IL_0047: call ""object C.Test(bool)""
IL_004c: starg.s V_0
IL_004e: ret
IL_001f: dup
IL_0020: stloc.s V_4
IL_0022: isinst ""int""
IL_0027: brfalse.s IL_003e
IL_0029: ldstr ""i""
IL_002e: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_0033: ldloc.s V_4
IL_0035: unbox.any ""int""
IL_003a: stind.i4
IL_003b: ldc.i4.1
IL_003c: br.s IL_003f
IL_003e: ldc.i4.0
IL_003f: call ""object C.Test(bool)""
IL_0044: starg.s V_0
IL_0046: ret
}");
});
}
......@@ -2105,14 +2095,13 @@ static int Test(bool y)
Assert.Equal(flags, DkmClrCompilationResultFlags.PotentialSideEffect | DkmClrCompilationResultFlags.ReadOnlyResult);
testData.GetMethodData("<>x.<>m0<T>").VerifyIL(
@"{
// Code size 118 (0x76)
// Code size 110 (0x6e)
.maxstack 4
.locals init (object V_0, //y
bool V_1,
object V_2,
System.Guid V_3,
bool V_4,
object V_5)
object V_4)
IL_0000: ldtoken ""int""
IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_000a: ldstr ""z""
......@@ -2132,25 +2121,21 @@ .maxstack 4
IL_003c: ldstr ""z""
IL_0041: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_0046: ldarg.0
IL_0047: stloc.s V_5
IL_0049: ldstr ""i""
IL_004e: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_0053: ldloc.s V_5
IL_0055: isinst ""int""
IL_005a: ldnull
IL_005b: cgt.un
IL_005d: dup
IL_005e: stloc.s V_4
IL_0060: brtrue.s IL_0065
IL_0062: ldc.i4.0
IL_0063: br.s IL_006c
IL_0065: ldloc.s V_5
IL_0067: unbox.any ""int""
IL_0047: dup
IL_0048: stloc.s V_4
IL_004a: isinst ""int""
IL_004f: brfalse.s IL_0066
IL_0051: ldstr ""i""
IL_0056: call ""int Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetVariableAddress<int>(string)""
IL_005b: ldloc.s V_4
IL_005d: unbox.any ""int""
IL_0062: stind.i4
IL_0063: ldc.i4.1
IL_0064: br.s IL_0067
IL_0066: ldc.i4.0
IL_0067: call ""int C.Test(bool)""
IL_006c: stind.i4
IL_006d: ldloc.s V_4
IL_006f: call ""int C.Test(bool)""
IL_0074: stind.i4
IL_0075: ret
IL_006d: ret
}");
});
}
......
......@@ -591,12 +591,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""C C.<M>d__1.<>4__this""
IL_0006: ret
......@@ -609,12 +608,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.o""
IL_0006: ret
......@@ -627,12 +625,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""string C.<M>d__1.<a>5__4""
IL_0006: ret
......@@ -645,12 +642,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""string C.<M>d__1.<s>5__5""
IL_0006: ret
......@@ -674,12 +670,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""C C.<M>d__1.<>4__this""
IL_0006: ret
......@@ -692,12 +687,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""object C.<M>d__1.o""
IL_0006: ret
......@@ -710,12 +704,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""string C.<M>d__1.<a>5__4""
IL_0006: ret
......@@ -728,12 +721,11 @@ .maxstack 1
object V_1,
object V_2,
string V_3,
bool V_4,
object V_5,
System.Runtime.CompilerServices.TaskAwaiter<object> V_6,
C.<M>d__1 V_7,
System.Runtime.CompilerServices.TaskAwaiter<object> V_8,
System.Exception V_9)
object V_4,
System.Runtime.CompilerServices.TaskAwaiter<object> V_5,
C.<M>d__1 V_6,
System.Runtime.CompilerServices.TaskAwaiter<object> V_7,
System.Exception V_8)
IL_0000: ldarg.0
IL_0001: ldfld ""int C.<M>d__1.<s>5__6""
IL_0006: ret
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册