ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Runtime.Interpreter.Types

Contents

- IServ
- JSInterp

Description

Types used by the runtime interpreter

Synopsis

- data Interp = Interp {
  - interpInstance :: !InterpInstance
  - interpLoader :: !Loader
  - interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ())))
  }
- data InterpInstance = ExternalInterp !ExtInterp
- data InterpProcess = InterpProcess {
  - interpPipe :: !Pipe
  - interpHandle :: !ProcessHandle
  - interpLock :: !(MVar ())
  }
- data ExtInterp
  - = ExtIServ !IServ
  - | ExtJS !JSInterp
  - | ExtWasm !WasmInterp
- type ExtInterpStatusVar d = MVar (InterpStatus (ExtInterpInstance d))
- data ExtInterpInstance c = ExtInterpInstance {
  - instProcess :: !InterpProcess
  - instPendingFrees :: !(MVar [HValueRef])
  - instExtra :: !c
  }
- data ExtInterpState cfg details = ExtInterpState {
  - interpConfig :: !cfg
  - interpStatus :: !(ExtInterpStatusVar details)
  }
- data InterpStatus inst
  - = InterpPending
  - | InterpRunning !inst
- type IServ = ExtInterpState IServConfig ()
- data IServConfig = IServConfig {
  - iservConfProgram :: !String
  - iservConfOpts :: ![String]
  - iservConfProfiled :: !Bool
  - iservConfDynamic :: !Bool
  - iservConfHook :: !(Maybe (CreateProcess -> IO ProcessHandle))
  - iservConfTrace :: IO ()
  }
- type JSInterp = ExtInterpState JSInterpConfig JSInterpExtra
- data JSInterpExtra = JSInterpExtra {
  - instStdIn :: !Handle
  - instFinderCache :: !FinderCache
  - instFinderOpts :: !FinderOpts
  - instJSState :: !(MVar JSState)
  - instGhciUnitId :: !UnitId
  }
- data JSInterpConfig = JSInterpConfig {
  - jsInterpNodeConfig :: !NodeJsSettings
  - jsInterpScript :: !FilePath
  - jsInterpTmpFs :: !TmpFs
  - jsInterpTmpDir :: !TempDir
  - jsInterpLogger :: !Logger
  - jsInterpCodegenCfg :: !StgToJSConfig
  - jsInterpUnitEnv :: !UnitEnv
  - jsInterpFinderOpts :: !FinderOpts
  - jsInterpFinderCache :: !FinderCache
  }
- data JSState = JSState {
  - jsLinkState :: !LinkPlan
  - jsServerStarted :: !Bool
  }
- data NodeJsSettings = NodeJsSettings {
  - nodeProgram :: FilePath
  - nodePath :: Maybe FilePath
  - nodeExtraArgs :: [String]
  - nodeKeepAliveMaxMem :: Integer
  }
- defaultNodeJsSettings :: NodeJsSettings
- type WasmInterp = ExtInterpState WasmInterpConfig ()
- data WasmInterpConfig = WasmInterpConfig {
  - wasmInterpDyLD :: !FilePath
  - wasmInterpLibDir :: FilePath
  - wasmInterpOpts :: ![String]
  - wasmInterpTargetPlatform :: !Platform
  - wasmInterpProfiled :: !Bool
  - wasmInterpHsSoSuffix :: !String
  - wasmInterpUnitState :: !UnitState
  }

# Documentation

data Interp Source #

Interpreter

Constructors

Interp |

Fields

- interpInstance :: !InterpInstance

  Interpreter instance (internal, external)

- interpLoader :: !Loader

  Interpreter loader

- interpLookupSymbolCache :: !(MVar (UniqFM FastString (Ptr ())))

  LookupSymbol cache

data InterpInstance Source #

Constructors

ExternalInterp !ExtInterp | External interpreter

data InterpProcess Source #

Constructors

InterpProcess |

Fields

- interpPipe :: !Pipe

  Pipe to communicate with the server

- interpHandle :: !ProcessHandle

  Process handle of the server

- interpLock :: !(MVar ())

  Lock to prevent concurrent access to the stream

data ExtInterp Source #

Constructors

ExtIServ !IServ |
ExtJS !JSInterp |
ExtWasm !WasmInterp |

