Skip to content
libgccffi interface for PHP, based on 7.4's FFI and FFIMe
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Parse double types into floats for PHP compatibility Mar 6, 2019
.gitignore
LICENSE First commit prior to rebuild Feb 19, 2019
README.md Update readme Feb 19, 2019
composer.json
composer.lock
demo_aot.php
demo_jit.php First shippable build Feb 19, 2019
rebuild.php

README.md

libgccjit

This is a wrapper library for libgccjit using 7.4's FFI.

Basically, it exposes a "nice" interface in PHP for building JITs with GCC.

Example (in C, from https://gcc.gnu.org/wiki/JIT):

gcc_jit_type *void_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
gcc_jit_type *const_char_ptr_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CONST_CHAR_PTR);
gcc_jit_param *param_name =
  gcc_jit_context_new_param (ctxt, NULL, const_char_ptr_type, "name");
gcc_jit_function *func =
  gcc_jit_context_new_function (ctxt, NULL,
                                GCC_JIT_FUNCTION_EXPORTED,
                                void_type,
                                "some_fn",
                                1, &param_name,
                                0);

Would become:

$void_type = gcc_jit_context_get_type($ctxt, GCC_JIT_TYPE_VOID);
$const_char_ptr_type = gcc_jit_context_get_type($ctxt, GCC_JIT_TYPE_CONST_CHAR_PTR);
$param_name = gcc_jit_context_new_param($ctxt, null, $const_char_ptr_type, "name");
$func = gcc_jit_context_new_function(
    $ctxt, 
    null,
    GCC_JIT_FUNCTION_EXPORTED,
    $void_type,
    "some_fn",
    1,
    gcc_jit_param_ptr_ptr::fromArray($param_name),
    0
);

It aims to be a simple, and type safe implementation in PHP.

You can’t perform that action at this time.