Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.35 KB

compiler.adoc

File metadata and controls

45 lines (33 loc) · 1.35 KB

Notes on an OCaml to WASM Compiler

Table of Contents
Goals
  • bring the OCaml ecosystem to WASM

  • interoperate with some deliberately chosen other languages that compile to WASM (C would be a likely candidate, since interoperating with C seems to be common for OCaml code, but Rust might be interesting as well)

Choices

Note that some choices will not be compatible with each other. In the longer run, I want to turn this into a graph with all the combinations that could make sense together.

Targets
  • Web browsers

  • WASM→native compilers

  • WASM PaaS

Compilation output
  • Per-module compilation (needs a linker for the generated WASM modules)

  • monolithic binary (can potentially perform cross-module optimizations, if we even want that)

Source language
  • Lambda

  • Clambda

  • Cmm

  • Mach

  • Bytecode

Garbage collection
  • WASM GC

  • JavaScript GC

  • shipping our own GC as part of the runtime

Exceptions
  • WASM exceptions extension

  • exception stack frames (bytecode)

  • WASM multi-return extension (return sucess or exception)

  • CPS transformation (passing continuation and exception handler through all function calls)

Important Keywords

  • uniform value representation, boxed values, polymorphism, no monomorphization, no type argument passing

  • 31-bit tagged integers, garbage collector distinguishing unboxed integers and pointers (word-aligned)