All Projects → CVM-Projects → JitFFI

CVM-Projects / JitFFI

Licence: MIT license
A fast and customizable JIT compiler for FFI (Foreign-Function Interface).

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to JitFFI

Rustler
Safe Rust bridge for creating Erlang NIF functions
Stars: ✭ 3,052 (+6682.22%)
Mutual labels:  ffi
efi
Ergonomic Rust framework for writing UEFI applications.
Stars: ✭ 44 (-2.22%)
Mutual labels:  ffi
yajl-ffi
Ruby FFI bindings to the native YAJL streaming JSON parser.
Stars: ✭ 15 (-66.67%)
Mutual labels:  ffi
cxx-cmake-example
An example repo to setup cxx (Rust FFI library) with the CMake build system.
Stars: ✭ 64 (+42.22%)
Mutual labels:  ffi
rust-ffi-examples
FFI examples written in Rust
Stars: ✭ 42 (-6.67%)
Mutual labels:  ffi
rsmpeg
A Rust crate that exposes FFmpeg's power as much as possible.
Stars: ✭ 390 (+766.67%)
Mutual labels:  ffi
Pythonnet
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
Stars: ✭ 2,873 (+6284.44%)
Mutual labels:  ffi
rdp
A library providing FFI access to fast Ramer–Douglas–Peucker and Visvalingam-Whyatt line simplification algorithms
Stars: ✭ 20 (-55.56%)
Mutual labels:  ffi
baccaml
Experimental implementation of a meta-hybrid JIT compiler mixing trace- and method-based compilation strategies.
Stars: ✭ 25 (-44.44%)
Mutual labels:  jit-compiler
neos
Language agnostic scripting engine with a custom bytecode JIT
Stars: ✭ 36 (-20%)
Mutual labels:  jit-compiler
elixir-ffi
Foreign Function Interface (FFI) for Elixir
Stars: ✭ 52 (+15.56%)
Mutual labels:  ffi
allo-isolate
Run Multithreaded Rust along with Dart VM (in isolate) 🌀
Stars: ✭ 93 (+106.67%)
Mutual labels:  ffi
libjit
Unofficial libjit mirror.
Stars: ✭ 46 (+2.22%)
Mutual labels:  jit-compiler
Curryrs
Bridge the gap between Haskell and Rust
Stars: ✭ 252 (+460%)
Mutual labels:  ffi
sqlite3
The fastest and correct module for SQLite3 in Deno.
Stars: ✭ 143 (+217.78%)
Mutual labels:  ffi
Python Mpv
Python interface to the awesome mpv media player
Stars: ✭ 245 (+444.44%)
Mutual labels:  ffi
tflite native
A Dart interface to TensorFlow Lite (tflite) through dart:ffi
Stars: ✭ 127 (+182.22%)
Mutual labels:  ffi
r6rs-pffi
Portable Foreign Function Interface (FFI) for R6RS
Stars: ✭ 40 (-11.11%)
Mutual labels:  ffi
crfsuite-rs
Rust binding to crfsuite
Stars: ✭ 19 (-57.78%)
Mutual labels:  ffi
DotNET.jl
Julia ❤️ .NET
Stars: ✭ 75 (+66.67%)
Mutual labels:  ffi

JitFFI

A fast and customizable JIT compiler for FFI (Foreign-Function Interface).

Support

Architecture Operating System Calling convention Compilers Support
x86-64 Windows Microsoft x64 MSVC, MinGW Most
x86-64 Linux System V AMD64 ABI GCC Most

Why Fast and Customizable?

The JitFFI is a compiler which compiles function info to a FFI function.

Call a function with JitFFI = Call a FFI function that JitFFI compiled. So it is fast.

It have many modes to compile, includes:

  1. Compile function-info.
  2. Compile function-info & arguments.
  3. Compile function-info & arguments & function-address. ... and more.

You can let JitFFI to compile in a mode you need. So it is customizable.

Run Example

python ./test.py -t n   # n is the num you want to run.

Compile to Static Library

python ./test.py -c

This command will create a 'libjitffi.a' file.

Usage (in C++)

JitFuncPool is a memory pool, which is executable.

JitFunc is a part of a JitFuncPool, which stands for a function.

To create JitFunc, JitFuncCreater is used.

  1. Compile to library.
  2. Using #include "jitffi.h" and import this library.

Example Code:

#include "jitffi.h"
#include <stdio.h>

double func(double v)
{
	printf("%lf\n", v);
	return v * 2;
}

int main(void)
{
	using namespace JitFFI;
	using namespace JitFFI::CurrABI;

	ArgTypeList tl = { &atu_double };

	ArgumentInfo info = GetArgInfo(atu_double, tl);

	JitFuncPool jfp(0x1000, JitFuncPool::ReadWrite);
	JitFunc jf(jfp);
	JitFuncCreater jfc(jf);

	auto f = Compile(jfc, info, func);

	double v = 3.14;
	double r;
	const void* dl[] = { &v };
	f(&r, dl);
	printf("%lf\n", r);
}

Command:

python ./test.py -c                 # Create libjitffi.a
g++ test.cpp -L. -ljitffi -o test   # Create test
./test                              # Run test

Usage (in C)

JitFFI has a header file named jitffi_c.h for C program.

All struct/class are packed with jitffi_XXX, and passed by pointer.

Only support CurrABI in C header.

JitFFI::_Platform_::atu_XX in C is jitffi_type_XX.

  1. Compile to library. (Add jitffi-c.cpp to source.)
  2. Using #include "jitffi-c.h" and import this library.

Example Code:

#include "jitffi-c.h"
#include <stdio.h>

double func(double v)
{
	printf("%lf\n", v);
	return v * 2;
}

int main(void)
{
	jitffi_argtype_ptr tl[] = { jitffi_type_double, NULL };

	jitffi_arginfo *info = jitffi_create_arginfo(jitffi_type_double, tl);

	jitffi_jfp *jfp = jitffi_create_jfp(0x1000, jitffi_readwrite);
	jitffi_jf *jf = jitffi_create_jf(jfp);
	jitffi_jfc *jfc = jitffi_create_jfc(jf);

	jitffi_f2* f = (jitffi_f2*)jitffi_compile(jfc, info, (void*)&func, NULL);

	double v = 3.14;
	double r;
	const void* dl[] = { &v };
	f(&r, dl);
	printf("%lf\n", r);

	jitffi_release_jfc(jfc);
	jitffi_release_jf(jf);
	jitffi_release_jfp(jfp);
}

Command:

python ./test.py -c               # Create libjitffi.a
gcc -c test.c                     # Create test.o
g++ test.o -L. -ljitffi -o test   # Create test
./test                            # Run test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].