Giter Site home page Giter Site logo

wtf_toolchain's Introduction

Ohhhh, brainfuck again, srsly?

Why?

This is my attempt to build a JIT powered BF interpreter using RPython toolchain. In order to make it even faster I have build a simple compiler, that generates flat and slightly optimized version of original *.b program.

Preparation

First things first, start with building the VM itself, PyPy toolchain is required.

python pypy3-v5.5.0-src/rpython/bin/rpython -Ojit bin/wtf_runner.py 

This should produce native wtf_runner-c binary - BF VM, yes.

Run

  • First build VM compatible representation:
$ wtf_compile -i src/mandelbrot.b -o mandelbrot.wtf
  • Run it with wtf_runner-c
~/workspace/bf $ time ./wtf_runner-c hanoi.wtf > /dev/null
real	0m0.370s
user	0m0.344s
sys	0m0.024s

~/workspace/bf $ time ./wtf_runner-c mandelbrot.wtf > /dev/null
real	0m3.143s
user	0m3.120s
sys	0m0.020s

In comparison to one of the fastest optimizing interpreters (written in pure C, ofc) I have found on the Internet:

~/workspace/bf $ time ../bff/bff src/hanoi.b > /dev/null 
real	0m0.537s
user	0m0.532s
sys	0m0.004s

~/workspace/bf $ time ../bff/bff src/mandelbrot.b > /dev/null 
real	0m4.777s
user	0m4.776s
sys	0m0.000s

See other assets inside src folder. Have fun!

wtf_toolchain's People

Contributors

magniff avatar

Stargazers

 avatar

Watchers

 avatar  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.