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)


PGDLLEXPORT 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 74 of file jit.h.

◆ JitProviderInit

typedef void(* JitProviderInit) (JitProviderCallbacks *cb)

Definition at line 70 of file jit.h.

◆ JitProviderReleaseContextCB

typedef void(* JitProviderReleaseContextCB) (JitContext *context)

Definition at line 72 of file jit.h.

◆ JitProviderResetAfterErrorCB

typedef void(* JitProviderResetAfterErrorCB) (void)

Definition at line 71 of file jit.h.

◆ SharedJitInstrumentation

Function Documentation

◆ _PG_jit_provider_init()

PGDLLEXPORT void _PG_jit_provider_init ( JitProviderCallbacks cb)

Definition at line 163 of file llvmjit.c.

164 {
168 }
static void llvm_release_context(JitContext *context)
Definition: llvmjit.c:264
void llvm_reset_after_error(void)
bool llvm_compile_expr(ExprState *state)
Definition: llvmjit_expr.c:78
JitProviderCompileExprCB compile_expr
Definition: jit.h:80
JitProviderResetAfterErrorCB reset_after_error
Definition: jit.h:78
JitProviderReleaseContextCB release_context
Definition: jit.h:79

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 151 of file jit.c.

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

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 137 of file jit.c.

138 {
142  pfree(context);
143 }
static bool provider_successfully_loaded
Definition: jit.c:44
void pfree(void *pointer)
Definition: mcxt.c:1520
tree context
Definition: radixtree.h:1829

References context, pfree(), provider, provider_successfully_loaded, and JitProviderCallbacks::release_context.

Referenced by FreeExecutorState(), and ResOwnerReleaseJitContext().

◆ jit_reset_after_error()

void jit_reset_after_error ( void  )

Definition at line 127 of file jit.c.

128 {
131 }

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().

◆ 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().