r/lua • • Sep 25 '26

Help Luava: Looking for contributors to build a modern Lua engine on JVM (LuaJ alternative)

Hi everyone,

I'm building Luava, a Lua 5.4 implementation for the JVM in pure Java 21. No JNI or FFM, and the jar has no transitive dependencies. It's aimed at the same use case as LuaJ, but tracks the Lua 5.4 spec.

Current state: 0.2.1-beta on Maven Central. It has a register bytecode VM, a tiered JIT, sandboxing with instruction limits and timeouts, and a Java interop bridge. It runs the PUC Lua 5.4.9 test suite.

I'd like help with a few things:

- The bytecode compiler and the call path, especially calls into non-trivial protos.
- Unboxing the integer array part of `LuaTable` so mixed-key access stays allocation-free.
- Shrinking the JIT kernel so C2 can inline it, and cutting allocation in closure factories.

Repo: https://github.com/KienPC1234/luava

Feedback, code review, and PRs are all welcome.
4 Upvotes

6 comments sorted by

6

u/rjek Sep 25 '26

This feels... very LLM-generated.

2

u/Itchy_Association_46 Sep 25 '26

I only used an LLM for boilerplate stuff like tests, docs, and commits due to limited time. The JIT and core optimizations are entirely written by me.

2

u/zeaga2 Sep 25 '26

Why is your time limited? When is the deadline and why?

2

u/Itchy_Association_46 Sep 25 '26

no deadline, it's just a side project and i'd rather spend my limited free time writing core code than docs

5

u/PhilipRoman Sep 25 '26 edited Sep 25 '26

Despite the LLM generated documentation this actually looks pretty cool. I wrote a Lua-to-java compiler a long time ago (before LLMs were a thing) and because I didn't have time to write a full bytecode interpreter I just generated java source and compiled on the fly with 'janino' library which is obviously extremely inefficient for a JIT. In my implementation there was never any interpreter or dynamic JIT (aside from the JVM's own) involved, all chunks were compiled upfront to (mediocre) java code.

Out of curiosity I ran your benchmarks on both implementations and my version was 2x slower for fib(35) but ~3x faster for arith loop, table ops, string concat and hash table.

If I have some spare time, I will check out your code and try to understand how your JIT works.

1

u/burnt-store-studio Sep 26 '26

Nicely helpful! 🙂 and well done for having created your own!