Giter Club home page Giter Club logo

luajit-remake's Introduction

LuaJIT Remake Project

This is a work-in-progress.

The ultimate goal of this project is to implement a multi-tier method-JIT for Lua.

We employ an unique approach where the interpreter and the JIT tiers are automatically generated from a semantical description of the bytecodes. We believe this will ultimately result in less engineering cost, cleaner and more maintainable code, as well as the generalizability to support other languages.

Currently we have implemented:

  • A feature-complete Lua 5.1 interpreter, which is automatically generated from a semantical description of the LuaJIT bytecodes.
  • A completely re-engineered Lua runtime. For example, our implementation of the Lua table uses hidden class, instead of a naive hash table as in Lua/LuaJIT.

You might want to read this blog post to understand more about our design.

Interpreter performance comparison

On a variety of benchmarks, we demonstrate that our interpreter is 34.6% faster than LuaJIT's interpreter, and 185% faster than the official PUC Lua5.1 interpreter1.

The following figure illustrates our performance vs LuaJIT interpreter, normalized to PUC Lua's performance. Blue shadow indicates benchmarks where we do better than LuaJIT, and red shadow indicates benchmarks where LuaJIT does better than us.

The JIT

The work for implementing the JIT tiers is ongoing...

Building and Testing

To build the project, make sure you have docker and python3 installed, and run:

python3 ljr-build make release

Once the build is complete, you should see an executable luajitr in the repository root directory. You can use it to run your Lua script, or run bash run_bench.sh to run all the benchmarks.

Caveats

Please note that this is an ongoing project that is still far from production-ready.

It currently comes with a number of caveats:

  1. GC is not implemented. (For a fair benchmark comparison with other Lua implementations, we turned off GC for their implementations as well.)
  2. It currently can only run on x86-64 Linux. I need to focus on the functionality implementations first before thinking about portability to other architecture/OS.
  3. Some standard library functions, most notably the package library (require and module), are not implemented.

License

Apache 2.0.

Footnotes

  1. The benchmarks are run on my laptop with Intel i7-12700H CPU and 32GB DDR4 memory. All benchmarks are repeated 5 times. Reported numbers are the geometric average over all benchmarks. โ†ฉ

luajit-remake's People

Contributors

sillycross avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.