PostgreSQL Source Code  git master
jit.h File Reference
Include dependency graph for jit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JitInstrumentation
struct  SharedJitInstrumentation
struct  JitContext
struct  JitProviderCallbacks


#define PGJIT_NONE   0
#define PGJIT_PERFORM   (1 << 0)
#define PGJIT_OPT3   (1 << 1)
#define PGJIT_INLINE   (1 << 2)
#define PGJIT_EXPR   (1 << 3)
#define PGJIT_DEFORM   (1 << 4)


typedef struct JitInstrumentation JitInstrumentation
typedef struct SharedJitInstrumentation SharedJitInstrumentation
typedef struct JitContext JitContext
typedef struct JitProviderCallbacks JitProviderCallbacks
typedef void(* JitProviderInit) (JitProviderCallbacks *cb)
typedef void(* JitProviderResetAfterErrorCB) (void)
typedef void(* JitProviderReleaseContextCB) (JitContext *context)
typedef bool(* JitProviderCompileExprCB) (struct ExprState *state)


void _PG_jit_provider_init (JitProviderCallbacks *cb)
void jit_reset_after_error (void)
void jit_release_context (JitContext *context)
bool jit_compile_expr (struct ExprState *state)
void InstrJitAgg (JitInstrumentation *dst, JitInstrumentation *add)


PGDLLIMPORT bool jit_enabled
PGDLLIMPORT char * jit_provider
PGDLLIMPORT bool jit_debugging_support
PGDLLIMPORT bool jit_dump_bitcode
PGDLLIMPORT bool jit_expressions
PGDLLIMPORT bool jit_profiling_support
PGDLLIMPORT bool jit_tuple_deforming
PGDLLIMPORT double jit_above_cost
PGDLLIMPORT double jit_inline_above_cost
PGDLLIMPORT double jit_optimize_above_cost

Macro Definition Documentation


#define PGJIT_DEFORM   (1 << 4)

Definition at line 24 of file jit.h.


#define PGJIT_EXPR   (1 << 3)

Definition at line 23 of file jit.h.


#define PGJIT_INLINE   (1 << 2)

Definition at line 22 of file jit.h.


#define PGJIT_NONE   0

Definition at line 19 of file jit.h.


#define PGJIT_OPT3   (1 << 1)

Definition at line 21 of file jit.h.


#define PGJIT_PERFORM   (1 << 0)

Definition at line 20 of file jit.h.

Typedef Documentation

◆ JitContext

typedef struct JitContext JitContext

◆ JitInstrumentation

◆ JitProviderCallbacks

Definition at line 1 of file jit.h.

◆ JitProviderCompileExprCB

typedef bool(* JitProviderCompileExprCB) (struct ExprState *state)

Definition at line 71 of file jit.h.

◆ JitProviderInit

typedef void(* JitProviderInit) (JitProviderCallbacks *cb)

Definition at line 67 of file jit.h.

◆ JitProviderReleaseContextCB

typedef void(* JitProviderReleaseContextCB) (JitContext *context)

Definition at line 69 of file jit.h.

◆ JitProviderResetAfterErrorCB

typedef void(* JitProviderResetAfterErrorCB) (void)

Definition at line 68 of file jit.h.

◆ SharedJitInstrumentation

Function Documentation

◆ _PG_jit_provider_init()

void _PG_jit_provider_init ( JitProviderCallbacks cb)

Definition at line 131 of file llvmjit.c.

132 {
136 }
static void llvm_release_context(JitContext *context)
Definition: llvmjit.c:171
void llvm_reset_after_error(void)
bool llvm_compile_expr(ExprState *state)
Definition: llvmjit_expr.c:78
JitProviderCompileExprCB compile_expr
Definition: jit.h:77
JitProviderResetAfterErrorCB reset_after_error
Definition: jit.h:75
JitProviderReleaseContextCB release_context
Definition: jit.h:76

References JitProviderCallbacks::compile_expr, llvm_compile_expr(), llvm_release_context(), llvm_reset_after_error(), JitProviderCallbacks::release_context, and JitProviderCallbacks::reset_after_error.

◆ InstrJitAgg()

◆ jit_compile_expr()

