ghc-lib-9.6.2.20231121: The GHC API, decoupled from GHC versions
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file LICENSE)
MaintainerSylvain Henry <sylvain.henry@iohk.io> Jeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stabilityexperimental Serialization/deserialization of binary .o files for the JavaScript backend The .o files contain dependency information and generated code. All strings are mapped to a central string table, which helps reduce file size and gives us efficient hash consing on read Binary intermediate JavaScript object files: serialized [Text] -> ([ClosureInfo], JStat) blocks file layout: - magic "GHCJSOBJ" - compiler version tag - module name - offsets of string table - dependencies - offset of the index - unit infos - index - string table
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.StgToJS.Object

Description

 
Synopsis

Documentation

putObject Source #

Arguments

:: BinHandle 
-> ModuleName

module

-> Deps

dependencies

-> [ObjUnit]

linkable units and their symbols

-> IO () 

Given a handle to a Binary payload, add the module, mod_name, its dependencies, deps, and its linkable units to the payload.

getObjectBody :: BinHandle -> ModuleName -> IO Object Source #

Parse object body. Must be called after a sucessful getObjectHeader

getObject :: BinHandle -> IO (Maybe Object) Source #

Parse object

readObject :: FilePath -> IO (Maybe Object) Source #

Read object from file

The object is still in memory after this (see objHandle).

getObjectUnits :: Object -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] Source #

Get units in the object file, using the given filtering function

readObjectUnits :: FilePath -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] Source #

Read units in the object file, using the given filtering function

readObjectDeps :: FilePath -> IO (Maybe Deps) Source #

Reads only the part necessary to get the dependencies

isGlobalUnit :: Int -> Bool Source #

we use the convention that the first unit (0) is a module-global unit that's always included when something from the module is loaded. everything in a module implicitly depends on the global block. the global unit itself can't have dependencies

isJsObjectFile :: FilePath -> IO Bool Source #

Test if the object file is a JS object

data Object Source #

An object file

Constructors

Object 

Fields

data IndexEntry Source #

Constructors

IndexEntry 

Fields

Instances

Instances details
Binary IndexEntry Source # 
Instance details

Defined in GHC.StgToJS.Object

data Deps Source #

dependencies for a single module

Constructors

Deps 

Fields

Instances

Instances details
Binary Deps Source # 
Instance details

Defined in GHC.StgToJS.Object

Methods

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

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

get :: BinHandle -> IO Deps #

Outputable Deps Source # 
Instance details

Defined in GHC.StgToJS.Object

Methods

ppr :: Deps -> SDoc #

data BlockDeps Source #

Constructors

BlockDeps 

Fields

  • blockBlockDeps :: [Int]

    dependencies on blocks in this object

  • blockFunDeps :: [ExportedFun]

    dependencies on exported symbols in other objects , blockForeignExported :: [ExpFun] , blockForeignImported :: [ForeignRef]

Instances

Instances details
Binary BlockDeps Source # 
Instance details

Defined in GHC.StgToJS.Object

data DepsLocation Source #

Where are the dependencies

Constructors

ObjectFile FilePath

In an object file at path

ArchiveFile FilePath

In a Ar file at path

InMemory String Object

In memory

Instances

Instances details
Outputable DepsLocation Source # 
Instance details

Defined in GHC.StgToJS.Object

Methods

ppr :: DepsLocation -> SDoc #

data ExportedFun Source #

Exported Functions

Constructors

ExportedFun 

Fields

Orphan instances

Binary Ident Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO Ident #

Binary JExpr Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO JExpr #

Binary JOp Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO JOp #

Binary JStat Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO JStat #

Binary JUOp Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO JUOp #

Binary JVal Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO JVal #

Binary SaneDouble Source # 
Instance details

Binary CILayout Source # 
Instance details

Binary CIRegs Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO CIRegs #

Binary CIStatic Source # 
Instance details

Binary CIType Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO CIType #

Binary ClosureInfo Source # 
Instance details

Binary ExpFun Source # 
Instance details

Methods

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

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

get :: BinHandle -> IO ExpFun #

Binary ForeignJSRef Source # 
Instance details

Binary JSFFIType Source # 
Instance details

Binary StaticArg Source # 
Instance details

Binary StaticInfo Source # 
Instance details

Binary StaticLit Source # 
Instance details

Binary StaticUnboxed Source # 
Instance details

Binary StaticVal Source # 
Instance details

Binary VarType Source # 
Instance details