[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] Re: [Maxima] Re: Lisp vs. Java vs. C++ speed comparison
Paul F. Dietz
Re: [Gcl-devel] Re: [Maxima] Re: Lisp vs. Java vs. C++ speed comparison time? [LONG]
Mon, 12 Jul 2004 18:43:55 -0500
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040514
Camm Maguire wrote:
I suppose the canonical way to do this is to make use of the two least
significant bits in the pointer value on 32bit machines to hold the
type information, but this seems quite expensive as each pointer
indirection must be accompanied by a pointer truncation.
The usual way to do this is to lop off the tag bits using offset
addressing modes (add -1 or 3 to the register before loading the word,
for example; this can be done as part of the load instruction on most
In C, you'd say something like this, I suppose:
*(long *)(((char *) p) + offset)
and hope this bit of nonstandardization was properly interpreted.
As a bonus, if p were not of the right type, and if the machine
trapped on 32 bit word loads that were not 4 byte aligned, then
this would trap argument type errors even compiled at safety 0.