[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heap corruption?

From: Gerd Moellmann
Subject: Re: Heap corruption?
Date: 20 Aug 2003 16:41:51 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

address@hidden (Kim F. Storm) writes:

> I wonder how any simple masking scheme can ever be guaranteed to work
> on all systems ... and obviously it has hit this limitation on
> FreeBSD.
> Wouldn't it be better -- at least as a compile-time option -- to implement
> a scheme where a lisp object is referenced as a relative (BLOCK#, OFFSET) 
> address

I think something simpler would be preferrable, and works very well in
contemporary Lisps: align all Lisp objects on 8-byte boundaries, so
that the 3 lowest bits are zero and free for tag bits.

That should work everywhere, and since conses are 8 bytes long, one
doesn't lose much memory.

And it's fast. To access the car/cdr of a cons P, for example, with
the cons tag being 3, one can use

   car = *(Lisp_Object *) ((char *) p - 3 + 0)
   cdr = *(Lisp_Object *) ((char *) p - 3 + 2)

which should give something like

   movl eax, [edi-3]
   movl eax, [edi-1]

with a good compiler on x86.

Finally, give even fixnums the tag #b000 and odd fixnums the tag
#b100. so that they can be added and subtracted easily, and so that
one wins 1 bit more for them :).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]