RFC: Introduce a serialisable bytecode format and corresponding "bytecode" way

We are planning on adding a new “bytecode” way, to enable the persisting and packaging of bytecode artifacts. At this stage it would be useful to gather feedback from any interested parties on the proposed interface for the design.

Please leave comments on this thread or on the GHC tracking ticket if you have any questions or suggestions.

GHC’s bytecode interpreter is widely used in GHCi and for Template Haskell evaluation with (-fprefer-bytecode), but until now it has only ever generated transient, in-memory bytecode. Every time you load a module in GHCi, the bytecode is regenerated from source.

The primary advantage of making bytecode into a persistable artifact is allowing caching of bytecode for REPL and tooling use.

This is not intended to replace native code for production executables, native code remains faster for runtime performance, but rather to extend GHC’s capabilities where fast build times, portability, and tooling integration are more important than peak execution speed

30 Likes

A cabal proposal for that side of the work: Support for bytecode files and libraries by mpickering · Pull Request #2 · haskell/cabal-proposals · GitHub

3 Likes

Thanks for pursuing this work. I may not know much in the way of compiler design but I do know that it’s going to be a fantastic thing to have.