dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog engine/verify_obj.c engine/verif...


From: Ivan de Jesus Deras Tabora
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/verify_obj.c engine/verif...
Date: Wed, 22 Aug 2007 19:21:29 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnet
Changes by:     Ivan de Jesus Deras Tabora <iderashn>   07/08/22 19:21:28

Modified files:
        .              : ChangeLog 
        engine         : verify_obj.c verify_ptr.c 

Log message:
        Implemented IL_OP_STELEM, fixed IL_OP_LDELEM and IL_OP_BOX

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3490&r2=1.3491
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify_obj.c?cvsroot=dotgnu-pnet&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify_ptr.c?cvsroot=dotgnu-pnet&r1=1.20&r2=1.21

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3490
retrieving revision 1.3491
diff -u -b -r1.3490 -r1.3491
--- ChangeLog   21 Aug 2007 18:11:42 -0000      1.3490
+++ ChangeLog   22 Aug 2007 19:21:28 -0000      1.3491
@@ -1,9 +1,17 @@
+2007-08-22  Ivan de Jesus Deras Tabora  <address@hidden>
+
+       * engine/verify_obj.c: Fixed IL_OP_BOX to be ECMA 335 compliant.  Now
+       the box operation is valid on reference and values types.
+       
+       * engine/verify_ptr.c: Implemented IL_OP_STELEM and fixed IL_OP_LDELEM, 
this two
+       operations are used with generics arrays.
+
 2007-08-20  Ivan de Jesus Deras Tabora  <address@hidden>
 
        * image/meta_types.c: Bug fixed in function ILTypeToName that prevented
        methods signature to be converted to string.
 
-       * image/class.c: Change in Load_TypeDef function to register the class
+       * image/meta_build.c: Change in Load_TypeDef function to register the 
class
        before its parent is loaded.  Read note in the function for further 
details.
 
 2007-08-18  Ivan de Jesus Deras Tabora  <address@hidden>

Index: engine/verify_obj.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/verify_obj.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- engine/verify_obj.c 18 Aug 2007 12:29:33 -0000      1.29
+++ engine/verify_obj.c 22 Aug 2007 19:21:28 -0000      1.30
@@ -317,8 +317,8 @@
 case IL_OP_BOX:
 {
        /* Box a value into an object */
-       classInfo = GetValueTypeToken(method, pc);
-       if(classInfo)
+       classInfo = GetClassToken(method, pc);
+       if(classInfo && ILClassIsValueType(classInfo))
        {
                if(BoxValue(_ILExecThreadProcess(thread), stack[stackSize - 
1].engineType,
                                        stack[stackSize - 1].typeInfo, 
classInfo))
@@ -331,7 +331,7 @@
                        VERIFY_TYPE_ERROR();
                }
        }
-       else
+       else if(!classInfo)
        {
                VERIFY_TYPE_ERROR();
        }

Index: engine/verify_ptr.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/verify_ptr.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- engine/verify_ptr.c 18 Aug 2007 12:29:33 -0000      1.20
+++ engine/verify_ptr.c 22 Aug 2007 19:21:28 -0000      1.21
@@ -96,6 +96,82 @@
        }
 }
 
+#define LDELEM_PRIMITIVE_TYPE(name) case IL_META_ELEMTYPE_##name: return 
IL_OP_LDELEM_##name
+#define LDELEM_PRIMITIVE_TYPE_OPCODE(name, opcode) case 
IL_META_ELEMTYPE_##name: return IL_OP_LDELEM_##opcode
+
+/*
+ * Return the corresponding LD_ELEM_* opcode corresponding to the type.
+ */
+static int TypeToLdElemOpcode(ILType *type)
+{
+       type = ILTypeGetEnumType(type);
+       if(ILType_IsPrimitive(type))
+       {
+               switch(ILType_ToElement(type))
+               {
+                       LDELEM_PRIMITIVE_TYPE_OPCODE(BOOLEAN, I1);
+                       LDELEM_PRIMITIVE_TYPE(I1);
+                       LDELEM_PRIMITIVE_TYPE(U1);
+                       LDELEM_PRIMITIVE_TYPE(I2);
+                       LDELEM_PRIMITIVE_TYPE(U2);
+                       LDELEM_PRIMITIVE_TYPE_OPCODE(CHAR, U2);
+                       LDELEM_PRIMITIVE_TYPE(I4);
+                       LDELEM_PRIMITIVE_TYPE(U4);
+                       LDELEM_PRIMITIVE_TYPE(I8);
+                       LDELEM_PRIMITIVE_TYPE(I);
+                       LDELEM_PRIMITIVE_TYPE(R4);
+                       LDELEM_PRIMITIVE_TYPE(R8);
+               }
+               return IL_OP_NOP;
+       }
+       else if(ILType_IsValueType(type))
+       {
+               return IL_OP_LDELEMA;
+       }
+       else if(ILType_IsClass(type))
+       {
+               return IL_OP_LDELEM_REF;
+       }
+       
+       return IL_OP_NOP;
+}
+
+#define STELEM_PRIMITIVE_TYPE(name) case IL_META_ELEMTYPE_##name: return 
IL_OP_STELEM_##name
+#define STELEM_PRIMITIVE_TYPE_OPCODE(name, opcode) case 
IL_META_ELEMTYPE_##name: return IL_OP_STELEM_##opcode
+
+/*
+ * Return the corresponding ST_ELEM_* opcode corresponding to the type.
+ */
+static int TypeToStElemOpcode(ILType *type)
+{
+       type = ILTypeGetEnumType(type);
+       if(ILType_IsPrimitive(type))
+       {
+               switch(ILType_ToElement(type))
+               {
+                       STELEM_PRIMITIVE_TYPE_OPCODE(BOOLEAN, I1);
+                       STELEM_PRIMITIVE_TYPE(I1);
+                       STELEM_PRIMITIVE_TYPE_OPCODE(U1, I1);
+                       STELEM_PRIMITIVE_TYPE(I2);
+                       STELEM_PRIMITIVE_TYPE_OPCODE(U2, I2);
+                       STELEM_PRIMITIVE_TYPE_OPCODE(CHAR, I2);
+                       STELEM_PRIMITIVE_TYPE(I4);
+                       STELEM_PRIMITIVE_TYPE_OPCODE(U4, I4);
+                       STELEM_PRIMITIVE_TYPE(I8);
+                       STELEM_PRIMITIVE_TYPE(I);
+                       STELEM_PRIMITIVE_TYPE(R4);
+                       STELEM_PRIMITIVE_TYPE(R8);
+               }
+               return IL_OP_NOP;
+       }
+       else if(ILType_IsClass(type))
+       {
+               return IL_OP_STELEM_REF;
+       }
+       
+       return IL_OP_NOP;
+}
+
 /*
  * Get a class token from the instruction stream.  Returns NULL
  * if not an accessible class token for the current method.
@@ -332,13 +408,16 @@
 case IL_OP_LDELEM:
 {
        classType = GetTypeToken(method, pc);
-       if(STK_BINARY_1 == ILEngineType_O)
+       if(classType && (STK_BINARY_1 == ILEngineType_O) &&
+          (STK_BINARY_2 == ILEngineType_I4 || STK_BINARY_2 == ILEngineType_I) 
&&
+          (elemType = ArrayElementType(stack[stackSize - 2].typeInfo)) != 0)
        {
-               elemType = ArrayElementType(stack[stackSize - 2].typeInfo);
-
-               if(elemType && ILTypeIdentical(classType, elemType))
+               if(ILTypeIdentical(classType, elemType))
                {
-                       ILCoderArrayAccess(coder, IL_OP_LDELEM, STK_BINARY_2, 
elemType);
+                       int opcode = TypeToLdElemOpcode(elemType);
+                       if(opcode != IL_OP_NOP)
+                       {
+                               ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType);
                        STK_BINARY_1 = TypeToEngineType(elemType);
                        STK_TYPEINFO_1 = elemType;
                        --stackSize;
@@ -352,6 +431,47 @@
        {
                VERIFY_TYPE_ERROR();
        }
+       }
+       else
+       {
+               VERIFY_TYPE_ERROR();
+       }
+}
+break;
+
+case IL_OP_STELEM:
+{
+       classType = GetTypeToken(method, pc);
+       if(classType && (STK_TERNARY_1 == ILEngineType_O) &&
+          (STK_TERNARY_2 == ILEngineType_I4 || STK_TERNARY_2 == 
ILEngineType_I) &&
+          (elemType = ArrayElementType(stack[stackSize - 3].typeInfo)) != 0)
+       {
+               if(elemType == ILType_Void || PtrCompatible(elemType, 
classType))
+               {
+                       int opcode = TypeToStElemOpcode(classType);
+                       if(opcode != IL_OP_NOP)
+                       {
+                               ILCoderArrayAccess(coder, opcode, 
STK_TERNARY_2, elemType);
+                       }
+                       else if(ILType_IsValueType(classType))
+                       {
+                               /* TODO: Handle value types */
+                       }
+                       else
+                       {
+                               VERIFY_TYPE_ERROR();
+                       }
+                       stackSize -= 3;
+               }
+               else
+               {
+                       VERIFY_TYPE_ERROR();
+               }
+       }
+       else
+       {
+               VERIFY_TYPE_ERROR();
+       }
 }
 break;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]