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.h engi...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog engine/jitc.c engine/jitc.h engi...
Date: Sun, 21 Sep 2008 17:40:37 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      08/09/21 17:40:37

Modified files:
        .              : ChangeLog 
        engine         : jitc.c jitc.h layout.c 

Log message:
        Partially fix a problem with layouting types used as method argumentd 
that
        depend on typed not yes completely layouted when build with libjit.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3566&r2=1.3567
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.c?cvsroot=dotgnu-pnet&r1=1.85&r2=1.86
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/jitc.h?cvsroot=dotgnu-pnet&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/layout.c?cvsroot=dotgnu-pnet&r1=1.47&r2=1.48

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3566
retrieving revision 1.3567
diff -u -b -r1.3566 -r1.3567
--- ChangeLog   30 Aug 2008 13:57:41 -0000      1.3566
+++ ChangeLog   21 Sep 2008 17:40:36 -0000      1.3567
@@ -1,3 +1,15 @@
+2008-09-21  Klaus Treichel  <address@hidden>
+
+       * engine/jitc.c (ILJitGetVtablePointer): Add function to get the jit
+       vtable entry for an ILMethod.
+
+       * engine/jitc.h (ILJitGetVtablePointer): Add prototype.
+
+       * engine/layout.c (LayoutClass): Move layout of the static class members
+       to the end so that the vtable is complete at that point.
+       Create virtual jit functions now during overriding the ancestors.
+       Create non virtual jit functions after the vtable is complete.
+
 2008-08-30  Klaus Treichel  <address@hidden>
 
        * libgc/allchblk.c, libgc/alloc.c, libgc/backgraph.c, 
libgc/bdw-gc.pc.in,

Index: engine/jitc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- engine/jitc.c       24 Aug 2008 17:45:31 -0000      1.85
+++ engine/jitc.c       21 Sep 2008 17:40:37 -0000      1.86
@@ -4315,6 +4315,19 @@
 }
 
 /*
+ * Get a pointer for a method suitable for a vtable.
+ * Returns 0 on error.
+ */
+void *ILJitGetVtablePointer(ILCoder *_coder, ILMethod *method)
+{
+       if(!ILJitFunctionCreate(_coder, method))
+       {
+               return  0;
+       }
+       return 
jit_function_to_vtable_pointer(ILJitFunctionFromILMethod(method));
+}
+
+/*
  * Create all jitMethods for the given class.
  * Returns 0 on error.
  */

Index: engine/jitc.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/jitc.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- engine/jitc.h       3 Apr 2007 07:47:09 -0000       1.23
+++ engine/jitc.h       21 Sep 2008 17:40:37 -0000      1.24
@@ -167,6 +167,12 @@
 int ILJitCreateFunctionsForClass(ILCoder *_coder, ILClass *info);
 
 /*
+ * Get a pointer for a method suitable for a vtable.
+ * Returns 0 on error.
+ */
+void *ILJitGetVtablePointer(ILCoder *_coder, ILMethod *method);
+
+/*
  * Get the ILJitFunction for an ILMethod.
  * Returns 0 if the jit function stub isn't created yet.
  */

Index: engine/layout.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/layout.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- engine/layout.c     10 Aug 2008 16:16:14 -0000      1.47
+++ engine/layout.c     21 Sep 2008 17:40:37 -0000      1.48
@@ -1372,11 +1372,12 @@
                                (layout->nativeSize % layout->nativeAlignment);
        }
 
-       /* Record the object size information for this class */
+       /* Record the object instance size information for this class */
        classPrivate->size = layout->size;
        classPrivate->alignment = layout->alignment;
        classPrivate->nativeSize = layout->nativeSize;
        classPrivate->nativeAlignment = layout->nativeAlignment;
+       classPrivate->managedInstance = layout->managedInstance;
 #ifdef IL_USE_JIT
        if(!ILJitTypeCreate(classPrivate, process))
        {
@@ -1394,66 +1395,6 @@
        }
 #endif /* IL_USE_TYPED_ALLOCATION */
 
