💾 Archived View for vierkantor.com › xukut › manual › compiler.gmi captured on 2024-07-08 at 23:32:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-10)

-=-=-=-=-=-=-

XukutOS manual → Compiler

The default XukutOS distribution includes a compiler for Swail, based on the assembler.

More information about the assembler.

(aarch64:compile fn) -> fn

Compile a callable object (in particular, an interpreted function defined with the `swail:fn' special operator). Returns a function that does exactly the same as the input `fn', except (hopefully) faster.

If `fn' is not callable, this raises an error. If `fn' is callable but not supported by the compiler (for example, because it has already been compiled), `compile' will return the original `fn'.

Some notes on the compiler's implementation

The compiler is essentially a copy of the interpreter, except it emits the code that the interpreter would execute. Thus, there is almost no optimization going on except for ensuring the basic code blocks are somewhat sensible.

Lexical scope, such as variables and macros, are passed around in a `context' object. The context is basically the same thing as the binderlists implementing lexical variables in the interpreter, except it saves metadata about a variable in the place of the variable's value. This metadata can be:

* `nil': a normal lexical variable

* a `macro' object: the variable's name should be compiled as a macro, using the implementation stored in the `macro' object.

The the result of compiling is a `fn-oarcc', which means that the function expects to be called using the OARCC calling convention. The use of this type is likely to change: in particular, it might be changed to store information such as the original's source code (for recompilation when an inlined function changed).

The calling conventions used by XukutOS

Any questions? Contact me:

By email at vierkantor@vierkantor.com

Through mastodon @vierkantor@mastodon.vierkantor.com

XukutOS user's manual

XukutOS main page