summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/jit-extensibility.html
blob: 3c2dd01871af5b7b77e30fa75e60741c177f4236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>32.4. Extensibility</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="jit-configuration.html" title="32.3. Configuration" /><link rel="next" href="regress.html" title="Chapter 33. Regression Tests" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">32.4. Extensibility</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="jit-configuration.html" title="32.3. Configuration">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="jit.html" title="Chapter 32. Just-in-Time Compilation (JIT)">Up</a></td><th width="60%" align="center">Chapter 32. Just-in-Time Compilation (<acronym class="acronym">JIT</acronym>)</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="regress.html" title="Chapter 33. Regression Tests">Next</a></td></tr></table><hr /></div><div class="sect1" id="JIT-EXTENSIBILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">32.4. Extensibility</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="jit-extensibility.html#JIT-EXTENSIBILITY-BITCODE">32.4.1. Inlining Support for Extensions</a></span></dt><dt><span class="sect2"><a href="jit-extensibility.html#JIT-PLUGGABLE">32.4.2. Pluggable <acronym class="acronym">JIT</acronym> Providers</a></span></dt></dl></div><div class="sect2" id="JIT-EXTENSIBILITY-BITCODE"><div class="titlepage"><div><div><h3 class="title">32.4.1. Inlining Support for Extensions</h3></div></div></div><p>
    <span class="productname">PostgreSQL</span>'s <acronym class="acronym">JIT</acronym>
    implementation can inline the bodies of functions
    of types <code class="literal">C</code> and <code class="literal">internal</code>, as well as
    operators based on such functions.  To do so for functions in extensions,
    the definitions of those functions need to be made available.
    When using <a class="link" href="extend-pgxs.html" title="38.18. Extension Building Infrastructure">PGXS</a> to build an extension
    against a server that has been compiled with LLVM JIT support, the
    relevant files will be built and installed automatically.
   </p><p>
    The relevant files have to be installed into
    <code class="filename">$pkglibdir/bitcode/$extension/</code> and a summary of them
    into <code class="filename">$pkglibdir/bitcode/$extension.index.bc</code>, where
    <code class="literal">$pkglibdir</code> is the directory returned by
    <code class="literal">pg_config --pkglibdir</code> and <code class="literal">$extension</code>
    is the base name of the extension's shared library.

    </p><div class="note"><h3 class="title">Note</h3><p>
      For functions built into <span class="productname">PostgreSQL</span> itself,
      the bitcode is installed into
      <code class="literal">$pkglibdir/bitcode/postgres</code>.
     </p></div><p>
   </p></div><div class="sect2" id="JIT-PLUGGABLE"><div class="titlepage"><div><div><h3 class="title">32.4.2. Pluggable <acronym class="acronym">JIT</acronym> Providers</h3></div></div></div><p>
    <span class="productname">PostgreSQL</span> provides a <acronym class="acronym">JIT</acronym>
    implementation based on <span class="productname">LLVM</span>.  The interface to
    the <acronym class="acronym">JIT</acronym> provider is pluggable and the provider can be
    changed without recompiling (although currently, the build process only
    provides inlining support data for <span class="productname">LLVM</span>).
    The active provider is chosen via the setting
    <a class="xref" href="runtime-config-client.html#GUC-JIT-PROVIDER">jit_provider</a>.
   </p><div class="sect3" id="id-1.6.19.8.3.3"><div class="titlepage"><div><div><h4 class="title">32.4.2.1. <acronym class="acronym">JIT</acronym> Provider Interface</h4></div></div></div><p>
     A <acronym class="acronym">JIT</acronym> 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 <acronym class="acronym">JIT</acronym> provider
     callbacks and to indicate that the library is actually a
     <acronym class="acronym">JIT</acronym> provider, it needs to provide a C function named
     <code class="function">_PG_jit_provider_init</code>. This function is passed a
     struct that needs to be filled with the callback function pointers for
     individual actions:
</p><pre class="programlisting">
struct JitProviderCallbacks
{
    JitProviderResetAfterErrorCB reset_after_error;
    JitProviderReleaseContextCB release_context;
    JitProviderCompileExprCB compile_expr;
};

extern void _PG_jit_provider_init(JitProviderCallbacks *cb);
</pre><p>
    </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="jit-configuration.html" title="32.3. Configuration">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="jit.html" title="Chapter 32. Just-in-Time Compilation (JIT)">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="regress.html" title="Chapter 33. Regression Tests">Next</a></td></tr><tr><td width="40%" align="left" valign="top">32.3. Configuration </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 33. Regression Tests</td></tr></table></div></body></html>