Compare commits

..

No commits in common. "5331b5a4d2e49c7f8bed8ac98542d475e3523384" and "c50c16b9dbc54ac6b764a88c35242ab386f36d8f" have entirely different histories.

5 changed files with 3 additions and 57 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
/flamegraph.svg
/luac.out
/perf.data*
/target
/untracked

View File

@ -10,12 +10,3 @@ edition = "2021"
# blake3, used to hash test vectors
blake3 = "1.5.0"
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
# Recommended for flamegraph
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]
[profile.release]
# Recommended for profiling, e.g. flamegraph
debug = true

View File

@ -34,33 +34,3 @@
- [ ] Long strings
- [ ] Using arrays internally for tables
- [ ] Compiling Lua source code to bytecode
# 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
```

View File

@ -508,7 +508,7 @@ impl <'a> State <'a> {
let value = {
let table = self.reg (*b).as_table ().expect ("GetI only works on tables").borrow ();
table.get_int (key)
table.get (key)
};
*self.reg_mut (*a) = value;
@ -752,7 +752,7 @@ impl <'a> State <'a> {
let mut dst = self.reg_mut (*a).as_table ().expect ("SetI only works on tables").borrow_mut ();
dst.insert_int (i64::from (*b), value);
dst.insert (i64::from (*b), value);
},
Instruction::SetList (a, b, c, k) => {
if *b == 0 {
@ -766,7 +766,7 @@ impl <'a> State <'a> {
for i in 1..=*b {
let src = self.reg (*a + i);
dst.insert_int (i64::from (*c + i), src.clone ());
dst.insert (Value::from (i64::from (*c + i)), src.clone ());
}
},
Instruction::SetTabUp (_a, _b, _c) => unimplemented! (),

View File

@ -261,16 +261,10 @@ impl Table {
self.get_inner (&(key.into ()))
}
pub fn get_int (&self, key: i64) -> Value {
self.get_inner (&(key.into ()))
}
fn insert_inner (&mut self, a: Value, b: Value) {
self.hash.insert (a, b);
}
/// Insert value at arbitrary key
pub fn insert <A: Into <Value>, B: Into <Value>> (
&mut self,
a: A,
@ -279,13 +273,6 @@ impl Table {
self.insert_inner (a.into (), b.into ())
}
/// Insert value at integer key
pub fn insert_int <A: Into <Value>> (&mut self, k: i64, v: A)
{
self.insert_inner (k.into (), v.into ())
}
pub fn length (&self) -> i64 {
for i in 1..i64::MAX {
if self.get (i) == Value::Nil {