r/Compilers • • Oct 20 '26

JIT Tuning at Runtime using LLM Agent

0 Upvotes

Hi all,

I have created a proof of concept that uses LLM agent to suggest performance at runtime. It proposes compiler directives based on JEP 165. These directives are then ingested by C2 to create optimized code.

Here is the link to full blog post: https://chains.proj.kth.se/llm-jit-agent/

Looking forward to a nice discussion here :)


r/Compilers • • Oct 19 '26

Towards Umka 2.0: Replacing reference counting with mark-and-sweep gives measurable performance gain

13 Upvotes
Software rendering profiling results

I've been developing the statically typed scripting language Umka for 6+ years. The limitations of reference counting used in Umka 1.x have become so obvious that replacing it with a mark-and-sweep garbage collector is now the key change made to the upcoming Umka 2.0.

The interpreter architecture has got cleaner. With many ad hoc fixes and workarounds having become redundant, the codebase is now 10% smaller. Freeing reference cycles is no longer a problem, so the weak pointers, arguably the most counterintuitive feature in a simple scripting language, are deprecated. It shouldn't be the user's responsibility to avoid memory leaks: the less the cognitive burden, the more attractive the language for a novice.

As Umka is used in the Tophat 2D game framework, I measured the impact of this change on rendering performance in my Hover! maze demo in "strabismic" mode, with two overlapping scenes rendered independently from different view angles. It would take 28 ms per frame with reference counting vs. only 22 ms (including 4 ms for garbage collection) with mark-and-sweep. I forced garbage collection at the end of each frame, but could have done it much less frequently to save more time.

Theory suggests that the average CPU time spent on reference counting and mark-and-sweep should be roughly equal. However, the redundant reference counting instructions injected into Umka 1.x bytecode to ensure memory safety in rare edge cases cost a lot.

Surprisingly, the most intricate part of this transition to mark-and-sweep was escape analysis that prevents pointers to local variables from escaping the function stack frame after the function returns. It eventually required a kind of rudimentary reference counting targeted specifically at escaping references. These reference counts are touched much less often, only on detecting escape suspects, so they don't affect performance, except some contrived examples. Hope I'll be able to come up with an even better solution by the Umka 2.0 release.


r/Compilers • • Oct 19 '26

Built an open-source visual workbench for parsing algorithms

Post image
12 Upvotes

I've been developing AutomataLab, a desktop application for exploring formal languages and computational models.

Its Parser Studio supports LL(1), LR(0), SLR(1), CLR(1), LALR(1), CYK, and Earley parsing, with visualizations of parse tables, LR item sets, and parsing steps.

It also includes:

  • Machine Studio: Interactive simulations of finite automata, PDAs, and Turing machines.
  • Grammar Lab: Grammar analysis, classification, derivations, and transformations.
  • Conversions: Transformations between supported computational models and formal representations.

Built with Tauri, React, TypeScript, and Rust, the goal is to make theoretical concepts easier to explore and understand.

GitHub: https://github.com/reeshavsinha/AutomataLab
Website: https://automata-lab-one.vercel.app

I'd appreciate feedback, especially on the parser implementations, visualizations, and features useful for compiler construction.

Note: The Windows build may show a Microsoft Defender SmartScreen warning because the application is not code-signed. Please verify downloads through the official GitHub repository.


r/Compilers • • Oct 20 '26

How I solved the object identity for NaN-boxed values?

Post image
0 Upvotes

Something new about my runtime 🐱.

With NaN boxing, x = 1.5 and y = float("1.5") are the same 64 bits. CPython says x is y is False, and there is no room left in the value to tell them apart.

Edge's design treats identity as history instead of bits. SSA already gives every definition its own number, so is just compares versions at compile time.

If the value went through the heap, the VM is deterministic, so it replays that stretch once and records where each value came from.

Normal code pays nothing for this optimization.

Right now I'm working on the next big challenge, inferring a few of types with RVSDG and compiling Python to LLVM to get close to C speed.


r/Compilers • • Oct 19 '26

Recompiling Game Boy machine code to Haxe, and checking every block against an interpreter in lockstep

10 Upvotes

I work since a while on gb2swf, a static recompiler that takes Game Boy (SM83) machine code and turns it into Haxe, which then compiles to a Flash SWF that runs in Ruffle. Yes, Flash. But the part that fits this sub is the recompiler so thats what this post is about

The classic problem with static recompilation of old console code is that you dont know what is code and what is data, and you dont know all jump targets (jp hl, jump tables). So I dont try to find it statically. The ROM first runs on an interpreter in Node.js, once without input and four times with random button presses, 6000 frames each, and it records every executed instruction and every jump target. Only blocks that were actually seen get recompiled.

