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
16 It uses static to avoid another problem.
19 using System.Runtime.CompilerServices;
20 using static System.Runtime.CompilerServices.MethodImplOptions;
26 a = b = c = d = e = f = g = h = 1;
28 public int a, b, c, d, e, f, g, h;
30 [MethodImpl (NoInlining)]
31 static int check (long stack1, long stack2)
33 return (stack1 == stack2) ? 0 : 1;
36 [MethodImpl (NoInlining)]
37 static public int f1 (int counter, long initial_stack, long current_stack)
40 object a = new T[101];
42 return f2 (counter - 1, initial_stack, (long)&local);
43 return check ((long)&local, current_stack);
46 [MethodImpl (NoInlining)]
47 static public int f2 (int counter, long initial_stack, long current_stack)
50 object a = new T[101];
52 return f1 (counter - 1, initial_stack, (long)&local);
53 return check ((long)&local, current_stack);
59 [MethodImpl (NoInlining)]
60 public static void Main()
63 Environment.Exit(A<int>().f1 (100, (long)&stack, 0));
68 .assembly extern mscorlib { }
70 .assembly 'tailcall-rgctxb' { }
74 // Remove this change the test a lot and make it pass.
75 extends [mscorlib]System.ValueType
78 .method static int32 check (int64 stack1, int64 stack2) noinlining
92 .method static int32 f1 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
107 call int32 valuetype A`1<!T>::f2 (int32, int64, int64)
114 call int32 valuetype A`1<!T>::check (int64, int64)
118 .method static int32 f2 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
132 call int32 valuetype A`1<!T>::f1 (int32, int64, int64)
139 call int32 valuetype A`1<!T>::check (int64, int64)
144 .class B extends [mscorlib]System.Object
147 .method static int32 Main() noinlining
156 call int32 valuetype A`1<int32>::f1 (int32, int64, int64)