Exemple #1
0
        private void decodePage(int[] @in, IntWrapper inpos, int[] @out, IntWrapper outpos, int thissize)
        {
            int tmpoutpos = outpos.get();
            int tmpinpos  = inpos.get();

            for (int run = 0; run < thissize / BLOCK_SIZE; ++run, tmpoutpos += BLOCK_SIZE)
            {
                int b          = @in[tmpinpos] & 0xFF;
                int cexcept    = (int)((uint)@in[tmpinpos] >> 8) & 0xFF;
                int exceptsize = (int)((uint)@in[tmpinpos] >> 16);
                ++tmpinpos;
                S16.uncompress(@in, tmpinpos, exceptsize, exceptbuffer,
                               0, 2 * cexcept);
                tmpinpos += exceptsize;
                for (int k = 0; k < BLOCK_SIZE; k += 32)
                {
                    BitPacking.fastunpack(@in, tmpinpos, @out,
                                          tmpoutpos + k, bits[b]);
                    tmpinpos += bits[b];
                }
                for (int k = 0; k < cexcept; ++k)
                {
                    @out[tmpoutpos + exceptbuffer[k + cexcept]] |= (exceptbuffer[k] << bits[b]);
                }
            }
            outpos.set(tmpoutpos);
            inpos.set(tmpinpos);
        }
Exemple #2
0
 public S07(
     S08 s08,
     S09 s09,
     S10 s10,
     S11 s11,
     S12 s12,
     S13 s13,
     S14 s14,
     S15 s15,
     S16 s16,
     S17 s17,
     S18 s18,
     S19 s19,
     S20 s20,
     S21 s21,
     S22 s22,
     S23 s23,
     S24 s24,
     S25 s25,
     S26 s26,
     S27 s27,
     S28 s28,
     S29 s29,
     S30 s30,
     S31 s31,
     S32 s32,
     S33 s33,
     S34 s34,
     S35 s35,
     S36 s36)
 {
 }
Exemple #3
0
 public S13(
     S14 s14,
     S15 s15,
     S16 s16,
     S17 s17,
     S18 s18,
     S19 s19,
     S20 s20,
     S21 s21,
     S22 s22,
     S23 s23,
     S24 s24,
     S25 s25,
     S26 s26,
     S27 s27,
     S28 s28,
     S29 s29,
     S30 s30,
     S31 s31,
     S32 s32,
     S33 s33,
     S34 s34,
     S35 s35,
     S36 s36)
 {
 }
Exemple #4
0
    private static string ValueTypeInstanceMethodCalli()
    {
        // Force helper-based tailcall out of this function by stackallocing
        Span <int> values = stackalloc int[Environment.TickCount < 0 ? 30 : 40];

        S16 s16 = new S16();

        IL.Push(ref s16);
        IL.Push(s_instanceMethodOnValueType);
        IL.Emit.Tail();
        IL.Emit.Calli(new StandAloneMethodSig(CallingConventions.Standard | CallingConventions.HasThis, typeof(string)));
        return(IL.Return <string>());
    }
Exemple #5
0
        private void getBestBFromData(int[] @in, int pos, IntWrapper bestb, IntWrapper bestexcept)
        {
            int mb   = Util.maxbits(@in, pos, BLOCK_SIZE);
            int mini = 0;

            if (mini + 28 < bits[invbits[mb]])
            {
                mini = bits[invbits[mb]] - 28; // 28 is the max for
            }
            // exceptions
            int besti         = bits.Length - 1;
            int bestcost      = bits[besti] * 4;
            int exceptcounter = 0;

            for (int i = mini; i < bits.Length - 1; ++i)
            {
                int tmpcounter = 0;
                for (int k = pos; k < BLOCK_SIZE + pos; ++k)
                {
                    if ((int)((uint)@in[k] >> bits[i]) != 0)
                    {
                        ++tmpcounter;
                    }
                }
                if (tmpcounter == BLOCK_SIZE)
                {
                    continue; // no need
                }
                for (int k = pos, c = 0; k < pos + BLOCK_SIZE; ++k)
                {
                    if ((int)((uint)@in[k] >> bits[i]) != 0)
                    {
                        exceptbuffer[tmpcounter + c] = k - pos;
                        exceptbuffer[c] = (int)((uint)@in[k] >> bits[i]);
                        ++c;
                    }
                }

                int thiscost = bits[i] * 4 + S16.estimatecompress(exceptbuffer, 0, 2 * tmpcounter);
                if (thiscost <= bestcost)
                {
                    bestcost      = thiscost;
                    besti         = i;
                    exceptcounter = tmpcounter;
                }
            }

            bestb.set(besti);
            bestexcept.set(exceptcounter);
        }
