How ocaml/ocaml works
OCaml is a statically typed functional language distribution with bytecode and native compilation. Its principal user workflow is to compile a program, then either run bytecode through the interpreter or execute native code; it also offers a bytecode REPL. The tree excerpt is runtime-heavy and omits the compiler implementations, so compiler-stage wiring is based on the README, not sampled source. Runtime components below reflect the available paths and documented domain, dynamic-loading, Unix, and event capabilities; their detailed call relationships were not fully sampled.
Main entry points: interp.c Bytecode interpreter · startup_byt.c Runtime startup · opcodes.ml.c Bytecode compiler · main.c Runtime entry
Components 20
Compilation
- Bytecode compiler
bytecomp/opcodes.ml.c - Native compiler
- Bytecode program
- Native program
- Interactive REPL
Runtime execution
- Runtime entry
runtime/main.c - Bytecode interpreter
runtime/interp.c - Runtime startup
runtime/startup_byt.c - Memory allocation
runtime/alloc.c - Minor collector
runtime/minor_gc.c - Major collector
runtime/major_gc.c - Dynamic loading
runtime/dynlink.c - Loaded code registry
runtime/codefrag.c
Concurrency
- Domains and fibers
runtime/domain.c - System threads
otherlibs/systhreads/st_stubs.c
System interfaces
- Unix interface
otherlibs/unix - Runtime events
runtime/runtime_events.c - Event consumer
otherlibs/runtime_events/runtime_events_consumer.c
Other components
- OCaml developer
- Operating system
Connections 20
- OCaml developer → Bytecode compiler: compiles bytecode
- OCaml developer → Native compiler: compiles native
- Bytecode compiler → Bytecode program: emits bytecode
- Native compiler → Native program: emits native code
- OCaml developer → Interactive REPL: uses interactively
- Bytecode program → Runtime entry: runs with
- Runtime entry → Runtime startup: starts runtime
- Runtime startup → Bytecode interpreter: enters interpreter
- Native program → Runtime startup: starts runtime
- Bytecode interpreter → Memory allocation: allocates values
- Memory allocation → Minor collector: requests collection
- Minor collector → Major collector: promotes work
- Runtime startup → Domains and fibers: initializes domains
- Domains and fibers → System threads: coordinates threads
- Dynamic loading → Loaded code registry: registers code
- Bytecode interpreter → Dynamic loading: loads modules
- Bytecode interpreter → Unix interface: calls system API
- Unix interface → Operating system: uses services
- Runtime events → Event consumer: publishes events
- Event consumer → Operating system: reads event ring