32.4. Extensibility
Prev | Up | Chapter 32. Just-in-Time Compilation (JIT) | Home | Next

## 32.4. Extensibility

### 32.4.1. Inlining Support for Extensions

PostgreSQL's JIT implementation can inline the implementation of operators and functions (of type `C` and `internal`). See Section 32.1.3. To do so for functions in extensions, the definition of these functions needs to be made available. When using PGXS to build an extension against a server that has been compiled with LLVM support, the relevant files will be installed automatically.

The relevant files have to be installed into `$pkglibdir/bitcode/$extension/` and a summary of them to `$pkglibdir/bitcode/$extension.index.bc`, where `$pkglibdir` is the directory returned by `pg_config --pkglibdir` and `$extension` the basename of the extension's shared library.

### Note

For functions built into PostgreSQL itself, the bitcode is installed into `$pkglibdir/bitcode/postgres`.

### 32.4.2. Pluggable JIT Provider

PostgreSQL provides a JIT implementation based on LLVM. The interface to the JIT provider is pluggable and the provider can be changed without recompiling. The provider is chosen via the jit_provider GUC.

#### 32.4.2.1. JIT Provider Interface

A JIT provider is loaded by dynamically loading the named shared library. The normal library search path is used to locate the library. To provide the required JIT provider callbacks and to indicate that the library is actually a JIT provider it needs to provide a function named `_PG_jit_provider_init`. This function is passed a struct that needs to be filled with the callback function pointers for individual actions.

    struct JitProviderCallbacks
    {
        JitProviderResetAfterErrorCB reset_after_error;
        JitProviderReleaseContextCB release_context;
        JitProviderCompileExprCB compile_expr;
    };
    extern void _PG_jit_provider_init(JitProviderCallbacks *cb);

Prev | Up | Next
32.3. Configuration | Home | Chapter 33. Regression Tests