|
|
CONVERSION ERROR
|
|
|
|
|
|
Error: HttpError (HttpExceptionRequest Request {
|
|
|
host = "ghc.haskell.org"
|
|
|
port = 443
|
|
|
secure = True
|
|
|
requestHeaders = []
|
|
|
path = "/trac/ghc/wiki/Commentary/Compiler/StgSynType"
|
|
|
queryString = "?version=6"
|
|
|
method = "GET"
|
|
|
proxy = Nothing
|
|
|
rawBody = False
|
|
|
redirectCount = 10
|
|
|
responseTimeout = ResponseTimeoutDefault
|
|
|
requestVersion = HTTP/1.1
|
|
|
}
|
|
|
(StatusCodeException (Response {responseStatus = Status {statusCode = 403, statusMessage = "Forbidden"}, responseVersion = HTTP/1.1, responseHeaders = [("Date","Sun, 10 Mar 2019 07:03:41 GMT"),("Server","Apache/2.2.22 (Debian)"),("Strict-Transport-Security","max-age=63072000; includeSubDomains"),("Vary","Accept-Encoding"),("Content-Encoding","gzip"),("Content-Length","264"),("Content-Type","text/html; charset=iso-8859-1")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don't have permission to access /trac/ghc/wiki/Commentary/Compiler/StgSynType\non this server.</p>\n<hr>\n<address>Apache/2.2.22 (Debian) Server at ghc.haskell.org Port 443</address>\n</body></html>\n"))
|
|
|
|
|
|
Original source:
|
|
|
|
|
|
```trac
|
|
|
|
|
|
|
|
|
Video: [http://video.google.com/videoplay?docid=-2701204964659708761 STG language] (17'21")
|
|
|
|
|
|
= The STG syntax data types =
|
|
|
|
|
|
Before code generation, GHC converts the Core-language program into {{{StgSyn}}}. The basic ideas are still pretty much exactly as described in the paper [http://research.microsoft.com/copyright/accept.asp?path=/users/simonpj/papers/spineless-tagless-gmachine.ps.gz Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine].
|
|
|
|
|
|
The best way to think of STG is as special form of [wiki:Commentary/Compiler/CoreSynType Core]. Specifically, the differences are these (see [[GhcFile(compiler/stgSyn/StgSyn.lhs)]]):
|
|
|
* Functions arguments are atoms (literals or variables), of type {{{StgArg}}}.
|
|
|
* The right hand side of a let-binding, {{{StgRhs}}}, is either
|
|
|
* `StgRhsCon`: a constructor application, or
|
|
|
* `StgRhsClosure`: '''lambda-form''' (possibly with zero arguments, in which case it's a thunk).
|
|
|
* Constructor applications are saturated.
|
|
|
* Applications of primitive operators are saturated.
|
|
|
* Lambdas can only appear the right-hand side of a let-binding. (There is an expression form {{{StgLam}}}, but it is only used during the Core-to-STG transformation, not in a valid STG program.)
|
|
|
* Types have largely been discarded, retaining only enough type information as is needed to guide code generation. There is an {{{StgLint}}} checker, which makes some consistency checks, but the !CoreLint guarantee that "if the program passes Lint it cannot crash" has been lost.
|
|
|
|
|
|
In addition, the STG program is decorated with the results of some analyses:
|
|
|
|
|
|
* Every lambda-form (`StgRhsClosure`) lists its free variables. These are the variables that are in the thunk of function closure that is allocated by the let.
|
|
|
|
|
|
* Every lambda-form gives its [wiki:Commentary/Rts/CAFs '''Static Reference Table'''] or '''SRT'''. You shold think of the SRT as the ''top-level'' free variables of the body. They do not need to be dynamically allocated in the heap object, but they do need to be accessible from the object's info-table, so that the garbage collector can find the CAFs kept alive by the object.
|
|
|
|
|
|
* A {{{StgCase}}} expression is decorated with its '''live variables'''; that is, variables reachable from the continuation of the case. More precisely, two sets of live variables, plus the SRT for the continuation. Todo: say more.
|
|
|
|
|
|
* The STG program has a new construct called '''let-no-escape''', that encodes so-called '''join points'''. Todo: say more.
|
|
|
|
|
|
``` |
|
|
|
|
|
Video: [ STG language](http://video.google.com/videoplay?docid=-2701204964659708761) (17'21")
|
|
|
|
|
|
# The STG syntax data types
|
|
|
|
|
|
|
|
|
Before code generation, GHC converts the Core-language program into `StgSyn`. The basic ideas are still pretty much exactly as described in the paper [ Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine](http://research.microsoft.com/en-us/um/people/simonpj/papers/spineless-tagless-gmachine.ps.gz).
|
|
|
|
|
|
|
|
|
The best way to think of STG is as special form of [Core](commentary/compiler/core-syn-type). Specifically, the differences are these (see [compiler/stgSyn/StgSyn.lhs](/trac/ghc/browser/ghc/compiler/stgSyn/StgSyn.lhs)):
|
|
|
|
|
|
- Functions arguments are atoms (literals or variables), of type `StgArg`.
|
|
|
- The right hand side of a let-binding, `StgRhs`, is either
|
|
|
|
|
|
- `StgRhsCon`: a constructor application, or
|
|
|
- `StgRhsClosure`: **lambda-form** (possibly with zero arguments, in which case it's a thunk).
|
|
|
- Constructor applications are saturated.
|
|
|
- Applications of primitive operators are saturated.
|
|
|
- Lambdas can only appear the right-hand side of a let-binding. (There is an expression form `StgLam`, but it is only used during the Core-to-STG transformation, not in a valid STG program.)
|
|
|
- Types have largely been discarded, retaining only enough type information as is needed to guide code generation. There is an `StgLint` checker, which makes some consistency checks, but the CoreLint guarantee that "if the program passes Lint it cannot crash" has been lost.
|
|
|
|
|
|
|
|
|
In addition, the STG program is decorated with the results of some analyses:
|
|
|
|
|
|
- Every lambda-form (`StgRhsClosure`) lists its free variables. These are the variables that are in the thunk of function closure that is allocated by the let.
|
|
|
|
|
|
- Every lambda-form gives its ['Static Reference Table'](commentary/rts/ca-fs) or **SRT**. You shold think of the SRT as the *top-level* free variables of the body. They do not need to be dynamically allocated in the heap object, but they do need to be accessible from the object's info-table, so that the garbage collector can find the CAFs kept alive by the object.
|
|
|
|
|
|
- A `StgCase` expression is decorated with its **live variables**; that is, variables reachable from the continuation of the case. More precisely, two sets of live variables, plus the SRT for the continuation. Todo: say more.
|
|
|
|
|
|
- The STG program has a new construct called **let-no-escape**, that encodes so-called **join points**. Todo: say more. |