speeding up IntInf?

Matthew Fluet fluet@cs.cornell.edu
Mon, 18 Feb 2002 18:29:04 -0500 (EST)


> What is the meaning of some types bing int and some being Int.int?  

Sorry; I was cut and pasting from the IntInf structure (in
/src/basis-library/misc/primitive.sml), so int's are IntInf.int's
(i.e., GMP bignums) and Int.int's are 32-bit signed integers.

> Also I am
> epsilon nervous about the size computed some where else and then  not  passed
> to  the  C code.  

Doesn't matter; I figured one less argument to pass; currently, we just
pass the array and assume it is of the right size.  Or maybe the IntInf.c
code checks the array length word?

> Wait, I don't see what the size primitive is doing.  What is  it's  argument?

It's agument would be an IntInf.int (= GMP bignum).  It would return the
size of big num; number of limbs, I guess, in their terms.

> Note, in general the maximum size is a function of the sizes of the arguments
> (if they are bignums).

Exactly; just as in /src/basis-library/integer/int-inf.sml where the
bigOp functions do an allocate that is computed from the sizes of its
arguments.

Essentially, wherever /src/basis-library/integer/int-inf.sml
has Prim.op (lhs, rhs, allocate size), replace it with 
Prim.op (lhs, rhs, size) and the underlying op will do the allocation.
Because we're now completely hiding the fact that bignums are
representationally equivalent to array/vectors, we can't use Vector.length
to get sizes, so we provide a primitive.