Programming with regions in the ml kit (for version 4)

2 Values and their Representation integer 32 bits, untagged. Unboxed (i.e., not region allocated). One bit is used for tagging when GC is enabled. real 64 bits, untagged. Boxed (i.e., allocated in region) string Unbounded size. Allocated in region. bool one 32-bit word. Unboxed. α list nil and :: cells unboxed (i.e., not region allocated). Auxiliary pairs in one region; elements in zero or more regions. Size of auxiliary pairs: two 32-bit words (three when GC is enabled). exn Exception values are boxed and are always stored in a global region. fn pat => exp An anonymous function is represented by a boxed, untagged closure. Its size is one 32-bit word plus one word for each free variable of the function. Free region variables also count as variables. One extra word is used when GC is enabled. fun f. .. Mutually recursive region-polymorphic functions share the same closure, which is region-allocated, untagged, and whose size (in words) is the number of variables that occur free in the recursive declaration. One extra word is used when GC is enabled. Regions and their Representation Finite (ρ:n) Region whose size can be determined at compile time. During compilation , a finite region size is given as a non-negative integer. After multiplicity inference, this integer indicates the number of times a value (of the appropriate type) is written into the region. Later, after physical size inference, the integer indicates the physical region size in words. At runtime, a finite region is allocated on the runtime stack. Infinite (ρ:INF) All other regions. At runtime, an infinite region consists of a stack allocated region descriptor, which contains pointers to the beginning and the end of a linked list of fixed size region pages. Storage Modes (only significant for infinite regions) atbot Reset region, then store value. sat Determine actual storage mode (attop/atbot) at runtime. attop Store at top of region, without destroying any values already in the region.