lunar_wave/README.md

67 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2023-09-27 19:13:56 +00:00
[LunarWaveVM](https://six-five-six-four.com/git/reactor/lunar_wave_vm) is a [Lua 5.4](https://www.lua.org/) virtual machine written in Rust.
2023-09-27 18:58:37 +00:00
2023-09-27 19:05:03 +00:00
![A star field with an orange crab-shaped nebula facing a dark purple moon with a bright magenta crescent.](pictures/lunar%20wave%20crab%20nebula.jpeg)
2023-09-27 18:58:37 +00:00
`luac5.4 -o - test_vectors/fizz_buzz.lua | cargo run -- --pipe-bytecode`
2023-09-27 19:06:54 +00:00
```
1
2
3 Fizz
4
5 Buzz
6 Fizz
7
...
44
45 FizzBuzz
46
47
48 Fizz
49
50 Buzz
```
2023-09-27 18:58:37 +00:00
# Roadmap
- [x] Loading simple pre-compiled bytecode programs
- [x] Hash tables
- [x] Fizzbuzz
- [ ] Closures
- [ ] Error handling
2023-09-27 18:58:37 +00:00
- [ ] Garbage collection
- [ ] Long strings
- [ ] Using arrays internally for tables
- [ ] Compiling Lua source code to bytecode
2023-10-01 07:00:23 +00:00
# Benchmark
9x slower than PUC Lua, 90x slower than LuaJIT.
Based only on the n-body simulation from the computer language benchmarks,
because it's easy to run.
```
time target/release/lunar_wave_vm --script test_vectors/n_body.lua -- 500000; time lua test_vectors/n_body.lua 500000; time luajit test_vectors/n_body.lua 500000;
-0.169075164
-0.169096567
[src/main.rs:110] x = []
real 0m10.543s
user 0m10.535s
sys 0m0.000s
-0.169075164
-0.169096567
real 0m1.173s
user 0m1.165s
sys 0m0.004s
-0.169075164
-0.169096567
real 0m0.117s
user 0m0.116s
sys 0m0.000s
```