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 StackTrace get_stacktrace_interp () {
79 var o = new object ();
80 return new StackTrace (true);
83 [MethodImplAttribute (MethodImplOptions.NoInlining)]
84 public static void throw_ex () {
89 /* The methods in this class will always be JITted */
92 [MethodImplAttribute (MethodImplOptions.NoInlining)]
93 public static int entry () {
94 InterpClass.entry_void_0 ();
95 InterpClass.entry_void_0 ();
96 int res = InterpClass.entry_int_int (1);
99 var c = new InterpClass ();
100 res = c.entry_int_this_int (1);
103 var s = InterpClass.entry_string_string ("A", "B");
106 var astruct = new AStruct () { i = 1 };
107 var astruct2 = InterpClass.entry_struct_struct (astruct);
110 var l = new List<string> ();
111 var l2 = InterpClass.entry_ginst_ginst (l);
114 var gstruct = new GStruct<string> () { i = 1 };
115 var gstruct2 = InterpClass.entry_ginst_ginst_vtype (gstruct);
119 InterpClass.entry_void_byref_int (ref val);
122 res = InterpClass.entry_8_int_args (1, 2, 3, 4, 5, 6, 7, 8);
125 res = InterpClass.entry_9_int_args (1, 2, 3, 4, 5, 6, 7, 8, 9);
128 var ptr = new IntPtr (32);
129 var ptr2 = InterpClass.entry_intptr_intptr (ptr);
135 [MethodImplAttribute (MethodImplOptions.NoInlining)]
136 public static AStruct exit_vtype (AStruct s) {
140 [MethodImplAttribute (MethodImplOptions.NoInlining)]
141 public static List<string> exit_ginst (List<string> l) {
145 [MethodImplAttribute (MethodImplOptions.NoInlining)]
146 public static GStruct<string> exit_ginst_vtype (GStruct<string> l) {
150 [MethodImplAttribute (MethodImplOptions.NoInlining)]
151 public static void exit_byref (ref int i) {
155 [MethodImplAttribute (MethodImplOptions.NoInlining)]
156 public static void throw_ex () {
157 throw new Exception ();
160 [MethodImplAttribute (MethodImplOptions.NoInlining)]
161 public static StackTrace get_stacktrace_jit () {
162 return InterpClass.get_stacktrace_interp ();
174 public static int Main (string[] args) {
175 return TestDriver.RunTests (typeof (Tests), args);
179 public static int test_0_entry () {
180 // This does an interp->jit transition
181 return JitClass.entry ();
184 public static int test_0_exit () {
185 var astruct = new AStruct () { i = 1};
186 var astruct2 = JitClass.exit_vtype (astruct);
189 var ginst = new List<string> ();
190 var ginst2 = JitClass.exit_ginst (ginst);
193 var gstruct = new GStruct<string> () { i = 1 };
194 var gstruct2 = JitClass.exit_ginst_vtype (gstruct);
198 JitClass.exit_byref (ref anint);
204 public static int test_0_throw () {
205 // Throw an exception from jitted code, catch it in interpreted code
207 JitClass.throw_ex ();
214 public static int test_0_throw_child () {
216 InterpClass.throw_ex ();
223 static bool finally_called;
225 public static void call_finally () {
227 JitClass.throw_ex ();
229 finally_called = true;
233 public static int test_0_eh2 () {
234 finally_called = false;
236 // Throw an exception from jitted code, execute finally in interpreted code
247 public static int test_0_stack_traces () {
249 // Get a stacktrace for an interp->jit->interp call stack
251 StackTrace st = JitClass.get_stacktrace_jit ();
252 var frame = st.GetFrame (0);
253 if (frame.GetMethod ().Name != "get_stacktrace_interp")
255 frame = st.GetFrame (1);
256 if (frame.GetMethod ().Name != "get_stacktrace_jit")
258 frame = st.GetFrame (2);
259 if (frame.GetMethod ().Name != "test_0_stack_traces")