stgi-1: Educational implementation of the STG (Spineless Tagless G-machine)

Safe HaskellNone
LanguageHaskell2010

Stg.Machine.GarbageCollection.Common

Description

Definitions used by various garbage collection algorithms.

Synopsis

Documentation

splitHeapWith :: GarbageCollectionAlgorithm -> StgState -> (Set MemAddr, Map MemAddr MemAddr, StgState) Source

Split the heap contained in a machine state in two parts: the dead objects that can safely be discarded, and the alive ones that are still needed by the program.

data GarbageCollectionAlgorithm Source

Constructors

GarbageCollectionAlgorithm Text (StgState -> (Set MemAddr, Map MemAddr MemAddr, StgState))

Dead addresses, moved addresses, new state

class Addresses a where Source

Collect all mentioned addresses in a machine element.

Note that none of the types in Stg.Language contain addresses, since an address is not something present in the STG _language_, only in the execution contest the language is put in in the Stg.Machine modules.

Minimal complete definition

addrs'

Methods

addrs :: a -> Seq MemAddr Source

All contained addresses in the order they appear, but without duplicates.

class UpdateAddrs a where Source

Update all contained addresses in a certain value. Useful for moving garbage collectors.

Methods

updateAddrs :: (MemAddr -> MemAddr) -> a -> a Source