예제 #1
0
 private void mkrefanyVerifyPass()
 {
     ILASM.Inline(".maxstack 10");
     ILASM.Inline("ldarg.0");
     ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data ");
     ILASM.Inline("ldc.i4.2");
     ILASM.Inline("ldelema !0    ");
     ILASM.Inline("mkrefany !0");
     ILASM.Inline("pop");
 }
예제 #2
0
 private void initobjVerifyFail()
 {
     ILASM.Inline(".maxstack 10");
     ILASM.Inline("ldarg.0");
     ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
     ILASM.Inline("ldc.i4.1");
     ILASM.Inline("readonly.");
     ILASM.Inline("ldelema !0");
     ILASM.Inline("initobj !0");
 }
예제 #3
0
    private void cpobjVerifyPass(T obj)
    {
        ILASM.Inline(".maxstack 8");
        T temp = obj;

        //
        // readonly source is OK
        //
        ILASM.Inline("ldarg.1");
        ILASM.Inline("stloc.0 ");
        temp.setx(1);
        temp.sety(1);
        temp.setz(1);
        //
        // cpobj from m_data[3] to temp
        //
        ILASM.Inline("ldloca 0 ");
        ILASM.Inline("ldarg.0");
        ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data ");
        ILASM.Inline("ldc.i4.3");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema !0    ");
        ILASM.Inline("cpobj !0");
        ReadonlyTests.Test(temp.getx() == 103, "cpobj1 x");
        ReadonlyTests.Test(temp.gety() == 104, "cpobj1 y");
        ReadonlyTests.Test(temp.getz() == 105, "cpobj1 z");
        temp.setx(1);
        temp.sety(1);
        temp.setz(1);
        // this fails with reference types, but succeeds with value types
        // with reference semantics m_data[3].x,y and z become 1
        ReadonlyTests.Test(m_data[3].getx() == 103, "cpobj2 x");
        ReadonlyTests.Test(m_data[3].gety() == 104, "cpobj2 y");
        ReadonlyTests.Test(m_data[3].getz() == 105, "cpobj2 z");
        //
        // no readonly is OK
        //
        // cpobj from m_data[3] to temp
        //
        ILASM.Inline("ldarg.0");
        ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data ");
        ILASM.Inline("ldc.i4.3");
        ILASM.Inline("ldelema !0");
        ILASM.Inline("ldloca 0 ");
        ILASM.Inline("cpobj !0");
        //for(int i = 0; i < 10 ; ++i)
        //{
        //    Console.WriteLine("i: " + i.ToString() + " data: " + m_data[i].getx().ToString());
        //}
        ReadonlyTests.Test(temp.getx() == 103, "cpobj3 x");
        ReadonlyTests.Test(temp.gety() == 104, "cpobj3 y");
        ReadonlyTests.Test(temp.getz() == 105, "cpobj3 z");
    }
예제 #4
0
    public static void stind_refFail()
    {
        Object [] arrayObject = new Object[1];
        Object    tempObject  = 101 as Object;

        arrayObject[0] = 1 as Object;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Object");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.ref");
    }
예제 #5
0
    public static void stind_r8Fail()
    {
        Double [] arrayDouble = new Double[1];
        Double    tempDouble  = 101;

        arrayDouble[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Double");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.r8");
    }
예제 #6
0
    public static void stind_iPass()
    {
        IntPtr [] arrayIntPtr = new IntPtr[1];
        IntPtr    tempIntPtr  = (IntPtr)101;

        arrayIntPtr[0] = (IntPtr)1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.IntPtr");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i");
        ReadonlyTests.Test(arrayIntPtr[0] == tempIntPtr, "stind_iPass");
    }
예제 #7
0
    public static void stind_i2Fail()
    {
        Int16 [] arrayInt16 = new Int16[1];
        Int16    tempInt16  = 101;

        arrayInt16[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Int16");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i2");
    }
예제 #8
0
    public static void stind_i4Fail()
    {
        Int32 [] arrayInt32 = new Int32[1];
        Int32    tempInt32  = 101;

        arrayInt32[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Int32");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i4");
    }
예제 #9
0
    public static void stind_i8Fail()
    {
        Int64 [] arrayInt64 = new Int64[1];
        Int64    tempInt64  = 101;

        arrayInt64[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Int64");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i8");
    }
예제 #10
0
    public static void stind_i2Pass()
    {
        Int16 [] arrayInt16 = new Int16[1];
        Int16    tempInt16  = 101;

        arrayInt16[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Int16");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i2");
        ReadonlyTests.Test(arrayInt16[0] == 101, "stind_i2Pass");
    }
예제 #11
0
    public static void stind_r4Pass()
    {
        Single [] arraySingle = new Single[1];
        Single    tempSingle  = 101;

        arraySingle[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Single");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.r4");
        ReadonlyTests.Test(arraySingle[0] == tempSingle, "stind_r4Pass");
    }
예제 #12
0
    public static void stind_i1Pass()
    {
        Byte [] arrayByte = new Byte[1];
        Byte    tempByte  = 101;

        arrayByte[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Byte");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i1");
        ReadonlyTests.Test(arrayByte[0] == 101, "stind_i1Pass");
    }
예제 #13
0
    public static void stind_iFail()
    {
        IntPtr [] arrayIntPtr = new IntPtr[1];
        IntPtr    tempIntPtr  = (IntPtr)101;

        arrayIntPtr[0] = (IntPtr)1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.IntPtr");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i");
    }
예제 #14
0
    public static void stind_r4Fail()
    {
        Single [] arraySingle = new Single[1];
        Single    tempSingle  = 101;

        arraySingle[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Single");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.r4");
    }
예제 #15
0
    public static void stind_r8Pass()
    {
        Double [] arrayDouble = new Double[1];
        Double    tempDouble  = 101;

        arrayDouble[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Double");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.r8");
        ReadonlyTests.Test(arrayDouble[0] == tempDouble, "stind_r8Pass");
    }
예제 #16
0
    public static void stind_i8Pass()
    {
        Int64 [] arrayInt64 = new Int64[1];
        Int64    tempInt64  = 101;

        arrayInt64[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Int64");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i8");
        ReadonlyTests.Test(arrayInt64[0] == 101, "stind_i8Pass");
    }
예제 #17
0
    public static void stind_i1Fail()
    {
        Byte [] arrayByte = new Byte[1];
        Byte    tempByte  = 101;

        arrayByte[0] = 1;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema [mscorlib]System.Byte");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.i1");
    }
예제 #18
0
    public static void stind_refPass()
    {
        Object [] arrayObject = new Object[1];
        Object    tempObject  = 101 as Object;

        arrayObject[0] = 1 as Object;
        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("ldelema [mscorlib]System.Object");
        ILASM.Inline("ldloc.1");
        ILASM.Inline("stind.ref");
        ReadonlyTests.Test(arrayObject[0] == tempObject, "stind_refPass");
        ReadonlyTests.Test(Object.ReferenceEquals(arrayObject[0], tempObject), "stind_refPass ReferenceEquals");
    }
예제 #19
0
    private static void callVerifyPass()
    {
        ILASM.Inline(".maxstack 8");
        ValType [] varr = new ValType[1];
        varr[0] = new ValType(1, 2, 3);
        int result = 0;

        ILASM.Inline("ldloc.0");
        ILASM.Inline("ldc.i4.0");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema ValType");
        ILASM.Inline("call instance int32 ValType::getx()");
        ILASM.Inline("stloc.1");
        ReadonlyTests.Test(result == 1, "callVerifyPass");
    }
예제 #20
0
    private void basicBlockPass()
    {
        ILASM.Inline(".maxstack 8");
        bool takeme = true;
        int  result = 0;

        if (takeme)
        {
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.5");
            ILASM.Inline("readonly.");
            ILASM.Inline("ldelema !0");
        }
        else
        {
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.6");
            ILASM.Inline("readonly.");
            ILASM.Inline("ldelema !0");
        }
        ILASM.Inline("constrained. !0");
        ILASM.Inline("callvirt instance int32 IPoint::getx()");
        ILASM.Inline("stloc.1");
        ReadonlyTests.Test(result == 105, "basicBlockPass");

        if (!takeme)
        {
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.5");
            ILASM.Inline("readonly.");
            ILASM.Inline("ldelema !0");
        }
        else
        {
            // note no readonly here
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.6");
            ILASM.Inline("ldelema !0");
        }
        ILASM.Inline("constrained. !0");
        ILASM.Inline("callvirt instance int32 IPoint::getx()");
        ILASM.Inline("stloc.1");
        ReadonlyTests.Test(result == 106, "basicBlockPass");
    }
