GHC.StgToJS.Types

ghc-9.14.0.20251028: The GHC API

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file LICENSE)
Maintainer | Jeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stability | experimental
Safe Haskell | None
Language | GHC2021

GHC.StgToJS.Types

Description

Module that holds the Types required for the StgToJS pass

Synopsis

- type G = StateT GenState IO
- data GenState = GenState {
  - gsSettings :: !StgToJSConfig
  - gsModule :: !Module
  - gsId :: !FastMutInt
  - gsIdents :: !IdCache
  - gsUnfloated :: !(UniqFM Id CgStgExpr)
  - gsGroup :: GenGroupState
  - gsGlobal :: [JStgStat]
  }
- data GenGroupState = GenGroupState {
  - ggsToplevelStats :: [JStgStat]
  - ggsClosureInfo :: [ClosureInfo]
  - ggsStatic :: [StaticInfo]
  - ggsStack :: [StackSlot]
  - ggsStackDepth :: Int
  - ggsExtraDeps :: Set OtherSymb
  - ggsGlobalIdCache :: GlobalIdCache
  - ggsForeignRefs :: [ForeignJSRef]
  }
- data StgToJSConfig = StgToJSConfig {
  - csInlinePush :: !Bool
  - csInlineBlackhole :: !Bool
  - csInlineLoadRegs :: !Bool
  - csInlineEnter :: !Bool
  - csInlineAlloc :: !Bool
  - csPrettyRender :: !Bool
  - csTraceRts :: !Bool
  - csAssertRts :: !Bool
  - csBoundsCheck :: !Bool
  - csDebugAlloc :: !Bool
  - csTraceForeign :: !Bool
  - csProf :: !Bool
  - csRuntimeAssert :: !Bool
  - csContext :: !SDocContext
  - csLinkerConfig :: !LinkerConfig
  }
- data ClosureInfo = ClosureInfo {
  - ciVar :: Ident
  - ciRegs :: CIRegs
  - ciName :: FastString
  - ciLayout :: CILayout
  - ciType :: CIType
  - ciStatic :: CIStatic
  }
- data CIRegs
  - = CIRegsUnknown
  - | CIRegs {
    - ciRegsSkip :: Int
    - ciRegsTypes :: [JSRep]
    }
- data CILayout
  - = CILayoutVariable
  - | CILayoutUnknown {
    - layoutSize :: !Int
    }
  - | CILayoutFixed {
    - layoutSize :: !Int
    - layout :: [JSRep]
    }
- data CIType
  - = CIFun {
    - citArity :: !Int
    - citRegs :: !Int
    }
  - | CIThunk
  - | CICon {
    - citConstructor :: !Int
    }
  - | CIPap
  - | CIBlackhole
  - | CIStackFrame
- newtype CIStatic = CIStaticRefs {
  - staticRefs :: [FastString]
  }
- data JSRep
  - = PtrV
  - | VoidV
  - | DoubleV
  - | IntV
  - | LongV
  - | AddrV
  - | ObjV
  - | ArrV
- data IdType
  - = IdPlain
  - | IdEntry
  - | IdConEntry
- data IdKey = IdKey !Word64 !Int !IdType
- data OtherSymb = OtherSymb !Module !FastString
- newtype IdCache = IdCache (Map IdKey Ident)
- newtype GlobalIdCache = GlobalIdCache (UniqFM Ident (IdKey, Id))
- data StackSlot
  - = SlotId !Id !Int
  - | SlotUnknown
- data StaticInfo = StaticInfo {
  - siVar :: !FastString
  - siVal :: !StaticVal
  - siCC :: !(Maybe Ident)
  }
- data StaticAppKind
  - = SAKFun
  - | SAKThunk
  - | SAKData
- data StaticVal
  - = StaticUnboxed !StaticUnboxed
  - | StaticList [StaticArg] (Maybe FastString)
  - | StaticApp StaticAppKind !FastString [StaticArg]
- data StaticUnboxed
  - = StaticUnboxedBool !Bool
  - | StaticUnboxedInt !Integer
  - | StaticUnboxedDouble !SaneDouble
  - | StaticUnboxedString !ByteString
  - | StaticUnboxedStringOffset !ByteString
- data StaticArg
  - = StaticObjArg !FastString
  - | StaticLitArg !StaticLit
  - | StaticConArg !FastString [StaticArg]
- data StaticLit
  - = BoolLit !Bool
  - | IntLit !Integer
  - | NullLit
  - | DoubleLit !SaneDouble
  - | StringLit !FastString
  - | BinLit !ByteString
  - | LabelLit !Bool !FastString
- data ForeignJSRef = ForeignJSRef {
  - foreignRefSrcSpan :: !FastString
  - foreignRefPattern :: !FastString
  - foreignRefSafety :: !Safety
  - foreignRefCConv :: !CCallConv
  - foreignRefArgs :: ![FastString]
  - foreignRefResult :: !FastString
  }
- data LinkableUnit = LinkableUnit {
  - luObjBlock :: ObjBlock
  - luIdExports :: [Id]
  - luOtherExports :: [FastString]
  - luIdDeps :: [Id]
  - luPseudoIdDeps :: [Unique]
  - luOtherDeps :: [OtherSymb]
  - luRequired :: Bool
  - luForeignRefs :: [ForeignJSRef]
  }
- data ObjBlock = ObjBlock {
  - oiSymbols :: [FastString]
  - oiClInfo :: [ClosureInfo]
  - oiStatic :: [StaticInfo]
  - oiStat :: JStat
  - oiRaw :: ByteString
  - oiFExports :: [ExpFun]
  - oiFImports :: [ForeignJSRef]
  }
- data ExpFun = ExpFun {
  - isIO :: !Bool
  - args :: [JSFFIType]
  - result :: !JSFFIType
  }
- data JSFFIType
  - = Int8Type
  - | Int16Type
  - | Int32Type
  - | Int64Type
  - | Word8Type
  - | Word16Type
  - | Word32Type
  - | Word64Type
  - | DoubleType
  - | ByteArrayType
  - | PtrType
  - | RefType
- data TypedExpr = TypedExpr {
  - typex_typ :: !PrimRep
  - typex_expr :: [JStgExpr]
  }
- data PrimRes
  - = PrimInline JStgStat
  - | PRPrimCall JStgStat
- data ExprResult
  - = ExprCont
  - | ExprInline
- newtype ExprValData = ExprValData [JStgExpr]
- data ClosureType
  - = Thunk
  - | Fun
  - | Pap
  - | Con
  - | Blackhole
  - | StackFrame
- ctNum :: ClosureType -> Int
- closureB :: ByteString
- closureNames :: Array ClosureType Ident
- ctJsName :: ClosureType -> String
- data ThreadStatus
  - = Running
  - | Blocked
  - | Finished
  - | Died
- threadStatusNum :: ThreadStatus -> Int
- threadStatusJsName :: ThreadStatus -> String

# Documentation

type G = StateT GenState IO Source #

A State monad over IO holding the generator state.

data GenState Source #

The JS code generator state

Constructors

GenState |
Fields gsSettings :: !StgToJSConfig codegen settings, read-only gsModule :: !Module current module gsId :: !FastMutInt unique number for the id generator gsIdents :: !IdCache hash consing for identifiers from a Unique gsUnfloated :: !(UniqFM Id CgStgExpr) unfloated arguments gsGroup :: GenGroupState state for the current binding group gsGlobal :: [JStgStat] global (per module) statements (gets included when anything else from the module is used)

data GenGroupState Source #

The JS code generator state relevant for the current binding group

Constructors

GenGroupState |
Fields ggsToplevelStats :: [JStgStat] extra toplevel statements for the binding group ggsClosureInfo :: [ClosureInfo] closure metadata (info tables) for the binding group ggsStatic :: [StaticInfo] static (CAF) data in our binding group ggsStack :: [StackSlot] stack info for the current expression ggsStackDepth :: Int current stack depth ggsExtraDeps :: Set OtherSymb extra dependencies for the linkable unit that contains this group ggsGlobalIdCache :: GlobalIdCache ggsForeignRefs :: [ForeignJSRef]

data StgToJSConfig Source #

The Configuration record for the StgToJS pass

Constructors

StgToJSConfig |
Fields csInlinePush :: !Bool csInlineBlackhole :: !Bool csInlineLoadRegs :: !Bool csInlineEnter :: !Bool csInlineAlloc :: !Bool csPrettyRender :: !Bool csTraceRts :: !Bool csAssertRts :: !Bool csBoundsCheck :: !Bool csDebugAlloc :: !Bool csTraceForeign :: !Bool csProf :: !Bool Profiling enabled csRuntimeAssert :: !Bool Enable runtime assertions settings csContext :: !SDocContext csLinkerConfig :: !LinkerConfig Emscripten linker

data ClosureInfo Source #

Closure info table

Constructors

ClosureInfo |
Fields ciVar :: Ident entry code identifier: infotable fields are stored as properties of this function ciRegs :: CIRegs size of the payload (in number of JS values) ciName :: FastString friendly name for printing ciLayout :: CILayout heap/stack layout of the object ciType :: CIType type of the object, with extra info where required ciStatic :: CIStatic static references of this object

#### Instances

Instances details

Binary ClosureInfo Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> ClosureInfo -> IO () Source # put :: WriteBinHandle -> ClosureInfo -> IO (Bin ClosureInfo) Source # get :: ReadBinHandle -> IO ClosureInfo Source #
Eq ClosureInfo Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ClosureInfo -> ClosureInfo -> Bool Source # (/=) :: ClosureInfo -> ClosureInfo -> Bool Source #
Show ClosureInfo Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> ClosureInfo -> ShowS Source # show :: ClosureInfo -> String Source # showList :: [ClosureInfo] -> ShowS Source #

data CIRegs Source #

Closure information, `ClosureInfo`, registers

Constructors

CIRegsUnknown | A value witnessing a state of unknown registers
CIRegs |
Fields ciRegsSkip :: Int unused registers before actual args start ciRegsTypes :: [JSRep] args

#### Instances

Instances details

Binary CIRegs Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> CIRegs -> IO () Source # put :: WriteBinHandle -> CIRegs -> IO (Bin CIRegs) Source # get :: ReadBinHandle -> IO CIRegs Source #
Eq CIRegs Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: CIRegs -> CIRegs -> Bool Source # (/=) :: CIRegs -> CIRegs -> Bool Source #
Ord CIRegs Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: CIRegs -> CIRegs -> Ordering Source # (<) :: CIRegs -> CIRegs -> Bool Source # (<=) :: CIRegs -> CIRegs -> Bool Source # (>) :: CIRegs -> CIRegs -> Bool Source # (>=) :: CIRegs -> CIRegs -> Bool Source # max :: CIRegs -> CIRegs -> CIRegs Source # min :: CIRegs -> CIRegs -> CIRegs Source #
Show CIRegs Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> CIRegs -> ShowS Source # show :: CIRegs -> String Source # showList :: [CIRegs] -> ShowS Source #

data CILayout Source #

Closure Information, `ClosureInfo`, layout

Constructors

CILayoutVariable | layout stored in object itself, first position from the start
CILayoutUnknown | fixed size, but content unknown (for example stack apply frame)
Fields layoutSize :: !Int closure size in array positions, including entry
CILayoutFixed | whole layout known
Fields layoutSize :: !Int closure size in array positions, including entry layout :: [JSRep] The list of JSReps to layout

#### Instances

Instances details

Binary CILayout Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> CILayout -> IO () Source # put :: WriteBinHandle -> CILayout -> IO (Bin CILayout) Source # get :: ReadBinHandle -> IO CILayout Source #
Eq CILayout Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: CILayout -> CILayout -> Bool Source # (/=) :: CILayout -> CILayout -> Bool Source #
Ord CILayout Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: CILayout -> CILayout -> Ordering Source # (<) :: CILayout -> CILayout -> Bool Source # (<=) :: CILayout -> CILayout -> Bool Source # (>) :: CILayout -> CILayout -> Bool Source # (>=) :: CILayout -> CILayout -> Bool Source # max :: CILayout -> CILayout -> CILayout Source # min :: CILayout -> CILayout -> CILayout Source #
Show CILayout Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> CILayout -> ShowS Source # show :: CILayout -> String Source # showList :: [CILayout] -> ShowS Source #

data CIType Source #

The type of `ClosureInfo`

Constructors

CIFun |
Fields citArity :: !Int function arity citRegs :: !Int number of registers for the args
CIThunk | The closure is a THUNK
CICon | The closure is a Constructor
Fields citConstructor :: !Int
CIPap | The closure is a Partial Application
CIBlackhole | The closure is a black hole
CIStackFrame | The closure is a stack frame

#### Instances

Instances details

Binary CIType Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> CIType -> IO () Source # put :: WriteBinHandle -> CIType -> IO (Bin CIType) Source # get :: ReadBinHandle -> IO CIType Source #
Eq CIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: CIType -> CIType -> Bool Source # (/=) :: CIType -> CIType -> Bool Source #
Ord CIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: CIType -> CIType -> Ordering Source # (<) :: CIType -> CIType -> Bool Source # (<=) :: CIType -> CIType -> Bool Source # (>) :: CIType -> CIType -> Bool Source # (>=) :: CIType -> CIType -> Bool Source # max :: CIType -> CIType -> CIType Source # min :: CIType -> CIType -> CIType Source #
Show CIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> CIType -> ShowS Source # show :: CIType -> String Source # showList :: [CIType] -> ShowS Source #

newtype CIStatic Source #

Static references that must be kept alive

Constructors

CIStaticRefs |
Fields staticRefs :: [FastString]

#### Instances

Instances details

