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

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

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 4357197102136ed953e50afe8de51dd88556a581
Date: Sat, 07 Nov 2009 18:18:38 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  4357197102136ed953e50afe8de51dd88556a581 (commit)
       via  7e9bed7615870e3c27831bce63ef144c90ed2491 (commit)
      from  bc705ada5a69d945f34ae93b1a3cb1f7167ee9d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=4357197102136ed953e50afe8de51dd88556a581

commit 4357197102136ed953e50afe8de51dd88556a581
Author: Klaus Treichel <address@hidden>
Date:   Sat Nov 7 19:17:49 2009 +0100

    Add missed file.

diff --git a/include/il_coder.h b/include/il_coder.h
index 05e3f7a..9fab3a2 100644
--- a/include/il_coder.h
+++ b/include/il_coder.h
@@ -96,6 +96,28 @@ typedef struct
 } ILCoderMethodInfo;
 
 /*
+ * Flags set if the corresponding prefix information is valid.
+ */
+#define IL_CODER_PREFIX_CONSTRAINED            0x01
+#define IL_CODER_PREFIX_NO                             0x02
+#define IL_CODER_PREFIX_READONLY               0x04
+#define IL_CODER_PREFIX_TAIL                   0x08
+#define IL_CODER_PREFIX_UNALIGNED              0x10
+#define IL_CODER_PREFIX_VOLATILE               0x20
+
+/*
+ * Information about the prefixed that tave been applied to an opcode.
+ */
+typedef struct
+{
+       ILUInt32        prefixFlags;
+       ILType     *constrainedType;
+       ILUInt32        noFlags;
+       ILUInt32        unalignedValue;
+
+} ILCoderPrefixInfo;
+
+/*
  * Inlineable method calls.
  */
 #define        IL_INLINEMETHOD_MONITOR_ENTER           0
@@ -332,12 +354,14 @@ struct _tagILCoderClass
         * is known.
         */
        void (*arrayAccess)(ILCoder *coder, int opcode,
-                                               ILEngineType indexType, ILType 
*elemType);
+                                               ILEngineType indexType, ILType 
*elemType,
+                                               const ILCoderPrefixInfo 
*prefixInfo);
 
        /*
         * Access a value by dereferencing a pointer.
         */
-       void (*ptrAccess)(ILCoder *coder, int opcode);
+       void (*ptrAccess)(ILCoder *coder, int opcode,
+                                         const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Access a value by dereferencing a pointer at the specified position.
@@ -348,7 +372,8 @@ struct _tagILCoderClass
         * Access a managed value by dereferencing a pointer.
         */
        void (*ptrAccessManaged)(ILCoder *coder, int opcode,
-                                                        ILClass *classInfo);
+                                                        ILClass *classInfo,
+                                                        const 
ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Output a branch instruction.
@@ -394,12 +419,6 @@ struct _tagILCoderClass
                                          ILEngineStackItem *type2);
 
        /*
-        * Process a pointer alignment prefix.  An "alignment" value
-        * of zero indicates a "volatile" prefix.
-        */
-       void (*ptrPrefix)(ILCoder *coder, int alignment);
-
-       /*
         * Get the length of an array.
         */
        void (*arrayLength)(ILCoder *coder);
@@ -422,7 +441,8 @@ struct _tagILCoderClass
         * push NULL onto the stack.
         */
        void (*castClass)(ILCoder *coder, ILClass *classInfo,
-                                         int throwException);
+                                         int throwException,
+                                         const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Load the contents of an instance field onto the stack.
@@ -433,19 +453,22 @@ struct _tagILCoderClass
         */
        void (*loadField)(ILCoder *coder, ILEngineType ptrType,
                                          ILType *objectType, ILField *field,
-                                         ILType *fieldType);
+                                         ILType *fieldType,
+                                         const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Load the contents of a static field onto the stack.
         */
        void (*loadStaticField)(ILCoder *coder, ILField *field,
-                                                       ILType *fieldType);
+                                                       ILType *fieldType,
+                                                       const ILCoderPrefixInfo 
*prefixInfo);
 
        /*
         * Load the contents of an instance field onto the stack,
         * where the pointer is an object reference in argument 0.
         */
-       void (*loadThisField)(ILCoder *coder, ILField *field, ILType 
*fieldType);
+       void (*loadThisField)(ILCoder *coder, ILField *field, ILType *fieldType,
+                                                 const ILCoderPrefixInfo 
*prefixInfo);
 
        /*
         * Load the address of an instance field onto the stack.
@@ -470,13 +493,15 @@ struct _tagILCoderClass
         */
        void (*storeField)(ILCoder *coder, ILEngineType ptrType,
                                           ILType *objectType, ILField *field,
-                                          ILType *fieldType, ILEngineType 
valueType);
+                                          ILType *fieldType, ILEngineType 
valueType,
+                                          const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Store a value from the stack into a stack field.
         */
        void (*storeStaticField)(ILCoder *coder, ILField *field,
-                                                        ILType *fieldType, 
ILEngineType valueType);
+                                                        ILType *fieldType, 
ILEngineType valueType,
+                                                        const 
ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Copy the contents of an object, which has the class "classInfo".
@@ -488,7 +513,8 @@ struct _tagILCoderClass
         * Copy the contents of a block of memory.
         */
        void (*copyBlock)(ILCoder *coder, ILEngineType destPtrType,
-                                         ILEngineType srcPtrType);
+                                         ILEngineType srcPtrType,
+                                         const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Initialize the contents of an object, which has the class 
"classInfo".
@@ -499,7 +525,8 @@ struct _tagILCoderClass
        /*
         * Initialize the contents of a block of memory.
         */
-       void (*initBlock)(ILCoder *coder, ILEngineType ptrType);
+       void (*initBlock)(ILCoder *coder, ILEngineType ptrType,
+                                         const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Box a value which is already in its natural representation.
@@ -524,7 +551,8 @@ struct _tagILCoderClass
        /*
         * Unbox an object into a managed pointer.
         */
-       void (*unbox)(ILCoder *coder, ILClass *boxClass);
+       void (*unbox)(ILCoder *coder, ILClass *boxClass,
+                                 const ILCoderPrefixInfo *prefixInfo);
 
        /*
         * Make a typed reference from a pointer.
@@ -950,16 +978,19 @@ struct _tagILCoderClass
                        ((*((coder)->classInfo->dup))((coder), (etype), (type)))
 #define        ILCoderPop(coder,etype,type)    \
                        ((*((coder)->classInfo->pop))((coder), (etype), (type)))
-#define        ILCoderArrayAccess(coder,opcode,itype,etype)    \
+#define        ILCoderArrayAccess(coder,opcode,itype,etype,prefixInfo) \
                        ((*((coder)->classInfo->arrayAccess))((coder), 
(opcode), \
-                                                                               
                  (itype), (etype)))
-#define        ILCoderPtrAccess(coder,opcode)  \
-                       ((*((coder)->classInfo->ptrAccess))((coder), (opcode)))
+                                                                               
                  (itype), (etype), \
+                                                                               
                  (prefixInfo)))
+#define        ILCoderPtrAccess(coder,opcode, prefixInfo)      \
+                       ((*((coder)->classInfo->ptrAccess))((coder), (opcode), \
+                                                                               
                (prefixInfo)))
 #define        ILCoderPtrDeref(coder,pos)      \
                        ((*((coder)->classInfo->ptrDeref))((coder), (pos)))
-#define        ILCoderPtrAccessManaged(coder,opcode,_classInfo)        \
+#define        ILCoderPtrAccessManaged(coder,opcode,_classInfo,prefixInfo)     
\
                        ((*((coder)->classInfo->ptrAccessManaged))((coder), 
(opcode), \
-                                                                               
                           (_classInfo)))
+                                                                               
                           (_classInfo), \
+                                                                               
                           (prefixInfo)))
 #define        ILCoderBranch(coder,opcode,dest,type1,type2)    \
                        ((*((coder)->classInfo->branch))((coder), (opcode), 
(dest), \
                                                                                
         (type1), (type2)))
@@ -977,8 +1008,6 @@ struct _tagILCoderClass
                        ((*((coder)->classInfo->conv))((coder), (opcode), 
(type)))
 #define        ILCoderToPointer(coder,type1,type2) \
                        ((*((coder)->classInfo->toPointer))((coder), (type1), 
(type2)))
-#define        ILCoderPtrPrefix(coder,alignment) \
-                       ((*((coder)->classInfo->ptrPrefix))((coder), 
(alignment)))
 #define        ILCoderArrayLength(coder) \
                        ((*((coder)->classInfo->arrayLength))((coder)))
 #define        ILCoderNewArray(coder,arrayType,arrayClass,lengthType) \
@@ -986,19 +1015,21 @@ struct _tagILCoderClass
                                                                                
           (arrayClass), (lengthType)))
 #define        ILCoderLocalAlloc(coder,sizeType) \
                        ((*((coder)->classInfo->localAlloc))((coder), 
(sizeType)))
-#define        ILCoderCastClass(coder,_classInfo,throwException) \
+#define        ILCoderCastClass(coder,_classInfo,throwException,prefixInfo) \
                        ((*((coder)->classInfo->castClass))((coder), 
(_classInfo), \
-                                                                               
                (throwException)))
-#define        ILCoderLoadField(coder,ptrType,objectType,field,fieldType) \
+                                                                               
                (throwException), \
+                                                                               
                (prefixInfo)))
+#define        
ILCoderLoadField(coder,ptrType,objectType,field,fieldType,prefixInfo) \
                        ((*((coder)->classInfo->loadField))((coder), (ptrType), 
\
                                                                                
                (objectType), (field), \
-                                                                               
                (fieldType)))
-#define        ILCoderLoadThisField(coder,field,fieldType) \
+                                                                               
                (fieldType), (prefixInfo)))
+#define        ILCoderLoadThisField(coder,field,fieldType,prefixInfo) \
                        ((*((coder)->classInfo->loadThisField))((coder), 
(field), \
-                                                                               
                        (fieldType)))
-#define        ILCoderLoadStaticField(coder,field,fieldType) \
+                                                                               
                        (fieldType), (prefixInfo)))
+#define        ILCoderLoadStaticField(coder,field,fieldType,prefixInfo) \
                        ((*((coder)->classInfo->loadStaticField))((coder), 
(field), \
-                                                                               
                          (fieldType)))
+                                                                               
                          (fieldType), \
+                                                                               
                          (prefixInfo)))
 #define        ILCoderLoadFieldAddr(coder,ptrType,objectType,field,fieldType) \
                        ((*((coder)->classInfo->loadFieldAddr))((coder), 
(ptrType), \
                                                                                
                    (objectType), (field), \
@@ -1006,24 +1037,28 @@ struct _tagILCoderClass
 #define        ILCoderLoadStaticFieldAddr(coder,field,fieldType) \
                        ((*((coder)->classInfo->loadStaticFieldAddr))((coder), 
(field), \
                                                                                
                              (fieldType)))
-#define        
ILCoderStoreField(coder,ptrType,objectType,field,fieldType,valueType) \
+#define        
ILCoderStoreField(coder,ptrType,objectType,field,fieldType,valueType,prefixInfo)
 \
                        ((*((coder)->classInfo->storeField))((coder), 
(ptrType), \
                                                                                
                 (objectType), (field), \
-                                                                               
                 (fieldType), (valueType)))
-#define        ILCoderStoreStaticField(coder,field,fieldType,valueType) \
+                                                                               
                 (fieldType), (valueType), \
+                                                                               
                 (prefixInfo)))
+#define        
ILCoderStoreStaticField(coder,field,fieldType,valueType,prefixInfo) \
                        ((*((coder)->classInfo->storeStaticField))((coder), 
(field), \
-                                                                               
               (fieldType), (valueType)))
+                                                                               
                           (fieldType), \
+                                                                               
                           (valueType), \
+                                                                               
                           (prefixInfo)))
 #define        ILCoderCopyObject(coder,destPtrType,srcPtrType,_classInfo) \
                        ((*((coder)->classInfo->copyObject))((coder), 
(destPtrType), \
                                                                                
             (srcPtrType), (_classInfo)))
-#define        ILCoderCopyBlock(coder,destPtrType,srcPtrType) \
+#define        ILCoderCopyBlock(coder,destPtrType,srcPtrType,prefixInfo) \
                        ((*((coder)->classInfo->copyBlock))((coder), 
(destPtrType), \
-                                                                               
            (srcPtrType)))
+                                                                               
            (srcPtrType), (prefixInfo)))
 #define        ILCoderInitObject(coder,ptrType,_classInfo) \
                        ((*((coder)->classInfo->initObject))((coder), 
(ptrType), \
                                                                                
             (_classInfo)))
-#define        ILCoderInitBlock(coder,ptrType) \
-                       ((*((coder)->classInfo->initBlock))((coder), (ptrType)))
+#define        ILCoderInitBlock(coder,ptrType,prefixInfo) \
+                       ((*((coder)->classInfo->initBlock))((coder), (ptrType), 
\
+                                                                               
                (prefixInfo)))
 #define        ILCoderBox(coder,boxClass,valueType,size) \
                        ((*((coder)->classInfo->box))((coder), (boxClass), \
                                                                                
  (valueType), (size)))
@@ -1033,8 +1068,8 @@ struct _tagILCoderClass
 #define        ILCoderBoxSmaller(coder,boxClass,valueType,smallerType) \
                        ((*((coder)->classInfo->boxSmaller))((coder), 
(boxClass), \
                                                                                
         (valueType), (smallerType)))
-#define        ILCoderUnbox(coder,boxClass) \
-                       ((*((coder)->classInfo->unbox))((coder), (boxClass)))
+#define        ILCoderUnbox(coder,boxClass,prefixInfo) \
+                       ((*((coder)->classInfo->unbox))((coder), (boxClass), 
(prefixInfo)))
 #define        ILCoderMakeTypedRef(coder,_classInfo) \
                        ((*((coder)->classInfo->makeTypedRef))((coder), 
(_classInfo)))
 #define        ILCoderRefAnyVal(coder,_classInfo) \

http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=7e9bed7615870e3c27831bce63ef144c90ed2491

commit 7e9bed7615870e3c27831bce63ef144c90ed2491
Author: Klaus Treichel <address@hidden>
Date:   Sat Nov 7 19:16:06 2009 +0100

    Rewrite prefix opcode handling in verifyer.

diff --git a/ChangeLog b/ChangeLog
index cd18e3a..6c597dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2009-11-07  Klaus Treichel  <address@hidden>
+
+       * include/il_coder.h: Declare the ILCoderPrefixInfo struct and add a
+       pointer to that struct as argument to coder functions where the used
+       prefixes might be interresting.
+
+       * engine/verify.c, engine/verify_call.c, engine/verify_obj.c,
+       engine/verify_ptr.c, engine/verify_var.c: Change the prefix handling to
+       storing the prefixes for a regular opcode in an ILCoderPrefixInfo struct
+       and pass it to the coder function while processing the regular opcode.
+
+       * engine/cvmc.c, engine/cvmc_obj.c, engine/cvmc_ptr.c: Add a pointer to
+       the prefix info struct to the coder functions where needed.
+
+       * engine/jitc.c, engine/jitc_array.c, engine/jitc_obj.c,
+       engine/jitc_ptr.c: likewise
+
+       * engine/null_coder.c: likewise
+       
 2009-10-29  Klaus Treichel  <address@hidden>
 
        * cscc/csharp/cs_grammar.y: Fix parsing for stackalloc.
diff --git a/engine/cvmc.c b/engine/cvmc.c
index 635c5ef..d14bb02 100644
--- a/engine/cvmc.c
+++ b/engine/cvmc.c
@@ -546,7 +546,6 @@ ILCoderClass const _ILCVMCoderClass =
        CVMCoder_Compare,
        CVMCoder_Conv,
        CVMCoder_ToPointer,
-       CVMCoder_PtrPrefix,
        CVMCoder_ArrayLength,
        CVMCoder_NewArray,
        CVMCoder_LocalAlloc,
diff --git a/engine/cvmc_obj.c b/engine/cvmc_obj.c
index 7ab25ce..0489acd 100644
--- a/engine/cvmc_obj.c
+++ b/engine/cvmc_obj.c
@@ -21,7 +21,8 @@
 #ifdef IL_CVMC_CODE
 
 static void CVMCoder_CastClass(ILCoder *coder, ILClass *classInfo,
-                                                          int throwException)
+                                                          int throwException,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        if(ILClass_IsInterface(classInfo))
        {
@@ -274,7 +275,8 @@ static void CVMLoadField(ILCoder *coder, ILEngineType 
ptrType,
 
 static void CVMCoder_LoadField(ILCoder *coder, ILEngineType ptrType,
                                                           ILType *objectType, 
ILField *field,
-                                                          ILType *fieldType)
+                                                          ILType *fieldType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
 #ifdef IL_NATIVE_INT64
        /* Convert I4 to I if necessary */
@@ -288,7 +290,8 @@ static void CVMCoder_LoadField(ILCoder *coder, ILEngineType 
ptrType,
 }
 
 static void CVMCoder_LoadThisField(ILCoder *coder, ILField *field,
-                                                                  ILType 
*fieldType)
+                                                                  ILType 
*fieldType,
+                                                                  const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILType *enumType;
 
@@ -370,7 +373,8 @@ static void LoadPInvokeFieldAddress(ILCoder *coder, ILField 
*field,
 #endif /* IL_CONFIG_PINVOKE */
 
 static void CVMCoder_LoadStaticField(ILCoder *coder, ILField *field,
-                                                                ILType 
*fieldType)
+                                                                        ILType 
*fieldType,
+                                                                        const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILClass *classInfo;
 
@@ -790,8 +794,9 @@ static void CVMStoreField(ILCoder *coder, ILField *field,
 }
 
 static void CVMCoder_StoreField(ILCoder *coder, ILEngineType ptrType,
-                                                           ILType *objectType, 
ILField *field,
-                                                           ILType *fieldType, 
ILEngineType valueType)
+                                                               ILType 
*objectType, ILField *field,
+                                                               ILType 
*fieldType, ILEngineType valueType,
+                                                               const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILUInt32 valueSize = GetStackTypeSize(((ILCVMCoder *)coder)->process, 
fieldType);
 
@@ -811,7 +816,8 @@ static void CVMCoder_StoreField(ILCoder *coder, 
ILEngineType ptrType,
 }
 
 static void CVMCoder_StoreStaticField(ILCoder *coder, ILField *field,
-                                                                 ILType 
*fieldType, ILEngineType valueType)
+                                                                         
ILType *fieldType, ILEngineType valueType,
+                                                                         const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILUInt32 valueSize = 
GetStackTypeSize(_ILCoderToILCVMCoder(coder)->process,
                                                                                
  fieldType);
@@ -910,7 +916,8 @@ static void CVMCoder_CopyObject(ILCoder *coder, 
ILEngineType destPtrType,
 }
 
 static void CVMCoder_CopyBlock(ILCoder *coder, ILEngineType destPtrType,
-                                                          ILEngineType 
srcPtrType)
+                                                          ILEngineType 
srcPtrType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
 #ifdef IL_NATIVE_INT64
        /* Normalize the pointers */
@@ -965,7 +972,8 @@ static void CVMCoder_InitObject(ILCoder *coder, 
ILEngineType ptrType,
        CVM_ADJUST(-1);
 }
 
-static void CVMCoder_InitBlock(ILCoder *coder, ILEngineType ptrType)
+static void CVMCoder_InitBlock(ILCoder *coder, ILEngineType ptrType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
 #ifdef IL_NATIVE_INT64
        /* Normalize the pointer */
@@ -987,7 +995,7 @@ static void CVMCoder_InitBlock(ILCoder *coder, ILEngineType 
ptrType)
 }
 
 static void CVMCoder_Box(ILCoder *coder, ILClass *boxClass,
-                                            ILEngineType valueType, ILUInt32 
size)
+                                                ILEngineType valueType, 
ILUInt32 size)
 {
        ILUInt32 sizeInWords;
 
@@ -1009,7 +1017,7 @@ static void CVMCoder_Box(ILCoder *coder, ILClass 
*boxClass,
 }
 
 static void CVMCoder_BoxSmaller(ILCoder *coder, ILClass *boxClass,
-                                                           ILEngineType 
valueType, ILType *smallerType)
+                                                               ILEngineType 
valueType, ILType *smallerType)
 {
        /* Align the value on the proper stack word boundary and then box it */
        switch(ILType_ToElement(smallerType))
@@ -1061,7 +1069,8 @@ static void CVMCoder_BoxPtr(ILCoder *coder, ILClass 
*boxClass,
        }
 }
 
-static void CVMCoder_Unbox(ILCoder *coder, ILClass *boxClass)
+static void CVMCoder_Unbox(ILCoder *coder, ILClass *boxClass,
+                                                  const ILCoderPrefixInfo 
*prefixInfo)
 {
        /* We don't have to do anything here: the object reference
           points at the start of the object's fields, which is
diff --git a/engine/cvmc_ptr.c b/engine/cvmc_ptr.c
index edad1dc..e8c6d43 100644
--- a/engine/cvmc_ptr.c
+++ b/engine/cvmc_ptr.c
@@ -106,7 +106,8 @@ static void StoreArrayElem(ILCoder *coder, int opcode1, int 
opcode2,
  * Handle an array access opcode.
  */
 static void CVMCoder_ArrayAccess(ILCoder *coder, int opcode,
-                                                                ILEngineType 
indexType, ILType *elemType)
+                                                                ILEngineType 
indexType, ILType *elemType,
+                                                                const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILUInt32 size;
 
@@ -379,7 +380,8 @@ static void CVMCoder_ArrayAccess(ILCoder *coder, int opcode,
 /*
  * Handle a pointer indirection opcode.
  */
-static void CVMCoder_PtrAccess(ILCoder *coder, int opcode)
+static void CVMCoder_PtrAccess(ILCoder *coder, int opcode,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        switch(opcode)
        {
@@ -543,12 +545,12 @@ void CVMCoder_PtrDeref(ILCoder *coder, int pos)
 {
        if(pos == 0)
        {
-               CVMCoder_PtrAccess(coder, IL_OP_LDIND_REF);
+               CVMCoder_PtrAccess(coder, IL_OP_LDIND_REF, 0);
        }
        else
        {
                CVM_OUT_WIDE(COP_DUP_WORD_N, pos);
-               CVMCoder_PtrAccess(coder, IL_OP_LDIND_REF);
+               CVMCoder_PtrAccess(coder, IL_OP_LDIND_REF, 0);
                CVMP_OUT_WORD(COP_PREFIX_REPL_WORD_N, pos+1);
        }
 }
@@ -557,7 +559,8 @@ void CVMCoder_PtrDeref(ILCoder *coder, int pos)
  * Handle a pointer indirection opcode for a managed value.
  */
 static void CVMCoder_PtrAccessManaged(ILCoder *coder, int opcode,
-                                                                         
ILClass *classInfo)
+                                                                         
ILClass *classInfo,
+                                                                         const 
ILCoderPrefixInfo *prefixInfo)
 {
        /* Compute the size of the managed value in memory and on the stack */
        ILUInt32 memorySize = _ILSizeOfTypeLocked(((ILCVMCoder 
*)coder)->process, ILType_FromValueType(classInfo));
@@ -602,15 +605,6 @@ static void CVMCoder_PtrAccessManaged(ILCoder *coder, int 
opcode,
 }
 
 /*
- * Process a pointer alignment prefix.  An "alignment" value
- * of zero indicates a "volatile" prefix.
- */
-static void CVMCoder_PtrPrefix(ILCoder *coder, int alignment)
-{
-       /* TODO */
-}
-
-/*
  * Get the length of an array.
  */
 static void CVMCoder_ArrayLength(ILCoder *coder)
diff --git a/engine/jitc.c b/engine/jitc.c
index d23c96b..57a6ed4 100755
--- a/engine/jitc.c
+++ b/engine/jitc.c
@@ -5144,7 +5144,6 @@ ILCoderClass const _ILJITCoderClass =
        JITCoder_Compare,
        JITCoder_Conv,
        JITCoder_ToPointer,
-       JITCoder_PtrPrefix,
        JITCoder_ArrayLength,
        JITCoder_NewArray,
        JITCoder_LocalAlloc,
diff --git a/engine/jitc_array.c b/engine/jitc_array.c
index 4118a3e..9b4a291 100755
--- a/engine/jitc_array.c
+++ b/engine/jitc_array.c
@@ -780,7 +780,8 @@ static void StoreArrayElem(ILJITCoder *coder, ILJitType 
type)
  * Handle an array access opcode.
  */
 static void JITCoder_ArrayAccess(ILCoder *coder, int opcode,
-                                                                ILEngineType 
indexType, ILType *elemType)
+                                                                ILEngineType 
indexType, ILType *elemType,
+                                                                const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(array);
diff --git a/engine/jitc_obj.c b/engine/jitc_obj.c
index 2dcaef7..0e1ef61 100755
--- a/engine/jitc_obj.c
+++ b/engine/jitc_obj.c
@@ -247,7 +247,6 @@ static ILJitValue _ILJitLoadField(ILJITCoder *coder, 
ILJitStackItem *base,
 static void _ILJitStoreField(ILJITCoder *coder, ILJitStackItem *base,
                                                                   ILJitValue 
value, ILType *fieldType,
                                                                   ILUInt32 
offset, int mayBeNull)
-                                                                  
 {
        ILJitType type = _ILJitGetReturnType(fieldType, coder->process);
 
@@ -263,7 +262,8 @@ static void _ILJitStoreField(ILJITCoder *coder, 
ILJitStackItem *base,
 }
 
 static void JITCoder_CastClass(ILCoder *coder, ILClass *classInfo,
-                                                          int throwException)
+                                                          int throwException,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitValue classTo = 
jit_value_create_nint_constant(jitCoder->jitFunction,
@@ -334,7 +334,8 @@ static void JITCoder_CastClass(ILCoder *coder, ILClass 
*classInfo,
 
 static void JITCoder_LoadField(ILCoder *coder, ILEngineType ptrType,
                                                           ILType *objectType, 
ILField *field,
-                                                          ILType *fieldType)
+                                                          ILType *fieldType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitValue value = 0;
@@ -373,7 +374,8 @@ static void JITCoder_LoadField(ILCoder *coder, ILEngineType 
ptrType,
 }
 
 static void JITCoder_LoadThisField(ILCoder *coder, ILField *field,
-                                                                  ILType 
*fieldType)
+                                                                  ILType 
*fieldType,
+                                                                  const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(param);
@@ -397,7 +399,8 @@ static void JITCoder_LoadThisField(ILCoder *coder, ILField 
*field,
 }
 
 static void JITCoder_LoadStaticField(ILCoder *coder, ILField *field,
-                                                                ILType 
*fieldType)
+                                                                        ILType 
*fieldType,
+                                                                        const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILJitValue value = 0;
@@ -653,8 +656,9 @@ static void JITCoder_LoadStaticFieldAddr(ILCoder *coder, 
ILField *field,
 }
 
 static void JITCoder_StoreField(ILCoder *coder, ILEngineType ptrType,
-                                                           ILType *objectType, 
ILField *field,
-                                                           ILType *fieldType, 
ILEngineType valueType)
+                                                               ILType 
*objectType, ILField *field,
+                                                               ILType 
*fieldType, ILEngineType valueType,
+                                                               const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(value);
@@ -682,7 +686,9 @@ static void JITCoder_StoreField(ILCoder *coder, 
ILEngineType ptrType,
 }
 
 static void JITCoder_StoreStaticField(ILCoder *coder, ILField *field,
-                                     ILType *fieldType, ILEngineType valueType)
+                                                                         
ILType *fieldType,
+                                                                         
ILEngineType valueType,
+                                                                         const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(stackItem);
@@ -826,7 +832,8 @@ static void JITCoder_CopyObject(ILCoder *coder, 
ILEngineType destPtrType,
 }
 
 static void JITCoder_CopyBlock(ILCoder *coder, ILEngineType destPtrType,
-                                                          ILEngineType 
srcPtrType)
+                                                          ILEngineType 
srcPtrType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(size);
@@ -849,7 +856,7 @@ static void JITCoder_CopyBlock(ILCoder *coder, ILEngineType 
destPtrType,
 }
 
 static void JITCoder_InitObject(ILCoder *coder, ILEngineType ptrType,
-                               ILClass *classInfo)
+                                                               ILClass 
*classInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILType *type = ILClassToType(classInfo);
@@ -874,7 +881,8 @@ static void JITCoder_InitObject(ILCoder *coder, 
ILEngineType ptrType,
                                                  memSize);
 }
 
-static void JITCoder_InitBlock(ILCoder *coder, ILEngineType ptrType)
+static void JITCoder_InitBlock(ILCoder *coder, ILEngineType ptrType,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        _ILJitStackItemNew(size);
@@ -1066,7 +1074,8 @@ static void JITCoder_BoxSmaller(ILCoder *coder, ILClass 
*boxClass,
        _ILJitStackPushNotNullValue(jitCoder, newObj);
 }
 
-static void JITCoder_Unbox(ILCoder *coder, ILClass *boxClass)
+static void JITCoder_Unbox(ILCoder *coder, ILClass *boxClass,
+                                                  const ILCoderPrefixInfo 
*prefixInfo)
 {
        /* We don't have to do anything here: the object reference
           points at the start of the object's fields, which is
diff --git a/engine/jitc_ptr.c b/engine/jitc_ptr.c
index 8f3fd18..16bceee 100755
--- a/engine/jitc_ptr.c
+++ b/engine/jitc_ptr.c
@@ -98,7 +98,8 @@ static void StoreRelative(ILJITCoder *coder, ILJitType type)
 /*
  * Handle a pointer indirection opcode.
  */
-static void JITCoder_PtrAccess(ILCoder *coder, int opcode)
+static void JITCoder_PtrAccess(ILCoder *coder, int opcode,
+                                                          const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
 
@@ -275,7 +276,8 @@ static void JITCoder_PtrDeref(ILCoder *coder, int pos)
  * Handle a pointer indirection opcode for a managed value.
  */
 static void JITCoder_PtrAccessManaged(ILCoder *coder, int opcode,
-                                                                         
ILClass *classInfo)
+                                                                         
ILClass *classInfo,
+                                                                         const 
ILCoderPrefixInfo *prefixInfo)
 {
        ILJITCoder *jitCoder = _ILCoderToILJITCoder(coder);
        ILType *type = ILClassToType(classInfo);
@@ -353,14 +355,6 @@ static void JITCoder_PtrAccessManaged(ILCoder *coder, int 
opcode,
 }
 
 /*
- * Process a pointer alignment prefix.  An "alignment" value
- * of zero indicates a "volatile" prefix.
- */
-static void JITCoder_PtrPrefix(ILCoder *coder, int alignment)
-{
-}
-
-/*
  * Check the top of stack value for NULL.
  */
 static void JITCoder_CheckNull(ILCoder *coder)
diff --git a/engine/null_coder.c b/engine/null_coder.c
index cc26b36..8f99fd4 100644
--- a/engine/null_coder.c
+++ b/engine/null_coder.c
@@ -114,7 +114,7 @@ static void Coder_LoadLocal(ILCoder *coder, ILUInt32 num, 
ILType *type)
 {
 }
 static void Coder_StoreLocal(ILCoder *coder, ILUInt32 num,
-                                                        ILEngineType 
engineType, ILType *type)
+                                                        ILEngineType 
engineType, ILType *type)
 {
 }
 static void Coder_AddrOfLocal(ILCoder *coder, ILUInt32 num)
@@ -127,21 +127,24 @@ static void Coder_Pop(ILCoder *coder, ILEngineType 
valueType, ILType *type)
 {
 }
 static void Coder_ArrayAccess(ILCoder *coder, int opcode,
-                                                         ILEngineType 
indexType, ILType *elemType)
+                                                         ILEngineType 
indexType, ILType *elemType,
+                                                         const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
-static void Coder_PtrAccess(ILCoder *coder, int opcode)
+static void Coder_PtrAccess(ILCoder *coder, int opcode,
+                                                       const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_PtrDeref(ILCoder *coder, int pos)
 {
 }
 static void Coder_PtrAccessManaged(ILCoder *coder, int opcode,
-                                                                  ILClass 
*classInfo)
+                                                                  ILClass 
*classInfo,
+                                                                  const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
 static void Coder_Branch(ILCoder *coder, int opcode, ILUInt32 dest,
-                                                ILEngineType type1, 
ILEngineType type2)
+                                                ILEngineType type1, 
ILEngineType type2)
 {
 }
 static void Coder_SwitchStart(ILCoder *coder, ILUInt32 numEntries)
@@ -154,7 +157,7 @@ static void Coder_SwitchEnd(ILCoder *coder)
 {
 }
 static void Coder_Compare(ILCoder *coder, int opcode,
-                                                 ILEngineType type1, 
ILEngineType type2,
+                                                 ILEngineType type1, 
ILEngineType type2,
                                                  int invertTest)
 {
 }
@@ -165,9 +168,6 @@ static void Coder_ToPointer(ILCoder *coder, ILEngineType 
type1,
                                                        ILEngineStackItem 
*type2)
 {
 }
-static void Coder_PtrPrefix(ILCoder *coder, int alignment)
-{
-}
 static void Coder_ArrayLength(ILCoder *coder)
 {
 }
@@ -179,20 +179,24 @@ static void Coder_LocalAlloc(ILCoder *coder, ILEngineType 
sizeType)
 {
 }
 static void Coder_CastClass(ILCoder *coder, ILClass *classInfo,
-                                                       int throwException)
+                                                       int throwException,
+                                                       const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_LoadField(ILCoder *coder, ILEngineType ptrType,
                                                        ILType *objectType, 
ILField *field,
-                                                       ILType *fieldType)
+                                                       ILType *fieldType,
+                                                       const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_LoadThisField(ILCoder *coder, ILField *field,
-                                                           ILType *fieldType)
+                                                               ILType 
*fieldType,
+                                                               const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
 static void Coder_LoadStaticField(ILCoder *coder, ILField *field,
-                                                             ILType *fieldType)
+                                                                 ILType 
*fieldType,
+                                                                 const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
 static void Coder_LoadFieldAddr(ILCoder *coder, ILEngineType ptrType,
@@ -206,11 +210,13 @@ static void Coder_LoadStaticFieldAddr(ILCoder *coder, 
ILField *field,
 }
 static void Coder_StoreField(ILCoder *coder, ILEngineType ptrType,
                                                         ILType *objectType, 
ILField *field,
-                                                        ILType *fieldType, 
ILEngineType valueType)
+                                                        ILType *fieldType, 
ILEngineType valueType,
+                                                        const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
 static void Coder_StoreStaticField(ILCoder *coder, ILField *field,
-                                                              ILType 
*fieldType, ILEngineType valueType)
+                                                              ILType 
*fieldType, ILEngineType valueType,
+                                                                  const 
ILCoderPrefixInfo *prefixInfo)
 {
 }
 static void Coder_CopyObject(ILCoder *coder, ILEngineType destPtrType,
@@ -218,14 +224,16 @@ static void Coder_CopyObject(ILCoder *coder, ILEngineType 
destPtrType,
 {
 }
 static void Coder_CopyBlock(ILCoder *coder, ILEngineType destPtrType,
-                                                       ILEngineType srcPtrType)
+                                                       ILEngineType srcPtrType,
+                                                       const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_InitObject(ILCoder *coder, ILEngineType ptrType,
                                                         ILClass *classInfo)
 {
 }
-static void Coder_InitBlock(ILCoder *coder, ILEngineType ptrType)
+static void Coder_InitBlock(ILCoder *coder, ILEngineType ptrType,
+                                                       const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_Box(ILCoder *coder, ILClass *boxClass,
@@ -240,7 +248,8 @@ static void Coder_BoxSmaller(ILCoder *coder, ILClass 
*boxClass,
                                                         ILEngineType 
valueType, ILType *smallerType)
 {
 }
-static void Coder_Unbox(ILCoder *coder, ILClass *boxClass)
+static void Coder_Unbox(ILCoder *coder, ILClass *boxClass,
+                                               const ILCoderPrefixInfo 
*prefixInfo)
 {
 }
 static void Coder_MakeTypedRef(ILCoder *coder, ILClass *classInfo)
@@ -495,7 +504,6 @@ ILCoderClass const _ILNullCoderClass = {
        Coder_Compare,
        Coder_Conv,
        Coder_ToPointer,
-       Coder_PtrPrefix,
        Coder_ArrayLength,
        Coder_NewArray,
        Coder_LocalAlloc,
diff --git a/engine/verify.c b/engine/verify.c
index 642ff39..9041901 100644
--- a/engine/verify.c
+++ b/engine/verify.c
@@ -165,6 +165,65 @@ static IL_INLINE int IsSpecialJumpTarget(unsigned long 
*jumpMask,
 }
 
 /*
+ * Clear valid prefixes for an insn
+ */
+#define CLEAR_VALID_PREFIXES(prefixInfo, p, n) \
+       do { \
+               (prefixInfo).prefixFlags &= ~(p); \
+               (prefixInfo).noFlags &= ~(n); \
+       } while (0)
+
+/*
+ * Initialize the prefix members indicating valid values.
+ */
+#define INIT_PREFIXES(prefixInfo) \
+       do { \
+               (prefixInfo).prefixFlags = 0; \
+               (prefixInfo).noFlags = 0; \
+       } while (0)
+
+/*
+ * Valid prefixes for the different insns.
+ */
+#define VALID_LDIND_PREFIX             (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_STIND_PREFIX             (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_LDELEM_PREFIX            (IL_CODER_PREFIX_NO)
+#define VALID_LDELEMA_PREFIX   (IL_CODER_PREFIX_NO | IL_PREFIX_OP_READONLY)
+#define VALID_LDELEM_T_PREFIX  (IL_CODER_PREFIX_NO)
+#define VALID_LDOBJ_PREFIX             (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_STELEM_PREFIX            (IL_CODER_PREFIX_NO)
+#define VALID_STELEM_T_PREFIX  (IL_CODER_PREFIX_NO)
+#define VALID_LDFLD_PREFIX             (IL_CODER_PREFIX_NO | 
IL_CODER_PREFIX_UNALIGNED | IL_CODER_PREFIX_VOLATILE)
+#define VALID_LDSFLD_PREFIX            (IL_CODER_PREFIX_VOLATILE)
+#define VALID_STFLD_PREFIX             (IL_CODER_PREFIX_NO | 
IL_CODER_PREFIX_UNALIGNED | IL_CODER_PREFIX_VOLATILE)
+#define VALID_STSFLD_PREFIX            (IL_CODER_PREFIX_VOLATILE)
+#define VALID_STOBJ_PREFIX             (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_CASTCLASS_PREFIX (IL_CODER_PREFIX_NO)
+#define VALID_CALL_PREFIX              (IL_PREFIX_OP_READONLY)
+#define VALID_CALLVIRT_PREFIX  (IL_CODER_PREFIX_NO | IL_PREFIX_OP_READONLY | 
IL_CODER_PREFIX_CONSTRAINED)
+#define VALID_CPBLK_PREFIX             (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_INITBLK_PREFIX   (IL_CODER_PREFIX_UNALIGNED | 
IL_CODER_PREFIX_VOLATILE)
+#define VALID_LDVIRTFTN_PREFIX (IL_CODER_PREFIX_NO)
+#define VALID_UNBOX_PREFIX             (IL_CODER_PREFIX_NO)
+
+/*
+ * Valid no flags for the different insns.
+ */
+#define VALID_NO_NONE          (0)
+#define VALID_NO_ALL           (IL_PREFIX_OP_NO_TYPECHECK | 
IL_PREFIX_OP_NO_RANGECHECK | IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_LDELEM                (IL_PREFIX_OP_NO_TYPECHECK | 
IL_PREFIX_OP_NO_RANGECHECK | IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_LDELEMA       (IL_PREFIX_OP_NO_TYPECHECK | 
IL_PREFIX_OP_NO_RANGECHECK | IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_LDELEM_T      (IL_PREFIX_OP_NO_RANGECHECK | 
IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_STELEM                (IL_PREFIX_OP_NO_TYPECHECK | 
IL_PREFIX_OP_NO_RANGECHECK | IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_STELEM_T      (IL_PREFIX_OP_NO_RANGECHECK | 
IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_LDFLD         (IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_STFLD         (IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_CASTCLASS     (IL_PREFIX_OP_NO_TYPECHECK)
+#define VALID_NO_CALLVIRT      (IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_LDVIRTFTN     (IL_PREFIX_OP_NO_NULLCHECK)
+#define VALID_NO_UNBOX         (IL_PREFIX_OP_NO_TYPECHECK)
+
+/*
  * Convert a type into an engine type.
  */
 static ILEngineType TypeToEngineType(ILType *type)
@@ -605,8 +664,18 @@ static int IsSubClass(ILType *type, ILClass *classInfo)
                                                                                
code->headerSize), \
                                                (insn ? insn->name : "none"), 
__FILE__, __LINE__); \
                        } while (0)
+#define        VERIFY_PREFIX_REPORT()  \
+                       do { \
+                               fprintf(stderr, "%s::%s [%lX] - invalid prefix 
for %s at %s:%d\n", \
+                                               
ILClass_Name(ILMethod_Owner(method)), \
+                                               ILMethod_Name(method), \
+                                               (unsigned long)(offset + 
ILMethod_RVA(method) + \
+                                                                               
code->headerSize), \
+                                               (insn ? insn->name : "none"), 
__FILE__, __LINE__); \
+                       } while (0)
 #else
 #define        VERIFY_REPORT() do {} while (0)
+#define        VERIFY_PREFIX_REPORT()  do {} while (0)
 #endif
 #define        VERIFY_TRUNCATED()              VERIFY_REPORT(); goto cleanup
 #define        VERIFY_BRANCH_ERROR()   VERIFY_REPORT(); goto cleanup
@@ -614,6 +683,7 @@ static int IsSubClass(ILType *type, ILClass *classInfo)
 #define        VERIFY_STACK_ERROR()    VERIFY_REPORT(); goto cleanup
 #define        VERIFY_TYPE_ERROR()             VERIFY_REPORT(); goto cleanup
 #define        VERIFY_MEMORY_ERROR()   VERIFY_REPORT(); goto cleanup
+#define        VERIFY_PREFIX_ERROR()   VERIFY_PREFIX_REPORT(); goto cleanup
 
 /*
  * Declare global definitions that are required by the include files.
@@ -665,13 +735,13 @@ int _ILVerify(ILCoder *coder, unsigned char **start, 
ILMethod *method,
        ILException *exceptions;
        ILException *exception, *currentException;
        int hasRethrow;
-       int tailCall = 0;
        int tryInlineType;
        int coderFlags;
        unsigned int tryInlineOpcode;
        unsigned char *tryInlinePc;
-       ILType *constraintType;
        ILUInt32 optimizationLevel;
+       ILBool lastInsnWasPrefix;
+       ILCoderPrefixInfo prefixInfo;
 #ifdef IL_CONFIG_DEBUG_LINES
        int haveDebug = ILDebugPresent(ILProgramItem_Image(method));
 #else
@@ -708,8 +778,6 @@ restart:
        result = 0;
        labelList = 0;
        hasRethrow = 0;
-       isReadOnly = 0;
-       constraintType = 0;
 
        /* Initialize the memory allocator that is used for temporary
           allocation during bytecode verification */
@@ -717,6 +785,9 @@ restart:
        allocator.posn = 0;
        allocator.overflow = 0;
 
+       /* Reset the prefix information */
+       ILMemZero(&prefixInfo, sizeof(ILCoderPrefixInfo));
+
        /* Set up the coder to process the method */
        if(!ILCoderSetup(coder, start, method, code))
        {
@@ -1071,6 +1142,7 @@ restart:
                ILCoderCallInlineable(coder, IL_INLINEMETHOD_MONITOR_ENTER, 0, 
0);
        }
 
+       lastInsnWasPrefix = 0;
        while(len > 0)
        {
                /* Fetch the instruction information block */
@@ -1125,13 +1197,26 @@ restart:
                /* Validate the stack height changes */
                if(stackSize < ((ILUInt32)(insn->popped)) ||
                   (stackSize - ((ILUInt32)(insn->popped)) + 
((ILUInt32)(insn->pushed)))
-                               > code->maxStack)
+                               > code->maxStack)
                {
                        VERIFY_STACK_ERROR();
                }
 
+               /*
+                * Check if all prefix flags are zero, otherwise an invalid 
prefix
+                * was used for the last instruction.
+                */
+               if(!lastInsnWasPrefix)
+               {
+                       if((prefixInfo.prefixFlags != 0) || (prefixInfo.noFlags 
!= 0))
+                       {
+                               VERIFY_PREFIX_ERROR();
+                       }
+               }
+
                /* Verify the instruction */
                lastWasJump = 0;
+               lastInsnWasPrefix = 0;
                switch(opcode)
                {
                        case IL_OP_NOP:   break;
diff --git a/engine/verify_call.c b/engine/verify_call.c
index 3e21185..807ab7e 100644
--- a/engine/verify_call.c
+++ b/engine/verify_call.c
@@ -1648,7 +1648,30 @@ break;
 
 case IL_OP_CALL:
 {
+       int tailCall;
+
        /* Call a particular method directly */
+       tailCall = ((prefixInfo.prefixFlags & IL_CODER_PREFIX_TAIL) != 0);
+       if(tailCall)
+       {
+               if(len < 6)
+               {
+                       VERIFY_TRUNCATED();
+               }
+
+               /* Check that this instruction is not a branch target */
+               if(IsJumpTarget(jumpMask, offset))
+               {
+                       VERIFY_BRANCH_ERROR();
+               }
+
+               /* Check that the instruction following the call is a ret */
+               if(pc[5] != IL_OP_RET)
+               {
+                       VERIFY_INSN_ERROR();
+               }
+       }
+
        methodInfo = GetMethodToken(_ILExecThreadProcess(thread), method, pc,
                                                                
&methodSignature);
        if(methodInfo && !ILMethod_IsAbstract(methodInfo))
@@ -1659,7 +1682,6 @@ case IL_OP_CALL:
                                                                           
methodSignature, methodInfo,
                                                                           
unsafeAllowed, 0, 0,
                                                                           
&callInfo, tailCall);
-                       tailCall = 0;
                        if(numParams >= 0)
                        {
                                returnType = ILTypeGetReturn(methodSignature);
@@ -1906,7 +1928,9 @@ callNonvirtualFromVirtual:
                                                                
if(AssignCompatible(method, &(stack[stackSize - 1]),
                                                                                
                        classType, unsafeAllowed))
                                                                {
-                                                                       
ILCoderStoreStaticField(coder, fieldInfo, classType, STK_UNARY);
+                                                                       
ILCoderStoreStaticField(coder, fieldInfo,
+                                                                               
                                        classType,
+                                                                               
                                        STK_UNARY, 0);
                                                                }
                                                                else
                                                                {
@@ -1922,19 +1946,19 @@ callNonvirtualFromVirtual:
                                                                        
if(IsSubClass(stack[stackSize - 2].typeInfo,
                                                                                
                ILField_Owner(fieldInfo)) &&
                                                                        
AssignCompatible(methodInfo, &(stack[stackSize - 1]),
-                                                                               
                                classType, unsafeAllowed))
+                                                                               
                         classType, unsafeAllowed))
                                                                        {
                                                                                
if(!ILField_IsStatic(fieldInfo))
                                                                                
{
                                                                                
        ILCoderStoreField(coder, ILEngineType_O,
-                                                                               
                                        stack[stackSize - 2].typeInfo,
-                                                                               
                                        fieldInfo, classType,
-                                                                               
                                        STK_BINARY_2);
+                                                                               
                                          stack[stackSize - 2].typeInfo,
+                                                                               
                                          fieldInfo, classType,
+                                                                               
                                          STK_BINARY_2, 0);
                                                                                
}
                                                                                
else
                                                                                
{
                                                                                
        ILCoderStoreStaticField(coder, fieldInfo, classType,
-                                                                               
                                                        STK_BINARY_2);
+                                                                               
                                                        STK_BINARY_2, 0);
                                                                                
        ILCoderPop(coder, ILEngineType_O, ILType_Invalid);
                                                                                
}
                                                                        }
@@ -1957,12 +1981,13 @@ callNonvirtualFromVirtual:
                                                                                
{
                                                                                
        ILCoderStoreField(coder, STK_BINARY_1,
                                                                                
                                        stack[stackSize - 2].typeInfo,
-                                                                               
                                        fieldInfo, classType, STK_BINARY_2);
+                                                                               
                                        fieldInfo, classType,
+                                                                               
                                        STK_BINARY_2, 0);
                                                                                
}
                                                                                
else
                                                                                
{
                                                                                
        ILCoderStoreStaticField(coder, fieldInfo, classType,
-                                                                               
                                                        STK_BINARY_2);
+                                                                               
                                                        STK_BINARY_2, 0);
                                                                                
        ILCoderPop(coder, STK_BINARY_2, ILType_Invalid);
                                                                                
}
                                                                        }
@@ -1982,13 +2007,14 @@ callNonvirtualFromVirtual:
                                                                        
if(!ILField_IsStatic(fieldInfo))
                                                                        {
                                                                                
ILCoderStoreField(coder, STK_BINARY_1,
-                                                                               
                                stack[stackSize - 2].typeInfo,
-                                                                               
                                fieldInfo, classType, STK_BINARY_2);
+                                                                               
                                  stack[stackSize - 2].typeInfo,
+                                                                               
                                  fieldInfo, classType,
+                                                                               
                                  STK_BINARY_2, 0);
                                                                        }
                                                                        else
                                                                        {
                                                                                
ILCoderStoreStaticField(coder, fieldInfo, classType,
-                                                                               
                                                STK_BINARY_2);
+                                                                               
                                                STK_BINARY_2, 0);
                                                                                
ILCoderPop(coder, STK_BINARY_1, ILType_Invalid);
                                                                        }
                                                                }
@@ -2003,7 +2029,7 @@ callNonvirtualFromVirtual:
                                                        if 
(ILMethod_IsStatic(methodInfo))
                                                        {
                                                                classType = 
ILField_Type(fieldInfo);
-                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType);
+                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType, 0);
                                                                
stack[stackSize].engineType = TypeToEngineType(classType);
                                                                
stack[stackSize].typeInfo = classType;
                                                        }
@@ -2019,8 +2045,8 @@ callNonvirtualFromVirtual:
                                                                                
                ILField_Owner(fieldInfo)))
                                                                                
{
                                                                                
        ILCoderLoadField(coder, ILEngineType_O,
-                                                                               
                                        stack[stackSize - 1].typeInfo,
-                                                                               
                                        fieldInfo, classType);
+                                                                               
                                         stack[stackSize - 1].typeInfo,
+                                                                               
                                         fieldInfo, classType, 0);
                                                                                
}
                                                                                
else
                                                                                
{
@@ -2030,7 +2056,7 @@ callNonvirtualFromVirtual:
                                                                        else
                                                                        {
                                                                                
ILCoderPop(coder, ILEngineType_O, ILType_Invalid);
-                                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType);
+                                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType, 0);
                                                                        }
                                                                }
                                                                else 
if(!unsafeAllowed &&
@@ -2045,12 +2071,12 @@ callNonvirtualFromVirtual:
                                                                                
{
                                                                                
        ILCoderLoadField(coder, STK_UNARY,
                                                                                
                                        stack[stackSize - 1].typeInfo,
-                                                                               
                                        fieldInfo, classType);
+                                                                               
                                        fieldInfo, classType, 0);
                                                                                
}
                                                                                
else
                                                                                
{
                                                                                
        ILCoderPop(coder, STK_UNARY, ILType_Invalid);
-                                                                               
        ILCoderLoadStaticField(coder, fieldInfo, classType);
+                                                                               
        ILCoderLoadStaticField(coder, fieldInfo, classType, 0);
                                                                                
}
                                                                        }
                                                                        else
