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

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

[Dotgnu-pnet-commits] CVS: pnet/engine cvm.h,1.36,1.37 cvm_dasm.c,1.42,1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine cvm.h,1.36,1.37 cvm_dasm.c,1.42,1.43 cvm_ptr.c,1.30,1.31
Date: Sun, 01 Dec 2002 02:39:41 -0500

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv11435/engine

Modified Files:
        cvm.h cvm_dasm.c cvm_ptr.c 
Log Message:


Add the "get2d" and "set2d" instructions to the CVM instruction
set to help speed up 2D array operations.


Index: cvm.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** cvm.h       16 Aug 2002 01:59:28 -0000      1.36
--- cvm.h       1 Dec 2002 07:39:39 -0000       1.37
***************
*** 395,414 ****
  #define       COP_PREFIX_FWRITE_ELEM          0x12
  #define       COP_PREFIX_DWRITE_ELEM          0x13
  
  /*
   * Prefixed call management opcodes.
   */
! #define       COP_PREFIX_TAIL_CALL            0x14
! #define       COP_PREFIX_LDFTN                        0x15
! #define       COP_PREFIX_LDVIRTFTN            0x16
! #define       COP_PREFIX_LDINTERFFTN          0x17
! #define       COP_PREFIX_PACK_VARARGS         0x18
  
  /*
   * Prefixed exception handling opcodes.
   */
! #define       COP_PREFIX_ENTER_TRY            0x19
! #define       COP_PREFIX_THROW                        0x1A
! #define       COP_PREFIX_THROW_CALLER         0x1B
  
  /*
--- 395,416 ----
  #define       COP_PREFIX_FWRITE_ELEM          0x12
  #define       COP_PREFIX_DWRITE_ELEM          0x13
+ #define       COP_PREFIX_GET2D                        0x14
+ #define       COP_PREFIX_SET2D                        0x15
  
  /*
   * Prefixed call management opcodes.
   */
! #define       COP_PREFIX_TAIL_CALL            0x16
! #define       COP_PREFIX_LDFTN                        0x17
! #define       COP_PREFIX_LDVIRTFTN            0x18
! #define       COP_PREFIX_LDINTERFFTN          0x19
! #define       COP_PREFIX_PACK_VARARGS         0x1A
  
  /*
   * Prefixed exception handling opcodes.
   */
! #define       COP_PREFIX_ENTER_TRY            0x1B
! #define       COP_PREFIX_THROW                        0x1C
! #define       COP_PREFIX_THROW_CALLER         0x1D
  
  /*

Index: cvm_dasm.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_dasm.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** cvm_dasm.c  28 Jun 2002 01:05:53 -0000      1.42
--- cvm_dasm.c  1 Dec 2002 07:39:39 -0000       1.43
***************
*** 448,451 ****
--- 448,453 ----
        {"fwrite_elem",         CVM_OPER_NONE},
        {"dwrite_elem",         CVM_OPER_NONE},
+       {"get2d",                       CVM_OPER_NONE},
+       {"set2d",                       CVM_OPER_UINT32},
  
        /*
***************
*** 468,473 ****
         * Reserved opcodes.
         */
-       {"preserved_1c",        CVM_OPER_NONE},
-       {"preserved_1d",        CVM_OPER_NONE},
        {"preserved_1e",        CVM_OPER_NONE},
  
--- 470,473 ----

