• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created about 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Emacs with an Emacs Lisp JIT (Just In Time) compiler using libjit.

emacs-jit

An Emacs with a JIT compiler for Emacs Lisp based on libjit. It improves the performance of lisp/raytracer.el by about 25%.

Work in progress. Latent bugs and emacs will not build with full JIT'ing enabled yet.

Usage

Provides a new function 'jit-compile' that takes a function symbol or a lambda expression as an argument that will jit compile the function.

To enable complete JIT'ing of all Emacs Lisp bytecode (here be dragons), uncomment the 'jit_hotspot_compile' lines in src/eval.c.

Installation

  1. Build and install libjit from git:

git clone git://git.savannah.gnu.org/libjit.git ...

  1. Build emacs as usual:

./configure ... && make && make install

Explanation

I did this work back in 2012, so this is an old emacs version and does not easily port forward. It is publshed as an example showing how to create a JIT compiler for Emacs Lisp using a technicque i call 'compiling down the spine'.

The compiler removes the overhead of the jump table used to dispatch the byte code operations by encapsulating bytecode functionality into individual functions and converting the bytecode into a linear array of function calls, precomputing and moving the dispatch overhead a level of abstration down into the processor rather than in software.

A byte compiled function that is jit-compiled has it's code vector replaced with a new one containing a single bytecode instruction Bjitcall followed by the JIT compiled code vector.

The JIT is currently 'working' when used on individual functions with M-x jit-compile, enough to run the raytracer in lisp/raytracer.el. If the 'hotspot' (WIP) compiler is enabled by default (see src/eval.c at jit_hotspot_bytecode) emacs will not build fully, so there are still lurking bugs in the implementation that need to be squashed.

The 'hotspot' compiler is anything but; it simply compiles the bytecode on first run for every evaluated piece of code and is a placeholder for a potential real hotspot compiler in the future.

New or Modified Files of Interest

src/bytecode-jit.c: the JIT compiler, included by bytecode.c

src/bytecode.c: minor modifications, original code sources for most of bytecode-jit.c

src/eval.c: where the call to the 'hotspot' compiler has been placed, search for jit_hotspot_compile to enable it and watch the emacs build fail during bytecode compilation.

lisp/raytracer.el: a raytracer in Emacs Lisp used to benchmark the JIT compiler raytracer.sh

lisp/emacs-lisp/byte-comp.el

configure.ac: check for libjit

-- Burton Samograd [email protected] 2016

More Repositories

1

sxc

sxc is an 'S-Expression C' transpiler for generating C code using macros written in Common Lisp
C
211
star
2

sigil

A Parenscript to Javascript command line compiler and interpreter.
Common Lisp
26
star
3

rsa

The RSA Encryption Algorithm written in Common Lisp
Common Lisp
20
star
4

px2

PX2 is a Javascript Front End Framework designed to replace Backbone written in Parenscript.
JavaScript
20
star
5

anser

A header only Boolean Propagator Network framework for the omni-directional computation of Integer mathematical functions and computation graph analysis.
C++
14
star
6

med

med - A fork of the emacs-like text editor for the Mezzano operating system
Common Lisp
13
star
7

autograph

Autograph is a CSS generation language that uses s-expressions for styling rules and allows for the use of variables and functions written in Common Lisp.
Common Lisp
7
star
8

typed-cl

Easier type declerations for for Common Lisp.
Common Lisp
4
star
9

cl-active-variables

Variables with read and write callbacks in Common Lisp.
Common Lisp
3
star
10

cl-magic

parse and decode 'magic bytes' in files
C
1
star
11

prototype

A starting point 'boilerplate' for a prototype Common Lisp web application.
Common Lisp
1
star
12

tracker

Tracker is the start of a music tracker interface written with PX2 in Parenscript.
CSS
1
star
13

woc

Word Occurance - a poor man's google for the filesystem
C
1
star
14

sb-directory

A suite of directory walking and sizing functions in Common Lisp using the sb-posix routines of SBCL.
Common Lisp
1
star
15

hackernews-reader

A web based Hacker News reader using a node.js server.
JavaScript
1
star
16

xp32

XP32 was my university graduation thesis (4th year) project, a graphics demo for DOS.
Emacs Lisp
1
star
17

Quill

The Quill Common Lisp Language (QCL) with Clarity
1
star