I hate to ask such a stupid question, but what is a power of two boundry and
why do we want it to be aligned on one? I was assuming a power of two
boundry to be some memory address N such that N = 2 ** i, but this
apparently is not the case. Sorry for asking such a rudimentary question,
but I'm trying to understand the memory allocation logic and failing
miserably.
Thanks!
Tanton
-----Original Message-----
From: Dan Sugalski
To: Hong Zhang; 'Philip Kendall'; [EMAIL PROTECTED]
Sent: 9/12/2001 12:19 PM
Subject: RE: Parrot coredumps on Solaris 8
At 09:57 AM 9/12/2001 -0700, Hong Zhang wrote:
> > Now works on Solaris and i386, but segfaults at the GRAB_IV call in
> > read_constants_table on my Alpha. Problems with the integer-pointer
> > conversions in memory.c? (line 29 is giving me a warning).
>
>The line 29 is extremely wrong. It assigns IV to void* without casting.
True. I'll go fix it.
>The alignment calculation is very wrong too. Using classic alignment,
>it should read as:
>
> mem = (void*) (((IV)mem + mask) & ~mask);
Nope. We're trying to align to a power-of-two boundary, and mask is set
to
chop off the low bits, not the high ones. It should be something like:
111111110000
The calc:
mem & mask + (~mask + 1)
will chop the low bits off of mem, making it too small, but power-of-two
aligned. Then we add in the inverse of mask + 1 (in the above example,
that'd be 10000) to jump it to the next power-of-two boundary.
Horribly wasteful of memory, definitely, and the final allocation system
will do things better, but this is OK to start.
Dan
--------------------------------------"it's like
this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk