On Sat, 2002-08-31 at 18:45, Steven W McDougall wrote:

Good write-up.


> I tested this theory by hacking mem_allocate() to enforce a minimum
> round-up to an 8-type boundary. 
> 
>     /* Round up to requested alignment */
>     if (align_1<7) align_1 = 7;  /* <<<==== HACK */
>     size = (size + align_1) & ~align_1;
> 
> This keeps top 8-byte aligned. The bus error went away, and
> t/pmc/perlhash_1.pbc produced the correct output.
> 
> 
> I don't know how this thing is supposed to work, so I don't know how
> to fix it. Logically, there are a few possibilities.
> 
> 1. Fix gcc on IRIX64 to permit assignment of unions with arbitrary
>    alignment.
> 
> 2. Add a parameter to mem_alloc() (or use align_1) to control the
>    alignment of the allocated block.
> 
> 3. Require all callers of mem_alloc() to pass an align_1 parameter
>    big enough to meet the alignment requirements of the platform.
>    (Seems like the Wrong Thing.)

IIRC, the impetus for rounding up memory allocations was to preserve
alignment efficiently, which would imply that the amount of rounding
should be a compile-time configure issue.

That is a potential space-waster on 64-bit platforms that are storing
many smaller items, but it's probably the thing to do anyway because:

a) you're going to really slow things down by having to determine if the
new thing you're allocating can fit on the tail of a previous
allocation, and

b) you're going to be wasting some of that space anyway in order to
align to the stricter requirements, even when you need to.

-- 
Bryan C. Warnock
bwarnock@(gtemail.net|raba.com)

Reply via email to