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

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

[dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_arith....


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc_arith....
Date: Mon, 24 Mar 2008 09:04:42 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      08/03/24 09:04:42

Modified files:
        .              : ChangeLog 
        engine         : jitc.c jitc_arith.c jitc_locals.c 

Log message:
        Add support for creating structs/unions in libjit including member 
information.
        Fix shift handling. Handle unions like structs in locals initialization.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3536&r2=1.3537
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_arith.c?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc_locals.c?cvsroot=dotgnu-pnet&r1=1.12&r2=1.13

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3536
retrieving revision 1.3537
diff -u -b -r1.3536 -r1.3537
--- ChangeLog   23 Mar 2008 10:52:31 -0000      1.3536
+++ ChangeLog   24 Mar 2008 09:04:41 -0000      1.3537
@@ -1,3 +1,14 @@
+2008-03-24  Klaus Treichel  <address@hidden>
+
+       * engine/jitc.c: Add creation of value types (structs/unions) including
+       the struct fields in libjit (Needed for X86_64 SysV abi struct passing).
+
+       * engine/jitc_arith.c: Fix shifts. The type to be shifted depends only
+       on the value to be shifted.
+
+       * engine/jitc_locals.c: Handle unions like structs in locals
+       initialization.
+
 2008-03-23  Klaus Treichel  <address@hidden>
 
        * support/wait_mutex.c: Fix compiler warnings on X86_64. Number of 
shifted

Index: engine/jitc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- engine/jitc.c       26 Dec 2007 15:35:10 -0000      1.79
+++ engine/jitc.c       24 Mar 2008 09:04:42 -0000      1.80
@@ -4225,6 +4225,116 @@
 }
 
 /*
+ * Create the type representation including fields for libjit.
+ */
+static ILJitType _ILJitTypeCreate(ILClass *info, ILExecProcess *process)
+{
+       ILJitType jitType = 0;
+       ILField *field;
+       ILUInt32 numFields = 0;
+
+       /* The parent class is always the first field */
+       if(info->parent)
+       {
+               ++numFields;
+       }
+
+       field = 0;
+       while((field = (ILField *)ILClassNextMemberByKind
+                       (info, (ILMember *)field, IL_META_MEMBERKIND_FIELD)) != 
0)
+       {
+               if((field->member.attributes & IL_META_FIELDDEF_STATIC) == 0)
+               {
+                       ++numFields;
+               }
+       }
+
+       if(numFields > 0)
+       {
+               ILInt32 jitTypeIsUnion = 1;
+               ILUInt32 currentField = 0;
+               ILJitType fields[numFields];
+               ILUInt32 offsets[numFields];
+
+               if(info->parent)
+               {
+                       /* The parent class must be laid out at this point */
+                       ILClass *parent = ILClassGetParent(info);
+
+                       if(parent && parent->userData)
+                       {
+                               fields[currentField] = ((ILClassPrivate 
*)(parent->userData))->jitTypes.jitTypeBase;
+                               /* Check if the size of the base type is > 0 */
+                               /* (it is not System.Object or System.ValueType 
for example */
+                               if(jit_type_get_size(fields[currentField]) > 0)
+                               {
+                                       offsets[currentField] = 0;
+                                       ++currentField;
+                               }
+                       }
+                       else
+                       {
+                               return 0;
+                       }
+               }
+
+               field = 0;
+               while((field = (ILField *)ILClassNextMemberByKind
+                               (info, (ILMember *)field, 
IL_META_MEMBERKIND_FIELD)) != 0)
+               {
+                       if((field->member.attributes & IL_META_FIELDDEF_STATIC) 
== 0)
+                       {
+                               ILType *type = field->member.signature;
+                               ILJitTypes *jitTypes;
+
+                               type = ILTypeStripPrefixes(type);
+                               if(ILType_IsClass(type))
+                               {
+                                       jitTypes = 
ILJitPrimitiveClrTypeToJitTypes(IL_META_ELEMTYPE_PTR);
+                               }
+                               else
+                               {
+                                       jitTypes = _ILJitGetTypes(type, 
process);
+                               }
+                               if(!jitTypes)
+                               {
+                                       return 0;
+                               }
+                               fields[currentField] = jitTypes->jitTypeBase;
+                               offsets[currentField] = field->offset;
+                               jitTypeIsUnion &= (field->offset == 0);
+                               ++currentField;
+                       }
+               }
+               if(jitTypeIsUnion && (currentField > 1))
+               {
+                       /* All fields have a 0 offset */
+                       jitType = jit_type_create_union(fields, currentField, 
0);
+               }
+               else
+               {
+                       jitType = jit_type_create_struct(fields, currentField, 
0);
+                       if(!jitType)
+                       {
+                               return 0;
+                       }
+                       /* Set the offsets of the fields in the struct */
+                       for(currentField = 0; currentField < numFields; 
currentField++)
+                       {
+                               jit_type_set_offset(jitType, currentField, 
offsets[currentField]);
+                       }
+               }
+       }
+       else
+       {
+               /* This must be the top level System.Object class. */
+               jitType = jit_type_create_struct(0, 0, 0);
+       }
+
+       return jitType;
+}
+
+/*
  * Create the class/struct representation of a clr type for libjit.
  * and store the type in classPrivate.
  * Returns the 1 on success else 0
@@ -4244,7 +4354,7 @@
                }
                if(!jitType)
                {
-                       if(!(jitType = jit_type_create_struct(0, 0, 0)))
+                       if(!(jitType = 
_ILJitTypeCreate(classPrivate->classInfo, process)))
                        {
                                return 0;
                        }
@@ -4571,6 +4681,7 @@
 #endif /* _IL_JIT_ENABLE_DEBUG */
 
 #define        IL_JITC_FUNCTIONS
