13 releases

Uses old Rust 2015

0.2.1 Jun 13, 2015
0.1.12 May 16, 2015
0.1.11 Feb 16, 2015
0.1.6 Jan 17, 2015
0.1.4 Dec 20, 2014

#925 in Programming languages


Used in 2 crates (via jit)

MIT license

6MB
121K SLoC

C 64K SLoC // 0.2% comments Bitbake 26K SLoC // 0.0% comments Shell 8K SLoC // 0.2% comments M4 7.5K SLoC // 0.2% comments Happy 6.5K SLoC Ruby 3K SLoC // 0.1% comments Pascal 2.5K SLoC // 0.0% comments Rust 1.5K SLoC // 0.0% comments C++ 1K SLoC // 0.3% comments Automake 331 SLoC

Contains (static library, 1.5MB) libjit/jit/.libs/libjit.a, (ELF exe/lib, 1MB) libjit/dpas/dpas, (ELF exe/lib, 685KB) libjit/jit/jit-rules-x86-64.o, (ELF exe/lib, 800KB) libjit/tutorial/t1, (ELF exe/lib, 1MB) libjit/tutorial/t2, (ELF exe/lib, 1MB) libjit/tutorial/t3 and 76 more.

JIT.rs

Build Status Latest Version

NOTE

Because LibJIT has been inactive for a year, it seems there won't be any more updates. On the other hand, LLVM is still very active, so I have been working on bindings for a couple of days now. There will be news soon about a replacement.

What is LibJIT?

LibJIT is a portable, lightweight JIT library developed by GNU in C. It aims to have an IR which is compatible with any language or runtime you throw at it, without forcing the programmer to use a specific one.

What's jit.rs?

jit.rs is a Rust library that wraps LibJIT in an idiomatic Rust way, which includes a macro for easy compilation of abritary types into JIT types. It also uses the Rust memory model to save some otherwide pointless operations that would me used if it were implemented in a GC language

Why are there so many packages?

  • libjit-sys - this contains the bindings to JIT functions, constants etc. If you want to stick to the original API, you should use this.
  • jit - this contains the Rust-style wrappers of the JIT functions and structures.
  • jit_macros - this contains the macro definitions that help to streamline code interacting with JIT.

How do I build this?

If you want to build this, you'll need to install these packages for Ubuntu or Debian:

sudo apt install autoconf automake texinfo libtool bison flex g++

Then, you can just use cargo to build it

cargo build

How do I use the macro?

Just annotate your types you want to pass into LibJIT like this

#[derive(Compile)]
struct Position {
  x: f64,
  y: f64
}

fn main() {
  ...
  let pos = Position {
    x: 5.0,
    y: -32.2
  };
  func.insn_return(func.insn_of(pos))
  ...
}

Are there any examples?

There's a Brainfuck virtual machine example with an nice command-line interface and everything. You can run it with this command from the project root:

cargo run --example brainfuck

You should then enter in the brainfuck code followed by a newline to run it.

> ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Hello, world!
>

You can also view its source code here.

Dependencies