[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / tests / tailcall-generic-cast-conservestack-il.il
blob105af5714062e27e6efd83e67c7cb8e49c2fe5ae
1 /*
2 Test tailcall-generic-cast-il.il.
4 Author:
5         Jay Krell (jaykrell@microsoft.com)
7 Copyright 2018 Microsoft
8 Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 This derived from nearby tailcall-generic-cast-cs.cs.
13 .assembly extern mscorlib { }
15 .assembly 'tailcall-generic-cast-conservestack-il' { }
17 .class public A { }
19 .class public B
21         .method public instance void .ctor ( )
22         {
23                 ldarg.0
24                 tail. call instance void [mscorlib]System.Object::.ctor ( )
25                 ret
26         }
29 .class public C
31         .field private static int32 i
33         .method public static void
34         check (int64 stack1, int64 stack2) noinlining
35         {
36                 ldsfld int32 C::i
37                 ldc.i4.1
38                 add
39                 stsfld int32 C::i
40                 //ldarg.0
41                 //brfalse.s IL_0010
42                 //ret
44 //IL_0010:
45                 ldarg.0
46                 ldarg.1
47                 beq.s IL_0037
49                 ldstr "{0} tailcall failure"
50                 ldsfld int32 C::i
51                 box [mscorlib]System.Int32
52                 call void [mscorlib]System.Console::WriteLine (string, object)
53                 ldc.i4.1
54                 tail. call void [mscorlib]System.Environment::Exit (int32)
55 IL_0037:
56                 ret
57         }
59         .method public static !!T
60         cast1<T> (object o, int32 counter, int64 stack) noinlining
61         {
62                 .locals init (int32 V_0)
64                 ldarg.1
65                 ldc.i4.0
66                 ble.s IL_0012
68                 ldarg.0
69                 ldarg.1
70                 ldc.i4.1
71                 sub
72                 ldloca.s V_0
73                 conv.u
74                 conv.u8
75                 tail. call !!0 C::cast1<!!0> (object, int32, int64)
76                 ret
78 IL_0012:
79                 ldloca.s V_0
80                 conv.u
81                 conv.u8
82                 ldarg.2
83                 call void C::check (int64, int64)
84                 ldarg.0
85                 unbox.any !!T
86                 ret
87         }
89         .method public static class B
90         cast2 (object o, int32 counter, int64 stack) noinlining
91         {
92                 .locals init (int32 V_0)
94                 ldarg.1
95                 ldc.i4.0
96                 ble.s IL_0012
98                 ldarg.0
99                 ldarg.1
100                 ldc.i4.1
101                 sub
102                 ldloca.s V_0
103                 conv.u
104                 conv.u8
105                 tail. call class B C::cast2 (object, int32, int64)
106                 ret
108 IL_0012:
109                 ldloca.s V_0
110                 conv.u
111                 conv.u8
112                 ldarg.2
113                 call void C::check (int64, int64)
114                 ldarg.0
115                 ldc.i4.s 100
116                 ldc.i4.0
117                 conv.i8
118                 tail. call !!0 C::cast1<class B> (object, int32, int64)
119                 ret
120         }
122         .method public static !!T
123         cast3<T> (object o, int32 counter, int64 stack) noinlining
124         {
125                 .locals init (int32 V_0)
127                 ldarg.1
128                 ldc.i4.0
129                 ble.s IL_0012
131                 ldarg.0
132                 ldarg.1
133                 ldc.i4.1
134                 sub
135                 ldloca.s V_0
136                 conv.u
137                 conv.u8
138                 tail. call !!0 C::cast3<!!0> (object, int32, int64)
139                 ret
141 IL_0012:
142                 ldloca.s V_0
143                 conv.u
144                 conv.u8
145                 ldarg.2
146                 call void C::check (int64, int64)
147                 ldarg.0
148                 ldc.i4.s 100
149                 ldc.i4.0
150                 conv.i8
151                 tail. call !!0 C::cast1<!!0> (object, int32, int64)
152                 ret
153         }
155         .method public static class B[]
156         cast4 (object o, int32 counter, int64 stack) noinlining
157         {
158                 .locals init (int32 V_0)
160                 ldarg.1
161                 ldc.i4.0
162                 ble.s IL_0012
164                 ldarg.0
165                 ldarg.1
166                 ldc.i4.1
167                 sub
168                 ldloca.s V_0
169                 conv.u
170                 conv.u8
171                 tail. call class B[] C::cast4 (object, int32, int64)
172                 ret
174 IL_0012:
175                 ldloca.s V_0
176                 conv.u
177                 conv.u8
178                 ldarg.2
179                 call void C::check (int64, int64)
180                 ldarg.0
181                 ldc.i4.s 100
182                 ldc.i4.0
183                 conv.i8
184                 tail. call !!0 C::cast1<class B[]> (object, int32, int64)
185                 ret
186         }
188         .method public static !!T[]
189         cast5<T> (object o, int32 counter, int64 stack) noinlining
190         {
191                 .locals init (int32 V_0)
193                 ldarg.1
194                 ldc.i4.0
195                 ble.s IL_0012
197                 ldarg.0
198                 ldarg.1
199                 ldc.i4.1
200                 sub
201                 ldloca.s V_0
202                 conv.u
203                 conv.u8
204                 tail. call !!0[] C::cast5<!!0> (object, int32, int64)
205                 ret
207 IL_0012:
208                 ldloca.s V_0
209                 conv.u
210                 conv.u8
211                 ldarg.2
212                 call void C::check (int64, int64)
213                 ldarg.0
214                 ldc.i4.s 100
215                 ldc.i4.0
216                 conv.i8
217                 tail. call !!0 C::cast1<!!0[]> (object, int32, int64)
218                 ret
219         }
222 .class public D`1<T1>
224         .method public static void
225         check (int64 stack1, int64 stack2) noinlining
226         {
227                 ldarg.0
228                 ldarg.1
229                 tail. call void C::check (int64, int64)
230                 ret
231         }
233         .method public static !!T
234         cast1<T> (object o, int32 counter, int64 stack) noinlining
235         {
236                 .locals init (int32 V_0)
238                 ldarg.1
239                 ldc.i4.0
240                 ble.s IL_0012
242                 ldarg.0
243                 ldarg.1
244                 ldc.i4.1
245                 sub
246                 ldloca.s V_0
247                 conv.u
248                 conv.u8
249                 tail. call !!0 class D`1<!T1>::cast1<!!0> (object, int32, int64)
250                 ret
252 IL_0012:
253                 ldloca.s V_0
254                 conv.u
255                 conv.u8
256                 ldarg.2
257                 call void class D`1<!T1>::check (int64, int64)
258                 ldarg.0
259                 unbox.any !!T
260                 ret
261         }
263         .method public static class B
264         cast2 (object o, int32 counter, int64 stack) noinlining
265         {
266                 .locals init (int32 V_0)
268                 ldarg.1
269                 ldc.i4.0
270                 ble.s IL_0012
272                 ldarg.0
273                 ldarg.1
274                 ldc.i4.1
275                 sub
276                 ldloca.s V_0
277                 conv.u
278                 conv.u8
279                 tail. call class B class D`1<!T1>::cast2 (object, int32, int64)
280                 ret
282 IL_0012:
283                 ldloca.s V_0
284                 conv.u
285                 conv.u8
286                 ldarg.2
287                 call void class D`1<!T1>::check (int64, int64)
288                 ldarg.0
289                 ldc.i4.s 100
290                 ldc.i4.0
291                 conv.i8
292                 tail. call !!0 class D`1<!T1>::cast1<class B> (object, int32, int64)
293                 ret
294         }
296         .method public static !!T
297         cast3<T> (object o, int32 counter, int64 stack) noinlining
298         {
299                 .locals init (int32 V_0)
301                 ldarg.1
302                 ldc.i4.0
303                 ble.s IL_0012
305                 ldarg.0
306                 ldarg.1
307                 ldc.i4.1
308                 sub
309                 ldloca.s V_0
310                 conv.u
311                 conv.u8
312                 tail. call !!0 class D`1<!T1>::cast3<!!0> (object, int32, int64)
313                 ret
315 IL_0012:
316                 ldloca.s V_0
317                 conv.u
318                 conv.u8
319                 ldarg.2
320                 call void class D`1<!T1>::check (int64, int64)
321                 ldarg.0
322                 ldc.i4.s 100
323                 ldc.i4.0
324                 conv.i8
325                 tail. call !!0 class D`1<!T1>::cast1<!!0> (object, int32, int64)
326                 ret
327         }
329         .method public static class B[]
330         cast4 (object o, int32 counter, int64 stack) noinlining
331         {
332                 .locals init (int32 V_0)
334                 ldarg.1
335                 ldc.i4.0
336                 ble.s IL_0012
338                 ldarg.0
339                 ldarg.1
340                 ldc.i4.1
341                 sub
342                 ldloca.s V_0
343                 conv.u
344                 conv.u8
345                 tail. call class B[] class D`1<!T1>::cast4 (object, int32, int64)
346                 ret
348 IL_0012:
349                 ldloca.s V_0
350                 conv.u
351                 conv.u8
352                 ldarg.2
353                 call void class D`1<!T1>::check (int64, int64)
354                 ldarg.0
355                 ldc.i4.s 100
356                 ldc.i4.0
357                 conv.i8
358                 tail. call !!0 class D`1<!T1>::cast1<class B[]> (object, int32, int64)
359                 ret
360         }
362         .method public static !!T[]
363         cast5<T> (object o, int32 counter, int64 stack) noinlining
364         {
365                 .locals init (int32 V_0)
367                 ldarg.1
368                 ldc.i4.0
369                 ble.s IL_0012
371                 ldarg.0
372                 ldarg.1
373                 ldc.i4.1
374                 sub
375                 ldloca.s V_0
376                 conv.u
377                 conv.u8
378                 tail. call !!0[] class D`1<!T1>::cast5<!!0> (object, int32, int64)
379                 ret
381 IL_0012:
382                 ldloca.s V_0
383                 conv.u
384                 conv.u8
385                 ldarg.2
386                 call void class D`1<!T1>::check (int64, int64)
387                 ldarg.0
388                 ldc.i4.s 100
389                 ldc.i4.0
390                 conv.i8
391                 tail. call !!0 class D`1<!T1>::cast1<!!0[]> (object, int32, int64)
392                 ret
393         }
395         .method public static !T1
396         cast6 (object o, int32 counter, int64 stack) noinlining
397         {
398                 .locals init (int32 V_0)
400                 ldarg.1
401                 ldc.i4.0
402                 ble.s IL_0012
404                 ldarg.0
405                 ldarg.1
406                 ldc.i4.1
407                 sub
408                 ldloca.s V_0
409                 conv.u
410                 conv.u8
411                 tail. call !0 class D`1<!T1>::cast6 (object, int32, int64)
412                 ret
414 IL_0012:
415                 ldloca.s V_0
416                 conv.u
417                 conv.u8
418                 ldarg.2
419                 call void class D`1<!T1>::check (int64, int64)
420                 ldarg.0
421                 ldc.i4.s 100
422                 ldc.i4.0
423                 conv.i8
424                 tail. call !!0 class D`1<!T1>::cast1<!0> (object, int32, int64)
425                 ret
426         }
428         .method public static !T1
429         cast7<T> (object o, int32 counter, int64 stack) noinlining
430         {
431                 .locals init (int32 V_0)
433                 ldarg.1
434                 ldc.i4.0
435                 ble.s IL_0012
437                 ldarg.0
438                 ldarg.1
439                 ldc.i4.1
440                 sub
441                 ldloca.s V_0
442                 conv.u
443                 conv.u8
444                 tail. call !0 class D`1<!T1>::cast7<!!0> (object, int32, int64)
445                 ret
447 IL_0012:
448                 ldloca.s V_0
449                 conv.u
450                 conv.u8
451                 ldarg.2
452                 call void class D`1<!T1>::check (int64, int64)
453                 ldarg.0
454                 ldc.i4.s 100
455                 ldc.i4.0
456                 conv.i8
457                 tail. call !!0 class D`1<!T1>::cast1<!0> (object, int32, int64)
458                 ret
459         }
461         .method public static !T1[]
462         cast8 (object o, int32 counter, int64 stack) noinlining
463         {
464                 .locals init (int32 V_0)
466                 ldarg.1
467                 ldc.i4.0
468                 ble.s IL_0012
470                 ldarg.0
471                 ldarg.1
472                 ldc.i4.1
473                 sub
474                 ldloca.s V_0
475                 conv.u
476                 conv.u8
477                 tail. call !0[] class D`1<!T1>::cast8 (object, int32, int64)
478                 ret
480 IL_0012:
481                 ldloca.s V_0
482                 conv.u
483                 conv.u8
484                 ldarg.2
485                 call void class D`1<!T1>::check (int64, int64)
486                 ldarg.0
487                 ldc.i4.s 100
488                 ldc.i4.0
489                 conv.i8
490                 tail. call !!0 class D`1<!T1>::cast3<!0[]> (object, int32, int64)
491                 ret
492         }
494         .method public static !T1[]
495         cast9<T> (object o, int32 counter, int64 stack) noinlining
496         {
497                 .locals init (int32 V_0)
499                 ldarg.1
500                 ldc.i4.0
501                 ble.s IL_0012
503                 ldarg.0
504                 ldarg.1
505                 ldc.i4.1
506                 sub
507                 ldloca.s V_0
508                 conv.u
509                 conv.u8
510                 tail. call !0[] class D`1<!T1>::cast9<!!0> (object, int32, int64)
511                 ret
513 IL_0012:
514                 ldloca.s V_0
515                 conv.u
516                 conv.u8
517                 ldarg.2
518                 call void class D`1<!T1>::check (int64, int64)
519                 ldarg.0
520                 ldc.i4.s 100
521                 ldc.i4.0
522                 conv.i8
523                 tail. call !!0 class D`1<!T1>::cast3<!0[]> (object, int32, int64)
524                 ret
525         }
527         .method public
528         instance void .ctor ( )
529         {
530                 ldarg.0
531                 tail. call instance void [mscorlib]System.Object::.ctor ( )
532                 ret
533         }
536 .class public E
538         .field private static int32 i
540         .method private static void
541         print (object o) noinlining
542         {
543                 ldsfld int32 E::i
544                 ldc.i4.1
545                 add
546                 stsfld int32 E::i
547                 ret
548         }
550         .method public static void
551         Main (string[] args) noinlining
552         {
553                 .entrypoint
555                 newobj instance void B::.ctor ( )
556                 ldc.i4.s 100
557                 ldc.i4.0
558                 conv.i8
559                 call class B C::cast2 (object, int32, int64)
560                 call void E::print (object)
562                 newobj instance void B::.ctor ( )
563                 ldc.i4.s 100
564                 ldc.i4.0
565                 conv.i8
566                 call !!0 C::cast3<class B> (object, int32, int64)
567                 call void E::print (object)
569                 ldc.i4.1
570                 newarr B
571                 ldc.i4.s 100
572                 ldc.i4.0
573                 conv.i8
574                 call !!0 C::cast3<class B[]> (object, int32, int64)
575                 call void E::print (object)
577                 ldc.i4.1
578                 newarr B
579                 ldc.i4.s 100
580                 ldc.i4.0
581                 conv.i8
582                 call class B[] C::cast4 (object, int32, int64)
583                 call void E::print (object)
585                 ldc.i4.1
586                 newarr B
587                 ldc.i4.s 100
588                 ldc.i4.0
589                 conv.i8
590                 call !!0[] C::cast5<class B> (object, int32, int64)
591                 call void E::print (object)
593                 newobj instance void B::.ctor ( )
594                 ldc.i4.s 100
595                 ldc.i4.0
596                 conv.i8
597                 call class B class D`1<class A>::cast2 (object, int32, int64)
598                 call void E::print (object)
600                 newobj instance void B::.ctor ( )
601                 ldc.i4.s 100
602                 ldc.i4.0
603                 conv.i8
604                 call !!0 class D`1<class A>::cast3<class B> (object, int32, int64)
605                 call void E::print (object)
607                 ldc.i4.1
608                 newarr B
609                 ldc.i4.s 100
610                 ldc.i4.0
611                 conv.i8
612                 call !!0 class D`1<class A>::cast3<class B[]> (object, int32, int64)
613                 call void E::print (object)
615                 ldc.i4.1
616                 newarr B
617                 ldc.i4.s 100
618                 ldc.i4.0
619                 conv.i8
620                 call class B[] class D`1<class A>::cast4 (object, int32, int64)
621                 call void E::print (object)
623                 ldc.i4.1
624                 newarr B
625                 ldc.i4.s 100
626                 ldc.i4.0
627                 conv.i8
628                 call !!0[] class D`1<class A>::cast5<class B> (object, int32, int64)
629                 call void E::print (object)
631                 newobj instance void B::.ctor ( )
632                 ldc.i4.s 100
633                 ldc.i4.0
634                 conv.i8
635                 call !0 class D`1<class B>::cast6 (object, int32, int64)
636                 call void E::print (object)
638                 newobj instance void B::.ctor ( )
639                 ldc.i4.s 100
640                 ldc.i4.0
641                 conv.i8
642                 call !0 class D`1<class B>::cast7<class A> (object, int32, int64)
643                 call void E::print (object)
645                 ldc.i4.1
646                 newarr B
647                 ldc.i4.s 100
648                 ldc.i4.0
649                 conv.i8
650                 call !0 class D`1<class B[]>::cast7<class A[]> (object, int32, int64)
651                 call void E::print (object)
653                 ldc.i4.1
654                 newarr B
655                 ldc.i4.s 100
656                 ldc.i4.0
657                 conv.i8
658                 call !0[] class D`1<class B>::cast8 (object, int32, int64)
659                 call void E::print (object)
661                 ldc.i4.1
662                 newarr B
663                 ldc.i4.s 100
664                 ldc.i4.0
665                 conv.i8
667                 call !0[] class D`1<class B>::cast9<class A> (object, int32, int64)
668                 call void E::print (object)
670                 ret
671         }