ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file LICENSE)
MaintainerJeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stabilityexperimental
Safe HaskellIgnore
LanguageGHC2021

GHC.StgToJS.Types

Description

Module that holds the Types required for the StgToJS pass

Synopsis

Documentation

type G = StateT GenState IO #

A State monad over IO holding the generator state.

data GenState #

The JS code generator state

Constructors

GenState 

Fields

data GenGroupState #

The JS code generator state relevant for the current binding group

Constructors

GenGroupState 

Fields

data StgToJSConfig #

The Configuration record for the StgToJS pass

Constructors

StgToJSConfig 

data ClosureInfo #

Information relevenat to code generation for closures.

Constructors

ClosureInfo 

Fields

Instances

Instances details
Show ClosureInfo # 
Instance details

Defined in GHC.StgToJS.Types

Binary ClosureInfo # 
Instance details

Defined in GHC.StgToJS.Object

Eq ClosureInfo # 
Instance details

Defined in GHC.StgToJS.Types

data CIRegs #

Closure information, ClosureInfo, registers

Constructors

CIRegsUnknown

A value witnessing a state of unknown registers

CIRegs 

Fields

Instances

Instances details
Show CIRegs # 
Instance details

Defined in GHC.StgToJS.Types

Binary CIRegs # 
Instance details

Defined in GHC.StgToJS.Object

Methods

put_ :: BinHandle -> CIRegs -> IO () #

put :: BinHandle -> CIRegs -> IO (Bin CIRegs) #

get :: BinHandle -> IO CIRegs #

Eq CIRegs # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: CIRegs -> CIRegs -> Bool #

(/=) :: CIRegs -> CIRegs -> Bool #

Ord CIRegs # 
Instance details

Defined in GHC.StgToJS.Types

data CILayout #

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

Instances

Instances details
Show CILayout # 
Instance details

Defined in GHC.StgToJS.Types

Binary CILayout # 
Instance details

Defined in GHC.StgToJS.Object

Eq CILayout # 
Instance details

Defined in GHC.StgToJS.Types

Ord CILayout # 
Instance details

Defined in GHC.StgToJS.Types

data CIType #

The type of ClosureInfo

Constructors

CIFun 

Fields

CIThunk

The closure is a THUNK

CICon

The closure is a Constructor

Fields

CIPap

The closure is a Partial Application

CIBlackhole

The closure is a black hole

CIStackFrame

The closure is a stack frame

Instances

Instances details
Show CIType # 
Instance details

Defined in GHC.StgToJS.Types

Binary CIType # 
Instance details

Defined in GHC.StgToJS.Object

Methods

put_ :: BinHandle -> CIType -> IO () #

put :: BinHandle -> CIType -> IO (Bin CIType) #

get :: BinHandle -> IO CIType #

Eq CIType # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: CIType -> CIType -> Bool #

(/=) :: CIType -> CIType -> Bool #

Ord CIType # 
Instance details

Defined in GHC.StgToJS.Types

newtype CIStatic #

Static references that must be kept alive

Constructors

CIStaticRefs 

Fields

Instances

Instances details
Monoid CIStatic # 
Instance details

Defined in GHC.StgToJS.Types

Semigroup CIStatic # 
Instance details

Defined in GHC.StgToJS.Types

Show CIStatic # 
Instance details

Defined in GHC.StgToJS.Types

ToJExpr CIStatic #

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

Binary CIStatic # 
Instance details

Defined in GHC.StgToJS.Object

Eq CIStatic # 
Instance details

Defined in GHC.StgToJS.Types

data JSRep #

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
Bounded JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Enum JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Show JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Methods

showsPrec :: Int -> JSRep -> ShowS #

show :: JSRep -> String #

showList :: [JSRep] -> ShowS #

ToJExpr JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Binary JSRep # 
Instance details

Defined in GHC.StgToJS.Object

Methods

put_ :: BinHandle -> JSRep -> IO () #

put :: BinHandle -> JSRep -> IO (Bin JSRep) #

get :: BinHandle -> IO JSRep #

Eq JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: JSRep -> JSRep -> Bool #

(/=) :: JSRep -> JSRep -> Bool #

Ord JSRep # 
Instance details

Defined in GHC.StgToJS.Types

Methods

compare :: JSRep -> JSRep -> Ordering #

(<) :: JSRep -> JSRep -> Bool #

(<=) :: JSRep -> JSRep -> Bool #

(>) :: JSRep -> JSRep -> Bool #

(>=) :: JSRep -> JSRep -> Bool #

max :: JSRep -> JSRep -> JSRep #

min :: JSRep -> JSRep -> JSRep #

data IdType #

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
Enum IdType # 
Instance details

Defined in GHC.StgToJS.Types

Eq IdType # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: IdType -> IdType -> Bool #

(/=) :: IdType -> IdType -> Bool #

Ord IdType # 
Instance details

Defined in GHC.StgToJS.Types

data IdKey #

Keys to differentiate Ident's in the ID Cache

Constructors

IdKey !Word64 !Int !IdType 

Instances

Instances details
Eq IdKey # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: IdKey -> IdKey -> Bool #

(/=) :: IdKey -> IdKey -> Bool #

Ord IdKey # 
Instance details

Defined in GHC.StgToJS.Types

Methods

compare :: IdKey -> IdKey -> Ordering #

(<) :: IdKey -> IdKey -> Bool #

(<=) :: IdKey -> IdKey -> Bool #

(>) :: IdKey -> IdKey -> Bool #

(>=) :: IdKey -> IdKey -> Bool #

max :: IdKey -> IdKey -> IdKey #

min :: IdKey -> IdKey -> IdKey #

data OtherSymb #

Some other symbol

Constructors

OtherSymb !Module !FastString 

Instances

Instances details
Eq OtherSymb # 
Instance details

Defined in GHC.StgToJS.Types

Ord OtherSymb # 
Instance details

Defined in GHC.StgToJS.Types

newtype IdCache #

The identifier cache indexed on IdKey local to a module

Constructors

IdCache (Map IdKey Ident) 

newtype GlobalIdCache #

The global Identifier Cache

Constructors

GlobalIdCache (UniqFM Ident (IdKey, Id)) 

data StackSlot #

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 # 
Instance details

Defined in GHC.StgToJS.Types

Ord StackSlot # 
Instance details

Defined in GHC.StgToJS.Types

data StaticInfo #

Constructors

StaticInfo 

Fields

Instances

Instances details
Show StaticInfo # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticInfo # 
Instance details

Defined in GHC.StgToJS.Object

Eq StaticInfo # 
Instance details

Defined in GHC.StgToJS.Types

data StaticVal #

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 !StaticUnboxed

unboxed constructor (Bool, Int, Double etc)

StaticData !FastString [StaticArg]

regular datacon app

StaticList [StaticArg] (Maybe FastString)

list initializer (with optional tail)

Instances

Instances details
Show StaticVal # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticVal # 
Instance details

Defined in GHC.StgToJS.Object

Eq StaticVal # 
Instance details

Defined in GHC.StgToJS.Types

data StaticArg #

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
Show StaticArg # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticArg # 
Instance details

Defined in GHC.StgToJS.Object

Outputable StaticArg # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: StaticArg -> SDoc #

Eq StaticArg # 
Instance details

Defined in GHC.StgToJS.Types

data StaticLit #

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
Show StaticLit # 
Instance details

Defined in GHC.StgToJS.Types

ToJExpr StaticLit # 
Instance details

Defined in GHC.StgToJS.Types

Binary StaticLit # 
Instance details

Defined in GHC.StgToJS.Object

Outputable StaticLit # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: StaticLit -> SDoc #

Eq StaticLit # 
Instance details

Defined in GHC.StgToJS.Types

data ForeignJSRef #

A foreign reference to some JS code

Instances

Instances details
Binary ForeignJSRef # 
Instance details

Defined in GHC.StgToJS.Object

data LinkableUnit #

data used to generate one ObjBlock in our object file

Constructors

LinkableUnit 

Fields

data ObjBlock #

one toplevel block in the object file

Constructors

ObjBlock 

Fields

data ExpFun #

Constructors

ExpFun 

Fields

Instances

Instances details
Show ExpFun # 
Instance details

Defined in GHC.StgToJS.Types

Binary ExpFun # 
Instance details

Defined in GHC.StgToJS.Object

Methods

put_ :: BinHandle -> ExpFun -> IO () #

put :: BinHandle -> ExpFun -> IO (Bin ExpFun) #

get :: BinHandle -> IO ExpFun #

Eq ExpFun # 
Instance details

Defined in GHC.StgToJS.Types

Methods

(==) :: ExpFun -> ExpFun -> Bool #

(/=) :: ExpFun -> ExpFun -> Bool #

Ord ExpFun # 
Instance details

Defined in GHC.StgToJS.Types

data JSFFIType #

Types of FFI values

data TypedExpr #

Typed expression

Constructors

TypedExpr 

Instances

Instances details
Outputable TypedExpr # 
Instance details

Defined in GHC.StgToJS.Types

Methods

ppr :: TypedExpr -> SDoc #

data PrimRes #

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 #

Constructors

ExprCont 
ExprInline 

Instances

Instances details
Eq ExprResult # 
Instance details

Defined in GHC.StgToJS.Types

newtype ExprValData #

Constructors

ExprValData [JStgExpr] 

Instances

Instances details
Eq ExprValData # 
Instance details

Defined in GHC.StgToJS.Types

data ClosureType #

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

ctNum :: ClosureType -> Int #

Convert ClosureType to an Int

ctJsName :: ClosureType -> String #

Convert ClosureType to a String

data ThreadStatus #

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

threadStatusNum :: ThreadStatus -> Int #

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

threadStatusJsName :: ThreadStatus -> String #

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