-       /* Allocate the static fields.  We must do this after the
-          regular fields because some of the statics may be instances
-          of the class that we are trying to lay out, especially
-          in value type definitions */
-       field = 0;
-       while((field = (ILField *)ILClassNextMemberByKind
-                       (info, (ILMember *)field, IL_META_MEMBERKIND_FIELD)) != 
0)
-       {
-               if((field->member.attributes & IL_META_FIELDDEF_STATIC) != 0 &&
-                  (field->member.attributes & IL_META_FIELDDEF_LITERAL) == 0)
-               {
-                       /* Lay out a static field */
-                       fieldRVA = ILFieldRVAGetFromOwner(field);
-                       if(fieldRVA && !allowRVALayout)
-                       {
-                               /* RVA fields are not permitted, so remove the 
attribute */
-                               field->member.attributes &= 
~IL_META_FIELDDEF_HAS_FIELD_RVA;
-                       }
-                       if(!fieldRVA || !allowRVALayout)
-                       {
-                               /* Get the layout information for this field's 
type */
-                               if(!LayoutType(process, 
field->member.signature, &typeLayout))
-                               {
-                                       info->userData = 0;
-                                       return 0;
-                               }
-
-                               /* Thread-static variables are allocated slots 
from the
-                                  ILExecProcess record.  We assume that some 
higher level
-                                  function has acquired the metadata lock on 
the process */
-                               if(ILFieldIsThreadStatic(field))
-                               {
-                                       /* Store the slot number in the 
"offset" field and
-                                          the field size in the "nativeOffset" 
field */
-                                       field->offset = 
(process->numThreadStaticSlots)++;
-                                       field->nativeOffset = typeLayout.size;
-                                       continue;
-                               }
-
-                               /* Align the field on an appropriate boundary */
-                               if((layout->staticSize % typeLayout.alignment) 
!= 0)
-                               {
-                                       layout->staticSize += 
typeLayout.alignment -
-                                               (layout->staticSize % 
typeLayout.alignment);
-                               }
-
-                               /* Record the field's offset and advance past 
it */
-                               field->offset = layout->staticSize;
-                               field->nativeOffset = layout->staticSize;
-                               layout->staticSize += typeLayout.size;
-
-                               /* Set the "managedStatic" flag if the type is 
managed */
-                               if(typeLayout.managedInstance)
-                               {
-                                       layout->managedStatic = 1;
-                               }
-                       }
-               }
-       }
-
        /* Allocate vtable slots to the virtual methods in this class */
        method = 0;
        explicitSize = layout->vtableSize;
@@ -1488,7 +1429,7 @@
                        method->index = layout->vtableSize;
                        ++(layout->vtableSize);
                        /* Initialize the metod vtable if this is a generic 
method */
-                       if(!ILMethodSetVirtualAncestor(method, ancestor))
+                       if(!ILMethodSetVirtualAncestor(method, (ILMethod *)0))
                        {
                                info->userData = 0;
                                return 0;
@@ -1541,18 +1482,6 @@
                return 0;
        }
 
-#ifdef IL_USE_JIT
-       if(isJitCoder)
-       {
-               if(!ILJitCreateFunctionsForClass(process->coder, info))
-               {
-                       ILJitTypesDestroy(&(classPrivate->jitTypes));
-                       info->userData = 0;
-                       return 0;
-               }
-       }
-#endif
-
        /* Allocate the vtable and copy the parent's vtable into it */
        if((vtable = (ILMethod **)
                        
ILMemStackAllocItem(&(info->programItem.image->memStack),
@@ -1574,10 +1503,18 @@
        {
                ILMemCpy(vtable, layout->vtable, explicitSize * sizeof(ILMethod 
*));
        #ifdef IL_USE_JIT
-               ILMemCpy(jitVtable, layout->jitVtable, explicitSize * 
sizeof(ILMethod *));
+               ILMemCpy(jitVtable, layout->jitVtable, explicitSize * 
sizeof(void *));
        #endif
        }
 
+       /* Record the rest of the layout information for this class */
+       classPrivate->vtableSize = layout->vtableSize;
+       classPrivate->vtable = vtable;
+       classPrivate->hasFinalizer = layout->hasFinalizer;
+#ifdef IL_USE_JIT
+       classPrivate->jitVtable = jitVtable;
+#endif
+
        /* Override the vtable slots with this class's method implementations */
        method = 0;
        while((method = (ILMethod *)ILClassNextMemberByKind
@@ -1587,11 +1524,91 @@
                {
                        vtable[method->index] = method;
                #ifdef IL_USE_JIT
-                       jitVtable[method->index] = 
jit_function_to_vtable_pointer(ILJitFunctionFromILMethod(method));
+                       /* NOTE: Here still exists the slight possibility that 
a type is
+                          layouted whose parent type's vtable is not complete 
yet.
+                          Maybe we'll have to loop over the whole vtable again 
to build the 
+                          jitvtable */
+                       jitVtable[method->index] = 
ILJitGetVtablePointer(process->coder, method);
                #endif
                }
        }
 
+#ifdef IL_USE_JIT
+       if(isJitCoder)
+       {
+               if(!ILJitCreateFunctionsForClass(process->coder, info))
+               {
+                       ILJitTypesDestroy(&(classPrivate->jitTypes));
+                       info->userData = 0;
+                       return 0;
+               }
+       }
+#endif
+
+       /* Allocate the static fields.  We must do this after the
+          regular fields because some of the statics may be instances
+          of the class that we are trying to lay out, especially
+          in value type definitions */
+       field = 0;
+       while((field = (ILField *)ILClassNextMemberByKind
+                       (info, (ILMember *)field, IL_META_MEMBERKIND_FIELD)) != 
0)
+       {
+               if((field->member.attributes & IL_META_FIELDDEF_STATIC) != 0 &&
+                  (field->member.attributes & IL_META_FIELDDEF_LITERAL) == 0)
+               {
+                       /* Lay out a static field */
+                       fieldRVA = ILFieldRVAGetFromOwner(field);
+                       if(fieldRVA && !allowRVALayout)
+                       {
+                               /* RVA fields are not permitted, so remove the 
attribute */
+                               field->member.attributes &= 
~IL_META_FIELDDEF_HAS_FIELD_RVA;
+                       }
+                       if(!fieldRVA || !allowRVALayout)
+                       {
+                               /* Get the layout information for this field's 
type */
+                               if(!LayoutType(process, 
field->member.signature, &typeLayout))
+                               {
+                                       info->userData = 0;
+                                       return 0;
+                               }
+
+                               /* Thread-static variables are allocated slots 
from the
+                                  ILExecProcess record.  We assume that some 
higher level
+                                  function has acquired the metadata lock on 
the process */
+                               if(ILFieldIsThreadStatic(field))
+                               {
+                                       /* Store the slot number in the 
"offset" field and
+                                          the field size in the "nativeOffset" 
field */
+                                       field->offset = 
(process->numThreadStaticSlots)++;
+                                       field->nativeOffset = typeLayout.size;
+                                       continue;
+                               }
+
+                               /* Align the field on an appropriate boundary */
+                               if((layout->staticSize % typeLayout.alignment) 
!= 0)
+                               {
+                                       layout->staticSize += 
typeLayout.alignment -
+                                               (layout->staticSize % 
typeLayout.alignment);
+                               }
+
+                               /* Record the field's offset and advance past 
it */
+                               field->offset = layout->staticSize;
+                               field->nativeOffset = layout->staticSize;
+                               layout->staticSize += typeLayout.size;
+
+                               /* Set the "managedStatic" flag if the type is 
managed */
+                               if(typeLayout.managedInstance)
+                               {
+                                       layout->managedStatic = 1;
+                               }
+                       }
+               }
+       }
+
+       /* Record the static layout information for this class */
+       classPrivate->staticSize = layout->staticSize;
+       classPrivate->managedStatic = layout->managedStatic;
+
        /* Compute the interface tables for this class */
        if((info->attributes & IL_META_TYPEDEF_CLASS_SEMANTICS_MASK) !=
                                IL_META_TYPEDEF_INTERFACE)
@@ -1613,15 +1630,8 @@
        }
 
        /* Record the rest of the layout information for this class */
-       classPrivate->staticSize = layout->staticSize;
-       classPrivate->vtableSize = layout->vtableSize;
-       classPrivate->vtable = vtable;
-       classPrivate->hasFinalizer = layout->hasFinalizer;
-       classPrivate->managedInstance = layout->managedInstance;
-       classPrivate->managedStatic = layout->managedStatic;
        layout->vtable = vtable;
 #ifdef IL_USE_JIT
-       classPrivate->jitVtable = jitVtable;
        layout->jitVtable = jitVtable;
 #endif
 




reply via email to

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