Codegen: every basic block becomes Haxe with the SM83 registers as local variables. Blocks are grouped into functions, so one block flows into the next without going back through a dispatch loop. The original instruction stays as a comment above each generated line so the output is still readable.

The verification is the part I would like feedback on. The game runs on the interpreter and on the recompiled code side by side with three input sequences, one of them the profiler never saw. At every block entry the registers and the cycle count have to match, and every frame has to match. If a block diverges it goes back to the interpreter and the check runs again, so a mismatch never ends up in the output. Code the profiler never reached also stays on the interpreter, the game always runs, unseen paths are just slower.

Interpreter and recompiler are both generated from one description of the instruction set so they cant drift apart. Memory accesses happen on the correct cycle inside each instruction, otherwise the cycle check would mean nothing.

Numbers on 7 open licensed homebrew games (M1, Ruffle in headless Chrome, input the profiler hadnt seen): 79 to 98% of executed instructions run as recompiled code, and a frame takes 6 to 11 ms of the 16.7 ms budget.

What still bothers me:

- the 2 to 21% that stays interpreted is mostly code behind rare input. You can record your own play and feed it back with `gb2swf --record`, on itself that works but its not really a solution

- lockstep only proves the two are equal on the inputs I tried, nothing more

Did someone here do something like this for another ISA? Mostly curious how you handled coverage, is there something smarter then random button mashing...

I made this, its MIT and the repo is public on the Burg Media github (no ROMs included ofcourse)


r/Compilers • • Oct 19 '26

Borrow Checking Zero-Cost Cyclic Mutability

Thumbnail antelang.org
5 Upvotes

r/Compilers • • Oct 20 '26

Why doesn't the compiler detect better instructions?

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Oct 20 '26

COMPRINLY vs NASM vs C

Thumbnail github.com
0 Upvotes

I benchmarked all three languages with their standard commands and the standard scripts without any made optimizations in the scripts.

The benchmark is Compile, Run, and Size.

Hello, World!:

Language - Compile - Run - Size

C (GCC 13.3) - 35.5 ms - 2.3 ms - 15,960 bytes

NASM 2.16 with LD - 6.4 ms - 1.5 ms - 8,864 bytes

COMPRINLY 1.3.2 - 9.6 ms - 1.5 ms - 274 bytes (Old version was 290 bytes)

Count primes below 300,000:

Language - Compile - Run - Size

C (GCC 13.3) - 38.6 ms - 50.2 ms - 15,960 bytes

NASM 2.16 with LD - 6.6 ms - 48.4 ms - 5,032 bytes

COMPRINLY 1.3.2 - 10.7 ms - 48.4 ms - 361 bytes

You could test Comprinly for this if you doubt the benchmark, I have no testers.

Overall:

Compile Speed - NASM

Run Speed - NASM and Comprinly

Size - Comprinly

You can try Comprinly in the linked repo


r/Compilers • • Oct 19 '26

tvm-recover: lifting virtualized x86 semantics into LLVM and recompiling to native code

3 Upvotes

I've published tvm-recover, a Tencent VM devirtualizer built around a recovery frontend and an LLVM reconstruction backend.

The compiler angle is what I wanted to share here: the input is a protected binary rather than source code. The frontend follows VM handlers, tracks guest register and memory effects, simplifies expressions algebraically, and reconstructs control flow. It emits a guest-level listing that the backend translates into LLVM IR and compiles into native analysis code.

The pipeline looks like this:

Protected PE → semantic recovery → guest IR → LLVM IR → native payload → patched PE

The repository includes an interpreter and a differential harness for comparing the compiled payload against the listing interpreter, plus PE/PDB tooling for inspecting the result in conventional reverse-engineering tools.

It's still a prototype, with known semantic issues being worked through. Differential agreement checks the backend against the interpreter; it doesn't independently prove equivalence to the original binary.

I'd especially welcome feedback on the boundary between the recovery IR and LLVM, and on testing a compiler pipeline whose frontend starts from obfuscated machine code.

Code and screenshots: https://github.com/NeuroSaki987/tvm-recover


r/Compilers • • Oct 19 '26

Are there any libraries for optimizing generated Java code?

2 Upvotes

Hi,

I’m working on a compiler at my company that generates Java code represented as a custom AST, then uses ASM to produce JVM bytecode.

I’d like to apply optimizations to this AST, or convert it to a standard AST representation if needed. Are there any libraries that support optimizations such as constant folding, dead code elimination, and factoring out duplicated code?

As an alternative, I’m considering targeting LLVM IR, although this would introduce other challenges, particularly around memory sharing and interoperability with the JVM. Do you know of any libraries or tools that can translate Java code or JVM bytecode into LLVM IR?


r/Compilers • • Oct 19 '26

Tridentix v0.1.0 — Custom Systems Language (LLVM Backend

3 Upvotes

Hey guys,

Been working on a custom systems language called Tridentix for a while now, and just published the initial v0.1.0 code on GitHub.

It's built with Rust, has a custom hand-written lexer/parser frontend, targets LLVM, and comes with Docker support for testing. Added the design specs and initial codebase in the repo.

Would love some honest feedback on the VM specs and compiler structure from fellow language dev folks. Thanks!


r/Compilers • • Oct 18 '26

Trials and Tribulation of Native Lua Compilation

Thumbnail samyeyo.github.io
9 Upvotes

r/Compilers • • Oct 19 '26

How to test my language compiles on multiple platforms, before committing to github?

0 Upvotes

I've been trying to get my compiler (Speedie) working on Mac and Linux.

Now... I had it working in the past, but it got broken by simple additions like a (C++) function that returns an ivec4, but linux's gcc (unlike clang for MacOS) does not allow a ivec4 to be returned like this:

return {1.0f, 1.0f, 1.0f, 1.0f};

It needs this:

return (ivec4){1.0f, 1.0f, 1.0f, 1.0f};

So... something as simple as this can break my builds. My compiler works on my Mac perfect, but can't even compile on Linux.

Even worse, is something like my current situation. My compiler is acting differnetly on Linux. And I don't know why.

So I've been uploading "bad builds" to github, not realising. So I need to get it reliable for Mac and Linux, or theres no point trying to have a popular language.

I don't want to be manually testing each time, via VirtualBox. I want something automated.

Secondly... how do i even debug my app on linux? haha. Maybe The RAD Debugger is good? I don't know.

All I know is that, even after getting it compiling, it is behaving differently, but I don't know why.

...

If anyone wants to help me with this debugging, let me know. I'm available on discord / telegram if you don't mind me bugging you with questions?


r/Compilers • • Oct 18 '26

A New Way to Think About Borrow Checking (In Reverse)

Thumbnail verdagon.dev
5 Upvotes

r/Compilers • • Oct 17 '26

JS formatters and transformer bugs abused to change script logic (186 techniques across 37+ libraries such as ESBuild, AString, SWC)

11 Upvotes

A formatter, minifier or deobfuscator can be made abused to change the entire logic.

You can go try out all 186 techniques with this script: https://divergence.trustsig.eu/

Or try the Tetris-Snake demo here (Tetris runs normally, copy the formatted output from even just DevTools and it becomes Snake): https://divergence-game.trustsig.eu/

Blog/writeup post: trustsig.eu/blog/javascript-divergence/


r/Compilers • • Oct 17 '26

Function calls in Python compiler went from 893 to 85 instructions

38 Upvotes

Hey everyone :)

Here I am after 8 months on the roadmap of Edge Python, my own Python compiler.

I want to share a small optimization I implemented for all function and object calls.

Compilers usually inline leaf functions, where the theoretical best is around 80 VM instructions.

A normal call in Edge Python cost 893 and for CPython 300 instructions.

Working on this problem I got it down to 85, with the body running inline and no frame.

For recursion I used reversible computation. Each call applies a step like n -> n - 1 and each return undoes it with n -> n + 1, so no frames are needed. Applying the same pattern to the other paths keeps all of them below 90 instructions.

I also removed the slow path completely. It now works for try and any kind of objects or functions.

Just want to show this is not a new algorithm but all this months studying runtimes and building edge python I didn't see anything similar.


r/Compilers • • Oct 17 '26

nullptr, zero initialization, is zero checks design question

10 Upvotes

Hi,

I'm working on mox (low level + metaprogramming) and currently in mox I have zero initialization for everything. For example:

x: T = 0;
x: []T = 0;
x: [10]T = 0;

Zero initializes the value. If T is struct, all fields gets zeroed, if it is fixed array, all elements are zeroed, if it is slice, it has ptr=0, len=0.

But the problem and question is with pointers. At first I thought adding explicit type for nullable pointers is a good thing. Because then you have explicit and readable contract on function arguments and you possibly could have some optimizations or checks in compiler. Because of this, not nullable pointer could not be initialized with zero (because it is semantically wrong).

But while I was writing in C++ and in mox I found that I never ever used nullable pointers. And not able to zero any pointer type just makes more headache. Having nil like in Odin instead of 0 makes not much sense for me. You just write more letters and think more about some special nil while 0 clearly says that you zero the value.

nullptr problem currently solved by having nullptr function:

fn foo(x: *i32) {}
fn foo(x: i32) {}

foo(nullptr(i32));

And in case we need zeroed value with expression, I have zeroed function:

fn foo(x: Smth) {}

foo(zeroed(Smth));

