logoalt Hacker News

Retrofitting JIT Compilers into C Interpreters

88 pointsby ltrattyesterday at 12:00 PM21 commentsview on HN

Comments

9fwfj9rtoday at 5:02 AM

Those interested in this type of work can also visit https://cfallin.org/blog/2024/08/28/weval/. The difference is that they use this technique to derive an AOT compiler.

fuhsnnyesterday at 11:35 PM

Took me a while to figure out whether it's interpreters for C programs or if there's a particular class of interpreters called "C". Turns out it's about interpreters implemented in C that they use modified LLVM to do the retrofitting, but couldn't it be applicable for other languages with LLVM IR, or other switch-in-a-loop patterns in C?

show 1 reply
djwatson24today at 12:09 AM

It's quite impressive they're able to take nearly arbitrary C and do this! Very similar to what pypy is doing here, but for C, and not a python subset.

However not without downsides. It sounds like average code is only 2x faster than Lua, vs. LuaJit which is often 5-10x faster.

show 1 reply
pjmlptoday at 7:31 AM

I find rather strange the complaint about compatibility across JIT implementations, there is exactly the same problem across any programming language with multiple implementations, interpreters, compilers, JIT, whatever.

edmondxtoday at 7:44 AM

Sounds very promising. Although right now I’m working on a project together with MLIR.

linzhangruntoday at 2:30 AM

It's truly a good thing to see a project like this in the era of Vibe Coding taking flight :)

measurablefunctoday at 4:18 AM

Why do they need to change LLVM? Why can't they make this another LLVM IR pass?

show 1 reply
sgbealyesterday at 12:36 PM

i tend to think of myself as a computing nerd, but posts like this one make me realize that i don't even rate on the computing nerd scale.

show 1 reply
mwkaufmayesterday at 11:35 PM

TL;DR compile with a fork of LLVM that enables runtime IR tracing. Very clever!