... | ... | @@ -13,17 +13,17 @@ The main pieces are: |
|
|
|
|
|
- `libraries/ghci`, containing:
|
|
|
|
|
|
- types for talking about remote values ([ GHCi.RemoteTypes](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/RemoteTypes.hs))
|
|
|
- the message protocol ([ GHCi.Message](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Message.hs))
|
|
|
- implementation of the messages ([ GHCi.Run](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Run.hs))
|
|
|
- implementation of Template Haskell ([ GHCi.TH](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/TH.hs))
|
|
|
- types for talking about remote values ([GHCi.RemoteTypes](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/RemoteTypes.hs))
|
|
|
- the message protocol ([GHCi.Message](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Message.hs))
|
|
|
- implementation of the messages ([GHCi.Run](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Run.hs))
|
|
|
- implementation of Template Haskell ([GHCi.TH](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/TH.hs))
|
|
|
- a few other things needed to run interpreted code
|
|
|
|
|
|
- `iserv` directory at the top-level, containing the code for the external
|
|
|
server. This is a fairly simple wrapper, most of the functionality
|
|
|
is provided by modules in `libraries/ghci`.
|
|
|
|
|
|
- The [ \| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs) module in `compiler/ghci` which provides the interface to the server used
|
|
|
- The [\| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs) module in `compiler/ghci` which provides the interface to the server used
|
|
|
by the rest of GHC.
|
|
|
|
|
|
## Implementation overview
|
... | ... | @@ -34,13 +34,13 @@ interpreted code is run by the `iserv` binary. Without the flag, |
|
|
interpreted code is run in the same process as GHC.
|
|
|
|
|
|
|
|
|
With `-fexternal-interpreter`, the first time we need to run some interpreted code, we start the `iserv` server. This is done by `withIServ` in [ \| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs).
|
|
|
With `-fexternal-interpreter`, the first time we need to run some interpreted code, we start the `iserv` server. This is done by `withIServ` in [\| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs).
|
|
|
|
|
|
|
|
|
GHC and `iserv` communicate over a pair of pipes, one for sending messages and one for receiving.
|
|
|
|
|
|
|
|
|
All communication is done using messages serialized using the `binary` package. The main message type is `Message` in [ GHCi.Message](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Message.hs). To send a message from GHC, use `iservCmd` in [ \| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs). There are wrappers for common message types.
|
|
|
All communication is done using messages serialized using the `binary` package. The main message type is `Message` in [GHCi.Message](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/Message.hs). To send a message from GHC, use `iservCmd` in [ \| GHCi](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Fghci%2FGHCi.hs). There are wrappers for common message types.
|
|
|
|
|
|
|
|
|
There are multiple versions of `iserv`: plain `iserv`, `iserv_p`, and `iserv_dyn`. The latter two are compiled with `-prof` and `-dynamic` respectively. One big advantage of `-fexternal-interpreter` is that we can run interpreted code in `-prof` mode without GHC itself being compiled with `-prof`; in order to do that, we invoke `iserv_p` rather than `iserv`.
|
... | ... | @@ -73,10 +73,10 @@ Any compiled packages and object files are linked into the `iserv` process using |
|
|
This is a bit more tricky, because the communication is two way: we send the TH code to `iserv`, but during execution the TH code may make requests back to GHC, e.g. to look up a `Name`.
|
|
|
|
|
|
|
|
|
The set of operations that TH code can perform is defined by the `Quasi` class in [ Language.Haskell.TH.Syntax](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/template-haskell/Language/Haskell/TH/Syntax.hs). Under `-fexternal-interpreter`, each of these operations results in a message sent back from `iserv` to GHC, and a response to the message sent from GHC back to `iserv`. The `iserv` side of this communication is in [ GHCi.TH](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/TH.hs), and the GHC side is in `runRemoteTH` in [ TcSplice.hs](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Ftypecheck%2FTcSplice.hs).
|
|
|
The set of operations that TH code can perform is defined by the `Quasi` class in [Language.Haskell.TH.Syntax](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/template-haskell/Language/Haskell/TH/Syntax.hs). Under `-fexternal-interpreter`, each of these operations results in a message sent back from `iserv` to GHC, and a response to the message sent from GHC back to `iserv`. The `iserv` side of this communication is in [ GHCi.TH](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/ghci/GHCi/TH.hs), and the GHC side is in `runRemoteTH` in [ TcSplice.hs](https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler%2Ftypecheck%2FTcSplice.hs).
|
|
|
|
|
|
|
|
|
|
|
|
For more details, see `Note [Remote Template Haskell]` in [ \| libraries/ghci/GHCi/TH.hs](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries%2Fghci%2FGHCi%2FTH.hs)
|
|
|
For more details, see `Note [Remote Template Haskell]` in [\| libraries/ghci/GHCi/TH.hs](https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries%2Fghci%2FGHCi%2FTH.hs)
|
|
|
|
|
|
|