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