Exemple #6
0
        private void encodePage(int[] @in, IntWrapper inpos, int thissize, int[] @out, IntWrapper outpos)
        {
            int        tmpoutpos  = outpos.get();
            int        tmpinpos   = inpos.get();
            IntWrapper bestb      = new IntWrapper();
            IntWrapper bestexcept = new IntWrapper();

            for (int finalinpos = tmpinpos + thissize; tmpinpos + BLOCK_SIZE <= finalinpos; tmpinpos += BLOCK_SIZE)
            {
                getBestBFromData(@in, tmpinpos, bestb, bestexcept);
                int tmpbestb   = bestb.get();
                int nbrexcept  = bestexcept.get();
                int exceptsize = 0;
                int remember   = tmpoutpos;
                tmpoutpos++;
                if (nbrexcept > 0)
                {
                    int c = 0;
                    for (int i = 0; i < BLOCK_SIZE; ++i)
                    {
                        if ((int)((uint)@in[tmpinpos + i] >> bits[tmpbestb]) != 0)
                        {
                            exceptbuffer[c + nbrexcept] = i;
                            exceptbuffer[c]             = (int)((uint)@in[tmpinpos + i] >> bits[tmpbestb]);
                            ++c;
                        }
                    }
                    exceptsize = S16.compress(exceptbuffer, 0,
                                              2 * nbrexcept, @out, tmpoutpos);
                    tmpoutpos += exceptsize;
                }
                @out[remember] = tmpbestb | (nbrexcept << 8)
                                 | (exceptsize << 16);
                for (int k = 0; k < BLOCK_SIZE; k += 32)
                {
                    BitPacking.fastpack(@in, tmpinpos + k, @out,
                                        tmpoutpos, bits[tmpbestb]);
                    tmpoutpos += bits[tmpbestb];
                }
            }
            inpos.set(tmpinpos);
            outpos.set(tmpoutpos);
        }
Exemple #7
0
        static int TestS16_Copy2()
        {
            S16Copy s1 = new S16Copy();
            S16     s2 = new S16();

            s2.i1 = 1;
            s2.i2 = 2;
            s2.i3 = 3;
            s2.i4 = 4;
            if (s1.i1 != 0)
            {
                return(101);
            }
            if (s1.i2 != 0)
            {
                return(101);
            }
            if (s1.i3 != 0)
            {
                return(101);
            }
            if (s1.i4 != 0)
            {
                return(101);
            }
            s1    = Unsafe.As <S16, S16Copy>(ref s2);
            s2.i1 = 5;
            s2.i2 = 6;
            s2.i3 = 7;
            s2.i4 = 8;

            if (s1.i1 != 1)
            {
                return(101);
            }
            if (s1.i2 != 2)
            {
                return(101);
            }
            if (s1.i3 != 3)
            {
                return(101);
            }
            if (s1.i4 != 4)
            {
                return(101);
            }

            if (s2.i1 != 5)
            {
                return(101);
            }
            if (s2.i2 != 6)
            {
                return(101);
            }
            if (s2.i3 != 7)
            {
                return(101);
            }
            if (s2.i4 != 8)
            {
                return(101);
            }
            return(100);
        }
Exemple #8
0
        static int TestS16_WW2()
        {
            S16WW s1 = new S16WW();
            S16   s2 = new S16();

            s2.i1 = 1;
            s2.i2 = 2;
            s2.i3 = 3;
            s2.i4 = 4;
            if (s1.s16W.s16.i1 != 0)
            {
                return(101);
            }
            if (s1.s16W.s16.i2 != 0)
            {
                return(101);
            }
            if (s1.s16W.s16.i3 != 0)
            {
                return(101);
            }
            if (s1.s16W.s16.i4 != 0)
            {
                return(101);
            }
            s1.s16W.s16 = s2;
            s2.i1       = 5;
            s2.i2       = 6;
            s2.i3       = 7;
            s2.i4       = 8;

            if (s1.s16W.s16.i1 != 1)
            {
                return(101);
            }
            if (s1.s16W.s16.i2 != 2)
            {
                return(101);
            }
            if (s1.s16W.s16.i3 != 3)
            {
                return(101);
            }
            if (s1.s16W.s16.i4 != 4)
            {
                return(101);
            }

            if (s2.i1 != 5)
            {
                return(101);
            }
            if (s2.i2 != 6)
            {
                return(101);
            }
            if (s2.i3 != 7)
            {
                return(101);
            }
            if (s2.i4 != 8)
            {
                return(101);
            }
            return(100);
        }