@@ -2068,13 +2094,13 @@ callNonvirtualFromVirtual:
                                                                                
{
                                                                                
        ILCoderLoadField(coder, ILEngineType_MV,
                                                                                
                                        stack[stackSize - 1].typeInfo,
-                                                                               
                                        fieldInfo, classType);
+                                                                               
                                        fieldInfo, classType, 0);
                                                                                
}
                                                                                
else
                                                                                
{
                                                                                
        ILCoderPop(coder, ILEngineType_MV,
                                                                                
                        stack[stackSize - 1].typeInfo);
-                                                                               
        ILCoderLoadStaticField(coder, fieldInfo, classType);
+                                                                               
        ILCoderLoadStaticField(coder, fieldInfo, classType, 0);
                                                                                
}
                                                                        }
                                                                        else
@@ -2094,12 +2120,12 @@ callNonvirtualFromVirtual:
                                                                        {
                                                                                
ILCoderLoadField(coder, STK_UNARY,
                                                                                
                                stack[stackSize - 1].typeInfo,
-                                                                               
                                fieldInfo, classType);
+                                                                               
                                fieldInfo, classType, 0);
                                                                        }
                                                                        else
                                                                        {
                                                                                
ILCoderPop(coder, STK_UNARY, ILType_Invalid);
-                                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType);
+                                                                               
ILCoderLoadStaticField(coder, fieldInfo, classType, 0);
                                                                        }
                                                                }
                                                                else
