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;
>
> (I assume that mmx and sse are some sort of i386-specific instructions.)

Indeed.

> Specifically, I'm wondering about two things:
>
> 1.  Is the comment backwards?  If I count correctly, including the
>     void *dummy means that u.data will *NOT* be aligned on an 8-byte
>     boundary.  Is that the actual intent?  (Of course, compilers are
>     free to add in extra padding inside structures, and it may end up
>     aligned with some compilers but not aligned with others.)

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.

The assembly coded mmx/sse copy subroutines were active at that time and did 
introduce a nice speedup.
These copy functions were used to copy register frames at - hmmm ancient - 
times before parrot got more than 32 registers.

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.

leo

[1] it was renamed later to a similar name and was removed thereafter:
    $ svn log include/parrot/pobj.h | grep version

[2] see also these (and related) in the parrot tree
    $ find . -type f | egrep '_mmx|_sse' | grep -v svn
    $ find . -type f | xargs grep mmx # ...

Reply via email to