Backends

The JIT and the ahead-of-time path, and where each one puts the machine code.

vlatest

There are two backends and they share most of their code. Both lower PickleIR to x86-64 machine code; they differ in where that code goes.

The JIT: pickle run

The JIT backend compiles for the host ISA and executes in the same process. No object file, no linker, no temporary binary.

Two code-generation settings are deliberate:

  • Code is not position independent. A symbol_value load becomes a plain absolute movabs rather than GOT-relative addressing, because there is no PIC runtime here to fill a GOT.
  • The machine-code verifier is off. Re-checking every generated function costs a fixed amount per function, which is noticeable on large modules. Backend bugs are caught by the test suite instead.

pickle run <FILE> [-- <ARGS>...] is the command. Anything after -- is surfaced to the program through the args() builtin, which returns List<string>.

Ahead of time: pickle build

build emits an object file and links it against the runtime:

pickle-cli build app.pkl -o app.exe

build takes exactly one option, -o / --output, which defaults to a path next to the source. The target is the host, native.

The link step needs the runtime and the generated program to agree on a panic strategy. The runtime is built for abort (it is also built with the nostd feature, which has no unwinding machinery), so the generated program has to be compiled the same way. Until both sides match, pickle run is the way to execute a program.

Runtime symbols

Both backends resolve the extern table against the runtime. Those symbols, pickle_print_i64, pickle_print_newline and the rest, are the entire interface between generated code and the runtime: allocation, the collector, printing, streams, files, processes and threads are all reached through externs rather than being inlined into the IR.