@@ -2122,7 +2148,7 @@ callNonvirtualFromVirtual:
                                                }
                                                /* Not a simple inlinable 
method so just generate a standard method call */
                                                ILCoderCallMethod(coder, 
&callInfo, &(stack[stackSize]),
-                                                                         
methodInfo);
+                                                                               
  methodInfo);
                                        }
                                }
                                else
@@ -2167,12 +2193,36 @@ callNonvirtualFromVirtual:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_CALL_PREFIX, VALID_NO_NONE);
 }
 break;
 
 case IL_OP_CALLI:
 {
+       int tailCall;
+
        /* Call a method using an indirect method pointer */
+       tailCall = ((prefixInfo.prefixFlags & IL_CODER_PREFIX_TAIL) != 0);
+       if(tailCall)
+       {
+               if(len < 6)
+               {
+                       VERIFY_TRUNCATED();
+               }
+
+               /* Check that this instruction is not a branch target */
+               if(IsJumpTarget(jumpMask, offset))
+               {
+                       VERIFY_BRANCH_ERROR();
+               }
+
+               /* Check that the instruction following the call is a ret */
+               if(pc[5] != IL_OP_RET)
+               {
+                       VERIFY_INSN_ERROR();
+               }
+       }
+
        if(stackSize < 1)
        {
                /* We don't have sufficient arguments on the stack */
@@ -2214,7 +2264,6 @@ case IL_OP_CALLI:
                                                                   
methodSignature, 0,
                                                                   
unsafeAllowed, 0, 1,
                                                                   &callInfo, 
tailCall);
-               tailCall = 0;
                if(numParams >= 0)
                {
                        returnType = ILTypeGetReturn(methodSignature);
@@ -2314,30 +2363,57 @@ case IL_OP_PREFIX + IL_PREFIX_OP_CONSTRAINED:
        classInfo = GetClassToken(method, pc);
        if (classInfo)
        {               
-               constraintType = ILClassToType(classInfo);
+               prefixInfo.constrainedType = ILClassToType(classInfo);
+               prefixInfo.prefixFlags |= IL_CODER_PREFIX_CONSTRAINED;
+               lastInsnWasPrefix = 1;
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
-       /* TODO: Verify that next instruction is callvirt */
 }
 break;
 
 case IL_OP_CALLVIRT:
 {
+       int tailCall;
+
        /* Call a virtual or interface method */
+       tailCall = ((prefixInfo.prefixFlags & IL_CODER_PREFIX_TAIL) != 0);
+       if(tailCall)
+       {
+               if(len < 6)
+               {
+                       VERIFY_TRUNCATED();
+               }
+
+               /* Check that this instruction is not a branch target */
+               if(IsJumpTarget(jumpMask, offset))
+               {
+                       VERIFY_BRANCH_ERROR();
+               }
+
+               /* Check that the instruction following the call is a ret */
+               if(pc[5] != IL_OP_RET)
+               {
+                       VERIFY_INSN_ERROR();
+               }
+       }
+
        methodInfo = GetMethodToken(_ILExecThreadProcess(thread), method, pc, 
&methodSignature);
        if(methodInfo)
        {
-               ILType *_constraintType = constraintType;
+               ILType *constrainedType = 0;
                int callNonVirtual = 0;
-               
-               constraintType = 0;
+
+               if((prefixInfo.prefixFlags & IL_CODER_PREFIX_CONSTRAINED) != 0)
+               {
+                       constrainedType = prefixInfo.constrainedType;
+               }
                classInfo = ILMethod_Owner(method);
                if(ILMemberAccessible((ILMember *)methodInfo, classInfo))
                {
-                       if(_constraintType)
+                       if(constrainedType)
                        {
                                ILEngineStackItem *item;
 
@@ -2346,10 +2422,10 @@ case IL_OP_CALLVIRT:
                                if (((item->engineType == ILEngineType_M) ||
                                         (item->engineType == ILEngineType_CM) 
||
                                         (item->engineType == ILEngineType_T)) 
&&
-                                       ILTypeIdentical(_constraintType, 
item->typeInfo))
+                                       ILTypeIdentical(constrainedType, 
item->typeInfo))
                                {
                                        ILClass *thisClass = 
ILClassFromType(ILProgramItem_Image(method),
-                                                                               
                                 0, _constraintType, 0);
+                                                                               
                                 0, constrainedType, 0);
 
                                        if(!ILClassIsValueType(thisClass))
                                        {
@@ -2367,13 +2443,13 @@ case IL_OP_CALLVIRT:
                                                {
                                                        methodInfo = (ILMethod 
*)member;
                                                        item->engineType = 
ILEngineType_M;
-                                                       item->typeInfo = 
_constraintType;
+                                                       item->typeInfo = 
constrainedType;
                                                        callNonVirtual = 1;
                                                }
                                                else
                                                {
                                                        
if(BoxPtr(_ILExecThreadProcess(thread), 
-                                                                         
_constraintType, thisClass, numParams))
+                                                                         
constrainedType, thisClass, numParams))
                                                        {
                                                                
item->engineType = ILEngineType_O;
                                                                item->typeInfo 
= ILType_FromClass(thisClass);
@@ -2394,7 +2470,6 @@ case IL_OP_CALLVIRT:
                                                                           
methodSignature, methodInfo,
                                                                           
unsafeAllowed, 0, 0,
                                                                           
&callInfo, tailCall);
-                       tailCall = 0;
                        if(numParams >= 0)
                        {
                                returnType = ILTypeGetReturn(methodSignature);
@@ -2449,6 +2524,7 @@ case IL_OP_CALLVIRT:
        {
                ThrowSystem("System", "MissingMethodException");
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_CALLVIRT_PREFIX, 
VALID_NO_CALLVIRT);
 }
 break;
 
@@ -2488,8 +2564,7 @@ case IL_OP_NEWOBJ:
                        numParams = MatchSignature(coder, stack, stackSize,
                                                                           
methodSignature, methodInfo,
                                                                           
unsafeAllowed, 1, 0,
-                                                                          
&callInfo, tailCall);
-                       tailCall = 0;
+                                                                          
&callInfo, 0);
                        if(numParams < 0)
                        {
                                VERIFY_TYPE_ERROR();
@@ -2529,8 +2604,7 @@ case IL_OP_NEWOBJ:
                        numParams = MatchSignature(coder, stack, stackSize,
                                                                           
methodSignature, methodInfo,
                                                                           
unsafeAllowed, 0, 0,
-                                                                          
&callInfo, tailCall);
-                       tailCall = 0;
+                                                                          
&callInfo, 0);
                        if(numParams < 0)
                        {
                                VERIFY_TYPE_ERROR();
@@ -2642,6 +2716,8 @@ case IL_OP_PREFIX + IL_PREFIX_OP_LDVIRTFTN:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDVIRTFTN_PREFIX,
+                                                VALID_NO_LDVIRTFTN);
 }
 break;
 
@@ -2673,7 +2749,8 @@ case IL_OP_PREFIX + IL_PREFIX_OP_TAIL:
        }
 
        /* Set the tail call flag and then advance to the next instruction */
-       tailCall = 1;
+       prefixInfo.prefixFlags |= IL_CODER_PREFIX_TAIL;
+       lastInsnWasPrefix = 1;
 }
 break;
 
diff --git a/engine/verify_obj.c b/engine/verify_obj.c
index be40ec0..ea30c7c 100644
--- a/engine/verify_obj.c
+++ b/engine/verify_obj.c
@@ -280,7 +280,7 @@ case IL_OP_CASTCLASS:
        {
                if(classInfo != 0)
                {
-                       ILCoderCastClass(coder, classInfo, 1);
+                       ILCoderCastClass(coder, classInfo, 1, &prefixInfo);
                        stack[stackSize - 1].typeInfo = 
ILClassToType(classInfo);
                }
                else
@@ -292,6 +292,8 @@ case IL_OP_CASTCLASS:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_CASTCLASS_PREFIX,
+                                                VALID_NO_CASTCLASS);
 }
 break;
 
@@ -303,7 +305,7 @@ case IL_OP_ISINST:
        {
                if(classInfo != 0)
                {
-                       ILCoderCastClass(coder, classInfo, 0);
+                       ILCoderCastClass(coder, classInfo, 0, &prefixInfo);
                        stack[stackSize - 1].typeInfo = 
ILClassToType(classInfo);
                }
                else
@@ -353,11 +355,11 @@ case IL_OP_UNBOX:
                   is not of the correct class */
                if(!IsSubClass(stack[stackSize - 1].typeInfo, classInfo))
                {
-                       ILCoderCastClass(coder, classInfo, 1);
+                       ILCoderCastClass(coder, classInfo, 1, &prefixInfo);
                }
 
                /* Unbox the object to produce a managed pointer */
-               ILCoderUnbox(coder, classInfo);
+               ILCoderUnbox(coder, classInfo, &prefixInfo);
                stack[stackSize - 1].engineType = ILEngineType_M;
                stack[stackSize - 1].typeInfo = ILClassToType(classInfo);
        }
@@ -365,6 +367,7 @@ case IL_OP_UNBOX:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_UNBOX_PREFIX, VALID_NO_UNBOX);
 }
 break;
 
@@ -383,18 +386,18 @@ case IL_OP_UNBOX_ANY:
                           is not of the correct class */
                        if(!IsSubClass(stack[stackSize - 1].typeInfo, 
classInfo))
                        {
-                               ILCoderCastClass(coder, classInfo, 1);
+                               ILCoderCastClass(coder, classInfo, 1, 
&prefixInfo);
                        }
                        stack[stackSize - 1].typeInfo = classType;
                }
                else
                {
-                       if(!(AssignCompatible(method, &(stack[stackSize - 1]),
+                       if(!(AssignCompatible(method, &(stack[stackSize - 1]),
                                                                  classType,
                                                                  
unsafeAllowed)))
                        {
                                /* To throw the InvalitCastException in this 
case. */
-                               ILCoderCastClass(coder, classInfo, 1);
+                               ILCoderCastClass(coder, classInfo, 1, 
&prefixInfo);
                        }
                        /* Unbox the object to produce a managed pointer */
                        stackItemClass = 
ILClassFromType(ILProgramItem_Image(method),
@@ -405,10 +408,11 @@ case IL_OP_UNBOX_ANY:
                                ThrowSystem("System", "TypeLoadException");
                        }
                        /* First get the pointer to the value */
-                       ILCoderUnbox(coder, stackItemClass);
+                       ILCoderUnbox(coder, stackItemClass, &prefixInfo);
                        stack[stackSize - 1].engineType = ILEngineType_M;
                        /* We have to dereference the value in this case. */
-                       ILCoderPtrAccessManaged(coder, IL_OP_LDOBJ, 
stackItemClass);
+                       ILCoderPtrAccessManaged(coder, IL_OP_LDOBJ, 
stackItemClass,
+                                                                       
&prefixInfo);
                        stack[stackSize - 1].engineType = 
TypeToEngineType(classType);
                        stack[stackSize - 1].typeInfo = classType;
                }
@@ -442,12 +446,13 @@ case IL_OP_LDFLD:
                                {
                                        ILCoderLoadField(coder, ILEngineType_O,
                                                                         
stack[stackSize - 1].typeInfo,
-                                                                        
fieldInfo, classType);
+                                                                        
fieldInfo, classType, &prefixInfo);
                                }
                                else
                                {
                                        ILCoderPop(coder, ILEngineType_O, 
ILType_Invalid);
-                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType);
+                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType,
+                                                                               
   &prefixInfo);
                                }
                        }
                        else
@@ -468,12 +473,13 @@ case IL_OP_LDFLD:
                                {
                                        ILCoderLoadField(coder, STK_UNARY,
                                                                         
stack[stackSize - 1].typeInfo,
-                                                                        
fieldInfo, classType);
+                                                                        
fieldInfo, classType, &prefixInfo);
                                }
                                else
                                {
                                        ILCoderPop(coder, STK_UNARY, 
ILType_Invalid);
-                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType);
+                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType,
+                                                                               
   &prefixInfo);
                                }
                        }
                        else
@@ -491,13 +497,14 @@ case IL_OP_LDFLD:
                                {
                                        ILCoderLoadField(coder, ILEngineType_MV,
                                                                         
stack[stackSize - 1].typeInfo,
-                                                                        
fieldInfo, classType);
+                                                                        
fieldInfo, classType, &prefixInfo);
                                }
                                else
                                {
                                        ILCoderPop(coder, ILEngineType_MV,
                                                           stack[stackSize - 
1].typeInfo);
-                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType);
+                                       ILCoderLoadStaticField(coder, 
fieldInfo, classType,
+                                                                               
   &prefixInfo);
                                }
                        }
                        else
@@ -518,12 +525,13 @@ case IL_OP_LDFLD:
                        {
                                ILCoderLoadField(coder, STK_UNARY,
                                                                 
stack[stackSize - 1].typeInfo,
-                                                                fieldInfo, 
classType);
+                                                                fieldInfo, 
classType, &prefixInfo);
                        }
                        else
                        {
                                ILCoderPop(coder, STK_UNARY, ILType_Invalid);
-                               ILCoderLoadStaticField(coder, fieldInfo, 
classType);
+                               ILCoderLoadStaticField(coder, fieldInfo, 
classType,
+                                                                          
&prefixInfo);
                        }
                }
                else
@@ -539,6 +547,7 @@ case IL_OP_LDFLD:
                   if the field cannot be found */
                ThrowSystem("System", "MissingFieldException");
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDFLD_PREFIX, VALID_NO_LDFLD);
 }
 break;
 
@@ -657,19 +666,19 @@ case IL_OP_STFLD:
                        if(IsSubClass(stack[stackSize - 2].typeInfo,
                                                  ILField_Owner(fieldInfo)) &&
                           AssignCompatible(method, &(stack[stackSize - 1]),
-                                                           classType, 
unsafeAllowed))
+                                                               classType, 
unsafeAllowed))
                        {
                                if(!ILField_IsStatic(fieldInfo))
                                {
                                        ILCoderStoreField(coder, ILEngineType_O,
                                                                          
stack[stackSize - 2].typeInfo,
                                                                          
fieldInfo, classType,
-                                                                         
STK_BINARY_2);
+                                                                         
STK_BINARY_2, &prefixInfo);
                                }
                                else
                                {
                                        ILCoderStoreStaticField(coder, 
fieldInfo, classType,
-                                                                               
        STK_BINARY_2);
+                                                                               
        STK_BINARY_2, &prefixInfo);
                                        ILCoderPop(coder, ILEngineType_O, 
ILType_Invalid);
                                }
                        }
@@ -693,12 +702,13 @@ case IL_OP_STFLD:
                                {
                                        ILCoderStoreField(coder, STK_BINARY_1,
                                                                          
stack[stackSize - 2].typeInfo,
-                                                                         
fieldInfo, classType, STK_BINARY_2);
+                                                                         
fieldInfo, classType, STK_BINARY_2,
+                                                                         
&prefixInfo);
                                }
                                else
                                {
                                        ILCoderStoreStaticField(coder, 
fieldInfo, classType,
-                                                                               
        STK_BINARY_2);
+                                                                               
        STK_BINARY_2, &prefixInfo);
                                        ILCoderPop(coder, STK_BINARY_2, 
ILType_Invalid);
                                }
                        }
@@ -720,12 +730,13 @@ case IL_OP_STFLD:
                        {
                                ILCoderStoreField(coder, STK_BINARY_1,
                                                                  
stack[stackSize - 2].typeInfo,
-                                                                 fieldInfo, 
classType, STK_BINARY_2);
+                                                                 fieldInfo, 
classType, STK_BINARY_2,
+                                                                 &prefixInfo);
                        }
                        else
                        {
                                ILCoderStoreStaticField(coder, fieldInfo, 
classType,
-                                                                               
STK_BINARY_2);
+                                                                               
STK_BINARY_2, &prefixInfo);
                                ILCoderPop(coder, STK_BINARY_1, ILType_Invalid);
                        }
                }
@@ -741,6 +752,7 @@ case IL_OP_STFLD:
                   if the field cannot be found */
                ThrowSystem("System", "MissingFieldException");
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STFLD_PREFIX, VALID_NO_STFLD);
 }
 break;
 
@@ -751,7 +763,7 @@ case IL_OP_LDSFLD:
        if(fieldInfo)
        {
                classType = ILField_Type(fieldInfo);
-               ILCoderLoadStaticField(coder, fieldInfo, classType);
+               ILCoderLoadStaticField(coder, fieldInfo, classType, 
&prefixInfo);
                stack[stackSize].engineType = TypeToEngineType(classType);
                stack[stackSize].typeInfo = classType;
                ++stackSize;
@@ -762,6 +774,7 @@ case IL_OP_LDSFLD:
                   if the field cannot be found */
                ThrowSystem("System", "MissingFieldException");
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDSFLD_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -796,7 +809,8 @@ case IL_OP_STSFLD:
                if(AssignCompatible(method, &(stack[stackSize - 1]),
                                                        classType, 
unsafeAllowed))
                {
-                       ILCoderStoreStaticField(coder, fieldInfo, classType, 
STK_UNARY);
+                       ILCoderStoreStaticField(coder, fieldInfo, classType, 
STK_UNARY,
+                                                                       
&prefixInfo);
                        --stackSize;
                }
                else
@@ -810,6 +824,7 @@ case IL_OP_STSFLD:
                   if the field cannot be found */
                ThrowSystem("System", "MissingFieldException");
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STSFLD_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -986,7 +1001,7 @@ case IL_OP_PREFIX + IL_PREFIX_OP_INITOBJ:
                {
                        /* Let's do a ldnull followed by stind.ref */
                        ILCoderConstant(coder, IL_OP_LDNULL, pc + 1);
-                       ILCoderPtrAccess(coder, IL_OP_STIND_REF);
+                       ILCoderPtrAccess(coder, IL_OP_STIND_REF, &prefixInfo);
                        --stackSize;
                }
                else
@@ -1015,13 +1030,14 @@ case IL_OP_PREFIX + IL_PREFIX_OP_CPBLK:
           IsBlkPointer(STK_TERNARY_2) &&
           STK_TERNARY_3 == ILEngineType_I4)
        {
-               ILCoderCopyBlock(coder, STK_TERNARY_1, STK_TERNARY_2);
+               ILCoderCopyBlock(coder, STK_TERNARY_1, STK_TERNARY_2, 
&prefixInfo);
                stackSize -= 3;
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_CPBLK_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -1033,13 +1049,14 @@ case IL_OP_PREFIX + IL_PREFIX_OP_INITBLK:
           STK_TERNARY_2 == ILEngineType_I4 &&
           STK_TERNARY_3 == ILEngineType_I4)
        {
-               ILCoderInitBlock(coder, STK_TERNARY_1);
+               ILCoderInitBlock(coder, STK_TERNARY_1, &prefixInfo);
                stackSize -= 3;
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_INITBLK_PREFIX, VALID_NO_NONE);
 }
 break;
 
diff --git a/engine/verify_ptr.c b/engine/verify_ptr.c
index e56dd28..c2da87b 100644
--- a/engine/verify_ptr.c
+++ b/engine/verify_ptr.c
@@ -259,7 +259,6 @@ static ILType *GetTypeToken(ILMethod *method, unsigned char 
*pc)
 ILType *elemType;
 ILClass *classInfo;
 ILType *classType;
-ILBool isReadOnly;
 
 #else /* IL_VERIFY_CODE */
 
@@ -273,7 +272,7 @@ case IL_OP_LDIND_##name: \
                if(unsafeAllowed || \
                   PtrCompatible(stack[stackSize - 1].typeInfo, (type))) \
                { \
-                       ILCoderPtrAccess(coder, opcode); \
+                       ILCoderPtrAccess(coder, opcode, &prefixInfo); \
                        STK_UNARY = (engineType); \
                        STK_UNARY_TYPEINFO = 0; \
                } \
@@ -286,7 +285,7 @@ case IL_OP_LDIND_##name: \
                (STK_UNARY == ILEngineType_I4 || STK_UNARY == ILEngineType_I)) \
        { \
                ILCoderToPointer(coder, STK_UNARY, (ILEngineStackItem *)0); \
-               ILCoderPtrAccess(coder, opcode); \
+               ILCoderPtrAccess(coder, opcode, &prefixInfo); \
                STK_UNARY = (engineType); \
                STK_UNARY_TYPEINFO = 0; \
        } \
@@ -294,6 +293,7 @@ case IL_OP_LDIND_##name: \
        { \
                VERIFY_TYPE_ERROR(); \
        } \
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDIND_PREFIX, VALID_NO_NONE); \
 } \
 break
 
