From 3c2143723af4a52064386104d2105137a77bd761 Mon Sep 17 00:00:00 2001 From: Ziv Scully Date: Mon, 28 Sep 2015 22:16:51 -0400 Subject: Begin work on cache merging. --- src/sqlcache.sml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/sqlcache.sml') diff --git a/src/sqlcache.sml b/src/sqlcache.sml index 1518e994..09feeb36 100644 --- a/src/sqlcache.sml +++ b/src/sqlcache.sml @@ -799,6 +799,45 @@ val freeVars = 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 = -- cgit v1.2.3