Code Monkey home page Code Monkey logo

jit-construct's Introduction

Interpreter, Compiler, JIT

This repository contains the programs used in Nick Desaulniers' blog post; an interpreter, a compiler, and a Just In Time (JIT) compiler for the brainfuck language. It is meant to show how similar these techniques are, and then improved by several students who learnt system programming to bring X86/ARM backend along with DynASM support.

Portability

While all three are written in C, only the interpreter should be portable, even to Emscripten. The compiler and JIT is highly dependant on the specific Instruction Set Architecture (ISA), and Linux style calling convention.

Prerequisites

Development packages for Ubuntu Linux Ubuntu:

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install gcc-multilib
sudo apt-get install luajit
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install qemu-user

Building

make

Running

The Interpreter

./interpreter progs/hello.bf

The Compiler

make run-compiler

The JIT

make run-jit-x86
make run-jit-x64
make run-jit-arm
make bench-jit-x86
make bench-jit-x64

License

Except the code in progs/ and dynasm/, the JIT-Construct source files are distributed BSD-style license found in the LICENSE file.

External sources:

  • DynASM is a tiny preprocessor and runtime for generating machine code at runtime and copyrighted by Mike Pall, released under the MIT license.
  • progs/mandelbrot.b is a mandelbrot set fractal viewer in brainfuck written by Erik Bosman.
  • progs/sierpinski.b is written by NYYRIKKI.
  • progs/awib.b is written by Mats Linander.
  • progs/hanoi.b is written by Clifford Wolf.
  • progs/oobrain.b is written by Chris Rathman

jit-construct's People

Contributors

coldnew avatar gic4107 avatar jserv avatar tony0620emma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jit-construct's Issues

Syntax misleading

According to page 8 in this slide. The left bracket ] is an unconditionally jump. But in the interpreter.c, I found the left bracket ] is translated to a conditionally jump.

error make

$ make
cc -Wall -Werror -std=gnu99 -I. -o interpreter interpreter.c
cc -Wall -Werror -std=gnu99 -I. -o compiler-x86 compiler-x86.c
cc -Wall -Werror -std=gnu99 -I. -o compiler-x64 compiler-x64.c
cc -Wall -Werror -std=gnu99 -I. -o compiler-arm compiler-arm.c
lua dynasm/dynasm.lua -o jit-x86.h jit-x86.dasc
jit-x86.dasc:4: error: cannot load module: dynasm/dasm_x86.lua:31: module 'bit' not found:
no field package.preload['bit']
no file 'dynasm/bit.lua'
no file '/usr/share/lua/5.3/bit.lua'
no file '/usr/share/lua/5.3/bit/init.lua'
no file '/usr/lib64/lua/5.3/bit.lua'
no file '/usr/lib64/lua/5.3/bit/init.lua'
no file './bit.lua'
no file './bit/init.lua'
no file '/usr/lib64/lua/5.3/bit.so'
no file '/usr/lib64/lua/5.3/loadall.so'
no file './bit.so':
|.arch x86
jit-x86.dasc:: error: missing .arch directive
jit-x86.dasc:
: info: fatal error in input file -- no output file generated.
Makefile:46: polecenia dla obiektu 'jit-x86.h' nie powiodły się
make: *** [jit-x86.h] Błąd 1

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.