alice
library
manual.

Alice Project

The Store structure


________ Synopsis ____________________________________________________

    signature STORE
    structure Store : STORE
  

The Store structure provides an interface to the Alice store that holds all data at runtime.

Note: This is a low-level module that should be used with care. Some of its functionality can compromise abstractions to a certain extent. For example, it is not encouraged to apply deepWait to values that contain instances of abstract types.


________ Import ______________________________________________________

    import signature STORE from "x-alice:/lib/data/STORE-sig"
    import structure Store from "x-alice:/lib/data/Store"

________ Interface ___________________________________________________

signature STORE =
  sig
      val same      : 'a * 'a -> bool
      val equiv     : 'a * 'a -> bool
      val minimize  : 'a -> 'a

      val futures   : 'a -> {total : int, concurrent : int, byneed : int}
      val deepWait  : 'a -> {total : int, concurrent : int, byneed : int}

      val size      : 'a -> {nodes : int, words : int}
      val sizeQuiet : 'a -> {nodes : int, words : int}

      val collect   : int -> unit
  end
  

________ Description _________________________________________________

same (x, y)

Tests whether x and y are physically equal, i.e. represented by the same object in the store.

equiv (x, y)

Tests whether x and y represent equal infinite trees, i.e. whether their respective graphs in the store are structurally equivalent. For example,

      equiv (rec x => 1::x, rec x => 1::1::x)          = true
      equiv (rec x => 1::x, 1::(rec x => 1::x))        = true
      equiv (rec x => (ref 1)::x, rec x => (ref 1)::x) = false
let val r = ref 1 in equiv (rec x => r::x, rec x => r::x) end = true
minimize x

Minimizes the store representation of x by computing the minimal representation for x that is structurally equivalent to the original.

futures x

Computes the number of futures appearing in the representation of x. For function values, this includes futures appearing in the respective closure, as well as any internal futures used in code representations (to represent not-yet-compiled code fragments, for example).

deepAwait x

Requests all futures in the representation of x until none remain. Returns the number of futures requested. Note that for function values, this may force compilation of all not-yet-compiled code fragments.

size x
sizeQuiet x

Computes the number and total size of store nodes used to represent x. While size is hyper-strict, i.e. it requests all futures in x, sizeQuiet does not request any futures but includes the sizes of closures associated with lazy futures. Note that the size of function values includes their respective closure and code representation. Due to just-in-time compilation, the size of the latter can vary over time. Ignoring concurrent interference, the following equivalence holds:

      size x = (deepAwait x; sizeQuiet x)
    
collect gen

Triggers a garbage collection up to generation gen (if the system features a generational garbage collector).



last modified 1970/01/01 01:00