PostgreSQL Source Code  git master
jit.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  * jit.h
3  * Provider independent JIT infrastructure.
4  *
5  * Copyright (c) 2016-2024, PostgreSQL Global Development Group
6  *
7  * src/include/jit/jit.h
8  *
9  *-------------------------------------------------------------------------
10  */
11 #ifndef JIT_H
12 #define JIT_H
13 
14 #include "executor/instrument.h"
15 #include "utils/resowner.h"
16 
17 
18 /* Flags determining what kind of JIT operations to perform */
19 #define PGJIT_NONE 0
20 #define PGJIT_PERFORM (1 << 0)
21 #define PGJIT_OPT3 (1 << 1)
22 #define PGJIT_INLINE (1 << 2)
23 #define PGJIT_EXPR (1 << 3)
24 #define PGJIT_DEFORM (1 << 4)
25 
26 
27 typedef struct JitInstrumentation
28 {
29  /* number of emitted functions */
31 
32  /* accumulated time to generate code */
34 
35  /* accumulated time to deform tuples, included into generation_counter */
37 
38  /* accumulated time for inlining */
40 
41  /* accumulated time for optimization */
43 
44  /* accumulated time for code emission */
47 
48 /*
49  * DSM structure for accumulating jit instrumentation of all workers.
50  */
52 {
56 
57 typedef struct JitContext
58 {
59  /* see PGJIT_* above */
60  int flags;
61 
64 
66 
68 typedef void (*JitProviderInit) (JitProviderCallbacks *cb);
69 typedef void (*JitProviderResetAfterErrorCB) (void);
71 struct ExprState;
73 
75 {
79 };
80 
81 
82 /* GUCs */
83 extern PGDLLIMPORT bool jit_enabled;
84 extern PGDLLIMPORT char *jit_provider;
86 extern PGDLLIMPORT bool jit_dump_bitcode;
87 extern PGDLLIMPORT bool jit_expressions;
90 extern PGDLLIMPORT double jit_above_cost;
93 
94 
95 extern void jit_reset_after_error(void);
97 
98 /*
99  * Functions for attempting to JIT code. Callers must accept that these might
100  * not be able to perform JIT (i.e. return false).
101  */
102 extern bool jit_compile_expr(struct ExprState *state);
103 extern void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add);
104 
105 
106 #endif /* JIT_H */
#define PGDLLIMPORT
Definition: c.h:1316
#define PGDLLEXPORT
Definition: c.h:1331
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:398
unsigned char bool
Definition: c.h:456
struct SharedJitInstrumentation SharedJitInstrumentation
void jit_reset_after_error(void)
Definition: jit.c:127
PGDLLIMPORT double jit_inline_above_cost
Definition: jit.c:40
PGDLLEXPORT void _PG_jit_provider_init(JitProviderCallbacks *cb)
Definition: llvmjit.c:163
PGDLLIMPORT char * jit_provider
Definition: jit.c:33
PGDLLIMPORT double jit_optimize_above_cost
Definition: jit.c:41
bool(* JitProviderCompileExprCB)(struct ExprState *state)
Definition: jit.h:72
void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add)
Definition: jit.c:182
struct JitInstrumentation JitInstrumentation
bool jit_compile_expr(struct ExprState *state)
Definition: jit.c:151
PGDLLIMPORT bool jit_tuple_deforming
Definition: jit.c:38
void(* JitProviderInit)(JitProviderCallbacks *cb)
Definition: jit.h:68
PGDLLIMPORT bool jit_dump_bitcode
Definition: jit.c:35
struct JitContext JitContext
void jit_release_context(JitContext *context)
Definition: jit.c:137
void(* JitProviderReleaseContextCB)(JitContext *context)
Definition: jit.h:70
void(* JitProviderResetAfterErrorCB)(void)
Definition: jit.h:69
PGDLLIMPORT bool jit_debugging_support
Definition: jit.c:34
PGDLLIMPORT bool jit_enabled
Definition: jit.c:32
PGDLLIMPORT bool jit_expressions
Definition: jit.c:36
PGDLLIMPORT double jit_above_cost
Definition: jit.c:39
PGDLLIMPORT bool jit_profiling_support
Definition: jit.c:37
tree context
Definition: radixtree.h:1835
Definition: jit.h:58
int flags
Definition: jit.h:60
JitInstrumentation instr
Definition: jit.h:62
instr_time generation_counter
Definition: jit.h:33
size_t created_functions
Definition: jit.h:30
instr_time optimization_counter
Definition: jit.h:42
instr_time deform_counter
Definition: jit.h:36
instr_time emission_counter
Definition: jit.h:45
instr_time inlining_counter
Definition: jit.h:39
JitProviderCompileExprCB compile_expr
Definition: jit.h:78
JitProviderResetAfterErrorCB reset_after_error
Definition: jit.h:76
JitProviderReleaseContextCB release_context
Definition: jit.h:77
JitInstrumentation jit_instr[FLEXIBLE_ARRAY_MEMBER]
Definition: jit.h:54
Definition: regguts.h:323