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.c engine/verify_ca...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/verify.c engine/verify_ca...
Date: Sat, 18 Aug 2007 12:29:33 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/08/18 12:29:33

Modified files:
        .              : ChangeLog 
        engine         : verify.c verify_call.c verify_obj.c 
                         verify_ptr.c 
        include        : il_coder.h 

Log message:
        Add support for the constrained prefix and the ldelem opcode in the 
verifier.
        (Ivan de Jesus Deras Tabora)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3488&r2=1.3489
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify.c?cvsroot=dotgnu-pnet&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify_call.c?cvsroot=dotgnu-pnet&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify_obj.c?cvsroot=dotgnu-pnet&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/verify_ptr.c?cvsroot=dotgnu-pnet&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pnet/include/il_coder.h?cvsroot=dotgnu-pnet&r1=1.55&r2=1.56

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3488
retrieving revision 1.3489
diff -u -b -r1.3488 -r1.3489
--- ChangeLog   18 Aug 2007 11:34:39 -0000      1.3488
+++ ChangeLog   18 Aug 2007 12:29:32 -0000      1.3489
@@ -1,3 +1,18 @@
+2007-08-18  Ivan de Jesus Deras Tabora  <address@hidden>
+
+       * engine/verify.c: Add the check for generic types in IsObjectRef. Add
+       the local constraintType to handle the constrained prefix.
+
+       * engine/verify_call.c: Add support for the constrained prefix.
+
+       * engine/verify_obj.c: Add the function BoxPtr to box a valuetype
+       referenced by a pointer somewhere on the stack.
+
+       * engine/verify_ptr.c: Add support for the LDELEM opcode.
+
+       * include/il_coder.h: Swap the definition of two macros to match the 
order
+       in the coder struct.
+
 2007-08-18  Klaus Treichel  <address@hidden>
 
        * engine/cvm_stack.c: Fix the opcode COP_PREFIX_REPL_WORD_N on x86_64

Index: engine/verify.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- engine/verify.c     22 Oct 2006 18:01:08 -0000      1.51
+++ engine/verify.c     18 Aug 2007 12:29:32 -0000      1.52
@@ -269,6 +269,10 @@
        {
                return 1;
        }
+       else if(ILType_IsWith(type))
+       {
+               return IsObjectRef(ILTypeGetWithMain(type));
+       }
        else
        {
                return 0;
@@ -665,6 +669,7 @@
        int coderFlags;
        unsigned int tryInlineOpcode;
        unsigned char *tryInlinePc;
+       ILType *constraintType;
 #ifdef IL_CONFIG_DEBUG_LINES
        int haveDebug = ILDebugPresent(ILProgramItem_Image(method));
 #else
@@ -701,6 +706,7 @@
        labelList = 0;
        hasRethrow = 0;
        isReadOnly = 0;
+       constraintType = 0;
 
        /* Initialize the memory allocator that is used for temporary
           allocation during bytecode verification */

Index: engine/verify_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_call.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- engine/verify_call.c        12 Nov 2006 17:10:10 -0000      1.56
+++ engine/verify_call.c        18 Aug 2007 12:29:32 -0000      1.57
@@ -1984,15 +1984,83 @@
 }
 break;
 
