[MLton-commit] r5387

Vesa Karvonen vesak at mlton.org
Sat Mar 3 06:35:48 PST 2007


Changed to use 64-bit counters to avoid overflows when compiling large
programs.

----------------------------------------------------------------------

U   mlton/trunk/lib/mlton/basic/property-list.fun

----------------------------------------------------------------------

Modified: mlton/trunk/lib/mlton/basic/property-list.fun
===================================================================
--- mlton/trunk/lib/mlton/basic/property-list.fun	2007-03-03 05:30:53 UTC (rev 5386)
+++ mlton/trunk/lib/mlton/basic/property-list.fun	2007-03-03 14:35:33 UTC (rev 5387)
@@ -18,17 +18,18 @@
 
 fun clear (T hs) = hs := []
 
-val numPeeks: int ref = ref 0
-val numLinks: int ref = ref 0
+val numPeeks: Int64.int ref = ref 0
+val numLinks: Int64.int ref = ref 0
 val maxLength: int ref = ref 0
 
 fun stats () =
    let open Layout
    in align
-      [seq [str "numPeeks = ", Int.layout (!numPeeks)],
+      [seq [str "numPeeks = ", str (Int64.toString (!numPeeks))],
        seq [str "maxLength = ", Int.layout (!maxLength)],
        seq [str "average position in property list = ",
             str let open Real
+                    val fromInt = fromIntInf o Int64.toLarge
                 in format (fromInt (!numLinks) / fromInt (!numPeeks),
                            Format.fix (SOME 3))
                 end]]
@@ -42,7 +43,7 @@
             fun loop (l, n) =
                let
                   fun update () =
-                     ((numLinks := n + !numLinks
+                     ((numLinks := Int64.fromInt n + !numLinks
                        handle Overflow => Error.bug "PropertyList: numLinks overflow")
                       ; if n > !maxLength
                            then maxLength := n




More information about the MLton-commit mailing list