@@ -306,7 +306,7 @@ case IL_OP_STIND_##name: \
                   (STK_BINARY_2 == (engineType) && \
                    PtrCompatible(stack[stackSize - 2].typeInfo, (type)))) \
                { \
-                       ILCoderPtrAccess(coder, opcode); \
+                       ILCoderPtrAccess(coder, opcode, &prefixInfo); \
                        stackSize -= 2; \
                } \
                else \
@@ -323,13 +323,14 @@ case IL_OP_STIND_##name: \
                           STK_BINARY_2 == ILEngineType_T)))) \
        { \
                ILCoderToPointer(coder, STK_BINARY_1, &(stack[stackSize - 1])); 
\
-               ILCoderPtrAccess(coder, opcode); \
+               ILCoderPtrAccess(coder, opcode, &prefixInfo); \
                stackSize -= 2; \
        } \
        else \
        { \
                VERIFY_TYPE_ERROR(); \
        } \
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STIND_PREFIX, VALID_NO_NONE); \
 } \
 break
 
@@ -342,7 +343,8 @@ case IL_OP_LDELEM_##name: \
        { \
                if(elemType == ILType_Void || PtrCompatible(elemType, (type))) \
                { \
-                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType); \
+                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType, \
+                                                          &prefixInfo); \
                        STK_BINARY_1 = (engineType); \
                        STK_TYPEINFO_1 = 0; \
                        --stackSize; \
@@ -356,6 +358,8 @@ case IL_OP_LDELEM_##name: \
        { \
                VERIFY_TYPE_ERROR(); \
        } \
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDELEM_T_PREFIX, \
+                                                VALID_NO_LDELEM_T); \
 } \
 break
 
@@ -370,7 +374,8 @@ case IL_OP_STELEM_##name: \
        { \
                if(elemType == ILType_Void || PtrCompatible(elemType, (type))) \
                { \
-                       ILCoderArrayAccess(coder, opcode, STK_TERNARY_2, 
elemType); \
+                       ILCoderArrayAccess(coder, opcode, STK_TERNARY_2, 
elemType, \
+                                                          &prefixInfo); \
                        stackSize -= 3; \
                } \
                else \
@@ -382,6 +387,8 @@ case IL_OP_STELEM_##name: \
        { \
                VERIFY_TYPE_ERROR(); \
        } \
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STELEM_T_PREFIX, \
+                                                VALID_NO_STELEM_T); \
 } \
 break
 
@@ -411,18 +418,52 @@ case IL_OP_LDELEM:
           (STK_BINARY_2 == ILEngineType_I4 || STK_BINARY_2 == ILEngineType_I) 
&&
           (elemType = ArrayElementType(stack[stackSize - 2].typeInfo)) != 0)
        {
-               if(ILTypeIdentical(classType, elemType))
+               if((prefixInfo.prefixFlags & IL_CODER_PREFIX_READONLY) == 0)
                {
+                       if(ILTypeIdentical(classType, elemType))
+                       {
+                               int opcode = TypeToLdElemOpcode(elemType);
+                               if(opcode != IL_OP_NOP)
+                               {
+                                       ILCoderArrayAccess(coder, opcode, 
STK_BINARY_2, elemType,
+                                                                          
&prefixInfo);
+                                       if(opcode == IL_OP_LDELEMA)
+                                       {
+                                               ILClass *classInfo = 
ILClassFromType(ILProgramItem_Image(method), 0, classType, 0);
+                                               ILCoderPtrAccessManaged(coder, 
IL_OP_LDOBJ, classInfo,
+                                                                               
                &prefixInfo);
+                                       }
+                                       STK_BINARY_1 = 
TypeToEngineType(elemType);
+                                       STK_TYPEINFO_1 = elemType;
+                                       --stackSize;
+                               }
+                               else
+                               {
+                                       VERIFY_TYPE_ERROR();
+                               }
+                       }
+                       else
+                       {
+                               VERIFY_TYPE_ERROR();
+                       }
+               }
+               else
+               {
+                       /*
+                        * Skip the exact type match check with the .readonly 
prefix
+                        */
                        int opcode = TypeToLdElemOpcode(elemType);
                        if(opcode != IL_OP_NOP)
                        {
-                               ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType);
+                               ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType,
+                                                                  &prefixInfo);
                                if(opcode == IL_OP_LDELEMA)
                                {
                                        ILClass *classInfo = 
ILClassFromType(ILProgramItem_Image(method), 0, classType, 0);
-                                       ILCoderPtrAccessManaged(coder, 
IL_OP_LDOBJ, classInfo);
+                                       ILCoderPtrAccessManaged(coder, 
IL_OP_LDOBJ, classInfo,
+                                                                               
        &prefixInfo);
                                }
-                               STK_BINARY_1 = TypeToEngineType(elemType);
+                               STK_BINARY_1 = ILEngineType_CM;
                                STK_TYPEINFO_1 = elemType;
                                --stackSize;
                        }
@@ -431,15 +472,12 @@ case IL_OP_LDELEM:
                                VERIFY_TYPE_ERROR();
                        }
                }
-               else
-               {
-                       VERIFY_TYPE_ERROR();
-               }
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDELEM_PREFIX, VALID_NO_LDELEM);
 }
 break;
 
@@ -455,7 +493,8 @@ case IL_OP_STELEM:
                        int opcode = TypeToStElemOpcode(classType);
                        if(opcode != IL_OP_NOP)
                        {
-                               ILCoderArrayAccess(coder, opcode, 
STK_TERNARY_2, elemType);
+                               ILCoderArrayAccess(coder, opcode, 
STK_TERNARY_2, elemType,
+                                                                  &prefixInfo);
                        }
                        else if(ILType_IsValueType(classType))
                        {
@@ -476,6 +515,7 @@ case IL_OP_STELEM:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STELEM_PREFIX, VALID_NO_STELEM);
 }
 break;
 
@@ -488,7 +528,7 @@ case IL_OP_LDIND_REF:
        {
                if(IsObjectRef(stack[stackSize - 1].typeInfo))
                {
-                       ILCoderPtrAccess(coder, opcode);
+                       ILCoderPtrAccess(coder, opcode, &prefixInfo);
                        stack[stackSize - 1].engineType = ILEngineType_O;
                }
                else
@@ -504,7 +544,7 @@ case IL_OP_LDIND_REF:
                   There really is nothing else that we can do because there
                   is no way to determine the actual type */
                ILCoderToPointer(coder, STK_UNARY, (ILEngineStackItem *)0);
-               ILCoderPtrAccess(coder, opcode);
+               ILCoderPtrAccess(coder, opcode, &prefixInfo);
                stack[stackSize - 1].engineType = ILEngineType_O;
                stack[stackSize - 1].typeInfo = 0;
        }
@@ -512,6 +552,7 @@ case IL_OP_LDIND_REF:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDIND_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -527,7 +568,7 @@ case IL_OP_STIND_REF:
                                                            stack[stackSize - 
2].typeInfo,
                                                                unsafeAllowed))
                        {
-                               ILCoderPtrAccess(coder, opcode);
+                               ILCoderPtrAccess(coder, opcode, &prefixInfo);
                                stackSize -= 2;
                        }
                        else
@@ -546,13 +587,14 @@ case IL_OP_STIND_REF:
                        STK_BINARY_2 == ILEngineType_O)
        {
                ILCoderToPointer(coder, STK_BINARY_1, &(stack[stackSize - 1]));
-               ILCoderPtrAccess(coder, opcode);
+               ILCoderPtrAccess(coder, opcode, &prefixInfo);
                stackSize -= 2;
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STIND_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -568,7 +610,7 @@ case IL_OP_LDOBJ:
                if(classInfo &&
                   ILTypeIdentical(stack[stackSize - 1].typeInfo, classType))
                {
-                       ILCoderPtrAccessManaged(coder, opcode, classInfo);
+                       ILCoderPtrAccessManaged(coder, opcode, classInfo, 
&prefixInfo);
                        stack[stackSize - 1].engineType = 
TypeToEngineType(classType);
                        stack[stackSize - 1].typeInfo = classType;
                }
@@ -583,7 +625,7 @@ case IL_OP_LDOBJ:
                if(classInfo)
                {
                        ILCoderToPointer(coder, STK_UNARY, (ILEngineStackItem 
*)0);
-                       ILCoderPtrAccessManaged(coder, opcode, classInfo);
+                       ILCoderPtrAccessManaged(coder, opcode, classInfo, 
&prefixInfo);
                        stack[stackSize - 1].engineType = 
TypeToEngineType(classType);
                        stack[stackSize - 1].typeInfo = classType;
                }
@@ -596,6 +638,7 @@ case IL_OP_LDOBJ:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDOBJ_PREFIX, VALID_NO_NONE);
 }
 break;
 
@@ -606,13 +649,13 @@ case IL_OP_STOBJ:
        if(STK_BINARY_1 == ILEngineType_M || STK_BINARY_1 == ILEngineType_T)
        {
                /* NOTE: ILTypeIdentical(stack[stackSize - 1].typeInfo,
-                                                   
ILType_FromValueType(classInfo))
+                                                   
ILType_FromValueType(classInfo))
                   was removed as ECMA spec leaves that check as unspecified. */
                if((STK_BINARY_2 == ILEngineType_MV || STK_BINARY_2 == 
ILEngineType_I 
                        || STK_BINARY_2 == ILEngineType_F)
                        && classInfo)
                {
-                       ILCoderPtrAccessManaged(coder, opcode, classInfo);
+                       ILCoderPtrAccessManaged(coder, opcode, classInfo, 
&prefixInfo);
                        stackSize -= 2;
                }
                else
@@ -626,10 +669,10 @@ case IL_OP_STOBJ:
        {
                if(STK_BINARY_2 == ILEngineType_MV && classInfo &&
                   ILTypeIdentical(stack[stackSize - 1].typeInfo,
-                                                  
ILType_FromValueType(classInfo)))
+                                                  
ILType_FromValueType(classInfo)))
                {
                        ILCoderToPointer(coder, STK_BINARY_1, &(stack[stackSize 
- 1]));
-                       ILCoderPtrAccessManaged(coder, opcode, classInfo);
+                       ILCoderPtrAccessManaged(coder, opcode, classInfo, 
&prefixInfo);
                        stackSize -= 2;
                }
                else
@@ -641,37 +684,18 @@ case IL_OP_STOBJ:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STOBJ_PREFIX, VALID_NO_NONE);
 }
 break;
 
 case IL_OP_PREFIX + IL_PREFIX_OP_UNALIGNED:
 {
        /* Process an "unaligned" prefix for pointer access */
-       if(pc[3] == IL_OP_LDIND_I1  || pc[3] == IL_OP_LDIND_U1  ||
-          pc[3] == IL_OP_LDIND_I2  || pc[3] == IL_OP_LDIND_U2  ||
-          pc[3] == IL_OP_LDIND_I4  || pc[3] == IL_OP_LDIND_U4  ||
-          pc[3] == IL_OP_LDIND_I8  || pc[3] == IL_OP_LDIND_I   ||
-          pc[3] == IL_OP_LDIND_R4  || pc[3] == IL_OP_LDIND_R8  ||
-          pc[3] == IL_OP_LDIND_REF || pc[3] == IL_OP_LDIND_REF ||
-          pc[3] == IL_OP_STIND_I1  || pc[3] == IL_OP_STIND_I2  ||
-          pc[3] == IL_OP_STIND_I4  || pc[3] == IL_OP_STIND_I8  ||
-          pc[3] == IL_OP_STIND_I   || pc[3] == IL_OP_STIND_R4  ||
-          pc[3] == IL_OP_STIND_R8  || pc[3] == IL_OP_STIND_REF ||
-          pc[3] == IL_OP_LDFLD     || pc[3] == IL_OP_STFLD     ||
-          pc[3] == IL_OP_LDOBJ     || pc[3] == IL_OP_STOBJ     ||
-          (pc[3] == IL_OP_PREFIX && pc[4] == IL_PREFIX_OP_INITBLK) ||
-          (pc[3] == IL_OP_PREFIX && pc[4] == IL_PREFIX_OP_CPBLK) ||
-          (pc[3] == IL_OP_PREFIX && pc[4] == IL_PREFIX_OP_UNALIGNED) ||
-          (pc[3] == IL_OP_PREFIX && pc[4] == IL_PREFIX_OP_VOLATILE))
-       {
-               if(pc[2] == 1 || pc[2] == 2 || pc[2] == 4)
-               {
-                       ILCoderPtrPrefix(coder, (int)(pc[2]));
-               }
-               else
-               {
-                       VERIFY_INSN_ERROR();
-               }
+       if(pc[2] == 1 || pc[2] == 2 || pc[2] == 4)
+       {
+               prefixInfo.prefixFlags |= IL_CODER_PREFIX_UNALIGNED;
+               prefixInfo.unalignedValue = (ILUInt32)pc[2];
+               lastInsnWasPrefix = 1;
        }
        else
        {
@@ -683,30 +707,8 @@ break;
 case IL_OP_PREFIX + IL_PREFIX_OP_VOLATILE:
 {
        /* Process a "volatile" prefix for pointer access */
-       if(pc[2] == IL_OP_LDIND_I1  || pc[2] == IL_OP_LDIND_U1  ||
-          pc[2] == IL_OP_LDIND_I2  || pc[2] == IL_OP_LDIND_U2  ||
-          pc[2] == IL_OP_LDIND_I4  || pc[2] == IL_OP_LDIND_U4  ||
-          pc[2] == IL_OP_LDIND_I8  || pc[2] == IL_OP_LDIND_I   ||
-          pc[2] == IL_OP_LDIND_R4  || pc[2] == IL_OP_LDIND_R8  ||
-          pc[2] == IL_OP_LDIND_REF || pc[2] == IL_OP_LDIND_REF ||
-          pc[2] == IL_OP_STIND_I1  || pc[2] == IL_OP_STIND_I2  ||
-          pc[2] == IL_OP_STIND_I4  || pc[2] == IL_OP_STIND_I8  ||
-          pc[2] == IL_OP_STIND_I   || pc[2] == IL_OP_STIND_R4  ||
-          pc[2] == IL_OP_STIND_R8  || pc[2] == IL_OP_STIND_REF ||
-          pc[2] == IL_OP_LDFLD     || pc[2] == IL_OP_STFLD     ||
-          pc[2] == IL_OP_LDOBJ     || pc[2] == IL_OP_STOBJ     ||
-          pc[2] == IL_OP_LDSFLD    || pc[2] == IL_OP_STSFLD    ||
-          (pc[2] == IL_OP_PREFIX && pc[3] == IL_PREFIX_OP_INITBLK) ||
-          (pc[2] == IL_OP_PREFIX && pc[3] == IL_PREFIX_OP_CPBLK) ||
-          (pc[2] == IL_OP_PREFIX && pc[3] == IL_PREFIX_OP_UNALIGNED) ||
-          (pc[2] == IL_OP_PREFIX && pc[3] == IL_PREFIX_OP_VOLATILE))
-       {
-               ILCoderPtrPrefix(coder, 0);
-       }
-       else
-       {
-               VERIFY_INSN_ERROR();
-       }
+       prefixInfo.prefixFlags |= IL_CODER_PREFIX_VOLATILE;
+       lastInsnWasPrefix = 1;
 }
 break;
 
@@ -716,57 +718,16 @@ case IL_OP_PREFIX + IL_PREFIX_OP_NO:
        if(unsafeAllowed)
        {
                /* The no prefix is allowed in unsafe code only. */
-               if(pc[2] & IL_PREFIX_OP_NO_TYPECHECK)
-               {
-                       if(!(pc[3] == IL_OP_LDELEMA || pc[3] == IL_OP_LDELEM    
 ||
-                                pc[3] == IL_OP_STELEM  || pc[3] == 
IL_OP_CASTCLASS  ||
-                                pc[3] == IL_OP_UNBOX))
-                       {
-                               VERIFY_INSN_ERROR();
-                       }
-               }
-               if(pc[2] & IL_PREFIX_OP_NO_RANGECHECK)
-               {
-                       if(!(pc[3] == IL_OP_LDELEMA   || pc[3] == 
IL_OP_LDELEM_I1  ||
-                                pc[3] == IL_OP_LDELEM_U1 || pc[3] == 
IL_OP_LDELEM_I2  ||
-                                pc[3] == IL_OP_LDELEM_U2 || pc[3] == 
IL_OP_LDELEM_I4  ||
-                                pc[3] == IL_OP_LDELEM_U4 || pc[3] == 
IL_OP_LDELEM_I8  ||
-                                pc[3] == IL_OP_LDELEM_I  || pc[3] == 
IL_OP_LDELEM_R4  ||
-                                pc[3] == IL_OP_LDELEM_R8 || pc[3] == 
IL_OP_LDELEM_REF ||
-                                pc[3] == IL_OP_STELEM_I  || pc[3] == 
IL_OP_STELEM_I1  ||
-                                pc[3] == IL_OP_STELEM_I2 || pc[3] == 
IL_OP_STELEM_I4  ||
-                                pc[3] == IL_OP_STELEM_I8 || pc[3] == 
IL_OP_STELEM_R4  ||
-                                pc[3] == IL_OP_STELEM_R8 || pc[3] == 
IL_OP_STELEM_REF))
-                       {
-                               VERIFY_INSN_ERROR();
-                       }
-
-               }
-               if(pc[2] & IL_PREFIX_OP_NO_RANGECHECK)
+               if(((pc[2] & VALID_NO_ALL) != 0) && ((pc[2] & ~VALID_NO_ALL) == 
0))
                {
-                       if(!(pc[3] == IL_OP_LDFLD      || pc[3] == IL_OP_STFLD  
    ||
-                                pc[3] == IL_OP_CALLVIRT   || pc[3] == 
IL_OP_LDELEMA    ||
-                                pc[3] == IL_OP_LDELEM_I1  || pc[3] == 
IL_OP_LDELEM_U1  ||
-                                pc[3] == IL_OP_LDELEM_I2  || pc[3] == 
IL_OP_LDELEM_U2  ||
-                                pc[3] == IL_OP_LDELEM_I4  || pc[3] == 
IL_OP_LDELEM_U4  ||
-                                pc[3] == IL_OP_LDELEM_I8  || pc[3] == 
IL_OP_LDELEM_I   ||
-                                pc[3] == IL_OP_LDELEM_R4  || pc[3] == 
IL_OP_LDELEM_R8  ||
-                                pc[3] == IL_OP_LDELEM_REF || pc[3] == 
IL_OP_STELEM_I   ||
-                                pc[3] == IL_OP_STELEM_I1  || pc[3] == 
IL_OP_STELEM_I2  ||
-                                pc[3] == IL_OP_STELEM_I4  || pc[3] == 
IL_OP_STELEM_I8  ||
-                                pc[3] == IL_OP_STELEM_R4  || pc[3] == 
IL_OP_STELEM_R8  ||
-                                pc[3] == IL_OP_STELEM_REF ||
-                                (pc[3] == IL_OP_PREFIX    && pc[4] == 
IL_PREFIX_OP_LDVIRTFTN)))
-                       {
-                               VERIFY_INSN_ERROR();
-                       }
+                       prefixInfo.prefixFlags |= IL_CODER_PREFIX_NO;
+                       prefixInfo.noFlags = (ILUInt32)pc[2];
+                       lastInsnWasPrefix = 1;
                }
-               if(pc[2] & ~(IL_PREFIX_OP_NO_TYPECHECK | 
IL_PREFIX_OP_NO_RANGECHECK |
-                                        IL_PREFIX_OP_NO_RANGECHECK))
+               else
                {
-                               VERIFY_INSN_ERROR();
+                       VERIFY_INSN_ERROR();
                }
-               /* TODO: Handle this opcode in the coder. */
        }
        else
        {
@@ -778,16 +739,8 @@ break;
 case IL_OP_PREFIX + IL_PREFIX_OP_READONLY:
 {
        /* Process a "readonly" prefix for array  access */
-       if(pc[2] == IL_OP_LDELEMA)
-       {
-               /* TODO: Handle this in the ldelema instruction so that a */
-               /* controlled-mutability managed pointer. */
-               isReadOnly = 1;
-       }
-       else
-       {
-               VERIFY_INSN_ERROR();
-       }
+       prefixInfo.prefixFlags |= IL_CODER_PREFIX_READONLY;
+       lastInsnWasPrefix = 1;
 }
 break;
 
@@ -866,7 +819,8 @@ case IL_OP_LDELEM_REF:
        {
                if(elemType == ILType_Void || IsObjectRef(elemType))
                {
-                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType);
+                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
elemType,
+                                                          &prefixInfo);
                        stack[stackSize - 2].engineType = ILEngineType_O;
                        stack[stackSize - 2].typeInfo = elemType;
                        --stackSize;
@@ -880,6 +834,7 @@ case IL_OP_LDELEM_REF:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDELEM_T_PREFIX, 
VALID_NO_LDELEM_T);
 }
 break;
 
@@ -891,12 +846,13 @@ case IL_OP_LDELEMA:
           (elemType = ArrayElementType(stack[stackSize - 2].typeInfo)) != 0)
        {
                classType = GetTypeToken(method, pc);
-               if(!isReadOnly)
+               if((prefixInfo.prefixFlags & IL_CODER_PREFIX_READONLY) == 0)
                {
                        if(classType &&
                           (elemType == ILType_Void || 
ILTypeIdentical(elemType, classType)))
                        {
-                               ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
classType);
+                               ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
classType,
+                                                                  &prefixInfo);
                                stack[stackSize - 2].engineType = 
ILEngineType_M;
                                stack[stackSize - 2].typeInfo = classType;
                                --stackSize;
@@ -913,18 +869,18 @@ case IL_OP_LDELEMA:
                {
                        /* Perform no type check in this case. */
                        /* But push an controlled-mutability managed pointer on 
the stack. */
-                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
classType);
+                       ILCoderArrayAccess(coder, opcode, STK_BINARY_2, 
classType,
+                                                          &prefixInfo);
                        stack[stackSize - 2].engineType = ILEngineType_CM;
                        stack[stackSize - 2].typeInfo = classType;
                        --stackSize;
                }
-               /* And reset the readonly prefix. */
-               isReadOnly = 0;
        }
        else
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_LDELEMA_PREFIX, 
VALID_NO_LDELEMA);
 }
 break;
 
@@ -939,9 +895,10 @@ case IL_OP_STELEM_REF:
        {
                if(elemType == ILType_Void ||
                   AssignCompatible(method, &(stack[stackSize - 1]),
-                                                       elemType, 
unsafeAllowed))
+                                                       elemType, 
unsafeAllowed))
                {
-                       ILCoderArrayAccess(coder, opcode, STK_TERNARY_2, 
elemType);
+                       ILCoderArrayAccess(coder, opcode, STK_TERNARY_2, 
elemType,
+                                                          &prefixInfo);
                        stackSize -= 3;
                }
                else
@@ -953,6 +910,7 @@ case IL_OP_STELEM_REF:
        {
                VERIFY_TYPE_ERROR();
        }
+       CLEAR_VALID_PREFIXES(prefixInfo, VALID_STELEM_T_PREFIX, 
VALID_NO_STELEM_T);
 }
 break;
 
diff --git a/engine/verify_var.c b/engine/verify_var.c
index df80626..6b6bc19 100644
--- a/engine/verify_var.c
+++ b/engine/verify_var.c
@@ -95,7 +95,8 @@ case IL_OP_LDARG_0:
                                        if(!ILField_IsStatic(fieldInfo))
                                        {
                                                /* Load the "this"-based field 
onto the stack */
-                                               ILCoderLoadThisField(coder, 
fieldInfo, classType);
+                                               ILCoderLoadThisField(coder, 
fieldInfo, classType,
+                                                                               
         &prefixInfo);
 
                                                /* Push the field's type onto 
the stack */
                                                stack[stackSize].engineType =

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog            |   19 ++++
 engine/cvmc.c        |    1 -
 engine/cvmc_obj.c    |   33 +++++---
 engine/cvmc_ptr.c    |   22 ++---
 engine/jitc.c        |    1 -
 engine/jitc_array.c  |    3 +-
 engine/jitc_obj.c    |   33 +++++---
 engine/jitc_ptr.c    |   14 +--
 engine/null_coder.c  |   46 ++++++----
 engine/verify.c      |   95 +++++++++++++++++++-
 engine/verify_call.c |  157 ++++++++++++++++++++++++---------
 engine/verify_obj.c  |   75 ++++++++++------
 engine/verify_ptr.c  |  238 +++++++++++++++++++++-----------------------------
 engine/verify_var.c  |    3 +-
 include/il_coder.h   |  123 +++++++++++++++++---------
 15 files changed, 534 insertions(+), 329 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

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