type ExtInterpStatusVar d = MVar (InterpStatus (ExtInterpInstance d)) Source #

data ExtInterpInstance c Source #

Common field between native external interpreter and the JS one

Constructors

ExtInterpInstance |

Fields

- instProcess :: !InterpProcess

  External interpreter process and its pipe (communication channel)

- instPendingFrees :: !(MVar [HValueRef])

  Values that need to be freed before the next command is sent. Finalizers for ForeignRefs can append values to this list asynchronously.

- instExtra :: !c

  Instance specific extra fields

data ExtInterpState cfg details Source #

External interpreter

The external interpreter is spawned lazily (on first use) to avoid slowing down sessions that don't require it. The contents of the MVar reflects the state of the interpreter (running or not).

Constructors

ExtInterpState |

Fields

- interpConfig :: !cfg
- interpStatus :: !(ExtInterpStatusVar details)

data InterpStatus inst Source #

Status of an external interpreter

Constructors

InterpPending | Not spawned yet
InterpRunning !inst | Running

# IServ

type IServ = ExtInterpState IServConfig () Source #

data IServConfig Source #

Configuration needed to spawn an external interpreter

Constructors

IServConfig |

Fields

- iservConfProgram :: !String

  External program to run

- iservConfOpts :: ![String]

  Command-line options

- iservConfProfiled :: !Bool

  Use Profiling way

- iservConfDynamic :: !Bool

  Use Dynamic way

- iservConfHook :: !(Maybe (CreateProcess -> IO ProcessHandle))

  Hook

- iservConfTrace :: IO ()

  Trace action executed after spawn

# JSInterp

type JSInterp = ExtInterpState JSInterpConfig JSInterpExtra Source #

data JSInterpExtra Source #

Constructors

JSInterpExtra |

Fields

- instStdIn :: !Handle

  Stdin for the process

- instFinderCache :: !FinderCache
- instFinderOpts :: !FinderOpts
- instJSState :: !(MVar JSState)

  Mutable state

- instGhciUnitId :: !UnitId

  GHCi unit-id

data JSInterpConfig Source #

Constructors

JSInterpConfig |

Fields

- jsInterpNodeConfig :: !NodeJsSettings

  NodeJS settings

- jsInterpScript :: !FilePath

  Path to "ghc-interp.js" script

- jsInterpTmpFs :: !TmpFs
- jsInterpTmpDir :: !TempDir
- jsInterpLogger :: !Logger
- jsInterpCodegenCfg :: !StgToJSConfig
- jsInterpUnitEnv :: !UnitEnv
- jsInterpFinderOpts :: !FinderOpts
- jsInterpFinderCache :: !FinderCache

data JSState Source #

Constructors

JSState |

Fields

- jsLinkState :: !LinkPlan

  Linker state of the interpreter

- jsServerStarted :: !Bool

  Is the Haskell server started?

data NodeJsSettings Source #

NodeJs configuration

Constructors

NodeJsSettings |

Fields

- nodeProgram :: FilePath

  location of node.js program

- nodePath :: Maybe FilePath

  value of NODE_PATH environment variable (search path for Node modules; GHCJS used to provide some)

- nodeExtraArgs :: [String]

  extra arguments to pass to node.js

- nodeKeepAliveMaxMem :: Integer

  keep node.js (TH, GHCJSi) processes alive if they don't use more than this

defaultNodeJsSettings :: NodeJsSettings Source #

type WasmInterp = ExtInterpState WasmInterpConfig () Source #

data WasmInterpConfig Source #

Constructors

WasmInterpConfig |

Fields

- wasmInterpDyLD :: !FilePath

  Location of dyld.mjs script

- wasmInterpLibDir :: FilePath

  wasi-sdk sysroot libdir containing libc.so, etc

- wasmInterpOpts :: ![String]

  Additional command line arguments for iserv

- wasmInterpTargetPlatform :: !Platform
- wasmInterpProfiled :: !Bool

  Are we profiling yet?

- wasmInterpHsSoSuffix :: !String

  Shared lib filename common suffix sans .so, e.g. p-ghc9.13.20241001

- wasmInterpUnitState :: !UnitState