summaryrefslogtreecommitdiff
path: root/src/sqlcache.sml
diff options
context:
space:
mode:
authorGravatar Ziv Scully <ziv@mit.edu>2015-09-28 22:16:51 -0400
committerGravatar Ziv Scully <ziv@mit.edu>2015-09-28 22:16:51 -0400
commit3c2143723af4a52064386104d2105137a77bd761 (patch)
tree0234e84fa3aa1e41f6a69374136faadcf43bc239 /src/sqlcache.sml
parent5d00499cabd7c0ddf5eb9e78c883615cb918197e (diff)
Begin work on cache merging.
Diffstat (limited to 'src/sqlcache.sml')
-rw-r--r--src/sqlcache.sml39
1 files changed, 39 insertions, 0 deletions
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 =