# New Ticket Created by  Andy Dougherty 
# Please include the string:  [perl #42772]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42772 >


On Thu, 26 Apr 2007, Leopold Toetsch wrote:

> Am Donnerstag, 26. April 2007 21:44 schrieb Andy Dougherty:
> > Does anyone understand the 'dummy' element in
> > include/parrot/stacks.h?  Here is the relevant snippet:
> >
> >     typedef struct Stack_Chunk {
> >         pobj_t obj;
> >         int size;
> >         const char * name;
> >         struct Stack_Chunk *prev;
> >     #if ! DISABLE_GC_DEBUG && defined(I386)
> >         void * dummy;   /* force 8 byte align for mmx and sse moves */
> >     #endif
> >         union { /* force appropriate alignment of 'data' */
> >             void *data;
> >     #ifndef I386
> >             double d_dummy;         /* align double values on stack */
> >     #endif
> >         } u;
> >     } Stack_Chunk_t;

> At some earlier time in parrot history, there was a (32 bit, pointer-sized) 
> 'version' [1] structure item in pobj_t, which was active 
> with !DISABLE_GC_DEBUG. The dummy was needed for i386 (when x86_64 didn't 
> even exist) to align the data pointer at an 8-byte boundary.

Ah, yes.  Thanks for the detailed reply.   At this point, removing the 
dummy will put u.data back on an 8-byte boundary (for i386), so that's 
probably a good thing all around.

I'd suggest the following patch:

diff -ru parrot-current/include/parrot/stacks.h 
parrot-andy/include/parrot/stacks.h
--- parrot-current/include/parrot/stacks.h      2006-11-12 03:15:19.000000000 
-0500
+++ parrot-andy/include/parrot/stacks.h 2007-04-27 09:24:04.000000000 -0400
@@ -29,13 +29,11 @@
     int size;
     const char * name;
     struct Stack_Chunk *prev;
-#if ! DISABLE_GC_DEBUG && defined(I386)
-    void * dummy;   /* force 8 byte align for mmx and sse moves */
-#endif
-    union { /* force appropriate alignment of 'data' */
+    union { /* force appropriate alignment of 'data'.  If alignment
+               is necessary, assume double is good enough.  27-04-2007. */
         void *data;
-#ifndef I386
-        double d_dummy;         /* align double values on stack */
+#if PARROT_PTR_ALIGNMENT > 1
+        double d_dummy;
 #endif
     } u;
 } Stack_Chunk_t;
--- parrot-current/src/stack_common.c   Thu Apr 26 19:15:14 2007
+++ parrot-andy/src/stack_common.c      Fri Apr 27 11:49:53 2007
@@ -59,9 +59,6 @@
     Stack_Chunk_t *chunk;
 
     item_size += offsetof(Stack_Chunk_t, u.data);
-    item_size += 7;
-    item_size &= ~7;    /* round up to 8 so that the chunk is aligned at
-                           the same size - the aligned MMX memcpy needs it */
     make_bufferlike_pool(interp, item_size);
     chunk = (Stack_Chunk_t *)new_bufferlike_header(interp, item_size);
     chunk->prev = chunk;        /* mark the top of the stack */




> As the past tense is indicating, above dummy is totally obsolete and the copy 
> functions[2] are unused. The latter could be removed too, but might be a 
> nice-to-have, when something faster than memcpy(3) is wanted or needed, 
> albeit only on restricted (but common) platforms and for aligned memory only. 
> Some recent CPUs do have special instructions for copying unaligned memory 
> reegions too.

Yes, indeed.  I could see a future optimization pairing memalign(3C) with 
specialized copy functions.

Thanks again,

-- 
    Andy Dougherty              [EMAIL PROTECTED]

Reply via email to