Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EXPERIMENTS: shorten cache lookup chains, invalidate cache on new ens…
…ures (#3998) ### Fixes #3982 To avoid situations where the cache contains successive mappings `e -> e1 -> e2 -> e3 ... -> e_n` (a "lookup chain"), the following modifications are made: 1. When inserting `e -> e1`, first check whether `e1 -> e2` is in the cache, and insert `e -> e2` instead in this case. 2. When looking up `e` and a binding `e -> e1` is found, check whether a binding `e1 -> e2` is also in the cache. In this case, update the binding for `e` to `e -> e2` and return `e2`. This will eventually lead to removing all lookup chains that may exist in a cache (for "interesting" cached values that are being looked up), without the risk of a loop. Assume the following: * the cache was initially empty; * insertions and lookups are performed as described above; * the cache contains a lookup chain `e -> e1 -> e2`. If `e1 -> e2` was inserted first, insertion of `e -> e1` would have resulted in storing `e -> e2`. Therefore, `e -> e1` must have been inserted first. A subsequent lookup of `e` will update the cache to contain `e -> e2`. Insertion of `e -> e1`, then `e1 -> e2`, then `e2 -> e3`, will create the lookup chain `e -> e1 -> e2 -> e3`. - A lookup of `e` would leave the cache containing two shorter chains `e -> e2 -> e3` and `e1 -> e2 -> e3`. - A lookup of `e1` would also leave the cache containing one shorter chain `e -> e1 -> e3`, and `e2 -> e3`. Every lookup potentially shortens a lookup chain, possibly to several chains. ### Fixes #3993 When a new path condition is added (from an `ensures` clause), the `Equations` cache is purged. While some entries may still be valid, * all entries `t -> t` (no simplification possible) may be invalid because new equations might be applicable with the new path condition * even entries `t -> t'` with `t /= t'` may be invalid because while they already memoise some applicable simplifications, they may store sub-terms that could now be evaluated or simplified further (new equations may apply) --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information