[EMAIL PROTECTED] (Carl R. Witty) writes:

> Sigbjorn Finne <[EMAIL PROTECTED]> writes:
> > Clearly there's a range of optimisations possible here; using an
> > efficiently implemented bignum library being one (not irrelevant) way
> > to improve matters. Changing the representation of Integer is another,
> > distinguishing at the Haskell level between ones that fit in a machine
> > word and those that don't. We plan to use such a representation for
> > GHC/Hugs.
> 
> I'm glad to hear it; do you have anything written on exactly how you
> this will work?

The plan is to use something like

        data Integer = Small Int# | Big { ... }

where '...' is the GMP representation.  You then need a full set of
overflow-detecting primitive operations on Int.  I've done a few
experiments with using gcc's 'long long' type to implement these
portably (well, portably across 32-bit architectures...), and it seems
possible.  

The common case of applying a dyadic operation to small Integers would
then be pretty close in performance to that of Int (a couple of
indirect jumps, and a test/branch for the overflow detection, to be
precise).

Cheers,
        Simon

-- 
Simon Marlow                                             [EMAIL PROTECTED]
University of Glasgow                       http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key


Reply via email to