Index: cvm_ptr.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_ptr.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** cvm_ptr.c   12 Aug 2002 06:59:12 -0000      1.30
--- cvm_ptr.c   1 Dec 2002 07:39:39 -0000       1.31
***************
*** 3195,3198 ****
--- 3195,3322 ----
  
  /**
+  * <opcode name="get2d" group="Array handling">
+  *   <operation>Prepare for a two-dimensional array get operation</operation>
+  *
+  *   <format>prefix<fsep/>get2d</format>
+  *   <dformat>{get2d}</dformat>
+  *
+  *   <form name="get2d" code="COP_PREFIX_GET2D"/>
+  *
+  *   <before>..., array, index1, index2</before>
+  *   <after>..., address</after>
+  *
+  *   <description>Pop <i>array</i>, <i>index1</i>, and
+  *   <i>index2</i> from the stack as the types <code>ptr</code>,
+  *   <code>int32</code>, and <code>int32</code> respectively.
+  *   The <i>address</i> of <i>array[index1, index2]</i> is pushed onto
+  *   the stack as type <code>ptr</code>.</description>
+  *
+  *   <notes>This instruction is normally followed by a <i>*read</i>
+  *   instruction to read the contents of the array element.</notes>
+  *
+  *   <exceptions>
+  *     <exception name="System.NullReferenceException">Raised if
+  *     <i>array</i> is <code>null</code>.</exception>
+  *     <exception name="System.IndexOutOfRangeException">Raised if
+  *     <i>index1</i> or <i>index2</i> is not within the array's
+  *     bounds.</exception>
+  *   </exceptions>
+  * </opcode>
+  */
+ VMCASE(COP_PREFIX_GET2D):
+ {
+       if(stacktop[-3].ptrValue)
+       {
+               System_MArray *array = (System_MArray *)(stacktop[-3].ptrValue);
+               ILInt32 index1 = stacktop[-2].intValue - array->bounds[0].lower;
+               ILInt32 index2 = stacktop[-1].intValue - array->bounds[1].lower;
+               if(((ILUInt32)index1) < ((ILUInt32)(array->bounds[0].size)) &&
+                  ((ILUInt32)index2) < ((ILUInt32)(array->bounds[1].size)))
+               {
+                       stacktop[-3].ptrValue = (void *)
+                               (((unsigned char *)(array->data)) +
+                                index1 * array->bounds[0].multiplier +
+                                index2 * array->bounds[1].multiplier);
+                       MODIFY_PC_AND_STACK(CVMP_LEN_NONE, -2);
+               }
+               else
+               {
+                       ARRAY_INDEX_EXCEPTION();
+               }
+       }
+       else
+       {
+               NULL_POINTER_EXCEPTION();
+       }
+ }
+ VMBREAK(COP_PREFIX_GET2D);
+ 
+ /**
+  * <opcode name="set2d" group="Array handling">
+  *   <operation>Prepare for a two-dimensional array set operation</operation>
+  *
+  *   <format>prefix<fsep/>set2d<fsep/>N[4]</format>
+  *   <dformat>{set2d}<fsep/>N</dformat>
+  *
+  *   <form name="set2d" code="COP_PREFIX_SET2D"/>
+  *
+  *   <before>..., array, index1, index2, value</before>
+  *   <after>..., address, value</after>
+  *
+  *   <description>Remove <i>array</i>, <i>index1</i>, and
+  *   <i>index2</i> from the stack as the types <code>ptr</code>,
+  *   <code>int32</code>, and <code>int32</code> respectively.
+  *   The <i>address</i> of <i>array[index1, index2]</i> is pushed into
+  *   the stack as type <code>ptr</code> just below <i>value</i>.
+  *   The operand <i>N</i> indicates the number of stack words that
+  *   are occupied by <i>value<i>.</description>
+  *
+  *   <notes>This instruction is normally followed by a <i>*write</i>
+  *   instruction to write the contents of the array element.</notes>
+  *
+  *   <exceptions>
+  *     <exception name="System.NullReferenceException">Raised if
+  *     <i>array</i> is <code>null</code>.</exception>
+  *     <exception name="System.IndexOutOfRangeException">Raised if
+  *     <i>index1</i> or <i>index2</i> is not within the array's
+  *     bounds.</exception>
+  *   </exceptions>
+  * </opcode>
+  */
+ VMCASE(COP_PREFIX_SET2D):
+ {
+       tempNum = CVMP_ARG_WORD;
+       if((stacktop - tempNum - 3)->ptrValue)
+       {
+               System_MArray *array =
+                       (System_MArray *)((stacktop - tempNum - 3)->ptrValue);
+               ILInt32 index1 = (stacktop - tempNum - 2)->intValue -
+                                                array->bounds[0].lower;
+               ILInt32 index2 = (stacktop - tempNum - 1)->intValue -
+                                                array->bounds[1].lower;
+               if(((ILUInt32)index1) < ((ILUInt32)(array->bounds[0].size)) &&
+                  ((ILUInt32)index2) < ((ILUInt32)(array->bounds[1].size)))
+               {
+                       (stacktop - tempNum - 3)->ptrValue = (void *)
+                               (((unsigned char *)(array->data)) +
+                                index1 * array->bounds[0].multiplier +
+                                index2 * array->bounds[1].multiplier);
+                       ILMemMove(stacktop - tempNum - 2, stacktop - tempNum,
+                                         tempNum * sizeof(CVMWord));
+                       MODIFY_PC_AND_STACK(CVMP_LEN_NONE, -2);
+               }
+               else
+               {
+                       ARRAY_INDEX_EXCEPTION();
+               }
+       }
+       else
+       {
+               NULL_POINTER_EXCEPTION();
+       }
+ }
+ VMBREAK(COP_PREFIX_SET2D);
+ 
+ /**
   * <opcode name="mkrefany" group="Object handling">
   *   <operation>Make a <code>typedref</code></operation>





reply via email to

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