| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- data Pool
- newPool :: Maybe Int -> IO Pool
- data PoolKey
- poolIndices :: Pool -> [PoolKey] -> IO (Map PoolKey Int)
- currentPool :: Pool -> IO (MutableArray (PrimState IO) Closure)
- poolStableSize :: Pool -> Int
- poolIndexCharTag :: Int
- poolIndexFloatTag :: Int
- poolIndexIntTag :: Int
- poolIndexNatTag :: Int
- poolIndexTrue :: Int
- poolIndexFalse :: Int
Documentation
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.
What a pool entry is. Entries are interned by key.
Constructors
| KeyEnum !Reference !PackedTag | a constructor with no fields. Also how a |
| KeyLit !MLit | a boxed literal (text, term link, type link) |
| KeyComb !CombIx !(GCombInfo MComb) | a known combinator as a value: a |
| KeyCached !CombIx !Closure | the boxed part of a top-level value that was evaluated when its
definition was loaded (a |
| 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
( |
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.
poolStableSize :: Pool -> Int Source #
poolIndexTrue :: Int Source #
The boolean closures, for comparison results.
poolIndexFalse :: Int Source #
The boolean closures, for comparison results.