ghc-9.6.5: The GHC API
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 HaskellSafe-Inferred
LanguageHaskell2010

GHC.StgToJS.Rts.Rts

Description

Top level driver of the JavaScript Backend RTS. This file is an implementation of the JS RTS for the JS backend written as an EDSL in Haskell. It assumes the existence of pre-generated JS functions, included as js-sources in base. These functions are similarly assumed for non-inline Primops, See Prim. Most of the elements in this module are constants in Haskell Land which define pieces of the JS RTS.

Synopsis

Documentation

garbageCollector :: JStat Source #

The garbageCollector resets registers and result variables.

resetRegister :: StgReg -> JStat Source #

Reset the register r in JS Land. Note that this "resets" by setting the register to a dummy variable called "null", not by setting to JS's nil value.

resetResultVar :: StgRet -> JStat Source #

Reset the return variable r in JS Land. Note that this "resets" by setting the register to a dummy variable called "null", not by setting to JS's nil value.

closureConstructors :: StgToJSConfig -> JStat Source #

Define closures based on size, these functions are syntactic sugar, e.g., a Haskell function which generates some useful JS. Each Closure constructor follows the naming convention h$cN, where N is a natural number. For example, h$c (with the nat omitted) is a JS Land Constructor for a closure in JS land which has a single entry function f, and no fields; identical to h$c0. h$c1 is a JS Land Constructor for a closure with an entry function f, and a single field x1, 'Just foo' is an example of this kind of closure. h$c2 is a JS Land Constructor for a closure with an entry function and two data fields: x1 and x2. And so on. Note that this has JIT performance implications; you should use h$c1, h$c2, h$c3, ... h$c24 instead of making objects manually so layouts and fields can be changed more easily and so the JIT can optimize better.

stackManip :: JStat Source #

JS Payload to perform stack manipulation in the RTS

declRegs :: JStat Source #

JS payload to declare the registers

regGettersSetters :: JStat Source #

JS payload to define getters and setters on the registers.

loadRegs :: JStat Source #

JS payload that defines the functions to load each register

assignRegs :: StgToJSConfig -> [JExpr] -> JStat Source #

Assign registers R1 ... Rn in descending order, that is assign Rn first. This function uses the assignRegs' array to construct functions which set the registers.

assignRegs' :: Array Int Ident Source #

JS payload which defines an array of function symbols that set N registers from M parameters. For example, h$l2 compiles to: function h$l4(x1, x2, x3, x4) { h$r4 = x1; h$r3 = x2; h$r2 = x3; h$r1 = x4; };

declRets :: JStat Source #

JS payload to declare return variables.

closureTypes :: JStat Source #

JS payload defining the types closures.

rtsDecls :: JStat Source #

JS payload declaring the RTS functions.

rtsText :: StgToJSConfig -> String Source #

print the embedded RTS to a String

rtsDeclsText :: String Source #

print the RTS declarations to a String.

rts :: StgToJSConfig -> JStat Source #

Wrapper over the RTS to guarentee saturation, see Transform

rts' :: StgToJSConfig -> JStat Source #

JS Payload which defines the embedded RTS.