summaryrefslogtreecommitdiff
path: root/tests/src/JIT/opt/Tailcall/FastTailCallStackFixup.cs
blob: f4caf37fd2795ef7ea3fbb891439385d0fb43d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;

public struct A
{
    public short a;
    public short b;
}

class TailCallStructPassing
{
    public static int bar(int count, A temp)
    {
        if (count < 100)
        {
            return count;
        }

        else
        {
            count -= 100;
            return bar(count, temp);
        }
    }

    public static int foo(A temp, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o, int p, int q, int r, int s, int t, int u, int v, int w, int decision, int count)
    {
        if (decision < 100)
        {
            return foo(temp, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, 500, 15);
        }

        else
        {
            return bar(count, temp);
        }
    }

    public static int foo(int decision, int count, int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o, int p, int q, int r, int s, int t, int u, int v, int w, int x, int y, int z, A temp)
    {
        if (decision < 100)
        {
            return foo(temp, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, 500, 15);
        }

        else
        {
            return bar(count, temp);
        }
    }

    public static int Main()
    {
        A temp = new A();
        temp.a = 50;
        temp.b = 100;

        int ret = foo(50, 19000, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, temp);

        temp.a = (short)ret;

        if (temp.a == 15)
        {
            return 100;
        }

        else
        {
            return -1;
        }
    } 
}