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-2019, 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 for inlining */
37 
38  /* accumulated time for optimization */
40 
41  /* accumulated time for code emission */
44 
45 /*
46  * DSM structure for accumulating jit instrumentation of all workers.
47  */
49 {
51  JitInstrumentation jit_instr[FLEXIBLE_ARRAY_MEMBER];
53 
54 typedef struct JitContext
55 {
56  /* see PGJIT_* above */
57  int flags;
58 
60 
62 } JitContext;
63 
65 
67 typedef void (*JitProviderInit) (JitProviderCallbacks *cb);
68 typedef void (*JitProviderResetAfterErrorCB) (void);
69 typedef void (*JitProviderReleaseContextCB) (JitContext *context);
70 struct ExprState;
72 
74 {
78 };
79 
80 
81 /* GUCs */
82 extern bool jit_enabled;
83 extern char *jit_provider;
84 extern bool jit_debugging_support;
85 extern bool jit_dump_bitcode;
86 extern bool jit_expressions;
87 extern bool jit_profiling_support;
88 extern bool jit_tuple_deforming;
89 extern double jit_above_cost;
90 extern double jit_inline_above_cost;
91 extern double jit_optimize_above_cost;
92 
93 
94 extern void jit_reset_after_error(void);
95 extern void jit_release_context(JitContext *context);
96 
97 /*
98  * Functions for attempting to JIT code. Callers must accept that these might
99  * not be able to perform JIT (i.e. return false).
100  */
101 extern bool jit_compile_expr(struct ExprState *state);
102 extern void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add);
103 
104 
105 #endif /* JIT_H */
JitProviderResetAfterErrorCB reset_after_error
Definition: jit.h:75
bool jit_tuple_deforming
Definition: jit.c:41
bool jit_dump_bitcode
Definition: jit.c:38
instr_time generation_counter
Definition: jit.h:33
struct timeval instr_time
Definition: instr_time.h:150
struct JitContext JitContext
Definition: jit.h:54
bool jit_expressions
Definition: jit.c:39
double jit_inline_above_cost
Definition: jit.c:43
bool jit_profiling_support
Definition: jit.c:40
void(* JitProviderReleaseContextCB)(JitContext *context)
Definition: jit.h:69
JitInstrumentation instr
Definition: jit.h:61
void _PG_jit_provider_init(JitProviderCallbacks *cb)
Definition: llvmjit.c:125
size_t created_functions
Definition: jit.h:30
void(* JitProviderResetAfterErrorCB)(void)
Definition: jit.h:68
instr_time optimization_counter
Definition: jit.h:39
ResourceOwner resowner
Definition: jit.h:59
bool jit_compile_expr(struct ExprState *state)
Definition: jit.c:156
double jit_optimize_above_cost
Definition: jit.c:44
char * jit_provider
Definition: jit.c:36
JitProviderCompileExprCB compile_expr
Definition: jit.h:77
instr_time inlining_counter
Definition: jit.h:36
bool jit_enabled
Definition: jit.c:35
void(* JitProviderInit)(JitProviderCallbacks *cb)
Definition: jit.h:67
bool jit_debugging_support
Definition: jit.c:37
void InstrJitAgg(JitInstrumentation *dst, JitInstrumentation *add)
Definition: jit.c:187
void jit_release_context(JitContext *context)
Definition: jit.c:141
double jit_above_cost
Definition: jit.c:42
Definition: regguts.h:298
instr_time emission_counter
Definition: jit.h:42
void jit_reset_after_error(void)
Definition: jit.c:131
struct JitInstrumentation JitInstrumentation
bool(* JitProviderCompileExprCB)(struct ExprState *state)
Definition: jit.h:71
JitProviderReleaseContextCB release_context
Definition: jit.h:76
struct SharedJitInstrumentation SharedJitInstrumentation
int flags
Definition: jit.h:57
unsigned char bool
Definition: c.h:308