Safe Haskell | None |
---|---|
Language | Haskell2010 |
User-facing API to work with STG programs.
- initialState :: Var -> Program -> StgState
- evalStep :: StgState -> StgState
- evalUntil :: RunForSteps -> HaltIf -> PerformGc -> StgState -> StgState
- evalsUntil :: RunForSteps -> HaltIf -> PerformGc -> StgState -> NonEmpty StgState
- terminated :: StgState -> Bool
- newtype HaltIf = HaltIf (StgState -> Bool)
- data RunForSteps
- garbageCollect :: GarbageCollectionAlgorithm -> StgState -> StgState
- newtype PerformGc = PerformGc (StgState -> Maybe GarbageCollectionAlgorithm)
- data GarbageCollectionAlgorithm
- triStateTracing :: GarbageCollectionAlgorithm
- twoSpaceCopying :: GarbageCollectionAlgorithm
Documentation
Evaluation
:: RunForSteps | Maximum number of steps allowed |
-> HaltIf | Halting decision function |
-> PerformGc | Condition under which to perform GC |
-> StgState | Initial state |
-> StgState | Final state |
Evaluate the STG until a predicate holds, aborting if the maximum number of steps are exceeded.
last
(evalsUntil
...) ≡evalUntil
:: RunForSteps | Maximum number of steps allowed |
-> HaltIf | Halting decision function |
-> PerformGc | Condition under which to perform GC |
-> StgState | Initial state |
-> NonEmpty StgState | Initial state plus intermediate states |
Evaluate the STG, and record all intermediate states.
- Stop when a predicate holds.
- Stop if the maximum number of steps are exceeded.
- Perform GC on every step.
evalsUntil
≈unfoldr
evalUntil
terminated :: StgState -> Bool Source #
Check whether a state is terminal.
Predicate to decide whether the machine should halt.
data RunForSteps Source #
Predicate to decide whether the machine should halt.
RunIndefinitely | Do not terminate based on the number of steps |
RunForMaxSteps Integer |
Garbage collection
garbageCollect :: GarbageCollectionAlgorithm -> StgState -> StgState Source #
Apply a garbage collection algorithm to the heap of the current machine state, and return the resulting cleaned state.
Decide whether garbage collection should be attempted, and with which algorithm.
data GarbageCollectionAlgorithm Source #
A garbage collection algorithm is a specific way to get rid of unused heap objects.
triStateTracing :: GarbageCollectionAlgorithm Source #
Remove all unused addresses, without moving the others.
twoSpaceCopying :: GarbageCollectionAlgorithm Source #
Move all used addresses by moving them to a safe location, and delete the leftovers.