Last active
July 28, 2023 12:40
-
-
Save tmcgilchrist/1bb5b67e60a2224f0ba8d58546b1d1cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
OCaml compilation pipeline | |
┌────────────────┐ | |
│ │ | |
│ Source code │ | |
│ │ parsing and preprocessing | |
└───────┬────────┘ preprocessor extensions (ppx) | |
│ | |
│ | |
┌───────▼────────┐ | |
│ │ | |
│ Parsetree │ | |
│ (untyped AST) │ | |
└───────┬────────┘ | |
│ | |
│ type inference and checking | |
┌───────▼────────┐ | |
│ │ | |
│ Typedtree │ | |
│ │ | |
└───────┬────────┘ | |
│ | |
│ pattern-matching compilation | |
┌───────▼────────┐ elimination of modules and classes (patches to pass more information down to Lambda) | |
│ │ | |
│ OCaml Lambda ├──────────────────────────────────────────────────────┐ | |
│ │ │ | |
└───────┬────────┘ closure conversion, │ melange/original Bucklescript | |
│ inlining, uncurrying, ┌───────────┼─────────────────────────────────────────────────────────────┐ | |
┌──────────────────────┐ ┌────────────────┴────────────────┐ data representation strategy │ │ │ | |
│ │ │ │ │ ┌───────▼────────┐ │ | |
│ ┌────────────────┐ │ ┌──────▼─────────┐ ┌───────▼────────┐ │ │ │ 6 Lambda Passes (lam_* files) │ | |
│ │ │ │ │ │ │ │ │ │ Buckle Lambda │ Optimisation/inlining/dead code elimination │ | |
│ │ js_of_ocaml │◄─┼────┤ Bytecode │ │ CMM │ │ │ │ │ | |
│ │ │ │ │ │ │ │ │ └───────┬────────┘ │ | |
│ └───────┬────────┘ │ └──────┬─────────┘ └───────┬────────┘ │ │ self tail call elimination │ | |
│ │ │ │ ocamlrun │ │ │ Constant folding + propagation │ | |
│ │ │ │ │ │ │ │ | |
│ ┌───────▼────────┐ │ ┌──────▼─────────┐ ┌───────▼────────┐ │ ┌───────▼────────┐ │ | |
│ │ Javascript code│ │ │ │ │ │ │ │ │ │ | |
│ │ │ │ │ Interpreted │ │ Compiled │ │ │ Javascript IR │ 6 JS Passes (js_* files) │ | |
│ │ │ │ │ │ │ │ │ │ │ Optimisation/inlining/dead code elimination │ | |
│ └────────────────┘ │ └────────────────┘ └────────────────┘ │ └───────┬────────┘ │ | |
│ │ │ │ │ | |
└──────────────────────┘ │ │ Smart printer include scope analysis │ | |
│ │ │ | |
│ ┌───────▼────────┐ │ | |
│ │ │ │ | |
│ │ Javascript Code│ │ | |
│ │ │ │ | |
│ └────────────────┘ │ | |
│ │ | |
└─────────────────────────────────────────────────────────────────────────┘ | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment