Skip to main content

Module native

Module native 

Source
Expand description

Running the machine code a .cdlb carries.

candela build compiles the functions it can to machine code and puts the code in the artifact beside the bytecode, one section per kind of machine (NativeImage). Loading a program picks the section this machine can run, copies its code into memory of its own, makes that memory executable (never writable and executable at once), and rewrites the calls the section covers so they call the machine code. Everything else runs on the interpreter, and any section that does not fit this machine, or memory the operating system refuses to make executable, leaves the whole program on bytecode, which is complete on its own.

The code reaches the VM only through a NativeCtx: the register file, the object pool, a few status words and the helpers it calls for anything the VM does itself. The contract between the two is versioned by abi::VERSION.

Modules§

abi
The contract between generated code and the VM: the layout of the context, the status codes, and the layout of an object in the pool.

Structs§

NativeCode
The machine code of a loaded program.
NativeCtx
What a native function and the VM share while it runs. One lives for each run of the interpreter, and every call into native code during that run reuses it.
NativeFunction
One function of the loaded code.

Functions§

load
Loads the first of sections this machine can run: maps its code, and rewrites the calls it covers in instructions. Answers None, leaving instructions as they were, when no section fits or the code cannot be made executable; the program then runs on bytecode alone.

Type Aliases§

Entry
The signature of every entry point: the context, and how far below the ceiling the function stands.