2 using System
.Collections
.Generic
;
3 using System
.Reflection
;
4 using System
.Runtime
.InteropServices
;
5 using System
.Runtime
.CompilerServices
;
6 using System
.Diagnostics
;
9 * Regression tests for the mixed-mode execution.
10 * Run with --interp=jit=JitClass
23 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
24 public static void entry_void_0 () {
27 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
28 public static int entry_int_int (int i
) {
32 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
33 public int entry_int_this_int (int i
) {
37 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
38 public static string entry_string_string (string s1
, string s2
) {
42 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
43 public static AStruct
entry_struct_struct (AStruct l
) {
47 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
48 public static List
<string> entry_ginst_ginst (List
<string> l
) {
52 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
53 public static GStruct
<string> entry_ginst_ginst_vtype (GStruct
<string> l
) {
57 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
58 public static void entry_void_byref_int (ref int i
) {
62 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
63 public static int entry_8_int_args (int i1
, int i2
, int i3
, int i4
, int i5
, int i6
, int i7
, int i8
) {
64 return i1
+ i2
+ i3
+ i4
+ i5
+ i6
+ i7
+ i8
;
67 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
68 public static int entry_9_int_args (int i1
, int i2
, int i3
, int i4
, int i5
, int i6
, int i7
, int i8
, int i9
) {
69 return i1
+ i2
+ i3
+ i4
+ i5
+ i6
+ i7
+ i8
+ i9
;
72 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
73 public static IntPtr
entry_intptr_intptr (IntPtr i
) {
77 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
78 public static int entry_deep_generic_vt (int i
, decimal? b
) {
83 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
84 public static StackTrace
get_stacktrace_interp () {
85 var o
= new object ();
86 return new StackTrace (true);
89 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
90 public static StackTrace
get_stacktrace_interp2 () {
91 return JitClass
.get_stacktrace_jit ();
94 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
95 public static void throw_ex () {
100 /* The methods in this class will always be JITted */
103 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
104 public static int entry () {
105 InterpClass
.entry_void_0 ();
106 InterpClass
.entry_void_0 ();
107 int res
= InterpClass
.entry_int_int (1);
110 var c
= new InterpClass ();
111 res
= c
.entry_int_this_int (1);
114 var s
= InterpClass
.entry_string_string ("A", "B");
117 var astruct
= new AStruct () { i = 1 }
;
118 var astruct2
= InterpClass
.entry_struct_struct (astruct
);
121 var l
= new List
<string> ();
122 var l2
= InterpClass
.entry_ginst_ginst (l
);
125 var gstruct
= new GStruct
<string> () { i = 1 }
;
126 var gstruct2
= InterpClass
.entry_ginst_ginst_vtype (gstruct
);
130 InterpClass
.entry_void_byref_int (ref val
);
133 res
= InterpClass
.entry_8_int_args (1, 2, 3, 4, 5, 6, 7, 8);
136 res
= InterpClass
.entry_9_int_args (1, 2, 3, 4, 5, 6, 7, 8, 9);
139 var ptr
= new IntPtr (32);
140 var ptr2
= InterpClass
.entry_intptr_intptr (ptr
);
143 var edgvt_ret
= InterpClass
.entry_deep_generic_vt (1337, 2m
);
144 if (edgvt_ret
!= 1337)
149 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
150 public static AStruct
exit_vtype (AStruct s
) {
154 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
155 public static List
<string> exit_ginst (List
<string> l
) {
159 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
160 public static GStruct
<string> exit_ginst_vtype (GStruct
<string> l
) {
164 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
165 public static void exit_byref (ref int i
) {
169 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
170 public static void throw_ex () {
171 throw new Exception ();
174 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
175 public static StackTrace
get_stacktrace_jit () {
176 return InterpClass
.get_stacktrace_interp ();
179 [MethodImplAttribute (MethodImplOptions
.NoInlining
)]
180 public static StackTrace
get_stacktrace_jit2 () {
181 return InterpClass
.get_stacktrace_interp2 ();
193 public static int Main (string[] args
) {
194 return TestDriver
.RunTests (typeof (Tests
), args
);
198 public static int test_0_entry () {
199 // This does an interp->jit transition
200 return JitClass
.entry ();
203 public static int test_0_exit () {
204 var astruct
= new AStruct () { i = 1}
;
205 var astruct2
= JitClass
.exit_vtype (astruct
);
208 var ginst
= new List
<string> ();
209 var ginst2
= JitClass
.exit_ginst (ginst
);
212 var gstruct
= new GStruct
<string> () { i = 1 }
;
213 var gstruct2
= JitClass
.exit_ginst_vtype (gstruct
);
217 JitClass
.exit_byref (ref anint
);
223 public static int test_0_throw () {
224 // Throw an exception from jitted code, catch it in interpreted code
226 JitClass
.throw_ex ();
233 public static int test_0_throw_child () {
235 InterpClass
.throw_ex ();
242 static bool finally_called
;
244 public static void call_finally () {
246 JitClass
.throw_ex ();
248 finally_called
= true;
252 public static int test_0_eh2 () {
253 finally_called
= false;
255 // Throw an exception from jitted code, execute finally in interpreted code
266 [Category ("!WASM")] //Stack traces / EH are super broken on WASM + Interpreter
267 public static int test_0_stack_traces () {
269 // Get a stacktrace for an interp->jit->interp call stack
271 StackTrace st
= JitClass
.get_stacktrace_jit2 ();
273 var frame0
= st
.GetFrame (0);
274 var frame1
= st
.GetFrame (1);
275 var frame2
= st
.GetFrame (2);
276 var frame3
= st
.GetFrame (3);
277 var frame4
= st
.GetFrame (4);
279 if (frame0
.GetMethod ().Name
!= "get_stacktrace_interp")
282 if (frame1
.GetMethod ().Name
!= "get_stacktrace_jit")
285 if (frame2
.GetMethod ().Name
!= "get_stacktrace_interp2")
288 if (frame3
.GetMethod ().Name
!= "get_stacktrace_jit2")
291 if (frame4
.GetMethod ().Name
!= "test_0_stack_traces")
296 // Finally exception will be thrown from this stack : interp -> jit -> eh -> interp
297 // Test that we propagate the finally exception over the jitted frames
298 public static int test_0_finex () {
299 bool called_finally
= false;
302 JitClass
.throw_ex ();
305 called_finally
= true;
306 throw new Exception ("E2");
308 } catch (Exception
) {