+#include "jitc_arith.c"
 #include "jitc_diag.c"
 #include "jitc_locals.c"
 #include "jitc_stack.c"

Index: engine/jitc_arith.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_arith.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- engine/jitc_arith.c 27 Nov 2006 19:14:03 -0000      1.8
+++ engine/jitc_arith.c 24 Mar 2008 09:04:42 -0000      1.9
@@ -18,6 +18,62 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#ifdef IL_JITC_FUNCTIONS
+
+static void AdjustShiftValue(ILJITCoder *jitCoder, int isUnsigned, ILJitValue 
*value)
+{
+       ILJitType type = jit_value_get_type(*value);
+       ILJitType newType = 0;
+       int typeKind = jit_type_get_kind(type);
+       int typeIsLong = _JIT_TYPEKIND_IS_LONG(typeKind);
+       int typeIsPointer = _JIT_TYPEKIND_IS_POINTER(typeKind);
+
+       if(typeIsLong)
+       {
+               /* If the arguments mix I8 and I4, then cast the I4 value to I8 
*/
+               if(isUnsigned)
+               {
+                       newType = _IL_JIT_TYPE_UINT64;
+               }
+               else
+               {
+                       newType = _IL_JIT_TYPE_INT64;
+               }
+       }
+       else if(typeIsPointer)
+       {
+               if(isUnsigned)
+               {
+                       newType = _IL_JIT_TYPE_NUINT;
+               }
+               else
+               {
+                       newType = _IL_JIT_TYPE_NINT;
+               }
+       }
+       else
+       {
+               /* We have only 32 bit values left. */
+               if(isUnsigned)
+               {
+                       newType = _IL_JIT_TYPE_UINT32;
+               }
+               else
+               {
+                       newType = _IL_JIT_TYPE_INT32;
+               }
+       }
+       
+       /* now do the conversion if necessairy. */
+       if(type != newType)
+       {
+               *value = _ILJitValueConvertImplicit(jitCoder->jitFunction, 
*value,
+                                                                               
         newType);
+       }
+}
+
+#endif /* IL_JITC_FUNCTIONS */
+
 #ifdef IL_JITC_CODE
 
 /*
@@ -302,10 +358,9 @@
        {
                case IL_OP_SHL:
                {
-                       AdjustMixedBinary(jitCoder,
+                       AdjustShiftValue(jitCoder,
                                                          0,
-                                                         
&(_ILJitStackItemValue(value1)),
-                                                         
&(_ILJitStackItemValue(value2)));
+                                                        
&(_ILJitStackItemValue(value1)));
                        result = jit_insn_shl(jitCoder->jitFunction,
                                                                  
_ILJitStackItemValue(value1),
                                                                  
_ILJitStackItemValue(value2));
@@ -314,10 +369,9 @@
 
                case IL_OP_SHR:
                {
-                       AdjustMixedBinary(jitCoder,
+                       AdjustShiftValue(jitCoder,
                                                          0,
-                                                         
&(_ILJitStackItemValue(value1)),
-                                                         
&(_ILJitStackItemValue(value2)));
+                                                        
&(_ILJitStackItemValue(value1)));
                        result= jit_insn_shr(jitCoder->jitFunction,
                                                                 
_ILJitStackItemValue(value1),
                                                                 
_ILJitStackItemValue(value2));
@@ -326,10 +380,9 @@
 
                case IL_OP_SHR_UN:
                {
-                       AdjustMixedBinary(jitCoder,
+                       AdjustShiftValue(jitCoder,
                                                          1,
-                                                         
&(_ILJitStackItemValue(value1)),
-                                                         
&(_ILJitStackItemValue(value2)));
+                                                        
&(_ILJitStackItemValue(value1)));
                        result = jit_insn_shr(jitCoder->jitFunction,
                                                                  
_ILJitStackItemValue(value1),
                                                                  
_ILJitStackItemValue(value2));

Index: engine/jitc_locals.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc_locals.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- engine/jitc_locals.c        14 Jun 2007 15:01:37 -0000      1.12
+++ engine/jitc_locals.c        24 Mar 2008 09:04:42 -0000      1.13
@@ -379,7 +379,7 @@
        {
                ILJitType type = jit_value_get_type(slot->value);
 
-               if(!jit_type_is_struct(type))
+               if(!jit_type_is_struct(type) && !jit_type_is_union(type))
                {
                        int typeKind = jit_type_get_kind(type);
                        ILJitValue constant = 0;




reply via email to

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