3 Jay Krell (jaykrell@microsoft.com)
5 Copyright 2018 Microsoft
6 Licensed under the MIT license. See LICENSE file in the project root for full license information.
8 http://www.mono-project.com/docs/advanced/runtime/docs/generic-sharing/
9 1. Non-generic non-static methods of reference types have access to the
10 RGCTX via the “this” argument (this->vtable->rgctx).
11 2. a. Non-generic static methods of reference types and b. non-generic methods
12 of value types need to be passed a pointer to the caller’s class’s VTable in the MONO_ARCH_RGCTX_REG register.
13 3. Generic methods need to be passed a pointer to the MRGCTX in the MONO_ARCH_RGCTX_REG register
18 using System.Runtime.CompilerServices;
19 using static System.Runtime.CompilerServices.MethodImplOptions;
23 [MethodImpl (NoInlining)]
24 static int check (long stack1, long stack2)
26 return (stack1 == stack2) ? 0 : 1;
29 [MethodImpl (NoInlining)]
30 public static int f1 (int counter, long initial_stack, long current_stack)
34 return f2 (counter - 1, initial_stack, (long)&local);
35 return check ((long)&local, current_stack);
38 [MethodImpl (NoInlining)]
39 public static int f2 (int counter, long initial_stack, long current_stack)
43 return f1 (counter - 1, initial_stack, (long)&local);
44 return check ((long)&local, current_stack);
50 [MethodImpl (NoInlining)]
51 public static void Main()
54 Environment.Exit(A<object>.f1 (100, (long)&stack, 0));
59 .assembly extern mscorlib { }
61 .assembly 'tailcall-rgctxa' { }
65 .method static int32 check (int64 stack1, int64 stack2) noinlining
78 .method static int32 f1 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
80 .locals init (int32 V_0)
91 tail. call int32 class A`1<!T>::f2 (int32, int64, int64)
99 tail. call int32 class A`1<!T>::check (int64, int64)
103 .method public hidebysig static int32 f2 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
105 .locals init (int32 V_0)
116 tail. call int32 class A`1<!T>::f1 (int32, int64, int64)
124 tail. call int32 class A`1<!T>::check (int64, int64)
128 .method instance void .ctor()
131 tail. call instance void [mscorlib]System.Object::.ctor ()
138 .method static int32 Main () noinlining
141 .locals init (int32 V_0)
148 tail. call int32 class A`1<object>::f1(int32, int64, int64)
152 .method instance void .ctor()
155 tail. call instance void [mscorlib]System.Object::.ctor()