Hi,
   Please find attached my notes on "libgccjit.so - An experimental
JIT library using GCC as backend". I would be grateful if you would
review it for me.

Thanks,
Prathamesh
libgccjit.so - An experimental JIT library using GCC as backend.

Author: David Malcolm
    
    libgccjit.so is a thread-safe JIT library using GCC as the backend. It can 
then be dynamically-linked into bytecode interpreters and other such programs 
that want to generate machine code "on the fly". It is useful for programs like 
interpreters that want JIT capabilties.
It is currently developed in git branch "dmalcolm/jit". Prebuilt packages are 
available for RHEL and fedora.

Features:
- method-based JIT
- can target all architectures supported by GCC, huge gain over other JIT 
libraries.
- thread safe

JIT API:
    The JIT C API is a high-level API meant for interfacing with C code, and 
correspondingly consists of C terminology. 
Currently the API is a C header file with 72 function prototypes, 12 opaque 
types and 8 enums.
It has first-class support for simple C types, functions, comments, tracking 
source locations etc.

Some of the features of the API are listed below:

a) State and Lifetime management:
All state is hung off "context" objects (gcc_jit_context).
Simple memory management for client code:
Everything that's created from a context is cleaned up when the context is 
released.

b) Debugging:
extern const char *
gcc_jit_object_get_debug_string (gcc_jit_object *obj);

gcc_jit_object_get_debug_string returns a string representation of the object.

c) Types:
Access to simple C types
Example:
gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);

Not yet supported by API:
    Optimizations like type inference, escape analysis, unboxing, inline 
caching, etc.

Bindings to other langauges:
    So far the library has bindings to C++ and Python. 

Implementation details
- Looks like a library to client code
- Looks like a front-end to gcc
- libgccjit.so is built against libbackend.a

In a nutshell, GCC is configured with a --enable-host-shared option, letting 
GCC to be built as position-independent code.
libgccjit.so appears as a "front-end" to GCC: the parsing hooks replay a record 
of API calls
called by client.

Users of the library:
a) "Coconut" - JIT compiler for python, written by David Malcolm.
b) GNU ocatve is being ported to use libgccjit.so by David Malcolm.

Reply via email to