bool jit_compile_expr ( struct ExprState state)

Definition at line 153 of file jit.c.

154 {
155  /*
156  * We can easily create a one-off context for functions without an
157  * associated PlanState (and thus EState). But because there's no executor
158  * shutdown callback that could deallocate the created function, they'd
159  * live to the end of the transactions, where they'd be cleaned up by the
160  * resowner machinery. That can lead to a noticeable amount of memory
161  * usage, and worse, trigger some quadratic behaviour in gdb. Therefore,
162  * at least for now, don't create a JITed function in those circumstances.
163  */
164  if (!state->parent)
165  return false;
167  /* if no jitting should be performed at all */
168  if (!(state->parent->state->es_jit_flags & PGJIT_PERFORM))
169  return false;
171  /* or if expressions aren't JITed */
172  if (!(state->parent->state->es_jit_flags & PGJIT_EXPR))
173  return false;
175  /* this also takes !jit_enabled into account */
176  if (provider_init())
177  return provider.compile_expr(state);
179  return false;
180 }
static bool provider_init(void)
Definition: jit.c:68
static JitProviderCallbacks provider
Definition: jit.c:43
#define PGJIT_EXPR
Definition: jit.h:23
Definition: jit.h:20
Definition: regguts.h:318

References JitProviderCallbacks::compile_expr, PGJIT_EXPR, PGJIT_PERFORM, provider, and provider_init().

Referenced by ExecReadyExpr().

◆ jit_release_context()

void jit_release_context ( JitContext context)

Definition at line 138 of file jit.c.

139 {
141  provider.release_context(context);
143  ResourceOwnerForgetJIT(context->resowner, PointerGetDatum(context));
144  pfree(context);
145 }
static bool provider_successfully_loaded
Definition: jit.c:44
void pfree(void *pointer)
Definition: mcxt.c:1175
#define PointerGetDatum(X)
Definition: postgres.h:600
void ResourceOwnerForgetJIT(ResourceOwner owner, Datum handle)
Definition: resowner.c:1395
ResourceOwner resowner
Definition: jit.h:59

References pfree(), PointerGetDatum, provider, provider_successfully_loaded, JitProviderCallbacks::release_context, ResourceOwnerForgetJIT(), and JitContext::resowner.

Referenced by FreeExecutorState(), and ResourceOwnerReleaseInternal().

◆ jit_reset_after_error()

void jit_reset_after_error ( void  )

Definition at line 128 of file jit.c.

129 {
132 }

References provider, provider_successfully_loaded, and JitProviderCallbacks::reset_after_error.

Referenced by PostgresMain().

Variable Documentation

◆ jit_above_cost

PGDLLIMPORT double jit_above_cost

Definition at line 39 of file jit.c.

Referenced by standard_planner().

◆ jit_debugging_support

PGDLLIMPORT bool jit_debugging_support

Definition at line 34 of file jit.c.

Referenced by llvm_session_initialize().

◆ jit_dump_bitcode

PGDLLIMPORT bool jit_dump_bitcode

Definition at line 35 of file jit.c.

Referenced by llvm_compile_module().

◆ jit_enabled

PGDLLIMPORT bool jit_enabled

Definition at line 32 of file jit.c.

Referenced by provider_init(), and standard_planner().

◆ jit_expressions

PGDLLIMPORT bool jit_expressions

Definition at line 36 of file jit.c.

Referenced by standard_planner().

◆ jit_inline_above_cost

PGDLLIMPORT double jit_inline_above_cost

Definition at line 40 of file jit.c.

Referenced by standard_planner().

◆ jit_optimize_above_cost

PGDLLIMPORT double jit_optimize_above_cost

Definition at line 41 of file jit.c.

Referenced by standard_planner().

◆ jit_profiling_support

PGDLLIMPORT bool jit_profiling_support

Definition at line 37 of file jit.c.

Referenced by llvm_session_initialize(), and llvm_shutdown().

◆ jit_provider

PGDLLIMPORT char* jit_provider

Definition at line 33 of file jit.c.

Referenced by provider_init().

◆ jit_tuple_deforming

PGDLLIMPORT bool jit_tuple_deforming

Definition at line 38 of file jit.c.

Referenced by standard_planner().