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 engine.h,1.63,1.64 layout.c,1.23


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine engine.h,1.63,1.64 layout.c,1.23,1.24
Date: Sun, 08 Dec 2002 06:05:08 -0500

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

Modified Files:
        engine.h layout.c 
Log Message:


Add "native" offset information to fields, to allow for the possibility of
native structures with different layout from their managed counterparts.


Index: engine.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -r1.63 -r1.64
*** engine.h    27 Nov 2002 00:24:49 -0000      1.63
--- engine.h    8 Dec 2002 11:05:06 -0000       1.64
***************
*** 234,241 ****
  {
        ILUInt32                size;                           /* Full 
instance size */
        ILUInt32                staticSize;                     /* Size of 
static data */
        ILUInt32                inLayout : 1;           /* Non-zero if in 
layout algorithm */
        ILUInt32                hasFinalizer : 1;       /* Non-zero if 
non-trivial finalizer */
!       ILUInt32                alignment : 14;         /* Preferred instance 
alignment */
        ILUInt32                vtableSize : 16;        /* Size of the vtable */
        ILMethod      **vtable;                         /* Methods within the 
vtable */
--- 234,243 ----
  {
        ILUInt32                size;                           /* Full 
instance size */
+       ILUInt32                nativeSize;                     /* Full native 
instance size */
        ILUInt32                staticSize;                     /* Size of 
static data */
        ILUInt32                inLayout : 1;           /* Non-zero if in 
layout algorithm */
        ILUInt32                hasFinalizer : 1;       /* Non-zero if 
non-trivial finalizer */
!       ILUInt32                alignment : 7;          /* Preferred instance 
alignment */
!       ILUInt32                nativeAlignment : 7;/* Preferred native 
alignment */
        ILUInt32                vtableSize : 16;        /* Size of the vtable */
        ILMethod      **vtable;                         /* Methods within the 
vtable */

Index: layout.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/layout.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** layout.c    20 Sep 2002 04:43:20 -0000      1.23
--- layout.c    8 Dec 2002 11:05:06 -0000       1.24
***************
*** 38,41 ****
--- 38,43 ----
        ILUInt32        size;
        ILUInt32        alignment;
+       ILUInt32        nativeSize;
+       ILUInt32        nativeAlignment;
        ILUInt32        vtableSize;
        ILMethod  **vtable;
***************
*** 163,166 ****
--- 165,170 ----
                        default: return 0;
                }
+               layout->nativeSize = layout->size;
+               layout->nativeAlignment = layout->alignment;
                layout->vtableSize = 0;
                layout->vtable = 0;
***************
*** 185,188 ****
--- 189,194 ----
                layout->alignment = _IL_ALIGN_FOR_TYPE(void_p);
        #endif
+               layout->nativeSize = layout->size;
+               layout->nativeAlignment = layout->alignment;
                layout->vtableSize = 0;
                layout->vtable = 0;
***************
*** 415,418 ****
--- 421,425 ----
        LayoutInfo typeLayout;
        ILUInt32 maxAlignment;
+       ILUInt32 maxNativeAlignment;
        ILUInt32 packingSize;
        ILUInt32 explicitSize;
***************
*** 443,446 ****
--- 450,455 ----
                        layout->size = classPrivate->size;
                        layout->alignment = classPrivate->alignment;
+                       layout->nativeSize = classPrivate->nativeSize;
+                       layout->nativeAlignment = classPrivate->nativeAlignment;
                        layout->vtableSize = classPrivate->vtableSize;
                        layout->vtable = classPrivate->vtable;
***************
*** 483,486 ****
--- 492,497 ----
                layout->size = 0;
                layout->alignment = 1;
+               layout->nativeSize = 0;
+               layout->nativeAlignment = 1;
                layout->vtableSize = 0;
                layout->hasFinalizer = 0;
***************
*** 542,545 ****
--- 553,557 ----
        field = 0;
        maxAlignment = 1;
+       maxNativeAlignment = 1;
        while((field = (ILField *)ILClassNextMemberByKind
                        (info, (ILMember *)field, IL_META_MEMBERKIND_FIELD)) != 
0)
***************
*** 559,562 ****
--- 571,578 ----
                                typeLayout.alignment = packingSize;
                        }
+                       if(packingSize != 0 && packingSize < 
typeLayout.nativeAlignment)
+                       {
+                               typeLayout.nativeAlignment = packingSize;
+                       }
  
                        /* Use an explicit field offset if necessary */
***************
*** 566,569 ****
--- 582,586 ----
                                /* Record the explicit field offset */
                                field->offset = fieldLayout->offset;
+                               field->nativeOffset = fieldLayout->offset;
  
                                /* Extend the default class size to include the 
field */
***************
*** 572,575 ****
--- 589,596 ----
                                        layout->size = field->offset + 
typeLayout.size;
                                }
+                               if((field->offset + typeLayout.nativeSize) > 
layout->nativeSize)
+                               {
+                                       layout->nativeSize = field->offset + 
typeLayout.nativeSize;
+                               }
                        }
                        else
***************
*** 581,588 ****
--- 602,616 ----
                                                (layout->size % 
typeLayout.alignment);
                                }
+                               if((layout->nativeSize % 
typeLayout.nativeAlignment) != 0)
+                               {
+                                       layout->nativeSize += 
typeLayout.nativeAlignment -
+                                               (layout->nativeSize % 
typeLayout.nativeAlignment);
+                               }
  
                                /* Record the field's offset and advance past 
it */
                                field->offset = layout->size;
+                               field->nativeOffset = layout->nativeSize;
                                layout->size += typeLayout.size;
+                               layout->nativeSize += typeLayout.nativeSize;
                        }
  
***************
*** 592,595 ****
--- 620,627 ----
                                maxAlignment = typeLayout.alignment;
                        }
+                       if(typeLayout.nativeAlignment > maxNativeAlignment)
+                       {
+                               maxNativeAlignment = typeLayout.nativeAlignment;
+                       }
                }
        }
***************
*** 609,616 ****
--- 641,663 ----
                                (layout->size % layout->alignment);
        }
+       if(maxNativeAlignment > layout->nativeAlignment)
+       {
+               layout->nativeAlignment = maxNativeAlignment;
+       }
+       if(explicitSize > layout->nativeSize)
+       {
+               layout->nativeSize = explicitSize;
+       }
+       else if((layout->nativeSize % layout->nativeAlignment) != 0)
+       {
+               layout->nativeSize += layout->nativeAlignment -
+                               (layout->nativeSize % layout->nativeAlignment);
+       }
  
        /* Record the object size information for this class */
        classPrivate->size = layout->size;
        classPrivate->alignment = layout->alignment;
+       classPrivate->nativeSize = layout->nativeSize;
+       classPrivate->nativeAlignment = layout->nativeAlignment;
        classPrivate->inLayout = 0;
  
***************
*** 651,654 ****
--- 698,702 ----
                                /* Record the field's offset and advance past 
it */
                                field->offset = layout->staticSize;
+                               field->nativeOffset = layout->staticSize;
                                layout->staticSize += typeLayout.size;
                        }




reply via email to

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