No description
  • Rust 71.2%
  • C 18.9%
  • Zig 4.3%
  • C++ 2.2%
  • Nix 1.8%
  • Other 1.6%
Find a file
2026-10-21 17:18:01 +03:00
.cargo rust target-cpu native 2026-10-08 22:14:17 +03:00
.helix more modern c and attempts at optimization 2026-10-08 21:44:53 +03:00
benches the great rename 2026-09-27 16:51:02 +03:00
c cleanup and flake update 2026-10-10 17:59:54 +03:00
fuzz the great rename 2026-09-27 16:51:02 +03:00
src test 2026-10-21 17:18:01 +03:00
tests cleanup and dep/toolchain updates 2026-09-28 01:44:35 +03:00
tree-sitter-cefre add helix grammar install commands 2026-10-03 15:06:49 +03:00
zig more renaming 2026-10-10 16:34:47 +03:00
.gitignore cleanup and dep/toolchain updates 2026-09-28 01:44:35 +03:00
build.rs more renaming 2026-10-10 16:34:47 +03:00
Cargo.lock cleanup and dep/toolchain updates 2026-09-28 01:44:35 +03:00
Cargo.toml cleanup and dep/toolchain updates 2026-09-28 01:44:35 +03:00
commands.txt the great rename 2026-09-27 16:51:02 +03:00
DESIGN.md feat(mir,asm): add xor, fix variable dropping in certain contexts 2026-05-22 19:43:28 +03:00
flake.lock more renaming 2026-10-10 16:34:47 +03:00
flake.nix output cefre.so to $out/lib/ instead of $out directly 2026-10-03 15:20:30 +03:00
random.bin wip 2026-08-10 23:50:22 +03:00
README.md the great rename 2026-09-27 16:51:02 +03:00
rust-toolchain.toml more renaming 2026-10-10 16:34:47 +03:00
rustfmt.toml wip 2026-07-28 13:16:52 +03:00

Pálinka

A very basic 64-bit, big-endian, stack-based VM, with a custom assembly language and low-level programming language, cefre, that compiles to it.

The assembly is largely feature-complete, aside from some missing opcodes that I haven't implemented yet (mainly bitwise operators).

The cefre MIR is also nearly feature complete:

  • Basic expressions
  • Control flow (if/else-if/else)
  • Loops with labelled break/continue
  • Function definitions
    • Multiple return values and the spread operator to use them inline in one expression
  • Access to all VM functionality (currently missing all the read/write/dread widths as I haven't gotten around to it yet)
  • Inline assembly and/or naked functions

The goal with cefre is to use it as a target for a higher level programming language in the future, to allow for an easier target than using the assembly directly. A work-in-progress design doc for this language can be found in ./DESIGN.md.

A tree-sitter grammar for cefre can be found at ./tree-sitter-cefre.

There are currently 4 implementations (all available in the palinka binary via the -i flag): two in rust (the canonical implementation and one using tail calls), one in zig, and one in C. Currently, the C implementation is the fastest; the functionality is described well in more detail here.

Wtf is Pálinka?

Pálinka is a Hungarian fruit spirit (similar to brandy), and cefre is the fruit mash that is fermented and then distilled into pálinka.

Performance

A basic mini benchmark can be run with nix run .#mini-benchmark.

Current results, on an M5 MacBook Pro:

Running rust...
time: 0.896774409
total cycles: 958145849
output: d239b78c b239ce12 85fdfb06 5e78f8d5 e51246c0 23871c2f 76b8e3bb 581a9623

real    0m0.899s
user    0m0.897s
sys     0m0.002s

Running rust-tc...
time: 1.110165928
total cycles: 958145849
output: d239b78c b239ce12 85fdfb06 5e78f8d5 e51246c0 23871c2f 76b8e3bb 581a9623

real    0m1.111s
user    0m1.110s
sys     0m0.001s

Running zig...
time: 1.558818126
total cycles: 958145849
output: d239b78c b239ce12 85fdfb06 5e78f8d5 e51246c0 23871c2f 76b8e3bb 581a9623

real    0m1.560s
user    0m1.559s
sys     0m0.001s

Running c...
time: 0.751701267
total cycles: 958145849
output: d239b78c b239ce12 85fdfb06 5e78f8d5 e51246c0 23871c2f 76b8e3bb 581a9623

real    0m0.752s
user    0m0.752s
sys     0m0.000s

AI Disclosure

Absolutely no AI was used in the making of this project, and it never will. Every line of code, every bug, every fix, every line of documentation (although strikingly lacking), was written by me. AI contributions are not welcome.