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

Stephen Weeks MLton@mlton.org
Sun, 22 Jun 2003 23:33:38 -0700


> 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).

Correct.

> Would the adjunction of an Int31 type allow the user to get the
> same space efficiency when needed (while keeping Int32 as the
> default) ? 

Yes, it would.  What is needed is a little bit more cleverness in the
representation pass of SsaToRssa, so that it notices that there are no
non-value carrying datatypes and one value carrying datatype can be
represented with <= 31 bits.

> 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

Unfortunately you are correct.

> It would be great if booleans in records would be automatically
> packed by the compiler.

There are two possibilities, neither of which is difficult.  The
representation pass could represent booleans with Word8 instead of
Word32.  Or, an earlier ssa-to-ssa pass could insert the
packing/unpacking code.

Even better would be a more general representation pass that kept
track of the number of bits needed to represent values and did all
kinds of clever packing/tagging to avoid boxing.  E.g. it could
represent the following type with a single word without any boxing.

datatype t =
    A
  | B of Word16.word
  | C of Word8.word



-------------------------------------------------------
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