+case IL_OP_PREFIX + IL_PREFIX_OP_CONSTRAINED:
+{      
+       classInfo = GetClassToken(method, pc);
+       if (classInfo)
+       {               
+               constraintType = ILClassToType(classInfo);
+       }
+       else
+       {
+               VERIFY_TYPE_ERROR();
+       }
+       /* TODO: Verify that next instruction is callvirt */
+}
+break;
+
 case IL_OP_CALLVIRT:
 {
        /* Call a virtual or interface method */
        methodInfo = GetMethodToken(_ILExecThreadProcess(thread), method, pc, 
&methodSignature);
        if(methodInfo)
        {
+               ILType *_constraintType = constraintType;
+               
+               constraintType = 0;
                classInfo = ILMethod_Owner(method);
                if(ILMemberAccessible((ILMember *)methodInfo, classInfo))
                {
+                       if(_constraintType)
+                       {
+                               ILEngineStackItem *item;
+                               numParams = ILTypeNumParams(methodSignature);
+                               item = &(stack[stackSize - numParams - 1]);
+                               if ((item->engineType == ILEngineType_M ||
+                                       item->engineType == ILEngineType_T) &&
+                                       ILTypeIdentical(_constraintType, 
item->typeInfo))
+                               {
+                                       ILClass *thisClass = 
ILClassFromType(ILProgramItem_Image(method),
+                                                                               
                                 0, _constraintType, 0);
+
+                                       if(!ILClassIsValueType(thisClass))
+                                       {
+                                               ILCoderPtrDeref(coder, 
numParams);
+                                               item->engineType = 
ILEngineType_O;
+                                               item->typeInfo = 
ILType_FromClass(thisClass);
+                                       }
+                                       else
+                                       {
+                                               ILMember *member = 
ILClassNextMemberMatch(thisClass, 0,
+                                                                               
                                                  IL_META_MEMBERKIND_METHOD,
+                                                                               
                                                  ILMethod_Name(methodInfo),
+                                                                               
                                                  
ILMethod_Signature(methodInfo));
+                                               if (member)
+                                               {
+                                                       methodInfo = (ILMethod 
*)member;
+                                                       item->engineType = 
ILEngineType_M;
+                                                       item->typeInfo = 
_constraintType;
+                                               }
+                                               else
+                                               {
+                                                       
if(BoxPtr(_ILExecThreadProcess(thread), 
+                                                                         
_constraintType, thisClass, numParams))
+                                                       {
+                                                               
item->engineType = ILEngineType_O;
+                                                               item->typeInfo 
= ILType_FromClass(thisClass);
+                                                       }
+                                                       else
+                                                       {
+                                                               
VERIFY_TYPE_ERROR();
+                                                       }
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       VERIFY_TYPE_ERROR();
+                               }
+                       }
                        numParams = MatchSignature(coder, stack, stackSize,
                                                                           
methodSignature, methodInfo,
                                                                           
unsafeAllowed, 0, 0,
@@ -2009,7 +2077,8 @@
                                {
                                        stack[stackSize].engineType = 
ILEngineType_Invalid;
                                }
-                               if(!ILMethod_IsVirtual(methodInfo))
+                               if(!ILMethod_IsVirtual(methodInfo) ||
+                                  (_constraintType && 
ILType_IsPrimitive(_constraintType)))
                                {
                                        goto callNonvirtualFromVirtual;
                                }

Index: engine/verify_obj.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_obj.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- engine/verify_obj.c 22 Oct 2006 18:01:08 -0000      1.28
+++ engine/verify_obj.c 18 Aug 2007 12:29:33 -0000      1.29
@@ -185,6 +185,31 @@
 }
 
 /*
+ * Process a "box" operation on a value.  Returns zero if
+ * invalid parameters.
+ */
+static int BoxPtr(ILExecProcess *process, ILType *typeInfo, 
+                                 ILClass *boxClass, ILUInt32 pos)
+{
+       ILUInt32 size;
+       ILType *rawType;
+
+       /* Determine the raw version of the boxing type */
+       rawType = ILTypeGetEnumType(ILClassToType(boxClass));
+
+       /* Get the size of the value type */
+       size = _ILSizeOfTypeLocked(process, rawType);
+
+       if(ILTypeIdentical(typeInfo, ILClassToType(boxClass)))
+       {
+               ILCoderBoxPtr(process->coder, boxClass, size, pos);
+               return 1;
+       }
+
+       return 0;
+}
+
+/*
  * Get a particular system value type.
  */
 static ILType *GetSystemValueType(ILMethod *method, const char *name)

Index: engine/verify_ptr.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_ptr.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- engine/verify_ptr.c 22 Oct 2006 18:01:08 -0000      1.19
+++ engine/verify_ptr.c 18 Aug 2007 12:29:33 -0000      1.20
@@ -329,6 +329,32 @@
 VERIFY_STIND(R4, ILType_Float32, ILEngineType_F);
 VERIFY_STIND(R8, ILType_Float64, ILEngineType_F);
 
+case IL_OP_LDELEM:
+{
+       classType = GetTypeToken(method, pc);
+       if(STK_BINARY_1 == ILEngineType_O)
+       {
+               elemType = ArrayElementType(stack[stackSize - 2].typeInfo);
+
+               if(elemType && ILTypeIdentical(classType, elemType))
+               {
+                       ILCoderArrayAccess(coder, IL_OP_LDELEM, STK_BINARY_2, 
elemType);
+                       STK_BINARY_1 = TypeToEngineType(elemType);
+                       STK_TYPEINFO_1 = elemType;
+                       --stackSize;
+               }
+               else
+               {
+                       VERIFY_TYPE_ERROR();
+               }
+       }
+       else
+       {
+               VERIFY_TYPE_ERROR();
+       }
+}
+break;
+
 case IL_OP_LDIND_REF:
 {
        /* Load an object reference from a pointer */

Index: include/il_coder.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/include/il_coder.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- include/il_coder.h  17 Aug 2007 19:18:27 -0000      1.55
+++ include/il_coder.h  18 Aug 2007 12:29:33 -0000      1.56
@@ -922,10 +922,10 @@
 #define        ILCoderArrayAccess(coder,opcode,itype,etype)    \
                        ((*((coder)->classInfo->arrayAccess))((coder), 
(opcode), \
                                                                                
                  (itype), (etype)))
-#define        ILCoderPtrDeref(coder,pos)      \
-                       ((*((coder)->classInfo->ptrDeref))((coder), (pos)))
 #define        ILCoderPtrAccess(coder,opcode)  \
                        ((*((coder)->classInfo->ptrAccess))((coder), (opcode)))
+#define        ILCoderPtrDeref(coder,pos)      \
+                       ((*((coder)->classInfo->ptrDeref))((coder), (pos)))
 #define        ILCoderPtrAccessManaged(coder,opcode,_classInfo)        \
                        ((*((coder)->classInfo->ptrAccessManaged))((coder), 
(opcode), \
                                                                                
                           (_classInfo)))




reply via email to

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