[MLton-devel] IntInf primops

Stephen Weeks MLton@mlton.org
Tue, 14 Jan 2003 21:02:52 -0800

> > Is there a reason for not putting the constant folding of IntInf primops
> > in?  So far, only IntInf_equals, IntInf_compare, and IntInf_{from,to}Word
> > are there.
> Sorry; screwed again by the heap parameter (I was looking in allConsts).
> I'll think harder before posting next time. ;-)

Yeah, as you saw the stuff is there.  I am a little bit worried about
constant folding of IntInfs because it can make the compiler blow up
and can hurt space safety.  For example, consider the following code

val x0: IntInf.int = 1234567890
val x1 = x0 * x0
val x2 = x1 * x1
val x3 = x2 * x2

As you can see, constant-folding could cause the compiler to do an
exponential amount of work, and could cause an exponentially large
value to be stored in a closure.

Even worse, IntInf.<< (1, 123456789), could be bad.  :-(

Fortunately or unfortunately, I'm not sure this problem could really
happen right now, because the code that we have wrapped around IntInf
ops seems to interfere with constant folding actually happening.  It's
on my todo list, but is not a very high priority.

Anyways, I guess we could be really safe by disabling IntInf.<< and
IntInf.*.  Anyone have any opinions?

This SF.NET email is sponsored by: Take your first step towards giving 
your online business a competitive advantage. Test-drive a Thawte SSL 
certificate - our easy online guide will show you how. Click here to get 
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
MLton-devel mailing list