# HG changeset patch # User Ziv Scully # Date 1443493011 14400 # Node ID 03b10c7fab9a724373e40c6b87159d8e10dce947 # Parent 6951a645ccdffd1ecc4441d6264856b2223a7ed8 Begin work on cache merging. diff -r 6951a645ccdf -r 03b10c7fab9a src/mono_fooify.sml --- a/src/mono_fooify.sml Sun Sep 27 17:24:57 2015 -0400 +++ b/src/mono_fooify.sml Mon Sep 28 22:16:51 2015 -0400 @@ -1,4 +1,4 @@ -structure MonoFooify (* :> MONO_FOOIFY *) = struct +structure MonoFooify :> MONO_FOOIFY = struct open Mono diff -r 6951a645ccdf -r 03b10c7fab9a src/sqlcache.sml --- a/src/sqlcache.sml Sun Sep 27 17:24:57 2015 -0400 +++ b/src/sqlcache.sml Mon Sep 28 22:16:51 2015 -0400 @@ -799,6 +799,45 @@ val expSize = MonoUtil.Exp.fold {typ = #2, exp = fn (_, n) => n+1} 0 +structure InvalidationInfo :> sig + type t + val fromList : int list -> t + val toList : t -> int list + val union : t * t -> t + val unbind : t * int -> t option +end = struct + +(* Keep track of the minimum explicitly. NONE is the empty set. *) +type t = (int * IS.set) option + +val fromList = + List.foldl + (fn (n, NONE) => SOME (n, IS.singleton n) + | (n', SOME (n, ns)) => SOME (Int.min (n, n'), IS.add (ns, n'))) + NONE + +val toList = + fn NONE => [] + | SOME (_, ns) => IS.listItems ns + +val union = + fn (SOME (n1, ns1), SOME (n2, ns2)) => SOME (Int.min (n1, n2), IS.union (ns1, ns2)) + | (NONE, x) => x + | (x, NONE) => x + +val unbind = + fn (SOME (n, ns), unbound) => + let + val n = n - unbound + in + if n < 0 + then NONE + else SOME (SOME (n, IS.map (fn n => n - unbound) ns)) + end + | _ => SOME NONE + +end + datatype subexp = Pure of unit -> exp | Impure of exp val isImpure =