docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

#9. Execution / tools overview

On this page

This block specifies the Nabi compiler nabic, the front-end nabi, and the execution environments (REPL / Jupyter kernel). It covers how the two engines (JIT / AOT) and the three user surfaces (REPL / Jupyter / direct execution of AOT output) defined in Execution engines and user surfaces are implemented.

#Contents

#Tool surface

The tool surface is organized as follows.

The toolchain consists of the compiler nabic (the counterpart of rustc), the cargo-style front-end nabi, the C compiler nabicc (9.13), the editor LSP executable nabils, and the runtime libnabir.a. nabi owns the manifest nabi.nabion / nabi.lock, dependencies, environments and the toolchain pin; build commands are delegated to nabic with the resolved dependency packages attached via --extern, and the tools run in nabi itself with the compiler linked in (9.10). There are no separate tools (nabi-fmt etc.).

#Implementation of the two engines

The two engines defined in Execution engines and user surfaces are divided as follows.

JIT engine  ──  used by nabi repl / jupyter
AOT engine  ──  used by nabic build / test, nabi run

Both engines go through the same compile pipeline (nabi-hir → nabi-mir → machine code) and diverge only in what happens to the code: loaded into a session's host, or linked into an executable. See Execution engines and user surfaces and Compile pipeline for details.

#Implementation of the three user surfaces

The three user surfaces and the commands that implement them are:

surface              command
────────             ──────
REPL                 nabi repl
Jupyter              nabi jupyter         (invoked by Jupyter, not directly)
AOT direct exec      nabic build → run artifact

The implementation of each surface is covered in the following documents.

#Package build output

A library package of a source unit compiles to libfoo.a and the interface foo.nabihir.

foo/
├── src/
│   ├── lib.nabi              <- input
│   └── ...
       v nabic build
foo/target/debug/
├── libfoo.a                 <- artifact (static archive)
├── foo.nabihir                 <- interface (NABIHIR)
├── build/                   <- intermediates (foo.o, ...)
└── ...

The per-profile layout is defined in 9.2.15, and the archive format in Package archive.

#NABIHIR: portable IR for generic functions

Generic functions must be monomorphized at the call site, so binary code alone is not enough. An interface file, NABIHIR, therefore sits next to the library. NABIHIR holds the package source with concrete function bodies stripped (because monomorphization takes the AST as input).

The detailed format is defined in NABIHIR format.

#Single dependency: libnabir.a

An executable links the user package's libfoo.a, the runtime libnabir.a, and the standard library functions it reaches, compiled from source with it or taken from the toolchain's function cache (9.3.6). There are no further dependencies beyond external OS libraries.

The detailed build flow is defined in AOT build pipeline.

Found a mistake? Edit this page on GitHub. Last updated