[MLton-devel] Re: MLton-devel digest, Vol 1 #351 - 1 msg

Alain Deutsch deutsch@pst.polyspace.com
Mon, 23 Jun 2003 08:07:48 +0200 (MET DST)


About scalar data types sizes, there is a point I was wondering
about. Take a data type which consists of two cases, one is an
integer, and the other one is a tuple:

datatype t =
   i of int
 | c of t * t;

If I am not mistaken, then MLton will represent objects of the
form i(...) by a boxed integer, which presumably costs 8 bytes
(header + integer bits).

An object of the form c(i(x), i(y)) will thus cost at least
8+8+12 = 28 bytes (assuming a tuple header costs 4 bytes only).

With SML/NJ, the situation is probably different, as integers are
31 bits. Here i(x) costs zero heap bytes, and c(i(x), i(y)) = 12
bytes, assuming a tuple header only costs 4 bytes.

Would the adjunction of an Int31 type allow the user to get the
same space efficiency when needed (while keeping Int32 as the
default) ? If all pointer objects are multiples of 4 then this
should be possible with MLton as well ? In the example above, the
heap occupancy ratio if 28/12 ~ 2.3, which is quite significant
and there are many cases were an Int31 is sufficient.

Another less important issue: the cost of booleans in records. We
often use them, and because we think that a record containing four
booleans will be coded with several words (whereas one byte would
suffice) we do partly by-hand bit packing in words, which is lower
level than in C (bit fields). It would be great if booleans in
records would be automatically packed by the compiler.

--
Alain Deutsch, CTO              tel.: +33 (0)1 49 65 32 64
PolySpace Technologies          fax.: +33 (0)1 49 65 05 77
mailto:deutsch@POLYSPACE.COM    http://www.polyspace.com



-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel