unison-runtime-0.0.0
Safe HaskellNone
LanguageHaskell2010

Unison.Runtime.JIT.Pool

Description

The constant pool: Haskell heap objects that native code needs, in an array whose address is passed on every entry. See unison-runtimesrcUnisonRuntimeJIT/design.md, "Appendix: the constant pool", which also says why there is one pool per process rather than one per module.

Indices are assigned when a module is compiled (poolIndices) and are constants in the generated code. The array grows by copying; the old arrays are kept, and new entries are written to them too where they fit, so an address read at entry stays valid for as long as that native run lasts. A run can still meet code that was installed after it began and uses an index past the end of the array the run holds: a function that uses an index of poolStableSize or more checks the array's size at entry, and exits to be entered again with the current array.

Synopsis

Documentation

data Pool Source #

The size of the first array: every array ever passed to native code has at least this many entries. | A pool, with the size its first array has: a function that uses only indices below it never has to check the array it was given (the stress mode pool=N makes it tiny, so that growing is exercised).

newPool :: Maybe Int -> IO Pool Source #

A pool holding the fixed entries. The argument is the stress mode's size for the first array, if any.

data PoolKey Source #

What a pool entry is. Entries are interned by key.

Constructors

KeyEnum !Reference !PackedTag

a constructor with no fields. Also how a Reference is kept: the entry for KeyEnum r 0 is an Enum whose reference field native code reads when it builds a constructor of that type.

KeyLit !MLit

a boxed literal (text, term link, type link)

KeyComb !CombIx !(GCombInfo MComb)

a known combinator as a value: a PAp with nothing captured, the same closure the interpreter builds for App (Env cix) ZArgs. Interned by the CombIx alone (the combinator has no Ord).

KeyCached !CombIx !Closure

the boxed part of a top-level value that was evaluated when its definition was loaded (a CachedVal), by its CombIx

KeyRecord !RecordShape

a record shape, kept as an empty record of that shape: native code copies the shape's words out of it when it builds a record (RecPack). Interned by the field names, which determine the shape.

Instances

Instances details
Show PoolKey Source # 
Instance details

Defined in Unison.Runtime.JIT.Pool

Eq PoolKey Source # 
Instance details

Defined in Unison.Runtime.JIT.Pool

Methods

(==) :: PoolKey -> PoolKey -> Bool #

(/=) :: PoolKey -> PoolKey -> Bool #

Ord PoolKey Source # 
Instance details

Defined in Unison.Runtime.JIT.Pool

poolIndices :: Pool -> [PoolKey] -> IO (Map PoolKey Int) Source #

The index of each key, adding the ones not seen before. Called when a module is compiled, before its code is generated.

currentPool :: Pool -> IO (MutableArray (PrimState IO) Closure) Source #

The array to pass to native code now.

poolIndexTrue :: Int Source #

The boolean closures, for comparison results.

poolIndexFalse :: Int Source #

The boolean closures, for comparison results.