예제 #21
0
 private void stobjVerifyPass(T obj)
 {
     ILASM.Inline(".maxstack 10");
     ReadonlyTests.Test(m_data[0].getx() == 100, "stobj1 x");
     ReadonlyTests.Test(m_data[0].gety() == 101, "stobj1 y");
     ReadonlyTests.Test(m_data[0].getz() == 102, "stobj1 z");
     ILASM.Inline("ldarg.0");
     ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
     ILASM.Inline("ldc.i4.0");
     ILASM.Inline("ldelema !0");
     ILASM.Inline("ldarg.1");
     ILASM.Inline("stobj !0");
     ReadonlyTests.Test(m_data[0].getx() == 345, "stobj2 x");
     ReadonlyTests.Test(m_data[0].gety() == 346, "stobj2 y");
     ReadonlyTests.Test(m_data[0].getz() == 347, "stobj2 z");
 }
예제 #22
0
    private void cpobjVerifyFail(T obj)
    {
        //
        // readonly dest fails
        //
        ILASM.Inline(".maxstack 8");
        T temp;

        ILASM.Inline("ldarg.1");
        ILASM.Inline("stloc.0  ");
        ILASM.Inline("ldarg.0");
        ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data ");
        ILASM.Inline("ldc.i4.3");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema !0    ");
        ILASM.Inline("ldloca 0");
        ILASM.Inline("cpobj !0");
    }
예제 #23
0
 private void initobjVerifyPass()
 {
     ILASM.Inline(".maxstack 10");
     //Console.WriteLine("m_data x " + m_data[0].getx().ToString());
     ReadonlyTests.Test(m_data[1].getx() == 101, "initobj1 x");
     ReadonlyTests.Test(m_data[1].gety() == 102, "initobj1 y");
     ReadonlyTests.Test(m_data[1].getz() == 103, "initobj1 z");
     ILASM.Inline("ldarg.0");
     ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
     ILASM.Inline("ldc.i4.1");
     ILASM.Inline("ldelema !0");
     ILASM.Inline("initobj !0");
     //
     // this only succeeds with value types)
     // with reftype m_data[0] itself becomes null and it errors out
     //
     ReadonlyTests.Test(m_data[1].getx() == 0, "initobj2 x");
     ReadonlyTests.Test(m_data[1].gety() == 0, "initobj2 y");
     ReadonlyTests.Test(m_data[1].getz() == 0, "initobj2 z");
 }
예제 #24
0
    private void constrainedVerifyPass()
    {
        ILASM.Inline(".maxstack 8");
        int result = 0;

        ILASM.Inline("ldarg.0");
        ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
        ILASM.Inline("ldc.i4.4");
        ILASM.Inline("readonly.");
        ILASM.Inline("ldelema !0");
        ILASM.Inline("constrained. !0");
        ILASM.Inline("callvirt instance int32 IPoint::getx()");
        ILASM.Inline("stloc.0");
        ReadonlyTests.Test(result == 104, "constrainedVerifyPass");
        //Console.WriteLine("result: " + result.ToString());
        //for(int i = 0; i < 10; ++i)
        //{
        //Console.WriteLine("i: " + i.ToString() + " data: " + m_data[i].getx().ToString());
        //}
    }
예제 #25
0
    private void basicBlockFail2()
    {
        ILASM.Inline(".maxstack 8");
        bool takeme = true;

        if (takeme)
        {
            // note no readonly here
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.6");
            ILASM.Inline("readonly.");
            ILASM.Inline("ldelema !0");
        }
        else
        {
            ILASM.Inline("ldarg.0");
            ILASM.Inline("ldfld      !0[] class FixedStack<!0>::m_data");
            ILASM.Inline("ldc.i4.5");
            ILASM.Inline("ldelema !0");
        }
        ILASM.Inline("initobj !0"); // verification error
    }