Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Does Caml have slow arithmetics ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-07 (15:41)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Does Caml have slow arithmetics ?
On Wed, 7 Jul 2004, Diego Olivier Fernandez Pons wrote:

> Subsidiary question : why LSB instead of MSB ? I thought it would be
> simpler to let the computations silently overflow and correct when
> necessary the tag bit.

Because everything is a word and word aligned, so pointers always point to
a word aligned address- which means that the low 2 (on 32-bit machines) or
3 (on 64-bit machines) bits are always zero for pointers.  So if we set 
the low bit of unboxed values, the garbage collector can simply walk 
through memory, looking at every word.  If the low bit is set, then it's 
an unboxed integer type and not a point.  If the low bit is clear, it's a 
pointer.  This speeds up the garbage collector, making the overall program 

"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: