Apply changes from https://github.com/dotnet/runtime/commit/eb1756e97d23df13bc6fe798e...
[mono-project.git] / mono / tests / invalid-isbyreflike.il
blob794f8c96557da9224e09aa7ad644f68ce4e8c24b
1 // This is a test that attempts to use BOX on an IsByRefLike struct.
3 .assembly extern mscorlib
5   .ver 4:0:0:0
6   .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
8 .assembly 'invalid-isbyreflike'
10   .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::'.ctor'(int32) =  (01 00 08 00 00 00 00 00 ) // ........
12   .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() =  (
13                 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
14                 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
16   .custom instance void class [mscorlib]System.Diagnostics.DebuggableAttribute::'.ctor'(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) =  (01 00 07 01 00 00 00 00 ) // ........
18   .hash algorithm 0x00008004
19   .ver  0:0:0:0
21 .module 'invalid-isbyreflike.exe'
24   .class public sequential ansi sealed beforefieldinit X
25         extends [mscorlib]System.ValueType
26   {
27     .field  public  int32 i
29   } // end of class X
31   .class public sequential ansi sealed beforefieldinit R
32         extends [mscorlib]System.ValueType
33   {
34     .custom instance void class [mscorlib]System.Runtime.CompilerServices.IsByRefLikeAttribute::'.ctor'() =  (01 00 00 00 ) // ....
36     .custom instance void class [mscorlib]System.ObsoleteAttribute::'.ctor'(string, bool) =  (
37                 01 00 52 54 79 70 65 73 20 77 69 74 68 20 65 6D   // ..RTypes with em
38                 62 65 64 64 65 64 20 72 65 66 65 72 65 6E 63 65   // bedded reference
39                 73 20 61 72 65 20 6E 6F 74 20 73 75 70 70 6F 72   // s are not suppor
40                 74 65 64 20 69 6E 20 74 68 69 73 20 76 65 72 73   // ted in this vers
41                 69 6F 6E 20 6F 66 20 79 6F 75 72 20 63 6F 6D 70   // ion of your comp
42                 69 6C 65 72 2E 01 00 00                         ) // iler....
44     .field  public  int32 i
46   } // end of class R
48   .class public auto ansi beforefieldinit G`1<T>
49        extends [mscorlib]System.Object
50   {
51     .method public hidebysig specialname rtspecialname 
52           instance void  .ctor() cil managed
53     {
54       // Code size       8 (0x8)
55       .maxstack  8
56       IL_0000:  ldarg.0
57       IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
58       IL_0006:  nop
59       IL_0007:  ret
60     } // end of method G`1::.ctor
61   } // end of class G`1
63   .class public auto ansi beforefieldinit C
64         extends [mscorlib]System.Object
65   {
67   .method public hidebysig static int32  Main() cil managed
68   {
69     .entrypoint
70     // Code size       171 (0xab)
71     .maxstack  2
72     .locals init (bool V_0,
73              bool V_1,
74              int32 V_2,
75              bool V_3,
76              bool V_4)
77     IL_0000:  nop
78     IL_0001:  ldc.i4.0
79     IL_0002:  stloc.0
80     .try
81     {
82       IL_0003:  nop
83       IL_0004:  call       void C::BadMethod1()
84       IL_0009:  nop
85       IL_000a:  nop
86       IL_000b:  leave.s    IL_001f
88     }  // end .try
89     catch [mscorlib]System.BadImageFormatException 
90     {
91       IL_000d:  pop
92       IL_000e:  nop
93       IL_000f:  ldstr      "good - BadImageFormatException for BadMethod1"
94       IL_0014:  call       void [mscorlib]System.Console::WriteLine(string)
95       IL_0019:  nop
96       IL_001a:  ldc.i4.1
97       IL_001b:  stloc.0
98       IL_001c:  nop
99       IL_001d:  leave.s    IL_001f
101     }  // end handler
102     IL_001f:  ldloc.0
103     IL_0020:  ldc.i4.0
104     IL_0021:  ceq
105     IL_0023:  stloc.1
106     IL_0024:  ldloc.1
107     IL_0025:  brfalse.s  IL_0037
109     IL_0027:  nop
110     IL_0028:  ldstr      "bad - no exception when JITing BadMethod1"
111     IL_002d:  call       void [mscorlib]System.Console::WriteLine(string)
112     IL_0032:  nop
113     IL_0033:  ldc.i4.1
114     IL_0034:  stloc.2
115     IL_0035:  br.s       IL_00a9
117     IL_0037:  ldc.i4.0
118     IL_0038:  stloc.0
119     .try
120     {
121       IL_0039:  nop
122       IL_003a:  call       void C::BadMethod2()
123       IL_003f:  nop
124       IL_0040:  nop
125       IL_0041:  leave.s    IL_0055
127     }  // end .try
128     catch [mscorlib]System.TypeLoadException
129     {
130       IL_0043:  pop
131       IL_0044:  nop
132       IL_0045:  ldstr      "good - TypeLoadException for BadMethod2"
133       IL_004a:  call       void [mscorlib]System.Console::WriteLine(string)
134       IL_004f:  nop
135       IL_0050:  ldc.i4.1
136       IL_0051:  stloc.0
137       IL_0052:  nop
138       IL_0053:  leave.s    IL_0055
140     }  // end handler
141     IL_0055:  ldloc.0
142     IL_0056:  ldc.i4.0
143     IL_0057:  ceq
144     IL_0059:  stloc.3
145     IL_005a:  ldloc.3
146     IL_005b:  brfalse.s  IL_006d
148     IL_005d:  nop
149     IL_005e:  ldstr      "bad - no exception when JITing BadMethod2"
150     IL_0063:  call       void [mscorlib]System.Console::WriteLine(string)
151     IL_0068:  nop
152     IL_0069:  ldc.i4.2
153     IL_006a:  stloc.2
154     IL_006b:  br.s       IL_00a9
156     IL_006d:  ldc.i4.0
157     IL_006e:  stloc.0
158     .try
159     {
160       IL_006f:  nop
161       IL_0070:  call       void C::BadMethod3()
162       IL_0075:  nop
163       IL_0076:  nop
164       IL_0077:  leave.s    IL_008b
166     }  // end .try
167     catch [mscorlib]System.BadImageFormatException 
168     {
169       IL_0079:  pop
170       IL_007a:  nop
171       IL_007b:  ldstr      "good - BadImageFormatException for BadMethod3"
172       IL_0080:  call       void [mscorlib]System.Console::WriteLine(string)
173       IL_0085:  nop
174       IL_0086:  ldc.i4.1
175       IL_0087:  stloc.0
176       IL_0088:  nop
177       IL_0089:  leave.s    IL_008b
179     }  // end handler
180     IL_008b:  ldloc.0
181     IL_008c:  ldc.i4.0
182     IL_008d:  ceq
183     IL_008f:  stloc.s    V_4
184     IL_0091:  ldloc.s    V_4
185     IL_0093:  brfalse.s  IL_00a5
187     IL_0095:  nop
188     IL_0096:  ldstr      "bad - no exception when JITing BadMethod3"
189     IL_009b:  call       void [mscorlib]System.Console::WriteLine(string)
190     IL_00a0:  nop
191     IL_00a1:  ldc.i4.3
192     IL_00a2:  stloc.2
193     IL_00a3:  br.s       IL_00a9
195     IL_00a5:  ldc.i4.0
196     IL_00a6:  stloc.2
197     IL_00a7:  br.s       IL_00a9
199     IL_00a9:  ldloc.2
200     IL_00aa:  ret
201   } // end of method C::Main
203     // method line 2
204     // noinling is important - we want the JIT to fail on this method, not on Main().
205     .method public static hidebysig 
206            default void BadMethod1 ()  cil managed noinlining 
207     {
208         // Method begins at RVA 0x209c
209         // Code size 48 (0x30)
210         .maxstack 2
211         .locals init (
212                 valuetype X     V_0,
213                 valuetype R     V_1,
214                 object  V_2,
215                 valuetype X     V_3,
216                 valuetype R     V_4)
217         IL_0000:  nop 
218         IL_0001:  ldloca.s 3
219         IL_0003:  initobj X
220         IL_0009:  ldloca.s 3
221         IL_000b:  ldc.i4.s 0x0a
222         IL_000d:  stfld int32 X::i
223         IL_0012:  ldloc.3 
224         IL_0013:  stloc.0 
225         IL_0014:  ldloca.s 4
226         IL_0016:  initobj R
227         IL_001c:  ldloca.s 4
228         IL_001e:  ldc.i4.s 0x2a
229         IL_0020:  stfld int32 R::i
230         IL_0025:  ldloc.s 4
231         IL_0027:  stloc.1 
232         IL_0028:  ldloc.1 
233         IL_0029:  box R    // box of an IsByRefLike type is not allowed
234         IL_002e:  stloc.2 
235         IL_002f:  ret 
236     } // end of method C::BadMethod1
238   .method public hidebysig static void  BadMethod2() cil managed noinlining
239   {
240     // Code size       8 (0x8)
241     .maxstack  1
242     .locals init (class G`1<valuetype R> V_0)
243     IL_0000:  nop
244     IL_0001:  newobj     instance void class G`1<valuetype R>::.ctor()
245     IL_0006:  stloc.0
246     IL_0007:  ret
247   } // end of method C::BadMethod2
249   .method public hidebysig static void  BadMethod3() cil managed noinlining
250   {
251     // Code size       8 (0x8)
252     .maxstack  8
253     IL_0000:  nop
254     IL_0001:  call       void C::GM<valuetype R>()
255     IL_0006:  nop
256     IL_0007:  ret
257   } // end of method C::BadMethod3
259   .method public hidebysig static void  GM<T>() cil managed
260   {
261     // Code size       2 (0x2)
262     .maxstack  8
263     IL_0000:  nop
264     IL_0001:  ret
265   } // end of method C::GM
267     // method line 3
268     .method public hidebysig specialname rtspecialname 
269            instance default void '.ctor' ()  cil managed 
270     {
271         // Method begins at RVA 0x20d8
272         // Code size 8 (0x8)
273         .maxstack 8
274         IL_0000:  ldarg.0 
275         IL_0001:  call instance void object::'.ctor'()
276         IL_0006:  nop 
277         IL_0007:  ret 
278     } // end of method C::.ctor
280   } // end of class C