rbartlensky / Lua-interpreter

A Lua interpreter in Rust
5 stars 2 forks source link

Improve performance #2

Closed rbartlensky closed 6 years ago

rbartlensky commented 6 years ago

One of the main changes is that the bytecode is now immutable. It is not possible to add or remove instructions from it.

Another change in the structure of the bytecode is that it does not keep track of registers any more. The original decision didn't make much sense, so now the bytecode only records the number of registers that are used by the instructions (represented by reg_count).

The interpreter now keeps track of all registers, and their values.

These changes are important because the interpreter can now get references to bytecode instructions, while before the instructions were always copied. The performance is also improved by the fact that the calls to bytecode.set/get_value have been removed. All register manipulation is done inside the interpreter.