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

Re: Harlequin 1.2 still available?



On Mon, 12 Jun 2000, Maury Markowitz wrote:
> "Neel Krishnaswami" <neelk@brick.cswv.com> wrote in message
> slrn8k8fme.k9p.neelk@brick.cswv.com">news:slrn8k8fme.k9p.neelk@brick.cswv.com...
> > dynamic-language features. (IIRC, the Sun SPARC has hardware support
> > for tagged integer arithmetic.)
> 
>  OOC, what are tagged integers?

I might be wrong here, but ...

A typical way to store runtime type information is to have an extra bit of
memory (usually just one word) before the "real" start of each object
which encodes this (probably by pointing to some class information).  I
believe this is how many JVMs do this for Java (and I seem to recall
reading a paper on how someone got the size overhead down from two words
to one -- the trade-off being more indirections, so decreased speed). 

If *everything* has to work this way then simple arithmetic could get
really slow, requiring loads of extra pointer indirection, and take up
twice as much space.  Java has "raw" types to get round this (e.g., "int"
instead of "Integer").  Presumably it has to be able to figure out which
things are "raw types" at compile time, so it can do away with the extra
word(s).

An alternative is to reserve a few "tag" bits in the first word of each
object to encode a very few possibilities like "integer", "character" or
"other object".  Then you only need the extra word for "other objects". 
This possibility is why the DRM only guarantees 28 bits for integers, not
32 (I believe FunDev provides 29 bits).  The trade-off here is that you
get fewer bits for your integers, characters etc.  There may also be a
little extra work for arithmetic (e.g., masking out the tag bits
beforehand, then ORing them back in afterwards -- I'm not a low-level
compiler guy :-) but probably much faster than pointer dereferencing and
possibly not much at all, if your instruction set supports tagged integers
(to bring us back to the point I think Neel was making).

Does that explain tagged integers?  If not, I'll try again (or let someone
else try ;-)

Hugh




Follow-Ups: References: