A State monad over IO holding the generator state.
Moduleghc-9.10.3GHC2021
GHC.StgToJS.Types
Module that holds the Types required for the StgToJS pass
- 32 types
- 4 values
- Packageghc-9.10.3
- Exports36
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceTypes.hs
The JS code generator state
Constructors
GenStategsSettings :: !StgToJSConfigcodegen settings, read-only
gsModule :: !Modulecurrent module
gsId :: !FastMutIntunique number for the id generator
gsIdents :: !IdCachehash consing for identifiers from a Unique
gsUnfloated :: !UniqFM Id CgStgExprunfloated arguments
gsGroup :: GenGroupStatestate for the current binding group
gsGlobal :: [JStgStat]global (per module) statements (gets included when anything else from the module is used)
The JS code generator state relevant for the current binding group
Constructors
GenGroupStateggsToplevelStats :: [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 :: Intcurrent stack depth
ggsExtraDeps :: Set OtherSymbextra dependencies for the linkable unit that contains this group
ggsGlobalIdCache :: GlobalIdCacheggsForeignRefs :: [ForeignJSRef]
The Configuration record for the StgToJS pass
Constructors
StgToJSConfigcsInlinePush :: !BoolcsInlineBlackhole :: !BoolcsInlineLoadRegs :: !BoolcsInlineEnter :: !BoolcsInlineAlloc :: !BoolcsPrettyRender :: !BoolcsTraceRts :: !BoolcsAssertRts :: !BoolcsBoundsCheck :: !BoolcsDebugAlloc :: !BoolcsTraceForeign :: !BoolcsProf :: !BoolProfiling enabled
csRuntimeAssert :: !BoolEnable runtime assertions settings
csContext :: !SDocContextcsLinkerConfig :: !LinkerConfigEmscripten linker
Information relevenat to code generation for closures.
Constructors
ClosureInfociVar :: Identobject being infod
ciRegs :: CIRegssize of the payload (in number of JS values)
ciName :: FastStringfriendly name for printing
ciLayout :: CILayoutheap/stack layout of the object
ciType :: CITypetype of the object, with extra info where required
ciStatic :: CIStaticstatic references of this object
Instances3Eq, Show, Binary
Eq ClosureInfoDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow ClosureInfoDefined in ghc-9.10.3 · GHC.StgToJS.TypesBinary ClosureInfoDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphan
Closure information, ClosureInfo, registers
Constructors
CIRegsUnknownA value witnessing a state of unknown registers
CIRegsciRegsSkip :: Intunused registers before actual args start
ciRegsTypes :: [JSRep]args
Closure Information, ClosureInfo, layout
Constructors
CILayoutVariablelayout stored in object itself, first position from the start
CILayoutUnknownfixed size, but content unknown (for example stack apply frame)
layoutSize :: !Intclosure size in array positions, including entry
CILayoutFixedwhole layout known
layoutSize :: !Intclosure size in array positions, including entry
layout :: [JSRep]The list of JSReps to layout
The type of ClosureInfo
Constructors
CIFunCIThunkThe closure is a THUNK
CIConThe closure is a Constructor
citConstructor :: !Int
CIPapThe closure is a Partial Application
CIBlackholeThe closure is a black hole
CIStackFrameThe closure is a stack frame
Static references that must be kept alive
Constructors
Instances6Eq, Show, Semigroup, Monoid, Binary, ToJExpr
Eq CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.TypesSemigroup CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.TypesMonoid CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.TypesBinary CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphanToJExpr CIStaticDefined in ghc-9.10.3 · GHC.StgToJS.Typesstatic refs: array = references, null = nothing to report note: only works after all top-level objects have been created
JS primitive representations
Constructors
PtrVpointer = reference to heap object (closure object), lifted or not. Can also be some RTS object (e.g. TVar#, MVar#, MutVar#, Weak#)
VoidVno fields
DoubleVA Double: one field
IntVAn Int (32bit because JS): one field
LongVA Long: two fields one for the upper 32bits, one for the lower (NB: JS is little endian)
AddrVa pointer not to the heap: two fields, array + index
ObjVsome JS object, user supplied, be careful around these, can be anything
ArrVboxed array
Instances7Bounded, Enum, Eq, Ord, Show, Binary, …
Bounded JSRepDefined in ghc-9.10.3 · GHC.StgToJS.TypesEnum JSRepDefined in ghc-9.10.3 · GHC.StgToJS.TypesEq JSRepDefined in ghc-9.10.3 · GHC.StgToJS.TypesOrd JSRepDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow JSRepDefined in ghc-9.10.3 · GHC.StgToJS.TypesBinary JSRepDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphanToJExpr JSRepDefined in ghc-9.10.3 · GHC.StgToJS.Types
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
IdPlainA plain identifier for values, no suffix added
IdEntryAn entry function, suffix = "_e" in makeIdentForId
IdConEntryA Constructor entry function, suffix = "_con_e" in makeIdentForId
Some other symbol
Constructors
The global Identifier Cache
Constructors
GlobalIdCache (UniqFM Ident (IdKey, Id))
A Stack Slot is either known or unknown. We avoid maybe here for more strictness.
Constructors
Constructors
Instances3Eq, Show, Binary
Eq StaticInfoDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow StaticInfoDefined in ghc-9.10.3 · GHC.StgToJS.TypesBinary StaticInfoDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphan
Constructors
StaticFun !FastString [StaticArg]heap object for function
StaticThunk !(Maybe (FastString, [StaticArg]))heap object for CAF (field is Nothing when thunk is initialized in an alternative way, like string thunks through h$str)
StaticUnboxed !StaticUnboxedunboxed constructor (Bool, Int, Double etc)
StaticData !FastString [StaticArg]regular datacon app
StaticList [StaticArg] (Maybe FastString)list initializer (with optional tail)
Instances4Eq, Ord, Show, Binary
Eq StaticUnboxedDefined in ghc-9.10.3 · GHC.StgToJS.TypesOrd StaticUnboxedDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow StaticUnboxedDefined in ghc-9.10.3 · GHC.StgToJS.TypesBinary StaticUnboxedDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphan
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 !FastStringreference to a heap object
StaticLitArg !StaticLitliteral
StaticConArg !FastString [StaticArg]unfloated constructor
A Static literal value
Constructors
BoolLit !BoolIntLit !IntegerNullLitDoubleLit !SaneDoubleStringLit !FastStringBinLit !ByteStringLabelLit !Bool !FastStringis function pointer, label (also used for string / binary init)
Instances5Eq, Show, Outputable, Binary, ToJExpr
A foreign reference to some JS code
Constructors
Instances1Binary
Binary ForeignJSRefDefined in ghc-9.10.3 · GHC.StgToJS.Object · orphan
data used to generate one ObjBlock in our object file
Constructors
LinkableUnitluObjBlock :: ObjBlockserializable 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 :: Boolalways link this unit
luForeignRefs :: [ForeignJSRef]
one toplevel block in the object file
Constructors
ObjBlockoiSymbols :: ![FastString]toplevel symbols (stored in index)
oiClInfo :: ![ClosureInfo]closure information of all closures in block
oiStatic :: ![StaticInfo]static closure data
oiStat :: JStatthe code
oiRaw :: !ByteStringraw JS code
oiFExports :: ![ExpFun]oiFImports :: ![ForeignJSRef]
Types of FFI values
Instances5Enum, Eq, Ord, Show, Binary
Typed expression
Constructors
TypedExprtypex_typ :: !PrimReptypex_expr :: [JStgExpr]
Instances1Outputable
Outputable TypedExprDefined in ghc-9.10.3 · GHC.StgToJS.Types
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 JStgStatprimop is inline, result is assigned directly
PRPrimCall JStgStatprimop is async call, primop returns the next function to run. result returned to stack top in registers
Instances1Eq
Eq ExprResultDefined in ghc-9.10.3 · GHC.StgToJS.Types
Constructors
Instances1Eq
Eq ExprValDataDefined in ghc-9.10.3 · GHC.StgToJS.Types
A Closure is one of six types
Instances6Bounded, Enum, Eq, Ord, Show, ToJExpr
Bounded ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.TypesEnum ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.TypesEq ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.TypesOrd ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.TypesToJExpr ClosureTypeDefined in ghc-9.10.3 · GHC.StgToJS.Types
Convert ClosureType to an Int
Convert ClosureType to a String
A thread is in one of 4 states
Instances5Bounded, Enum, Eq, Ord, Show
Bounded ThreadStatusDefined in ghc-9.10.3 · GHC.StgToJS.TypesEnum ThreadStatusDefined in ghc-9.10.3 · GHC.StgToJS.TypesEq ThreadStatusDefined in ghc-9.10.3 · GHC.StgToJS.TypesOrd ThreadStatusDefined in ghc-9.10.3 · GHC.StgToJS.TypesShow ThreadStatusDefined in ghc-9.10.3 · GHC.StgToJS.Types
Convert the status of a thread in JS land to an Int
convert the status of a thread in JS land to a string