PostgreSQL Source Code git master
llvmjit_error.cpp File Reference
#include "postgres.h"
#include <llvm/Support/ErrorHandling.h>
#include "jit/llvmjit.h"
#include <new>
Include dependency graph for llvmjit_error.cpp:

Go to the source code of this file.

Functions

static void fatal_system_new_handler (void)
 
static void fatal_llvm_new_handler (void *user_data, const char *reason, bool gen_crash_diag)
 
static void fatal_llvm_error_handler (void *user_data, const char *reason, bool gen_crash_diag)
 
void llvm_enter_fatal_on_oom (void)
 
void llvm_leave_fatal_on_oom (void)
 
bool llvm_in_fatal_on_oom (void)
 
void llvm_reset_after_error (void)
 
void llvm_assert_in_fatal_section (void)
 

Variables

static int fatal_new_handler_depth = 0
 
static std::new_handler old_new_handler = NULL
 

Function Documentation

◆ fatal_llvm_error_handler()

static void fatal_llvm_error_handler ( void *  user_data,
const char *  reason,
bool  gen_crash_diag 
)
static

Definition at line 134 of file llvmjit_error.cpp.

137{
139 (errcode(ERRCODE_OUT_OF_MEMORY),
140 errmsg("fatal llvm error: %s", reason)));
141}
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define FATAL
Definition: elog.h:41
#define ereport(elevel,...)
Definition: elog.h:149

References ereport, errcode(), errmsg(), and FATAL.

Referenced by llvm_enter_fatal_on_oom().

◆ fatal_llvm_new_handler()

static void fatal_llvm_new_handler ( void *  user_data,
const char *  reason,
bool  gen_crash_diag 
)
static

Definition at line 123 of file llvmjit_error.cpp.

126{
128 (errcode(ERRCODE_OUT_OF_MEMORY),
129 errmsg("out of memory"),
130 errdetail("While in LLVM: %s", reason)));
131}
int errdetail(const char *fmt,...)
Definition: elog.c:1203

References ereport, errcode(), errdetail(), errmsg(), and FATAL.

Referenced by llvm_enter_fatal_on_oom().

◆ fatal_system_new_handler()

static void fatal_system_new_handler ( void  )
static

Definition at line 114 of file llvmjit_error.cpp.

115{
117 (errcode(ERRCODE_OUT_OF_MEMORY),
118 errmsg("out of memory"),
119 errdetail("while in LLVM")));
120}

References ereport, errcode(), errdetail(), errmsg(), and FATAL.

Referenced by llvm_enter_fatal_on_oom().

◆ llvm_assert_in_fatal_section()

void llvm_assert_in_fatal_section ( void  )

Definition at line 108 of file llvmjit_error.cpp.

109{
111}
#define Assert(condition)
Definition: c.h:815
static int fatal_new_handler_depth

References Assert, and fatal_new_handler_depth.

Referenced by llvm_create_context(), llvm_get_function(), and llvm_mutable_module().

◆ llvm_enter_fatal_on_oom()

void llvm_enter_fatal_on_oom ( void  )

Definition at line 55 of file llvmjit_error.cpp.

56{
58 {
59 old_new_handler = std::set_new_handler(fatal_system_new_handler);
60 llvm::install_bad_alloc_error_handler(fatal_llvm_new_handler);
61 llvm::install_fatal_error_handler(fatal_llvm_error_handler);
62 }
64}
static std::new_handler old_new_handler
static void fatal_system_new_handler(void)
static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag)
static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag)

References fatal_llvm_error_handler(), fatal_llvm_new_handler(), fatal_new_handler_depth, fatal_system_new_handler(), and old_new_handler.

Referenced by ExecRunCompiledExpr(), llvm_compile_expr(), and llvm_release_context().

◆ llvm_in_fatal_on_oom()

bool llvm_in_fatal_on_oom ( void  )

Definition at line 86 of file llvmjit_error.cpp.

87{
88 return fatal_new_handler_depth > 0;
89}

References fatal_new_handler_depth.

Referenced by llvm_shutdown().

◆ llvm_leave_fatal_on_oom()

void llvm_leave_fatal_on_oom ( void  )

Definition at line 70 of file llvmjit_error.cpp.

71{
74 {
75 std::set_new_handler(old_new_handler);
76 llvm::remove_bad_alloc_error_handler();
77 llvm::remove_fatal_error_handler();
78 }
79}

References fatal_new_handler_depth, and old_new_handler.

Referenced by ExecRunCompiledExpr(), and llvm_release_context().

◆ llvm_reset_after_error()

void llvm_reset_after_error ( void  )

Definition at line 96 of file llvmjit_error.cpp.

97{
99 {
100 std::set_new_handler(old_new_handler);
101 llvm::remove_bad_alloc_error_handler();
102 llvm::remove_fatal_error_handler();
103 }
105}

References fatal_new_handler_depth, and old_new_handler.

Referenced by _PG_jit_provider_init().

Variable Documentation

◆ fatal_new_handler_depth

int fatal_new_handler_depth = 0
static

◆ old_new_handler

std::new_handler old_new_handler = NULL
static