So the question is, what do you think about having explicit nil for zeroing and nullable pointers? How often do you really use it? Are there any other problems/things that I dont see here?


r/Compilers • • Oct 17 '26

Mucc: a self hosting C compiler in one static binary, with its own assembler, linker and musl (x86-64 and ARM64 Linux)

33 Upvotes

Mucc is a small C compiler for Linux that ships as a single 8.5 MB static file. The preprocessor, assembler, linker, archiver, headers and C library (musl, like zig cc does) are all built in, so you can drop it into an empty container, an old distro or a Raspberry Pi and build C with nothing else installed: no gcc, no binutils, no system headers. 

Programs it builds are static, so they run on any x86-64 Linux. There's a native ARM64 build too, and it can cross-compile between the two.

The whole project actually started as a fork of Rui Ueyama's chibicc. I felt more could be done on this design. So now Mucc adds its own assembler and linker, an ARM64 backend, register allocation, the bundled musl, DWARF debug info, C23 support and a reproducible bootstrap chain.

What’s actually working so far 

- C17 by default, C23 with `-std=c23`, plus the GNU extensions real code uses

- Self-hosting: each release is built by the one before it, and a Mucc-built Mucc produces byte-identical output

- Real projects build and pass their own test suites: SQLite, Lua, zlib, jq, Redis and Tcl with the bundled musl; CPython and Git with the system glibc

- Same ABI as gcc, so objects from either link together

- Compiles its own 33k lines in 0.46 s (gcc -O0: 1.22 s, gcc -O2: 5.35 s)

What’s currently not working, it does no optimization beyond register allocation and constant folding, so programs run about as fast as gcc -O0. No C++, Linux only. For performance-critical code, use gcc or clang.

If you've got C code it chokes on, or a use for it I haven't thought of, I'd like to hear it.

GitHub: https://github.com/Dom-Yan/Mucc

Website: https://dom-yan.github.io/Mucc/

Thanks to Rui Ueyama for chibicc, and to Fabrice Bellard, whose TinyCC showed how much a small compiler can do.


r/Compilers • • Oct 17 '26

code optimization

0 Upvotes

ive seen that compiler middle end optimized code,

how do i optimize that code without the compiler; and then the

compiler takes less time doing it for me.

ie; i change some loops to be better, and change ome if statments to add less conditions


r/Compilers • • Oct 17 '26

The Promo Video for The Pie Programming Language

Thumbnail youtu.be
0 Upvotes

r/Compilers • • Oct 16 '26

SentryWard: Formal Verification of Warp-Specialized GPU Kernels

Thumbnail sentryward.io
6 Upvotes

r/Compilers • • Oct 16 '26

Bandedness Propagation Analysis of Tensor Compilers

Thumbnail homepages.dcc.ufmg.br
5 Upvotes

r/Compilers • • Oct 17 '26

Brinch Hansen Compier 'emit' routine problem

1 Upvotes

Just for fun I am implementing the sample compiler in the appendices of 'Brinch Hansen on Pascal Compilers' - as a first step.

One puzzle: he uses a procedure named emit to write to files: (pg 242)

procedure emit(value: Integer);

begin if emitting then write(chr(value)

end;

But this procedure is used to write integers up to his maxint of 32767. No Pascal I know has chr() available for arguments > 255.

Is this something special in his OS or bootstrapping compiler, Pascal* ?

TIA

Gordon


r/Compilers • • Oct 16 '26

How would you go about translating programming language keywords, documentation and error messages to other non-English languages?

7 Upvotes

Take Python for instance.

>>> listss = [1, 2, "sfd"]
>>> kook = listss + 2
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    kook = listss + 2
           ~~~~~~~^~~
TypeError: can only concatenate list (not "int") to list
>>>

How would I translate all the results given to me by Python into another language of my choosing, and get something like below (written in Kinyarwanda):

>>> listss = [1, 2, "sfd"]
>>> kook = listss + 2
Ibisobanuro (Ihamagarwa rya mbere riri hejuru yurutonde):
  Inyandiko "<python-shyira-1>", umurongo wa 1, muri <igitabo>
    kook = listss + 2
           ~~~~~~~^~~
Ikosa ry'ubwoko: urutonde ugendana nurundi rutonde; ntabwo rugendana numubare wuzuye.
>>>

The intention is not to create custom messages, exceptions, and documentation that sits beside or on top of python. I want python itself to respond like this, from the get-go?

I would like the translation to be complete. CLI options, help messages, information on built-in modules, keywords, everything.

While thinking about this, I realized that the end result would just be a completely new language, and I'm fine with that, but I also don't know enough about creating languages or where to get the source code of an existing language to translate it to a new language, so I come here to ask for guidance.