Thanks Alex,
About why I am trying it - it's primarily just a learning exercise for me.
What I am trying is expanding the cell to 4 words instead of two and use
the extra words as the meta data and not require tagged pointers. This way
I could even build it with TCC that does not seem to align functions at 4
byte boundary.

Sorry if I am missing something, but wouldn't x-1 result in shifting the
pointer by 8 bytes instead of 4 (since size of cell is 8). Which is
probably why cdr is used instead of car?

regards,
Kashyap

On Wed, Aug 26, 2020 at 10:56 PM Alexander Burger <a...@software-lab.de>
wrote:

> Hi Kashyap,
>
> > I am still working on the idea of using non-tagged pointers in
> miniPicoLisp
> > - in order to get rid of the requirement that function pointers be word
> > aligned.
>
> Why would you want to do that? The concept of encoding the tags in the
> lowest
> bits of a pointer is the core idea of PicoLisp. Pointer alignment to 8
> bytes (on
> 32 bits) gives three tag bits for free.
>
> Three tag bits are needed (gc mark, number and symbol tag). If you use
> other
> bits (e.g. the highest ones) you lose 87.5 percent of the address space.
> And
> runtime checks for higher bits are more expensive. Similar for other
> concepts
> like using separate heaps.
>
> The alignment comes at low cost, only once when the heap is allocated.
> After
> that all cells are guaranteed to be properly aligned. Most hardware has
> that
> requirement anyway. If not, word accesses become intolerably slow.
>
>
>
> > #define tail(x)         (((x)-1)->cdr)
> >
> > Does this not result in going outside the 0th cell? Would this be more
> > appropriate?
>
> No, because 'x' points to an offset of four (because of the tag bit!) to
> the
> symbol
>
>             Symbol
>             |
>             V
>       +-----+-----+
>       |  |  | VAL |
>       +--+--+-----+
>          | tail
>          |
>          V                                                      name
>
> so that 'tail' points to the start address of that cell.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to