Exemple #9
0
        static int TestS16_Simple()
        {
            S16 s1 = new S16();
            S16 s2 = new S16();

            s2.i1 = 1;
            s2.i2 = 2;
            s2.i3 = 3;
            s2.i4 = 4;
            if (s1.i1 != 0)
            {
                return(101);
            }
            if (s1.i2 != 0)
            {
                return(101);
            }
            if (s1.i3 != 0)
            {
                return(101);
            }
            if (s1.i4 != 0)
            {
                return(101);
            }
            blockPromotion(ref s2);
            s1    = s2;
            s2.i1 = 5;
            s2.i2 = 6;
            s2.i3 = 7;
            s2.i4 = 8;

            if (s1.i1 != 1)
            {
                return(101);
            }
            if (s1.i2 != 2)
            {
                return(101);
            }
            if (s1.i3 != 3)
            {
                return(101);
            }
            if (s1.i4 != 4)
            {
                return(101);
            }

            if (s2.i1 != 5)
            {
                return(101);
            }
            if (s2.i2 != 6)
            {
                return(101);
            }
            if (s2.i3 != 7)
            {
                return(101);
            }
            if (s2.i4 != 8)
            {
                return(101);
            }
            return(100);
        }
Exemple #10
0
    private static int Main()
    {
        const int numCalcIters = 1000000;
        const int countUpIters = 1000000;

        int x        = numCalcIters;
        S32 s        = default;
        int expected = 0;

        while (x != 0)
        {
            if (x % 2 == 0)
            {
                s = default;
            }

            Calc(ref x, ref s, ref expected);
        }

        bool result = true;

        void Test <T>(Func <T> f, T expected, string name)
        {
            Console.Write("{0}: ", name);
            Stopwatch timer = Stopwatch.StartNew();
            T         val   = f();

            timer.Stop();
            if (val.Equals(expected))
            {
                Console.WriteLine("OK in {1} ms", name, timer.ElapsedMilliseconds);
                return;
            }

            Console.WriteLine("FAIL (expected {1}, got {2})", name, expected, val);
            result = false;
        }

        void TestCalc <T>(Func <int, int, T> f, T expected, string name)
        => Test(() => f(numCalcIters, 0), expected, name);

        ClassImpl c = new ClassImpl();

        c.Other = c;

        InterfaceImpl i = new InterfaceImpl();

        i.Other = i;

        GenInstance <string, int>      g   = new GenInstance <string, int>();
        IGenInterface <string, int>    ig  = new GenInterfaceImpl <string, int>();
        IGenInterface <string, object> ig2 = new GenInterfaceImpl <string, object>();
        GenAbstractImpl <string>       ga1 = new GenAbstractImpl <string>();
        GenAbstractImpl <int>          ga2 = new GenAbstractImpl <int>();

        long expectedI8  = (long)(((ulong)(uint)expected << 32) | (uint)expected);
        S16  expectedS16 = new S16 {
            A = expected, B = expected,
        };
        S32 expectedS32 = new S32 {
            A = expected, B = expected, C = expected, D = expected,
        };
        int ten = 10;

        TestCalc(CalcStatic, expected, "Static non-generic");
        TestCalc(CalcStaticSmall, (byte)expected, "Static non-generic small");
        TestCalc(CalcStaticRetbuf, expectedS32, "Static non-generic retbuf");
        TestCalc(CalcStaticLong, expectedI8, "Static non-generic long");
        TestCalc(CalcStaticS16, expectedS16, "Static non-generic S16");
        TestCalc((x, s) => { CalcStaticVoid(x, s); return(s_result); }, expected, "Static void");
        TestCalc(new Instance().CalcInstance, expected, "Instance non-generic");
        TestCalc(new Instance().CalcInstanceRetbuf, expectedS32, "Instance non-generic retbuf");
        TestCalc(c.CalcAbstract, expected, "Abstract class non-generic");
        TestCalc(c.CalcAbstractRetbuf, expectedS32, "Abstract class non-generic retbuf");
        TestCalc(i.CalcInterface, expected, "Interface non-generic");
        TestCalc(i.CalcInterfaceRetbuf, expectedS32, "Interface non-generic retbuf");
        TestCalc(CalcStaticCalli, expected, "Static calli");
        TestCalc(CalcStaticCalliRetbuf, expectedS32, "Static calli retbuf");
        TestCalc(new Instance().CalcInstanceCalli, expected, "Instance calli");
        TestCalc(new Instance().CalcInstanceCalliRetbuf, expectedS32, "Instance calli retbuf");
        Test(() => EmptyCalli(), "Empty calli", "Static calli without args");
        Test(() => ValueTypeInstanceMethodCalli(), "Instance method", "calli to an instance method on a value type");
        Test(() => ValueTypeExplicitThisInstanceMethodCalli(), "Instance method", "calli to an instance method on a value type with explicit this");
        Test(() => { var v = new InstanceValueType(); v.CountUp(countUpIters); return(v.Count); }, countUpIters, "Value type instance call");
        Test(() => new Instance().GC("2", 3, "4", 5, "6", "7", "8", 9, ref ten), "2 3 4 5 6 7 8 9 10", "Instance with GC");
        Test(() => CountUpHeap(countUpIters, new HeapInt(0)), countUpIters, "Count up with heap int");
        Test(() => { int[] val = new int[1]; CountUpRef(countUpIters, ref val[0]); return(val[0]); }, countUpIters, "Count up with byref to heap");
        Test(() => GenName1Forward("hello"), "System.String hello", "Static generic string");
        Test(() => GenName1Forward <object>("hello"), "System.Object hello", "Static generic object");
        Test(() => GenName1Forward(5), "System.Int32 5", "Static generic int");
        Test(() => GenName2ForwardBoth("hello", (object)"hello2"), "System.String System.Object hello hello2", "Static generic 2 string object");
        Test(() => GenName2ForwardBoth("hello", 5), "System.String System.Int32 hello 5", "Static generic 2 string int");
        Test(() => GenName2ForwardOne("hello", "hello2"), "System.String System.String hello hello2", "Static generic 1 string");
        Test(() => GenName2ForwardOne((object)"hello", "hello2"), "System.Object System.String hello hello2", "Static generic 1 object");
        Test(() => GenName2ForwardOne(5, "hello2"), "System.Int32 System.String 5 hello2", "Static generic 1 int");
        Test(() => GenName2ForwardNone("hello", "hello2"), "System.Object System.String hello hello2", "Static generic 0");
        Test(() => g.NonVirtForward <object, string>("a", 5, "b", "c"),
             "System.String System.Int32 System.Object System.String a 5 b c", "Instance generic 4");
        Test(() => g.VirtForward <object, string>("a", 5, "b", "c"),
             "System.String System.Int32 System.Object System.String a 5 b c", "Virtual instance generic 4");
        Test(() => GenInterfaceForwardF <string, int, string, object>("a", 5, "c", "d", ig),
             "System.String System.Int32 System.String System.Object a 5 c d", "Interface generic 4");
        Test(() => GenInterfaceForwardG <string, int>("a", 5, ig),
             "System.String System.Int32 a 5", "Interface generic forward G");
        Test(() => GenInterfaceForwardNone("a", "b", 5, "d", ig2),
             "System.String System.Object System.Int32 System.Object a b 5 d", "Interface generic 0");
        Test(() => GenInterfaceForward2("a", "b", ig2),
             "System.String System.Object a b", "Interface generic without generics on method");
        Test(() => GenAbstractFString(ga1), "System.String System.Object", "Abstract generic with generic on method 1");
        Test(() => GenAbstractFInt(ga2), "System.Int32 System.Object", "Abstract generic with generic on method 2");
        Test(() => GenAbstractGString(ga1), "System.String", "Abstract generic without generic on method 1");
        Test(() => GenAbstractGInt(ga2), "System.Int32", "Abstract generic without generic on method 2");

        if (result)
        {
            Console.WriteLine("All tailcall-via-help succeeded");
        }
        else
        {
            Console.WriteLine("One or more failures in tailcall-via-help test");
        }

        return(result ? 100 : 1);
    }
Exemple #11
0
/* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved.
 *
 *      [DllImport("jitstructtests_lib")]
 *      public static extern S28 InvokeCallback28R(MyCallback28 callback, S28 s);
 *
 *      [DllImport("jitstructtests_lib")]
 *      public static extern S29 InvokeCallback29R(MyCallback29 callback, S29 s);
 * Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved. */
        static public int Main1()
        {
            Program3 p  = new Program3();
            S1       s1 = new S1();

            s1.x = 1;
            s1.y = 2;
            s1.z = 3;
            s1.w = 4;

            try
            {
                InvokeCallback1((par) =>
                {
                    Console.WriteLine("S1: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s1);

                S2 s2;
                s2.x = 1;
                s2.y = 2;
                s2.z = 3;
                InvokeCallback2((par) =>
                {
                    Console.WriteLine("S2: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s2);

                S3 s3;
                s3.x = 1;
                s3.y = 2;
                s3.z = 3;
                InvokeCallback3((par) =>
                {
                    Console.WriteLine("S3: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s3);

                S4 s4;
                s4.x = 1;
                s4.y = 2;
                InvokeCallback4((par) =>
                {
                    Console.WriteLine("S4: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s4);

                S5 s5;
                s5.x = 1;
                s5.y = 2;
                InvokeCallback5((par) =>
                {
                    Console.WriteLine("S5: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s5);

                S6 s6;
                s6.x = 1;
                s6.y = 2;
                s6.z = 3;
                s6.w = 4;
                InvokeCallback6((par) =>
                {
                    Console.WriteLine("S6: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s6);

                S7 s7;
                s7.x = 1;
                s7.y = 2;
                s7.z = 3;
                InvokeCallback7((par) =>
                {
                    Console.WriteLine("S7: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s7);

                S8 s8;
                s8.x = 1;
                s8.y = 2;
                InvokeCallback8((par) =>
                {
                    Console.WriteLine("S8: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s8);

                S9 s9;
                s9.x = 1;
                s9.y = 2;
                s9.z = 3;
                s9.w = 4;
                InvokeCallback9((par) =>
                {
                    Console.WriteLine("S9: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s9);

                S10 s10;
                s10.a = 1;
                s10.b = 2;
                s10.c = 3;
                s10.d = 4;
                s10.e = 5;
                s10.f = 6;
                s10.g = 7;
                s10.h = 8;
                InvokeCallback10((par) =>
                {
                    Console.WriteLine("S10: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8)
                    {
                        throw new System.Exception();
                    }
                }, s10);

                S11 s11;
                s11.a = 1;
                s11.b = 2;
                s11.c = 3;
                s11.d = 4;
                s11.e = 5;
                InvokeCallback11((par) =>
                {
                    Console.WriteLine("S11: {0}, {1}, {2}, {3}, {4}", par.a, par.b, par.c, par.d, par.e);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 || par.e != 5)
                    {
                        throw new System.Exception();
                    }
                }, s11);

                S12 s12;
                s12.a = 1;
                s12.b = 2;
                s12.c = 3;
                s12.d = 4;
                s12.e = 5;
                s12.f = 6;
                s12.g = 7;
                s12.h = 8;
                s12.i = 9;
                InvokeCallback12((par) =>
                {
                    Console.WriteLine("S12: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s12);

                S13 s13;
                s13.hasValue = 1;
                s13.x        = 2;
                InvokeCallback13((par) =>
                {
                    Console.WriteLine("S13: {0}, {1}", par.hasValue, par.x);
                    if (par.hasValue != 1 || par.x != 2)
                    {
                        throw new System.Exception();
                    }
                }, s13);

                S14 s14;
                s14.x = 1;
                s14.y = 2;
                InvokeCallback14((par) =>
                {
                    Console.WriteLine("S14: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s14);

                S15 s15;
                s15.a = 1;
                s15.b = 2;
                s15.c = 3;
                s15.d = 4;
                s15.e = 5;
                s15.f = 6;
                s15.g = 7;
                s15.h = 8;
                s15.i = 9;
                InvokeCallback15((par) =>
                {
                    Console.WriteLine("S15: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s15);

                S16 s16;
                s16.x = 1;
                s16.y = 2;
                InvokeCallback16((par) =>
                {
                    Console.WriteLine("S16: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s16);

                S17 s17;
                s17.x = 1;
                s17.y = 2;
                InvokeCallback17((par) =>
                {
                    Console.WriteLine("S17: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s17);

                S18 s18;
                s18.x = 1;
                s18.y = 2;
                s18.z = 3;
                InvokeCallback18((par) =>
                {
                    Console.WriteLine("S18: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s18);

                S19 s19;
                s19.x = 1;
                s19.y = 2;
                s19.z = 3;
                s19.w = 4;
                InvokeCallback19((par) =>
                {
                    Console.WriteLine("S19: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s19);

                S20 s20;
                s20.x = 1;
                s20.y = 2;
                s20.z = 3;
                s20.w = 4;
                InvokeCallback20((par) =>
                {
                    Console.WriteLine("S20: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s20);

                /* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved.
                 * TestClass testClass = new TestClass();
                 * S28 s28;
                 * s28.x = null;
                 * s28.y = 1;
                 *
                 * InvokeCallback28((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != null || par.y != 1)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 *
                 * s28.x = testClass;
                 * s28.y = 5;
                 *
                 * InvokeCallback28((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != testClass || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 *
                 * S29 s29;
                 * s29.x = 1;
                 * s29.y = null;
                 *
                 * InvokeCallback29((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 1 || par.y != null)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 *
                 * s29.x = 5;
                 * s29.y = testClass;
                 *
                 * InvokeCallback29((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y != testClass)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved. */
                S30 s30;
                s30.x = 1;
                s30.y = 2;

                S30 s30_2;
                s30_2.x = 3;
                s30_2.y = 4;

                S30 s30_3;
                s30_3.x = 5;
                s30_3.y = 6;

                // Program p = new Program();
                InvokeCallback30(p.Test30, s30, s30_2, s30_3);
                S1 s1r = InvokeCallback1R((par) =>
                {
                    Console.WriteLine("S1: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s1);
                Console.WriteLine("S1R: {0}, {1}, {2}, {3}", s1r.x, s1r.y, s1r.z, s1r.w);
                if (s1r.x != 1 || s1r.y != 2 || s1r.z != 3 || s1r.w != 4)
                {
                    throw new System.Exception();
                }

                S2 s2r = InvokeCallback2R((par) =>
                {
                    Console.WriteLine("S2: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s2);
                Console.WriteLine("S2R: {0}, {1}, {2}", s2r.x, s2r.y, s2r.z);
                if (s2r.x != 1 || s2r.y != 2 || s2r.z != 3)
                {
                    throw new System.Exception();
                }

                S3 s3r = InvokeCallback3R((par) =>
                {
                    Console.WriteLine("S3: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s3);
                Console.WriteLine("S3R: {0}, {1}, {2}", s3r.x, s3r.y, s3r.z);
                if (s3r.x != 1 || s3r.y != 2 || s3r.z != 3)
                {
                    throw new System.Exception();
                }

                S4 s4r = InvokeCallback4R((par) =>
                {
                    Console.WriteLine("S4: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s4);
                Console.WriteLine("S4R: {0}, {1}", s4r.x, s4r.y);
                if (s4r.x != 1 || s4r.y != 2)
                {
                    throw new System.Exception();
                }

                S5 s5r = InvokeCallback5R((par) =>
                {
                    Console.WriteLine("S5: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s5);
                Console.WriteLine("S5R: {0}, {1}", s5r.x, s5r.y);
                if (s5r.x != 1 || s5r.y != 2)
                {
                    throw new System.Exception();
                }

                S6 s6r = InvokeCallback6R((par) =>
                {
                    Console.WriteLine("S6: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s6);
                Console.WriteLine("S6R: {0}, {1}, {2}, {3}", s6r.x, s6r.y, s6r.z, s6r.w);
                if (s6r.x != 1 || s6r.y != 2 || s6r.z != 3 || s6r.w != 4)
                {
                    throw new System.Exception();
                }

                S7 s7r = InvokeCallback7R((par) =>
                {
                    Console.WriteLine("S7: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s7);
                Console.WriteLine("S7R: {0}, {1}, {2}", s7r.x, s7r.y, s7r.z);
                if (s7r.x != 1 || s7r.y != 2 || s7r.z != 3)
                {
                    throw new System.Exception();
                }

                S8 s8r = InvokeCallback8R((par) =>
                {
                    Console.WriteLine("S8: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s8);
                Console.WriteLine("S8R: {0}, {1}", s8r.x, s8r.y);
                if (s8r.x != 1 || s8r.y != 2)
                {
                    throw new System.Exception();
                }

                S9 s9r = InvokeCallback9R((par) =>
                {
                    Console.WriteLine("S9: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s9);
                Console.WriteLine("S9R: {0}, {1}, {2}, {3}", s9r.x, s9r.y, s9r.z, s9r.w);
                if (s9r.x != 1 || s9r.y != 2 || s9r.z != 3 || s9r.w != 4)
                {
                    throw new System.Exception();
                }

                S10 s10r = InvokeCallback10R((par) =>
                {
                    Console.WriteLine("S10: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8)
                    {
                        throw new System.Exception();
                    }
                }, s10);
                Console.WriteLine("S10R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", s10r.a, s10r.b, s10r.c, s10r.d, s10r.e, s10r.f, s10r.g, s10r.h);
                if (s10r.a != 1 || s10r.b != 2 || s10r.c != 3 || s10r.d != 4 ||
                    s10r.e != 5 || s10r.f != 6 || s10r.g != 7 || s10r.h != 8)
                {
                    throw new System.Exception();
                }

                S11 s11r = InvokeCallback11R((par) =>
                {
                    Console.WriteLine("S11: {0}, {1}, {2}, {3}, {4}", par.a, par.b, par.c, par.d, par.e);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 || par.e != 5)
                    {
                        throw new System.Exception();
                    }
                }, s11);
                Console.WriteLine("S11R: {0}, {1}, {2}, {3}, {4}", s11r.a, s11r.b, s11r.c, s11r.d, s11r.e);
                if (s11r.a != 1 || s11r.b != 2 || s11r.c != 3 || s11r.d != 4 || s11r.e != 5)
                {
                    throw new System.Exception();
                }

                S12 s12r = InvokeCallback12R((par) =>
                {
                    Console.WriteLine("S12: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s12);
                Console.WriteLine("S12R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", s12r.a, s12r.b, s12r.c, s12r.d, s12r.e, s12r.f, s12r.g, s12r.h, s12r.i);
                if (s12r.a != 1 || s12r.b != 2 || s12r.c != 3 || s12r.d != 4 ||
                    s12r.e != 5 || s12r.f != 6 || s12r.g != 7 || s12r.h != 8 || s12r.i != 9)
                {
                    throw new System.Exception();
                }

                S13 s13r = InvokeCallback13R((par) =>
                {
                    Console.WriteLine("S13: {0}, {1}", par.hasValue, par.x);
                    if (par.hasValue != 1 || par.x != 2)
                    {
                        throw new System.Exception();
                    }
                }, s13);
                Console.WriteLine("S13R: {0}, {1}", s13r.hasValue, s13r.x);
                if (s13r.hasValue != 1 || s13r.x != 2)
                {
                    throw new System.Exception();
                }

                S14 s14r = InvokeCallback14R((par) =>
                {
                    Console.WriteLine("S14: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s14);
                Console.WriteLine("S14R: {0}, {1}", s14r.x, s14r.y);
                if (s14r.x != 1 || s14r.y != 2)
                {
                    throw new System.Exception();
                }

                S15 s15r = InvokeCallback15R((par) =>
                {
                    Console.WriteLine("S15: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", par.a, par.b, par.c, par.d, par.e, par.f, par.g, par.h, par.i);
                    if (par.a != 1 || par.b != 2 || par.c != 3 || par.d != 4 ||
                        par.e != 5 || par.f != 6 || par.g != 7 || par.h != 8 || par.i != 9)
                    {
                        throw new System.Exception();
                    }
                }, s15);
                Console.WriteLine("S15R: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", s15r.a, s15r.b, s15r.c, s15r.d, s15r.e, s15r.f, s15r.g, s15r.h, s15r.i);
                if (s15r.a != 1 || s15r.b != 2 || s15r.c != 3 || s15r.d != 4 ||
                    s15r.e != 5 || s15r.f != 6 || s15r.g != 7 || s15r.h != 8 || s15r.i != 9)
                {
                    throw new System.Exception();
                }

                S16 s16r = InvokeCallback16R((par) =>
                {
                    Console.WriteLine("S16: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s16);
                Console.WriteLine("S16R: {0}, {1}", s16r.x, s16r.y);
                if (s16r.x != 1 || s16r.y != 2)
                {
                    throw new System.Exception();
                }

                S17 s17r = InvokeCallback17R((par) =>
                {
                    Console.WriteLine("S17: {0}, {1}", par.x, par.y);
                    if (par.x != 1 || par.y != 2)
                    {
                        throw new System.Exception();
                    }
                }, s17);
                Console.WriteLine("S17R: {0}, {1}", s17r.x, s17r.y);
                if (s17r.x != 1 || s17r.y != 2)
                {
                    throw new System.Exception();
                }

                S18 s18r = InvokeCallback18R((par) =>
                {
                    Console.WriteLine("S18: {0}, {1}, {2}", par.x, par.y, par.z);
                    if (par.x != 1 || par.y != 2 || par.z != 3)
                    {
                        throw new System.Exception();
                    }
                }, s18);
                Console.WriteLine("S18R: {0}, {1}, {2}", s18r.x, s18r.y, s18r.z);
                if (s18r.x != 1 || s18r.y != 2 || s18r.z != 3)
                {
                    throw new System.Exception();
                }

                S19 s19r = InvokeCallback19R((par) =>
                {
                    Console.WriteLine("S19: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s19);
                Console.WriteLine("S19R: {0}, {1}, {2}, {3}", s19r.x, s19r.y, s19r.z, s19r.w);
                if (s19r.x != 1 || s19r.y != 2 || s19r.z != 3 || s19r.w != 4)
                {
                    throw new System.Exception();
                }

                S20 s20r = InvokeCallback20R((par) =>
                {
                    Console.WriteLine("S20: {0}, {1}, {2}, {3}", par.x, par.y, par.z, par.w);
                    if (par.x != 1 || par.y != 2 || par.z != 3 || par.w != 4)
                    {
                        throw new System.Exception();
                    }
                }, s20);
                Console.WriteLine("S20R: {0}, {1}, {2}, {3}", s20r.x, s20r.y, s20r.z, s20r.w);
                if (s20r.x != 1 || s20r.y != 2 || s20r.z != 3 || s20r.w != 4)
                {
                    throw new System.Exception();
                }

                /* These tests are not working on non Windows CoreCLR.  Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved.
                 * s28.x = null;
                 * S28 s28r = InvokeCallback28R((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x == null || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 * Console.WriteLine("S28R: {0}, {1}", s28r.x == null ? "Null" : "Not null", s28r.y);
                 * if (s28r.x == null || s28r.y != 5)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s28.x = testClass;
                 * s28.y = 5;
                 *
                 * s28r = InvokeCallback28R((par) => {
                 *  Console.WriteLine("S28: {0}, {1}", par.x == null ? "Null" : "Not null", par.y);
                 *  if (par.x != testClass || par.y != 5)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s28);
                 * Console.WriteLine("S28R: {0}, {1}", s28r.x == null ? "Null" : "Not null", s28r.y);
                 * if (s28r.x != testClass || s28r.y != 5)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s29.y = null;
                 * S29 s29r = InvokeCallback29R((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y == null)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Console.WriteLine("S29R: {0}, {1}", s29r.x, s29r.y == null ? "Null" : "Not null");
                 * if (s29r.x != 5 || s29r.y == null)
                 * {
                 *  throw new System.Exception();
                 * }
                 *
                 * s29.x = 5;
                 * s29.y = testClass;
                 * s29r = InvokeCallback29R((par) => {
                 *  Console.WriteLine("S29: {0}, {1}", par.x, par.y == null ? "Null" : "Not null");
                 *  if (par.x != 5 || par.y != testClass)
                 *  {
                 *      throw new System.Exception();
                 *  }
                 * }, s29);
                 * Console.WriteLine("S29R: {0}, {1}", s29r.x, s29r.y == null ? "Null" : "Not null");
                 * if (s29r.x != 5 || s29r.y != testClass)
                 * {
                 *  throw new System.Exception();
                 * }
                 * Enable this when https://github.com/dotnet/coreclr/issues/2076 is resolved. */
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(-1);
            }
            return(100);
        }
Exemple #12
0
 public static extern S16 InvokeCallback16R(MyCallback16 callback, S16 s);
Exemple #13
0
 public static extern void InvokeCallback16(MyCallback16 callback, S16 s);
Exemple #14
0
 static int Call(int r0, int r1, int r2, int r3, int r4, int r5, int r6, S16 s)
 {
     return((s.i0 == 0x12345678 && s.i1 == 0x87654321) ? 100 : 1);
 }
 public static extern S16 InvokeCallback16R(MyCallback16 callback, S16 s);
 public static extern void InvokeCallback16(MyCallback16 callback, S16 s);