ToJExpr CIStatic Source # | static refs: array = references, null = nothing to report note: only works after all top-level objects have been created
Instance details Defined in GHC.StgToJS.Types Methods toJExpr :: CIStatic -> JStgExpr Source # toJExprFromList :: [CIStatic] -> JStgExpr Source #
Binary CIStatic Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> CIStatic -> IO () Source # put :: WriteBinHandle -> CIStatic -> IO (Bin CIStatic) Source # get :: ReadBinHandle -> IO CIStatic Source #
Monoid CIStatic Source # |
Instance details Defined in GHC.StgToJS.Types Methods mempty :: CIStatic Source # mappend :: CIStatic -> CIStatic -> CIStatic Source # mconcat :: [CIStatic] -> CIStatic Source #
Semigroup CIStatic Source # |
Instance details Defined in GHC.StgToJS.Types Methods (<>) :: CIStatic -> CIStatic -> CIStatic Source # sconcat :: NonEmpty CIStatic -> CIStatic Source # stimes :: Integral b => b -> CIStatic -> CIStatic Source #
Eq CIStatic Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: CIStatic -> CIStatic -> Bool Source # (/=) :: CIStatic -> CIStatic -> Bool Source #
Show CIStatic Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> CIStatic -> ShowS Source # show :: CIStatic -> String Source # showList :: [CIStatic] -> ShowS Source #

data JSRep Source #

JS primitive representations

Constructors

PtrV | pointer = reference to heap object (closure object), lifted or not. Can also be some RTS object (e.g. TVar#, MVar#, MutVar#, Weak#)
VoidV | no fields
DoubleV | A Double: one field
IntV | An Int (32bit because JS): one field
LongV | A Long: two fields one for the upper 32bits, one for the lower (NB: JS is little endian)
AddrV | a pointer not to the heap: two fields, array + index
ObjV | some JS object, user supplied, be careful around these, can be anything
ArrV | boxed array

#### Instances

Instances details

ToJExpr JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods toJExpr :: JSRep -> JStgExpr Source # toJExprFromList :: [JSRep] -> JStgExpr Source #
Binary JSRep Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> JSRep -> IO () Source # put :: WriteBinHandle -> JSRep -> IO (Bin JSRep) Source # get :: ReadBinHandle -> IO JSRep Source #
Eq JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: JSRep -> JSRep -> Bool Source # (/=) :: JSRep -> JSRep -> Bool Source #
Ord JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: JSRep -> JSRep -> Ordering Source # (<) :: JSRep -> JSRep -> Bool Source # (<=) :: JSRep -> JSRep -> Bool Source # (>) :: JSRep -> JSRep -> Bool Source # (>=) :: JSRep -> JSRep -> Bool Source # max :: JSRep -> JSRep -> JSRep Source # min :: JSRep -> JSRep -> JSRep Source #
Bounded JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods minBound :: JSRep Source # maxBound :: JSRep Source #
Enum JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods succ :: JSRep -> JSRep Source # pred :: JSRep -> JSRep Source # toEnum :: Int -> JSRep Source # fromEnum :: JSRep -> Int Source # enumFrom :: JSRep -> [JSRep] Source # enumFromThen :: JSRep -> JSRep -> [JSRep] Source # enumFromTo :: JSRep -> JSRep -> [JSRep] Source # enumFromThenTo :: JSRep -> JSRep -> JSRep -> [JSRep] Source #
Show JSRep Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> JSRep -> ShowS Source # show :: JSRep -> String Source # showList :: [JSRep] -> ShowS Source #

data IdType Source #

The type of identifiers. These determine the suffix of generated functions in JS Land. For example, the entry function for the `Just` constructor is a `IdConEntry` which compiles to: `function h$ghczminternalZCGHCziInternalziMaybeziJust_con_e() { return h$rs() };` which just returns whatever the stack point is pointing to. Whereas the entry function to `Just` is an `IdEntry` and does the work. It compiles to: `function h$ghczminternalZCGHCziInternalziMaybeziJust_e() { var h$$baseZCGHCziMaybezieta_8KXnScrCjF5 = h$r2; h$r1 = h$c1(h$ghczminternalZCGHCziInternalziMaybeziJust_con_e, h$$ghczminternalZCGHCziInternalziMaybezieta_8KXnScrCjF5); return h$rs(); };` Which loads some payload from register 2, and applies the Constructor Entry function for the Just to the payload, returns the result in register 1 and returns whatever is on top of the stack

Constructors

IdPlain | A plain identifier for values, no suffix added
IdEntry | An entry function, suffix = "_e" in `makeIdentForId`
IdConEntry | A Constructor entry function, suffix = "_con_e" in `makeIdentForId`

#### Instances

Instances details

Eq IdType Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: IdType -> IdType -> Bool Source # (/=) :: IdType -> IdType -> Bool Source #
Ord IdType Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: IdType -> IdType -> Ordering Source # (<) :: IdType -> IdType -> Bool Source # (<=) :: IdType -> IdType -> Bool Source # (>) :: IdType -> IdType -> Bool Source # (>=) :: IdType -> IdType -> Bool Source # max :: IdType -> IdType -> IdType Source # min :: IdType -> IdType -> IdType Source #
Enum IdType Source # |
Instance details Defined in GHC.StgToJS.Types Methods succ :: IdType -> IdType Source # pred :: IdType -> IdType Source # toEnum :: Int -> IdType Source # fromEnum :: IdType -> Int Source # enumFrom :: IdType -> [IdType] Source # enumFromThen :: IdType -> IdType -> [IdType] Source # enumFromTo :: IdType -> IdType -> [IdType] Source # enumFromThenTo :: IdType -> IdType -> IdType -> [IdType] Source #

data IdKey Source #

Keys to differentiate Ident's in the ID Cache

Constructors

IdKey !Word64 !Int !IdType |

#### Instances

Instances details

Eq IdKey Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: IdKey -> IdKey -> Bool Source # (/=) :: IdKey -> IdKey -> Bool Source #
Ord IdKey Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: IdKey -> IdKey -> Ordering Source # (<) :: IdKey -> IdKey -> Bool Source # (<=) :: IdKey -> IdKey -> Bool Source # (>) :: IdKey -> IdKey -> Bool Source # (>=) :: IdKey -> IdKey -> Bool Source # max :: IdKey -> IdKey -> IdKey Source # min :: IdKey -> IdKey -> IdKey Source #

data OtherSymb Source #

Some other symbol

Constructors

OtherSymb !Module !FastString |

#### Instances

Instances details

Eq OtherSymb Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: OtherSymb -> OtherSymb -> Bool Source # (/=) :: OtherSymb -> OtherSymb -> Bool Source #
Ord OtherSymb Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: OtherSymb -> OtherSymb -> Ordering Source # (<) :: OtherSymb -> OtherSymb -> Bool Source # (<=) :: OtherSymb -> OtherSymb -> Bool Source # (>) :: OtherSymb -> OtherSymb -> Bool Source # (>=) :: OtherSymb -> OtherSymb -> Bool Source # max :: OtherSymb -> OtherSymb -> OtherSymb Source # min :: OtherSymb -> OtherSymb -> OtherSymb Source #

newtype IdCache Source #

The identifier cache indexed on `IdKey` local to a module

Constructors

IdCache (Map IdKey Ident) |

newtype GlobalIdCache Source #

The global Identifier Cache

Constructors

GlobalIdCache (UniqFM Ident (IdKey, Id)) |

data StackSlot Source #

A Stack Slot is either known or unknown. We avoid maybe here for more strictness.

Constructors

SlotId !Id !Int |
SlotUnknown |

#### Instances

Instances details

Eq StackSlot Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StackSlot -> StackSlot -> Bool Source # (/=) :: StackSlot -> StackSlot -> Bool Source #
Ord StackSlot Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: StackSlot -> StackSlot -> Ordering Source # (<) :: StackSlot -> StackSlot -> Bool Source # (<=) :: StackSlot -> StackSlot -> Bool Source # (>) :: StackSlot -> StackSlot -> Bool Source # (>=) :: StackSlot -> StackSlot -> Bool Source # max :: StackSlot -> StackSlot -> StackSlot Source # min :: StackSlot -> StackSlot -> StackSlot Source #

data StaticInfo Source #

Constructors

StaticInfo |
Fields siVar :: !FastString global object siVal :: !StaticVal static initialization siCC :: !(Maybe Ident) optional CCS name

#### Instances

Instances details

Binary StaticInfo Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> StaticInfo -> IO () Source # put :: WriteBinHandle -> StaticInfo -> IO (Bin StaticInfo) Source # get :: ReadBinHandle -> IO StaticInfo Source #
Eq StaticInfo Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticInfo -> StaticInfo -> Bool Source # (/=) :: StaticInfo -> StaticInfo -> Bool Source #
Show StaticInfo Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticInfo -> ShowS Source # show :: StaticInfo -> String Source # showList :: [StaticInfo] -> ShowS Source #

data StaticAppKind Source #

Constructors

SAKFun | heap object for function
SAKThunk | heap object for CAF
SAKData | regular datacon app

#### Instances

Instances details

Eq StaticAppKind Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticAppKind -> StaticAppKind -> Bool Source # (/=) :: StaticAppKind -> StaticAppKind -> Bool Source #
Show StaticAppKind Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticAppKind -> ShowS Source # show :: StaticAppKind -> String Source # showList :: [StaticAppKind] -> ShowS Source #

data StaticVal Source #

Constructors

StaticUnboxed !StaticUnboxed | unboxed constructor (Bool, Int, Double etc)
StaticList [StaticArg] (Maybe FastString) | list initializer (with optional tail)
StaticApp StaticAppKind !FastString [StaticArg] | static application of static args. Can be a CAF, a FUN, or a CON app.

#### Instances

Instances details

Binary StaticVal Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> StaticVal -> IO () Source # put :: WriteBinHandle -> StaticVal -> IO (Bin StaticVal) Source # get :: ReadBinHandle -> IO StaticVal Source #
Eq StaticVal Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticVal -> StaticVal -> Bool Source # (/=) :: StaticVal -> StaticVal -> Bool Source #
Show StaticVal Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticVal -> ShowS Source # show :: StaticVal -> String Source # showList :: [StaticVal] -> ShowS Source #

data StaticUnboxed Source #

Constructors

StaticUnboxedBool !Bool |
StaticUnboxedInt !Integer |
StaticUnboxedDouble !SaneDouble |
StaticUnboxedString !ByteString |
StaticUnboxedStringOffset !ByteString |

#### Instances

Instances details

Binary StaticUnboxed Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> StaticUnboxed -> IO () Source # put :: WriteBinHandle -> StaticUnboxed -> IO (Bin StaticUnboxed) Source # get :: ReadBinHandle -> IO StaticUnboxed Source #
Eq StaticUnboxed Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticUnboxed -> StaticUnboxed -> Bool Source # (/=) :: StaticUnboxed -> StaticUnboxed -> Bool Source #
Ord StaticUnboxed Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: StaticUnboxed -> StaticUnboxed -> Ordering Source # (<) :: StaticUnboxed -> StaticUnboxed -> Bool Source # (<=) :: StaticUnboxed -> StaticUnboxed -> Bool Source # (>) :: StaticUnboxed -> StaticUnboxed -> Bool Source # (>=) :: StaticUnboxed -> StaticUnboxed -> Bool Source # max :: StaticUnboxed -> StaticUnboxed -> StaticUnboxed Source # min :: StaticUnboxed -> StaticUnboxed -> StaticUnboxed Source #
Show StaticUnboxed Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticUnboxed -> ShowS Source # show :: StaticUnboxed -> String Source # showList :: [StaticUnboxed] -> ShowS Source #

data StaticArg Source #

Static Arguments. Static Arguments are things that are statically allocated, i.e., they exist at program startup. These are static heap objects or literals or things that have been floated to the top level binding by ghc.

Constructors

StaticObjArg !FastString | reference to a heap object
StaticLitArg !StaticLit | literal
StaticConArg !FastString [StaticArg] | unfloated constructor

#### Instances

Instances details

Binary StaticArg Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> StaticArg -> IO () Source # put :: WriteBinHandle -> StaticArg -> IO (Bin StaticArg) Source # get :: ReadBinHandle -> IO StaticArg Source #
Outputable StaticArg Source # |
Instance details Defined in GHC.StgToJS.Types Methods ppr :: StaticArg -> SDoc Source #
Eq StaticArg Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticArg -> StaticArg -> Bool Source # (/=) :: StaticArg -> StaticArg -> Bool Source #
Show StaticArg Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticArg -> ShowS Source # show :: StaticArg -> String Source # showList :: [StaticArg] -> ShowS Source #

data StaticLit Source #

A Static literal value

Constructors

BoolLit !Bool |
IntLit !Integer |
NullLit |
DoubleLit !SaneDouble |
StringLit !FastString |
BinLit !ByteString |
LabelLit !Bool !FastString | is function pointer, label (also used for string / binary init)

#### Instances

Instances details

ToJExpr StaticLit Source # |
Instance details Defined in GHC.StgToJS.Types Methods toJExpr :: StaticLit -> JStgExpr Source # toJExprFromList :: [StaticLit] -> JStgExpr Source #
Binary StaticLit Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> StaticLit -> IO () Source # put :: WriteBinHandle -> StaticLit -> IO (Bin StaticLit) Source # get :: ReadBinHandle -> IO StaticLit Source #
Outputable StaticLit Source # |
Instance details Defined in GHC.StgToJS.Types Methods ppr :: StaticLit -> SDoc Source #
Eq StaticLit Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: StaticLit -> StaticLit -> Bool Source # (/=) :: StaticLit -> StaticLit -> Bool Source #
Show StaticLit Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> StaticLit -> ShowS Source # show :: StaticLit -> String Source # showList :: [StaticLit] -> ShowS Source #

data ForeignJSRef Source #

A foreign reference to some JS code

Constructors

ForeignJSRef |
Fields foreignRefSrcSpan :: !FastString foreignRefPattern :: !FastString foreignRefSafety :: !Safety foreignRefCConv :: !CCallConv foreignRefArgs :: ![FastString] foreignRefResult :: !FastString

#### Instances

Instances details

Binary ForeignJSRef Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> ForeignJSRef -> IO () Source # put :: WriteBinHandle -> ForeignJSRef -> IO (Bin ForeignJSRef) Source # get :: ReadBinHandle -> IO ForeignJSRef Source #
Show ForeignJSRef Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> ForeignJSRef -> ShowS Source # show :: ForeignJSRef -> String Source # showList :: [ForeignJSRef] -> ShowS Source #

data LinkableUnit Source #

data used to generate one ObjBlock in our object file

Constructors

LinkableUnit |
Fields luObjBlock :: ObjBlock serializable unit info luIdExports :: [Id] exported names from haskell identifiers luOtherExports :: [FastString] other exports luIdDeps :: [Id] identifiers this unit depends on luPseudoIdDeps :: [Unique] pseudo-id identifiers this unit depends on (fixme) luOtherDeps :: [OtherSymb] symbols not from a haskell id that this unit depends on luRequired :: Bool always link this unit luForeignRefs :: [ForeignJSRef]

data ObjBlock Source #

one toplevel block in the object file

Constructors

ObjBlock |
Fields oiSymbols :: [FastString] toplevel symbols (stored in index) oiClInfo :: [ClosureInfo] closure information of all closures in block oiStatic :: [StaticInfo] static closure data oiStat :: JStat the code oiRaw :: ByteString raw JS code oiFExports :: [ExpFun] oiFImports :: [ForeignJSRef]

data ExpFun Source #

Constructors

ExpFun |
Fields isIO :: !Bool args :: [JSFFIType] result :: !JSFFIType

#### Instances

Instances details

Binary ExpFun Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> ExpFun -> IO () Source # put :: WriteBinHandle -> ExpFun -> IO (Bin ExpFun) Source # get :: ReadBinHandle -> IO ExpFun Source #
Eq ExpFun Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ExpFun -> ExpFun -> Bool Source # (/=) :: ExpFun -> ExpFun -> Bool Source #
Ord ExpFun Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: ExpFun -> ExpFun -> Ordering Source # (<) :: ExpFun -> ExpFun -> Bool Source # (<=) :: ExpFun -> ExpFun -> Bool Source # (>) :: ExpFun -> ExpFun -> Bool Source # (>=) :: ExpFun -> ExpFun -> Bool Source # max :: ExpFun -> ExpFun -> ExpFun Source # min :: ExpFun -> ExpFun -> ExpFun Source #
Show ExpFun Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> ExpFun -> ShowS Source # show :: ExpFun -> String Source # showList :: [ExpFun] -> ShowS Source #

data JSFFIType Source #

Types of FFI values

Constructors

Int8Type |
Int16Type |
Int32Type |
Int64Type |
Word8Type |
Word16Type |
Word32Type |
Word64Type |
DoubleType |
ByteArrayType |
PtrType |
RefType |

#### Instances

Instances details

Binary JSFFIType Source # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> JSFFIType -> IO () Source # put :: WriteBinHandle -> JSFFIType -> IO (Bin JSFFIType) Source # get :: ReadBinHandle -> IO JSFFIType Source #
Eq JSFFIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: JSFFIType -> JSFFIType -> Bool Source # (/=) :: JSFFIType -> JSFFIType -> Bool Source #
Ord JSFFIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: JSFFIType -> JSFFIType -> Ordering Source # (<) :: JSFFIType -> JSFFIType -> Bool Source # (<=) :: JSFFIType -> JSFFIType -> Bool Source # (>) :: JSFFIType -> JSFFIType -> Bool Source # (>=) :: JSFFIType -> JSFFIType -> Bool Source # max :: JSFFIType -> JSFFIType -> JSFFIType Source # min :: JSFFIType -> JSFFIType -> JSFFIType Source #
Enum JSFFIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods succ :: JSFFIType -> JSFFIType Source # pred :: JSFFIType -> JSFFIType Source # toEnum :: Int -> JSFFIType Source # fromEnum :: JSFFIType -> Int Source # enumFrom :: JSFFIType -> [JSFFIType] Source # enumFromThen :: JSFFIType -> JSFFIType -> [JSFFIType] Source # enumFromTo :: JSFFIType -> JSFFIType -> [JSFFIType] Source # enumFromThenTo :: JSFFIType -> JSFFIType -> JSFFIType -> [JSFFIType] Source #
Show JSFFIType Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> JSFFIType -> ShowS Source # show :: JSFFIType -> String Source # showList :: [JSFFIType] -> ShowS Source #

data TypedExpr Source #

Typed expression

Constructors

TypedExpr |
Fields typex_typ :: !PrimRep typex_expr :: [JStgExpr]

#### Instances

Instances details

Outputable TypedExpr Source # |
Instance details Defined in GHC.StgToJS.Types Methods ppr :: TypedExpr -> SDoc Source #

data PrimRes Source #

A Primop result is either an inlining of some JS payload, or a primitive call to a JS function defined in Shim files in base.

Constructors

PrimInline JStgStat | primop is inline, result is assigned directly
PRPrimCall JStgStat | primop is async call, primop returns the next function to run. result returned to stack top in registers

data ExprResult Source #

Constructors

ExprCont |
ExprInline |

#### Instances

Instances details

Eq ExprResult Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ExprResult -> ExprResult -> Bool Source # (/=) :: ExprResult -> ExprResult -> Bool Source #

newtype ExprValData Source #

Constructors

ExprValData [JStgExpr] |

#### Instances

Instances details

Eq ExprValData Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ExprValData -> ExprValData -> Bool Source # (/=) :: ExprValData -> ExprValData -> Bool Source #

data ClosureType Source #

A Closure is one of six types

Constructors

Thunk | The closure is a THUNK
Fun | The closure is a Function
Pap | The closure is a Partial Application
Con | The closure is a Constructor
Blackhole | The closure is a Blackhole
StackFrame | The closure is a stack frame

#### Instances

Instances details

ToJExpr ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods toJExpr :: ClosureType -> JStgExpr Source # toJExprFromList :: [ClosureType] -> JStgExpr Source #
Eq ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ClosureType -> ClosureType -> Bool Source # (/=) :: ClosureType -> ClosureType -> Bool Source #
Ord ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: ClosureType -> ClosureType -> Ordering Source # (<) :: ClosureType -> ClosureType -> Bool Source # (<=) :: ClosureType -> ClosureType -> Bool Source # (>) :: ClosureType -> ClosureType -> Bool Source # (>=) :: ClosureType -> ClosureType -> Bool Source # max :: ClosureType -> ClosureType -> ClosureType Source # min :: ClosureType -> ClosureType -> ClosureType Source #
Bounded ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods minBound :: ClosureType Source # maxBound :: ClosureType Source #
Enum ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods succ :: ClosureType -> ClosureType Source # pred :: ClosureType -> ClosureType Source # toEnum :: Int -> ClosureType Source # fromEnum :: ClosureType -> Int Source # enumFrom :: ClosureType -> [ClosureType] Source # enumFromThen :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromTo :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromThenTo :: ClosureType -> ClosureType -> ClosureType -> [ClosureType] Source #
Ix ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods range :: (ClosureType, ClosureType) -> [ClosureType] Source # index :: (ClosureType, ClosureType) -> ClosureType -> Int Source # unsafeIndex :: (ClosureType, ClosureType) -> ClosureType -> Int Source # inRange :: (ClosureType, ClosureType) -> ClosureType -> Bool Source # rangeSize :: (ClosureType, ClosureType) -> Int Source # unsafeRangeSize :: (ClosureType, ClosureType) -> Int Source #
Show ClosureType Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> ClosureType -> ShowS Source # show :: ClosureType -> String Source # showList :: [ClosureType] -> ShowS Source #

ctNum :: ClosureType -> Int Source #

Convert `ClosureType` to an Int

closureB :: ByteString Source #

closureNames :: Array ClosureType Ident Source #

ctJsName :: ClosureType -> String Source #

Convert `ClosureType` to a String

data ThreadStatus Source #

A thread is in one of 4 states

Constructors

Running | The thread is running
Blocked | The thread is blocked
Finished | The thread is done
Died | The thread has died

#### Instances

Instances details

Eq ThreadStatus Source # |
Instance details Defined in GHC.StgToJS.Types Methods (==) :: ThreadStatus -> ThreadStatus -> Bool Source # (/=) :: ThreadStatus -> ThreadStatus -> Bool Source #
Ord ThreadStatus Source # |
Instance details Defined in GHC.StgToJS.Types Methods compare :: ThreadStatus -> ThreadStatus -> Ordering Source # (<) :: ThreadStatus -> ThreadStatus -> Bool Source # (<=) :: ThreadStatus -> ThreadStatus -> Bool Source # (>) :: ThreadStatus -> ThreadStatus -> Bool Source # (>=) :: ThreadStatus -> ThreadStatus -> Bool Source # max :: ThreadStatus -> ThreadStatus -> ThreadStatus Source # min :: ThreadStatus -> ThreadStatus -> ThreadStatus Source #
Bounded ThreadStatus Source # |
Instance details Defined in GHC.StgToJS.Types Methods minBound :: ThreadStatus Source # maxBound :: ThreadStatus Source #
Enum ThreadStatus Source # |
Instance details Defined in GHC.StgToJS.Types Methods succ :: ThreadStatus -> ThreadStatus Source # pred :: ThreadStatus -> ThreadStatus Source # toEnum :: Int -> ThreadStatus Source # fromEnum :: ThreadStatus -> Int Source # enumFrom :: ThreadStatus -> [ThreadStatus] Source # enumFromThen :: ThreadStatus -> ThreadStatus -> [ThreadStatus] Source # enumFromTo :: ThreadStatus -> ThreadStatus -> [ThreadStatus] Source # enumFromThenTo :: ThreadStatus -> ThreadStatus -> ThreadStatus -> [ThreadStatus] Source #
Show ThreadStatus Source # |
Instance details Defined in GHC.StgToJS.Types Methods showsPrec :: Int -> ThreadStatus -> ShowS Source # show :: ThreadStatus -> String Source # showList :: [ThreadStatus] -> ShowS Source #

threadStatusNum :: ThreadStatus -> Int Source #

Convert the status of a thread in JS land to an Int

threadStatusJsName :: ThreadStatus -> String Source #

convert the status of a thread in JS land to a string